From eea0ec4b2b869cc1691c0326c12421bb4a022b53 Mon Sep 17 00:00:00 2001 From: hartator Date: Thu, 19 Nov 2015 15:28:50 -0600 Subject: [PATCH] Test both only filter being a string or a regex --- test/test_wayback_machine_downloader.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test_wayback_machine_downloader.rb b/test/test_wayback_machine_downloader.rb index 610b729..5640caf 100644 --- a/test/test_wayback_machine_downloader.rb +++ b/test/test_wayback_machine_downloader.rb @@ -29,14 +29,19 @@ class WaybackMachineDownloaderTest < Minitest::Test assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-1] end - def test_file_list_notthere_regex - regextester = WaybackMachineDownloader.new base_url: 'http://www.onlyfreegames.net', accept_regex: 'abc123' - assert_equal 0, regextester.get_file_list_curated.length + def test_file_list_only_filter_without_matches + @wayback_machine_downloader.only_filter = 'abc123' + assert_equal 0, @wayback_machine_downloader.get_file_list_curated.size end - def test_file_list_singleresult_regex - regextester = WaybackMachineDownloader.new base_url: 'http://www.onlyfreegames.net', accept_regex: 'menu.html$' - assert_equal 1, regextester.get_file_list_curated.length + def test_file_list_only_filter_with_1_match + @wayback_machine_downloader.only_filter = 'menu.html' + assert_equal 1, @wayback_machine_downloader.get_file_list_curated.size + end + + def test_file_list_only_filter_with_a_regex + @wayback_machine_downloader.only_filter = '/\.(gif|je?pg|bmp)$/i' + assert_equal 37, @wayback_machine_downloader.get_file_list_curated.size end def test_file_download