diff --git a/spec/lib/common/browser_spec.rb b/spec/lib/common/browser_spec.rb index 438383bf..e82bba6b 100644 --- a/spec/lib/common/browser_spec.rb +++ b/spec/lib/common/browser_spec.rb @@ -25,7 +25,7 @@ describe Browser do json_expected_vars['max_threads'] ||= 20 # max_thread can not be nil instance_vars_to_check.each do |variable_name| - browser.send(:"#{variable_name}").should === json_expected_vars[variable_name] + expect(browser.send(:"#{variable_name}")).to be === json_expected_vars[variable_name] end end @@ -50,7 +50,7 @@ describe Browser do let(:cache_dir) { CACHE_DIR + '/somewhere' } let(:options) { { cache_dir: cache_dir } } - after { subject.cache_dir.should == cache_dir } + after { expect(subject.cache_dir).to eq cache_dir } it 'sets @cache_dir' do @json_expected_vars = json_config_without_proxy @@ -84,11 +84,11 @@ describe Browser do describe '::append_params_header_field' do after :each do - Browser.append_params_header_field( + expect(Browser.append_params_header_field( @params, @field, @field_value - ).should === @expected + )).to be === @expected end context 'when there is no headers' do @@ -140,7 +140,7 @@ describe Browser do browser.user_agent = 'SomeUA' browser.cache_ttl = 250 - browser.merge_request_params(params).should == @expected + expect(browser.merge_request_params(params)).to eq @expected end it 'sets the User-Agent header field and cache_ttl' do @@ -205,12 +205,12 @@ describe Browser do let(:url) { 'http://example.localhost' } it 'returns the correct Typhoeus::Request' do - subject.stub(merge_request_params: { cache_ttl: 10 }) + allow(subject).to receive_messages(merge_request_params: { cache_ttl: 10 }) request = subject.forge_request(url) - request.should be_a Typhoeus::Request - request.url.should == url - request.cache_ttl.should == 10 + expect(request).to be_a Typhoeus::Request + expect(request.url).to eq url + expect(request.cache_ttl).to eq 10 end end @@ -225,7 +225,7 @@ describe Browser do response1 = Browser.get(url) response2 = Browser.get(url) - response1.body.should == response2.body + expect(response1.body).to eq response2.body #WebMock.should have_requested(:get, url).times(1) # This one fail, dunno why :s (but it works without mock) end end diff --git a/spec/lib/common/cache_file_store_spec.rb b/spec/lib/common/cache_file_store_spec.rb index def5df67..4bce8a10 100644 --- a/spec/lib/common/cache_file_store_spec.rb +++ b/spec/lib/common/cache_file_store_spec.rb @@ -17,14 +17,14 @@ describe CacheFileStore do describe '#storage_path' do it 'returns the storage path given in the #new' do - @cache.storage_path.should match(/#{cache_dir}/) + expect(@cache.storage_path).to match(/#{cache_dir}/) end end describe '#serializer' do it 'should return the default serializer : Marshal' do - @cache.serializer.should == Marshal - @cache.serializer.should_not == YAML + expect(@cache.serializer).to eq Marshal + expect(@cache.serializer).not_to eq YAML end end @@ -35,15 +35,15 @@ describe CacheFileStore do File.new(@cache.storage_path + "/file_#{i}.txt", File::CREAT) end - count_files_in_dir(@cache.storage_path, 'file_*.txt').should == 6 + expect(count_files_in_dir(@cache.storage_path, 'file_*.txt')).to eq 6 @cache.clean - count_files_in_dir(@cache.storage_path).should == 0 + expect(count_files_in_dir(@cache.storage_path)).to eq 0 end end describe '#read_entry (nonexistent entry)' do it 'should return nil' do - @cache.read_entry(Digest::SHA1.hexdigest('hello world')).should be_nil + expect(@cache.read_entry(Digest::SHA1.hexdigest('hello world'))).to be_nil end end @@ -51,7 +51,7 @@ describe CacheFileStore do after :each do @cache.write_entry(@key, @data, @timeout) - @cache.read_entry(@key).should === @expected + expect(@cache.read_entry(@key)).to be === @expected end it 'should get the correct entry (string)' do @@ -79,7 +79,7 @@ describe CacheFileStore do storage_dirs << CacheFileStore.new(cache_dir).storage_path end - storage_dirs.uniq.size.should == 5 + expect(storage_dirs.uniq.size).to eq 5 end end end diff --git a/spec/lib/common/collections/wp_plugins/detectable_spec.rb b/spec/lib/common/collections/wp_plugins/detectable_spec.rb index bbc5fecf..beab6e4f 100644 --- a/spec/lib/common/collections/wp_plugins/detectable_spec.rb +++ b/spec/lib/common/collections/wp_plugins/detectable_spec.rb @@ -15,7 +15,7 @@ describe 'WpPlugins::Detectable' do context 'when no header' do it 'returns an empty WpPlugins' do stub_request(:get, url).to_return(status: 200) - subject.send(:from_header, wp_target).should == subject.new + expect(subject.send(:from_header, wp_target)).to eq subject.new end end @@ -25,7 +25,7 @@ describe 'WpPlugins::Detectable' do after :each do stub_request(:get, url).to_return(status: 200, headers: headers, body: '') - subject.send(:from_header, wp_target).should == expected + expect(subject.send(:from_header, wp_target)).to eq expected end context 'when w3-total-cache detected' do @@ -66,7 +66,7 @@ describe 'WpPlugins::Detectable' do context 'when no body' do it 'returns an empty WpPlugins' do stub_request(:get, url).to_return(status: 200, body: '') - subject.send(:from_content, wp_target).should == subject.new + expect(subject.send(:from_content, wp_target)).to eq subject.new end end @@ -77,7 +77,7 @@ describe 'WpPlugins::Detectable' do after :each do stub_request(:get, url).to_return(status: 200, body: @body) stub_request(:get, /readme\.txt/i).to_return(status: 404) - subject.send(:from_content, wp_target).should == expected + expect(subject.send(:from_content, wp_target)).to eq expected end context 'when w3 total cache detected' do diff --git a/spec/lib/common/collections/wp_timthumbs/detectable_spec.rb b/spec/lib/common/collections/wp_timthumbs/detectable_spec.rb index c1d22579..83587e9b 100644 --- a/spec/lib/common/collections/wp_timthumbs/detectable_spec.rb +++ b/spec/lib/common/collections/wp_timthumbs/detectable_spec.rb @@ -38,7 +38,7 @@ describe 'WpTimthumbs::Detectable' do describe '::passive_detection' do it 'returns an empty WpTimthumbs' do - subject.passive_detection(wp_target).should == subject.new + expect(subject.passive_detection(wp_target)).to eq subject.new end end @@ -46,7 +46,7 @@ describe 'WpTimthumbs::Detectable' do after do targets = subject.send(:targets_items_from_file, file, wp_target) - targets.map { |t| t.url }.should == @expected.map { |t| t.url } + expect(targets.map { |t| t.url }).to eq @expected.map { |t| t.url } end context 'when an empty file' do @@ -71,7 +71,7 @@ describe 'WpTimthumbs::Detectable' do theme = 'hello-world' targets = subject.send(:theme_timthumbs, theme, wp_target) - targets.map { |t| t.url }.should == expected_targets_from_theme(theme).map { |t| t.url } + expect(targets.map { |t| t.url }).to eq expected_targets_from_theme(theme).map { |t| t.url } end end @@ -81,7 +81,7 @@ describe 'WpTimthumbs::Detectable' do after do targets = subject.send(:targets_items, wp_target, options) - targets.map { |t| t.url }.should == @expected.sort.map { |t| t.url } + expect(targets.map { |t| t.url }).to eq @expected.sort.map { |t| t.url } end context 'when no :theme_name' do diff --git a/spec/lib/common/collections/wp_users/detectable_spec.rb b/spec/lib/common/collections/wp_users/detectable_spec.rb index c3581f92..3a8c0f3b 100644 --- a/spec/lib/common/collections/wp_users/detectable_spec.rb +++ b/spec/lib/common/collections/wp_users/detectable_spec.rb @@ -22,13 +22,13 @@ describe 'WpUsers::Detectable' do describe '::request_params' do it 'return an empty Hash' do - subject.request_params.should === {} + expect(subject.request_params).to be === {} end end describe '::passive_detection' do it 'return an empty WpUsers' do - subject.passive_detection(wp_target).should == subject.new + expect(subject.passive_detection(wp_target)).to eq subject.new end end @@ -36,7 +36,7 @@ describe 'WpUsers::Detectable' do after do targets = subject.send(:targets_items, wp_target, options) - targets.should == @expected + expect(targets).to eq @expected end context 'when no :range' do diff --git a/spec/lib/common/collections/wp_users/output_spec.rb b/spec/lib/common/collections/wp_users/output_spec.rb index 2e9aea23..eed376c0 100644 --- a/spec/lib/common/collections/wp_users/output_spec.rb +++ b/spec/lib/common/collections/wp_users/output_spec.rb @@ -25,7 +25,7 @@ describe 'WpUsers::Output' do subject.push(@input) subject.flatten! subject.remove_junk_from_display_names - subject.should === @expected + expect(subject).to be === @expected end it 'should return an empty array' do diff --git a/spec/lib/common/common_helper_spec.rb b/spec/lib/common/common_helper_spec.rb index a423a573..25b67977 100644 --- a/spec/lib/common/common_helper_spec.rb +++ b/spec/lib/common/common_helper_spec.rb @@ -7,7 +7,7 @@ describe 'common_helper' do after :each do output = get_equal_string_end(@input) - output.should == @expected + expect(output).to eq @expected end it 'returns an empty string' do @@ -75,7 +75,7 @@ describe 'common_helper' do describe '#remove_base64_images_from_html' do after :each do output = remove_base64_images_from_html(@html) - output.should == @expected + expect(output).to eq @expected end it 'removes the valid base64 image' do @@ -92,7 +92,7 @@ describe 'common_helper' do describe '#truncate' do after :each do output = truncate(@input, @length, @trailing) - output.should == @expected + expect(output).to eq @expected end it 'returns nil on no input' do diff --git a/spec/lib/common/custom_option_parser_spec.rb b/spec/lib/common/custom_option_parser_spec.rb index 4cec8d18..a8752638 100644 --- a/spec/lib/common/custom_option_parser_spec.rb +++ b/spec/lib/common/custom_option_parser_spec.rb @@ -15,7 +15,7 @@ describe CustomOptionParser do if @exception expect { CustomOptionParser::option_to_symbol(@option) }.to raise_error(@exception) else - CustomOptionParser::option_to_symbol(@option).should === @expected + expect(CustomOptionParser::option_to_symbol(@option)).to be === @expected end end @@ -100,7 +100,7 @@ describe CustomOptionParser do parser.add_option(['-v', '--verbose']) parser.add_option(['--url TARGET_URL']) - parser.symbols_used.sort.should === [:url, :verbose] + expect(parser.symbols_used.sort).to be === [:url, :verbose] end context 'parsing' do @@ -118,7 +118,7 @@ describe CustomOptionParser do it 'should retrieve the correct argument' do parser.parse!(['-u', 'iam_the_target']) - parser.results.should === { url: 'iam_the_target' } + expect(parser.results).to be === { url: 'iam_the_target' } end end end @@ -134,8 +134,8 @@ describe CustomOptionParser do context 'single option' do it 'should add the :url option, and retrieve the correct argument' do - parser.symbols_used.should === [:url] - parser.results(['-u', 'target.com']).should === { url: 'target.com' } + expect(parser.symbols_used).to be === [:url] + expect(parser.results(['-u', 'target.com'])).to be === { url: 'target.com' } end end @@ -146,8 +146,8 @@ describe CustomOptionParser do ['--test [TEST_NUMBER]'] ]) - parser.symbols_used.sort.should === [:test, :url, :verbose] - parser.results(['-u', 'wp.com', '-v', '--test']).should === { test: nil, url: 'wp.com', verbose: true } + expect(parser.symbols_used.sort).to be === [:test, :url, :verbose] + expect(parser.results(['-u', 'wp.com', '-v', '--test'])).to be === { test: nil, url: 'wp.com', verbose: true } end end end diff --git a/spec/lib/common/models/wp_item_spec.rb b/spec/lib/common/models/wp_item_spec.rb index 2849a805..9ce20aec 100644 --- a/spec/lib/common/models/wp_item_spec.rb +++ b/spec/lib/common/models/wp_item_spec.rb @@ -30,30 +30,30 @@ describe WpItem do describe '#new' do context 'with no options' do - its(:wp_content_dir) { should == 'wp-content' } - its(:wp_plugins_dir) { should == 'wp-content/plugins' } - its(:uri) { should be uri } + its(:wp_content_dir) { is_expected.to eq 'wp-content' } + its(:wp_plugins_dir) { is_expected.to eq 'wp-content/plugins' } + its(:uri) { is_expected.to be uri } end context 'with :wp_content_dir' do let(:options) { { wp_content_dir: 'custom' } } - its(:wp_content_dir) { should == 'custom' } - its(:wp_plugins_dir) { should == 'custom/plugins' } + its(:wp_content_dir) { is_expected.to eq 'custom' } + its(:wp_plugins_dir) { is_expected.to eq 'custom/plugins' } end context 'with :wp_plugins_dir' do let(:options) { { wp_plugins_dir: 'c-plugins' } } - its(:wp_content_dir) { should == 'wp-content' } - its(:wp_plugins_dir) { should == 'c-plugins' } + its(:wp_content_dir) { is_expected.to eq 'wp-content' } + its(:wp_plugins_dir) { is_expected.to eq 'c-plugins' } end end describe '#set_options' do context 'no an allowed option' do it 'ignores the option' do - wp_item.should_not_receive(:not_allowed=) + expect(wp_item).not_to receive(:not_allowed=) wp_item.send(:set_options, { not_allowed: 'owned' }) end @@ -61,7 +61,7 @@ describe WpItem do context 'allowed option, w/o setter method' do it 'raises an error' do - wp_item.stub(:allowed_options).and_return([:no_setter]) + allow(wp_item).to receive(:allowed_options).and_return([:no_setter]) expect { wp_item.send(:set_options, { no_setter: 'hello' }) @@ -73,7 +73,7 @@ describe WpItem do describe '#path=' do after do wp_item.path = @path - wp_item.path.should == @expected + expect(wp_item.path).to eq @expected end context 'with default variable value' do @@ -90,8 +90,8 @@ describe WpItem do context 'whith custom variable values' do before { - wp_item.stub(:wp_content_dir).and_return('custom-content') - wp_item.stub(:wp_plugins_dir).and_return('plugins') + allow(wp_item).to receive(:wp_content_dir).and_return('custom-content') + allow(wp_item).to receive(:wp_plugins_dir).and_return('plugins') } it 'replaces $wp-content$ by custom-content' do @@ -117,7 +117,7 @@ describe WpItem do path = 'somedir/somefile.php' wp_item.path = path - wp_item.uri.should == uri.merge(path) + expect(wp_item.uri).to eq uri.merge(path) end end end @@ -127,7 +127,7 @@ describe WpItem do wp_item.name = 'a-name' other = WpItem.new(uri, name: 'other-name') - wp_item.<=>(other).should === 'a-name'.<=>('other-name') + expect(wp_item.<=>(other)).to be === 'a-name'.<=>('other-name') end end @@ -137,7 +137,7 @@ describe WpItem do wp_item.name = 'some-name' other = WpItem.new(uri, name: 'some-name') - wp_item.should == other + expect(wp_item).to eq other end end @@ -146,7 +146,7 @@ describe WpItem do wp_item.name = 'Test' other = WpItem.new(uri, name: 'hello') - wp_item.should_not == other + expect(wp_item).not_to eq other end end end @@ -156,13 +156,13 @@ describe WpItem do context 'when the :name and :version are the same' do it 'is ===' do - WpItem.new(uri, options).should === WpItem.new(uri.merge('yo'), options) + expect(WpItem.new(uri, options)).to be === WpItem.new(uri.merge('yo'), options) end end context 'otherwise' do it 'is not ===' do - WpItem.new(uri, options).should_not === WpItem.new(uri, options.merge(version: '1.0')) + expect(WpItem.new(uri, options)).not_to be === WpItem.new(uri, options.merge(version: '1.0')) end end end diff --git a/spec/lib/common/models/wp_plugin_spec.rb b/spec/lib/common/models/wp_plugin_spec.rb index 50dca22f..87e07d28 100644 --- a/spec/lib/common/models/wp_plugin_spec.rb +++ b/spec/lib/common/models/wp_plugin_spec.rb @@ -23,7 +23,7 @@ describe WpPlugin do let(:options) { { name: 'plugin-name' } } describe '#forge_uri' do - its('uri.to_s') { should == 'http://example.com/wp-content/plugins/plugin-name/' } + its('uri.to_s') { is_expected.to eq 'http://example.com/wp-content/plugins/plugin-name/' } end end diff --git a/spec/lib/common/models/wp_theme/findable_spec.rb b/spec/lib/common/models/wp_theme/findable_spec.rb index 58ed03ef..fc160d02 100644 --- a/spec/lib/common/models/wp_theme/findable_spec.rb +++ b/spec/lib/common/models/wp_theme/findable_spec.rb @@ -18,9 +18,9 @@ describe 'WpTheme::Findable' do wp_theme = WpTheme.send(:find_from_css_link, uri) if @expected - wp_theme.should be_a WpTheme + expect(wp_theme).to be_a WpTheme end - wp_theme.should == @expected + expect(wp_theme).to eq @expected end context 'when theme is not present' do @@ -66,9 +66,9 @@ describe 'WpTheme::Findable' do wp_theme = WpTheme.send(:find_from_wooframework, uri) if @expected - wp_theme.should be_a WpTheme + expect(wp_theme).to be_a WpTheme end - wp_theme.should == @expected + expect(wp_theme).to eq @expected end context 'when theme is not present' do @@ -96,7 +96,7 @@ describe 'WpTheme::Findable' do # Stub all WpTheme::find_from_* to return nil def stub_all_to_nil WpTheme.methods.grep(/^find_from_/).each do |method| - WpTheme.stub(method).and_return(nil) + allow(WpTheme).to receive(method).and_return(nil) end end @@ -120,7 +120,7 @@ describe 'WpTheme::Findable' do it 'returns nil' do stub_all_to_nil() - WpTheme.find(uri).should be_nil + expect(WpTheme.find(uri)).to be_nil end end @@ -130,12 +130,12 @@ describe 'WpTheme::Findable' do stub_request(:get, /.+\/the-oracle\/style.css$/).to_return(status: 200) expected = WpTheme.new(uri, name: 'the-oracle') - WpTheme.stub(:find_from_css_link).and_return(expected) + allow(WpTheme).to receive(:find_from_css_link).and_return(expected) wp_theme = WpTheme.find(uri) - wp_theme.should be_a WpTheme - wp_theme.should == expected - wp_theme.found_from.should === 'css link' + expect(wp_theme).to be_a WpTheme + expect(wp_theme).to eq expected + expect(wp_theme.found_from).to be === 'css link' end end diff --git a/spec/lib/common/models/wp_theme_spec.rb b/spec/lib/common/models/wp_theme_spec.rb index 328fc8fa..e8d79334 100644 --- a/spec/lib/common/models/wp_theme_spec.rb +++ b/spec/lib/common/models/wp_theme_spec.rb @@ -29,22 +29,22 @@ describe WpTheme do let(:theme_path) { 'wp-content/themes/theme-name/' } describe '#allowed_options' do - its(:allowed_options) { should include :style_url } + its(:allowed_options) { is_expected.to include :style_url } end describe '#forge_uri' do - its(:uri) { should == uri.merge(theme_path) } + its(:uri) { is_expected.to eq uri.merge(theme_path) } end describe '#style_url' do - its(:style_url) { should == uri.merge(theme_path + '/style.css').to_s } + its(:style_url) { is_expected.to eq uri.merge(theme_path + '/style.css').to_s } context 'when its already set' do it 'returns it instead of the default one' do url = uri.merge(theme_path + '/custom.css').to_s wp_theme.style_url = url - wp_theme.style_url.should == url + expect(wp_theme.style_url).to eq url end end end diff --git a/spec/lib/common/models/wp_timthumb_spec.rb b/spec/lib/common/models/wp_timthumb_spec.rb index 34aad56a..a368bf38 100644 --- a/spec/lib/common/models/wp_timthumb_spec.rb +++ b/spec/lib/common/models/wp_timthumb_spec.rb @@ -13,17 +13,19 @@ describe WpTimthumb do describe '#==' do context 'when both url are equal' do it 'returns true' do - WpTimthumb.new(uri, path: 'timtuhumb.php'). - should == + expect(WpTimthumb.new(uri, path: 'timtuhumb.php')). + to eq( WpTimthumb.new(uri, path: 'timtuhumb.php') + ) end end context 'when urls are different' do it 'returns false' do - WpTimthumb.new(uri, path: 'hello/timtuhumb.php'). - should_not == + expect(WpTimthumb.new(uri, path: 'hello/timtuhumb.php')). + not_to eq( WpTimthumb.new(uri, path: 'some-dir/timtuhumb.php') + ) end end end diff --git a/spec/lib/common/models/wp_user_spec.rb b/spec/lib/common/models/wp_user_spec.rb index ce5c6e14..fdaf5be9 100644 --- a/spec/lib/common/models/wp_user_spec.rb +++ b/spec/lib/common/models/wp_user_spec.rb @@ -12,10 +12,10 @@ describe WpUser do describe '#allowed_options' do [:id, :login, :display_name, :password].each do |sym| - its(:allowed_options) { should include sym } + its(:allowed_options) { is_expected.to include sym } end - its(:allowed_options) { should_not include :name } + its(:allowed_options) { is_expected.not_to include :name } end describe '#uri' do @@ -29,7 +29,7 @@ describe WpUser do it 'returns the uri to the auhor page' do wp_user.id = 2 - wp_user.uri.should == uri.merge('?author=2') + expect(wp_user.uri).to eq uri.merge('?author=2') end end end @@ -37,7 +37,7 @@ describe WpUser do describe '#to_s' do after do subject.id = 1 - subject.to_s.should == @expected + expect(subject.to_s).to eq @expected end it 'returns @id' do @@ -67,20 +67,20 @@ describe WpUser do wp_user.id = 1 other = WpUser.new(uri, id: 3) - wp_user.<=>(other).should === 1.<=>(3) + expect(wp_user.<=>(other)).to be === 1.<=>(3) end end describe '#===, #==' do context 'when the :id and :login are the same' do it 'is ===, and ==' do - WpUser.new(uri, id: 1, name: 'yo').should == WpUser.new(uri, id: 1, name: 'yo') + expect(WpUser.new(uri, id: 1, name: 'yo')).to eq WpUser.new(uri, id: 1, name: 'yo') end end context 'when :id and :login are different' do it 'is not === or ==' do - WpUser.new(uri, id: 1, name: 'yo').should_not == WpUser.new(uri, id: 2, name:'yo') + expect(WpUser.new(uri, id: 1, name: 'yo')).not_to eq WpUser.new(uri, id: 2, name:'yo') end end end diff --git a/spec/lib/common/models/wp_version/findable_spec.rb b/spec/lib/common/models/wp_version/findable_spec.rb index 994ff744..58636cbf 100644 --- a/spec/lib/common/models/wp_version/findable_spec.rb +++ b/spec/lib/common/models/wp_version/findable_spec.rb @@ -26,7 +26,7 @@ describe 'WpVersion::Findable' do fixture = fixtures_dir + dir_name + @fixture stub_request_to_fixture(url: url, fixture: fixture) - WpVersion.send(method, uri).should == @expected + expect(WpVersion.send(method, uri)).to eq @expected end context 'when generator not found' do @@ -81,7 +81,7 @@ describe 'WpVersion::Findable' do :find_from_advanced_fingerprinting, uri, wp_content_dir, wp_plugins_dir, versions_xml ) - version.should == @expected + expect(version).to eq @expected end context 'when' do @@ -108,7 +108,7 @@ describe 'WpVersion::Findable' do fixture = fixtures_dir + 'readme' + @fixture stub_request_to_fixture(url: url, fixture: fixture) - WpVersion.send(:find_from_readme, uri).should == @expected + expect(WpVersion.send(:find_from_readme, uri)).to eq @expected end context 'when version not found' do @@ -138,7 +138,7 @@ describe 'WpVersion::Findable' do fixture = fixtures_dir + 'links_opml' + @fixture stub_request_to_fixture(url: url, fixture: fixture) - WpVersion.send(:find_from_links_opml, uri).should == @expected + expect(WpVersion.send(:find_from_links_opml, uri)).to eq @expected end it 'returns 3.4.2' do @@ -158,7 +158,7 @@ describe 'WpVersion::Findable' do # Stub all WpVersion::find_from_* to return nil def stub_all_to_nil WpVersion.methods.grep(/^find_from_/).each do |method| - WpVersion.stub(method).and_return(nil) + allow(WpVersion).to receive(method).and_return(nil) end end @@ -170,9 +170,9 @@ describe 'WpVersion::Findable' do stub_request(:get, /#{uri.to_s}.*/).to_return(status: 0) version = WpVersion.find(uri, wp_content_dir, wp_plugins_dir, version_xml) - version.should == @expected + expect(version).to eq @expected if @expected - version.found_from.should == @found_from + expect(version.found_from).to eq @found_from end end @@ -191,7 +191,7 @@ describe 'WpVersion::Findable' do it "returns the correct WpVersion" do stub_all_to_nil() - WpVersion.stub(method).and_return(number) + allow(WpVersion).to receive(method).and_return(number) @expected = WpVersion.new(uri, number: number) @found_from = found_from diff --git a/spec/lib/common/models/wp_version_spec.rb b/spec/lib/common/models/wp_version_spec.rb index 85387fb6..01621113 100644 --- a/spec/lib/common/models/wp_version_spec.rb +++ b/spec/lib/common/models/wp_version_spec.rb @@ -24,7 +24,7 @@ describe WpVersion do describe '#allowed_options' do [:number, :found_from].each do |sym| - its(:allowed_options) { should include sym } + its(:allowed_options) { is_expected.to include sym } end end diff --git a/spec/lib/common/plugins/plugin_spec.rb b/spec/lib/common/plugins/plugin_spec.rb index d3c3faf9..a7e7fd12 100644 --- a/spec/lib/common/plugins/plugin_spec.rb +++ b/spec/lib/common/plugins/plugin_spec.rb @@ -10,7 +10,7 @@ describe Plugin do subject(:plugin) { Plugin.new(infos) } let(:infos) { { author: 'John' } } - its(:author) { should === infos[:author] } + its(:author) { is_expected.to be === infos[:author] } end end @@ -26,7 +26,7 @@ describe Plugin do expect { plugin.register_options(*@options) }.to raise_error(@exception) else plugin.register_options(*@options) - plugin.registered_options.sort.should === @expected.sort + expect(plugin.registered_options.sort).to be === @expected.sort end end diff --git a/spec/lib/common/plugins/plugins_spec.rb b/spec/lib/common/plugins/plugins_spec.rb index d18f979e..f86f7535 100644 --- a/spec/lib/common/plugins/plugins_spec.rb +++ b/spec/lib/common/plugins/plugins_spec.rb @@ -23,18 +23,18 @@ describe Plugins do describe '#new' do context 'without argument' do - its(:option_parser) { should be_a CustomOptionParser } + its(:option_parser) { is_expected.to be_a CustomOptionParser } it 'should be an Array' do - plugins.should be_an Array + expect(plugins).to be_an Array end end context 'with an option_parser argument' do subject(:plugin) { Plugins.new(CustomOptionParser.new('the banner')) } - its(:option_parser) { should be_a CustomOptionParser } - its('option_parser.banner') { should === 'the banner' } + its(:option_parser) { is_expected.to be_a CustomOptionParser } + its('option_parser.banner') { is_expected.to be === 'the banner' } it 'should raise an eror if the parser is not an instance of CustomOptionParser' do expect { Plugins.new(OptionParser.new) }.to raise_error('The parser must be an instance of CustomOptionParser, OptionParser supplied') @@ -48,8 +48,8 @@ describe Plugins do expect { plugins.register_plugin(@plugin) }.to raise_error(@exception) else plugins.register_plugin(@plugin) - plugins.should include(@plugin) - plugins.should === @expected + expect(plugins).to include(@plugin) + expect(plugins).to be === @expected end end @@ -78,11 +78,11 @@ describe Plugins do plugins.register(*@plugins_to_register) @plugins_to_register.each do |plugin| - plugins.should include(plugin) + expect(plugins).to include(plugin) end # For the correct order - plugins.should === @plugins_to_register + expect(plugins).to be === @plugins_to_register end it 'should register 1 plugin' do diff --git a/spec/lib/common/updater/git_updater_spec.rb b/spec/lib/common/updater/git_updater_spec.rb index 607cbcb1..f10838cb 100644 --- a/spec/lib/common/updater/git_updater_spec.rb +++ b/spec/lib/common/updater/git_updater_spec.rb @@ -11,7 +11,7 @@ describe GitUpdater do describe '#is_installed?' do after :each do stub_system_command(@git_updater, /^git .* status/, @stub_value) - @git_updater.is_installed?.should === @expected + expect(@git_updater.is_installed?).to be === @expected end it 'should return false if the command is not found' do @@ -28,7 +28,7 @@ describe GitUpdater do describe '#local_revision_number' do after :each do stub_system_command(@git_updater, /^git .* log/, @stub_value) - @git_updater.local_revision_number.should === @expected + expect(@git_updater.local_revision_number).to be === @expected end it 'should return 79c01f3' do @@ -43,14 +43,14 @@ describe GitUpdater do describe '#update' do it 'should do nothing xD' do stub_system_command(@git_updater, /^git .* pull/, 'Already up-to-date.') - @git_updater.update().should === 'Already up-to-date.' + expect(@git_updater.update()).to be === 'Already up-to-date.' end end describe '#has_local_changes?' do after :each do stub_system_command(@git_updater, /^git .* diff --exit-code 2>&1/, @stub_value) - @git_updater.has_local_changes?.should === @expected + expect(@git_updater.has_local_changes?).to be === @expected end it 'should return true if there are local changes' do @@ -67,7 +67,7 @@ describe GitUpdater do describe '#reset_head' do it 'should reset the local repo' do stub_system_command(@git_updater, /^git .* reset --hard HEAD/, 'HEAD is now at') - @git_updater.reset_head.should match(/^HEAD is now at/) + expect(@git_updater.reset_head).to match(/^HEAD is now at/) end end diff --git a/spec/lib/common/updater/svn_updater_spec.rb b/spec/lib/common/updater/svn_updater_spec.rb index 24c2c69a..351ac12a 100644 --- a/spec/lib/common/updater/svn_updater_spec.rb +++ b/spec/lib/common/updater/svn_updater_spec.rb @@ -11,7 +11,7 @@ describe SvnUpdater do describe '#is_installed?' do after :each do stub_system_command(@svn_updater, /^svn info/, @stub_value) - @svn_updater.is_installed?.should === @expected + expect(@svn_updater.is_installed?).to be === @expected end it 'should return false if the svn command is not found' do @@ -50,7 +50,7 @@ describe SvnUpdater do describe '#local_revision_number' do after :each do stub_system_command(@svn_updater, /^svn info/, @stub_value) - @svn_updater.local_revision_number.should === @expected + expect(@svn_updater.local_revision_number).to be === @expected end it 'should return 399' do @@ -79,7 +79,7 @@ describe SvnUpdater do describe '#update' do it 'should do nothing xD' do stub_system_command(@svn_updater, /^svn up/, 'At revision 425.') - @svn_updater.update().should === 'At revision 425.' + expect(@svn_updater.update()).to be === 'At revision 425.' end end diff --git a/spec/lib/common/updater/updater_factory_spec.rb b/spec/lib/common/updater/updater_factory_spec.rb index bcedbdf5..dc51f4fd 100644 --- a/spec/lib/common/updater/updater_factory_spec.rb +++ b/spec/lib/common/updater/updater_factory_spec.rb @@ -6,7 +6,7 @@ describe UpdaterFactory do describe '#available_updaters_classes' do after :each do - UpdaterFactory.available_updaters_classes.sort.should === @expected.sort + expect(UpdaterFactory.available_updaters_classes.sort).to be === @expected.sort end it 'should return [:GitUpdater, :SvnUpdater]' do diff --git a/spec/lib/common/version_compare_spec.rb b/spec/lib/common/version_compare_spec.rb index 10f75900..d052f772 100644 --- a/spec/lib/common/version_compare_spec.rb +++ b/spec/lib/common/version_compare_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe 'VersionCompare' do describe '::is_newer_or_same?' do context 'version checked is newer' do - after { VersionCompare::is_newer_or_same?(@version1, @version2).should be_true } + after { expect(VersionCompare::is_newer_or_same?(@version1, @version2)).to be_truthy } it 'returns true' do @version1 = '1.0' @@ -39,7 +39,7 @@ describe 'VersionCompare' do end context 'version checked is older' do - after { VersionCompare::is_newer_or_same?(@version1, @version2).should be_false } + after { expect(VersionCompare::is_newer_or_same?(@version1, @version2)).to be_falsey } it 'returns false' do @version1 = '1' @@ -63,7 +63,7 @@ describe 'VersionCompare' do end context 'version checked is the same' do - after { VersionCompare::is_newer_or_same?(@version1, @version2).should be_true } + after { expect(VersionCompare::is_newer_or_same?(@version1, @version2)).to be_truthy } it 'returns true' do @version1 = '1' @@ -78,7 +78,7 @@ describe 'VersionCompare' do end context 'version number causes Gem::Version new Exception' do - after { VersionCompare::is_newer_or_same?(@version1, @version2).should be_false } + after { expect(VersionCompare::is_newer_or_same?(@version1, @version2)).to be_falsey } it 'returns false' do @version1 = 'a' @@ -87,7 +87,7 @@ describe 'VersionCompare' do end context 'one version number is not set' do - after { VersionCompare::is_newer_or_same?(@version1, @version2).should be_false } + after { expect(VersionCompare::is_newer_or_same?(@version1, @version2)).to be_falsey } it 'returns false (version2 nil)' do @version1 = '1' diff --git a/spec/lib/wpscan/web_site_spec.rb b/spec/lib/wpscan/web_site_spec.rb index c69c245f..64144d38 100644 --- a/spec/lib/wpscan/web_site_spec.rb +++ b/spec/lib/wpscan/web_site_spec.rb @@ -18,13 +18,13 @@ describe 'WebSite' do end describe "#new" do - its(:url) { should === 'http://example.localhost/' } + its(:url) { is_expected.to be === 'http://example.localhost/' } end describe '#url=' do after :each do web_site.url = @uri - web_site.url.should === @expected + expect(web_site.url).to be === @expected end context 'when protocol or trailing slash is missing' do @@ -45,30 +45,30 @@ describe 'WebSite' do describe '#online?' do it 'should not be considered online if the status code is 0' do stub_request(:get, web_site.url).to_return(status: 0) - web_site.should_not be_online + expect(web_site).not_to be_online end it 'should be considered online if the status code is != 0' do stub_request(:get, web_site.url).to_return(status: 200) - web_site.should be_online + expect(web_site).to be_online end end describe '#has_basic_auth?' do it 'should detect that the wpsite is basic auth protected' do stub_request(:get, web_site.url).to_return(status: 401) - web_site.should have_basic_auth + expect(web_site).to have_basic_auth end it 'should not have a basic auth for a 200' do stub_request(:get, web_site.url).to_return(status: 200) - web_site.should_not have_basic_auth + expect(web_site).not_to have_basic_auth end end describe '#xml_rpc_url' do it 'returns the xmlrpc url' do - web_site.xml_rpc_url.should === "http://example.localhost/xmlrpc.php" + expect(web_site.xml_rpc_url).to be === "http://example.localhost/xmlrpc.php" end end @@ -77,17 +77,17 @@ describe 'WebSite' do stub_request(:get, web_site.xml_rpc_url). to_return(status: 200, body: "XML-RPC server accepts POST requests only") - web_site.should have_xml_rpc + expect(web_site).to have_xml_rpc end it 'returns false' do stub_request(:get, web_site.xml_rpc_url).to_return(status: 200) - web_site.should_not have_xml_rpc + expect(web_site).not_to have_xml_rpc end end describe '#page_hash' do - after { WebSite.page_hash(page).should == Digest::MD5.hexdigest(@expected) } + after { expect(WebSite.page_hash(page)).to eq Digest::MD5.hexdigest(@expected) } context 'when the page is an url' do let(:page) { 'http://e.localhost/somepage.php' } @@ -125,7 +125,7 @@ describe 'WebSite' do body = 'Hello World' stub_request(:get, web_site.url).to_return(body: body) - web_site.homepage_hash.should === Digest::MD5.hexdigest(body) + expect(web_site.homepage_hash).to be === Digest::MD5.hexdigest(body) end end @@ -134,19 +134,19 @@ describe 'WebSite' do stub_request(:any, /.*/). to_return(status: 404, body: '404 page !') - web_site.error_404_hash.should === Digest::MD5.hexdigest('404 page !') + expect(web_site.error_404_hash).to be === Digest::MD5.hexdigest('404 page !') end end describe '#rss_url' do it 'returns nil if the url is not found' do stub_request(:get, web_site.url).to_return(body: 'No RSS link in this body !') - web_site.rss_url.should be_nil + expect(web_site.rss_url).to be_nil end it "returns 'http://lamp-wp/wordpress-3.5/?feed=rss2'" do stub_request_to_fixture(url: web_site.url, fixture: fixtures_dir + '/rss_url/wordpress-3.5.htm') - web_site.rss_url.should === 'http://lamp-wp/wordpress-3.5/?feed=rss2' + expect(web_site.rss_url).to be === 'http://lamp-wp/wordpress-3.5/?feed=rss2' end end @@ -156,7 +156,7 @@ describe 'WebSite' do after do stub_request_to_fixture(url: log_url, fixture: fixtures_dir + "/has_log/#{@file}") - WebSite.has_log?(log_url, pattern).should == @expected + expect(WebSite.has_log?(log_url, pattern)).to eq @expected end context 'when the pattern does not match' do diff --git a/spec/lib/wpscan/wp_target_spec.rb b/spec/lib/wpscan/wp_target_spec.rb index 132c80bb..e558859e 100644 --- a/spec/lib/wpscan/wp_target_spec.rb +++ b/spec/lib/wpscan/wp_target_spec.rb @@ -37,7 +37,7 @@ describe WpTarget do it 'returns the login url of the target' do stub_request(:get, login_url).to_return(status: 200, body: '') - wp_target.login_url.should === login_url + expect(wp_target.login_url).to be === login_url end it 'returns the redirection url if there is one (ie: for https)' do @@ -46,7 +46,7 @@ describe WpTarget do stub_request(:get, login_url).to_return(status: 302, headers: { location: https_login_url }) stub_request(:get, https_login_url).to_return(status: 200) - wp_target.login_url.should === https_login_url + expect(wp_target.login_url).to be === https_login_url end end @@ -57,7 +57,7 @@ describe WpTarget do to_return(status: 200, body: '', headers: { 'X-Pingback' => wp_target.uri.merge('xmlrpc.php')}) # Preventing redirection check from login_url() - wp_target.stub(redirection: nil) + allow(wp_target).to receive_messages(redirection: nil) [wp_target.login_url, wp_target.xml_rpc_url].each do |url| stub_request(:get, url).to_return(status: 404, body: '') @@ -67,25 +67,25 @@ describe WpTarget do it 'returns true if there is a /wp-content/ detected in the index page source' do stub_request_to_fixture(url: wp_target.url, fixture: fixtures_dir + '/wp_content_dir/wordpress-3.4.1.htm') - wp_target.should be_wordpress + expect(wp_target).to be_wordpress end it 'returns true if the xmlrpc is found' do stub_request(:get, wp_target.xml_rpc_url). to_return(status: 200, body: File.new(fixtures_dir + '/xmlrpc.php')) - wp_target.should be_wordpress + expect(wp_target).to be_wordpress end it 'returns true if the wp-login is found and is a valid wordpress one' do stub_request(:get, wp_target.login_url). to_return(status: 200, body: File.new(fixtures_dir + '/wp-login.php')) - wp_target.should be_wordpress + expect(wp_target).to be_wordpress end it 'returns false if both files are not found (404)' do - wp_target.should_not be_wordpress + expect(wp_target).not_to be_wordpress end context 'when the url contains "wordpress" and is a 404' do @@ -94,7 +94,7 @@ describe WpTarget do it 'returns false' do stub_request(:get, wp_target.login_url).to_return(status: 404, body: 'The requested URL /wordpress-3.5. was not found on this server.') - wp_target.should_not be_wordpress + expect(wp_target).not_to be_wordpress end end @@ -110,17 +110,17 @@ describe WpTarget do describe '#wordpress_hosted?' do it 'returns true if target url is a wordpress.com subdomain' do target = WpTarget.new('http://test.wordpress.com/') - target.wordpress_hosted?.should be_true + expect(target.wordpress_hosted?).to be_truthy end it 'returns true if target url is a wordpress.com subdomain and has querystring' do target = WpTarget.new('http://test.wordpress.com/path/file.php?a=b') - target.wordpress_hosted?.should be_true + expect(target.wordpress_hosted?).to be_truthy end it 'returns false if target url is not a wordpress.com subdomain' do target = WpTarget.new('http://test.example.com/') - target.wordpress_hosted?.should be_false + expect(target.wordpress_hosted?).to be_falsey end end @@ -128,7 +128,7 @@ describe WpTarget do it 'returns nil if no redirection detected' do stub_request(:get, wp_target.url).to_return(status: 200, body: '') - wp_target.redirection.should be_nil + expect(wp_target.redirection).to be_nil end [301, 302].each do |status_code| @@ -140,7 +140,7 @@ describe WpTarget do stub_request(:get, new_location).to_return(status: 200) - wp_target.redirection.should === 'http://new-location.com' + expect(wp_target.redirection).to be === 'http://new-location.com' end end @@ -153,15 +153,15 @@ describe WpTarget do stub_request(:get, first_redirection).to_return(status: 302, headers: { location: last_redirection }) stub_request(:get, last_redirection).to_return(status: 200) - wp_target.redirection.should === last_redirection + expect(wp_target.redirection).to be === last_redirection end end end describe '#debug_log_url' do it "returns 'http://example.localhost/wp-content/debug.log" do - wp_target.stub(wp_content_dir: 'wp-content') - wp_target.debug_log_url.should === 'http://example.localhost/wp-content/debug.log' + allow(wp_target).to receive_messages(wp_content_dir: 'wp-content') + expect(wp_target.debug_log_url).to be === 'http://example.localhost/wp-content/debug.log' end end @@ -169,9 +169,9 @@ describe WpTarget do let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR + '/debug_log' } after :each do - wp_target.stub(wp_content_dir: 'wp-content') + allow(wp_target).to receive_messages(wp_content_dir: 'wp-content') stub_request_to_fixture(url: wp_target.debug_log_url(), fixture: @fixture) - wp_target.has_debug_log?.should === @expected + expect(wp_target.has_debug_log?).to be === @expected end it 'returns false' do @@ -192,24 +192,24 @@ describe WpTarget do describe '#search_replace_db_2_url' do it 'returns the correct url' do - wp_target.search_replace_db_2_url.should == 'http://example.localhost/searchreplacedb2.php' + expect(wp_target.search_replace_db_2_url).to eq 'http://example.localhost/searchreplacedb2.php' end end describe '#search_replace_db_2_exists?' do it 'returns true' do stub_request(:any, wp_target.search_replace_db_2_url).to_return(status: 200, body: 'asdf by interconnect asdf') - wp_target.search_replace_db_2_exists?.should be_true + expect(wp_target.search_replace_db_2_exists?).to be_truthy end it 'returns false' do stub_request(:any, wp_target.search_replace_db_2_url).to_return(status: 500) - wp_target.search_replace_db_2_exists?.should be_false + expect(wp_target.search_replace_db_2_exists?).to be_falsey end it 'returns false' do stub_request(:any, wp_target.search_replace_db_2_url).to_return(status: 500, body: 'asdf by interconnect asdf') - wp_target.search_replace_db_2_exists?.should be_false + expect(wp_target.search_replace_db_2_exists?).to be_falsey end end diff --git a/spec/lib/wpscan/wpscan_options_spec.rb b/spec/lib/wpscan/wpscan_options_spec.rb index fb50350a..947229d9 100644 --- a/spec/lib/wpscan/wpscan_options_spec.rb +++ b/spec/lib/wpscan/wpscan_options_spec.rb @@ -11,7 +11,7 @@ describe 'WpscanOptions' do describe '#initialize' do it 'should set all options to nil' do WpscanOptions::ACCESSOR_OPTIONS.each do |option| - @wpscan_options.send(option).should === nil + expect(@wpscan_options.send(option)).to be === nil end end end @@ -24,27 +24,27 @@ describe 'WpscanOptions' do it 'should add the http protocol if not present' do @wpscan_options.url = 'example.com' - @wpscan_options.url.should === 'http://example.com' + expect(@wpscan_options.url).to be === 'http://example.com' end it "should not add the http protocol if it's already present" do url = 'http://example.com' @wpscan_options.url = url - @wpscan_options.url.should === url + expect(@wpscan_options.url).to be === url end end describe '#threads=' do it 'should convert an integer in a string into an integr' do @wpscan_options.threads = '10' - @wpscan_options.threads.should be_an Integer - @wpscan_options.threads.should === 10 + expect(@wpscan_options.threads).to be_an Integer + expect(@wpscan_options.threads).to be === 10 end it 'should set to correct number of threads' do @wpscan_options.threads = 15 - @wpscan_options.threads.should be_an Integer - @wpscan_options.threads.should === 15 + expect(@wpscan_options.threads).to be_an Integer + expect(@wpscan_options.threads).to be === 15 end end @@ -57,7 +57,7 @@ describe 'WpscanOptions' do wordlist_file = "#{SPEC_FIXTURES_WPSCAN_WPSCAN_OPTIONS_DIR}/wordlist.txt" @wpscan_options.wordlist = wordlist_file - @wpscan_options.wordlist.should === wordlist_file + expect(@wpscan_options.wordlist).to be === wordlist_file end end @@ -69,7 +69,7 @@ describe 'WpscanOptions' do it 'should not raise an error' do proxy = '127.0.0.1:3038' @wpscan_options.proxy = proxy - @wpscan_options.proxy.should === proxy + expect(@wpscan_options.proxy).to be === proxy end end @@ -81,7 +81,7 @@ describe 'WpscanOptions' do it 'should not raise en error' do proxy_auth = 'user:pass' @wpscan_options.proxy_auth = proxy_auth - @wpscan_options.proxy_auth.should === proxy_auth + expect(@wpscan_options.proxy_auth).to be === proxy_auth end end @@ -97,7 +97,7 @@ describe 'WpscanOptions' do @wpscan_options.enumerate_only_vulnerable_plugins = false @wpscan_options.enumerate_plugins = true - @wpscan_options.enumerate_plugins.should be_true + expect(@wpscan_options.enumerate_plugins).to be_truthy end end @@ -113,7 +113,7 @@ describe 'WpscanOptions' do @wpscan_options.enumerate_only_vulnerable_themes = false @wpscan_options.enumerate_themes = true - @wpscan_options.enumerate_themes.should be_true + expect(@wpscan_options.enumerate_themes).to be_truthy end end @@ -129,7 +129,7 @@ describe 'WpscanOptions' do @wpscan_options.enumerate_plugins = false @wpscan_options.enumerate_only_vulnerable_plugins = true - @wpscan_options.enumerate_only_vulnerable_plugins.should be_true + expect(@wpscan_options.enumerate_only_vulnerable_plugins).to be_truthy end end @@ -145,7 +145,7 @@ describe 'WpscanOptions' do @wpscan_options.enumerate_themes = false @wpscan_options.enumerate_only_vulnerable_themes = true - @wpscan_options.enumerate_only_vulnerable_themes.should be_true + expect(@wpscan_options.enumerate_only_vulnerable_themes).to be_truthy end end @@ -161,7 +161,7 @@ describe 'WpscanOptions' do @wpscan_options.enumerate_themes = false @wpscan_options.enumerate_all_themes = true - @wpscan_options.enumerate_all_themes.should be_true + expect(@wpscan_options.enumerate_all_themes).to be_truthy end end @@ -177,7 +177,7 @@ describe 'WpscanOptions' do @wpscan_options.enumerate_plugins = false @wpscan_options.enumerate_all_plugins = true - @wpscan_options.enumerate_all_plugins.should be_true + expect(@wpscan_options.enumerate_all_plugins).to be_truthy end end @@ -193,39 +193,39 @@ describe 'WpscanOptions' do context 'valid format' do it "should add the 'Basic' word and do the encode64. See RFC 2617" do @wpscan_options.basic_auth = 'Aladdin:open sesame' - @wpscan_options.basic_auth.should == 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' + expect(@wpscan_options.basic_auth).to eq 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' end end end describe '#has_options?' do it 'should return false' do - @wpscan_options.has_options?.should be_false + expect(@wpscan_options.has_options?).to be_falsey end it 'should return true' do @wpscan_options.verbose = false - @wpscan_options.has_options?.should be_true + expect(@wpscan_options.has_options?).to be_truthy end end describe '#to_h' do it 'should return an empty hash' do - @wpscan_options.to_h.should be_a Hash - @wpscan_options.to_h.should be_empty + expect(@wpscan_options.to_h).to be_a Hash + expect(@wpscan_options.to_h).to be_empty end it 'should return a hash with :verbose = true' do expected = {verbose: true} @wpscan_options.verbose = true - @wpscan_options.to_h.should === expected + expect(@wpscan_options.to_h).to be === expected end end describe '#clean_option' do after :each do - WpscanOptions.clean_option(@option).should === @expected + expect(WpscanOptions.clean_option(@option)).to be === @expected end it "should return 'url'" do @@ -246,7 +246,7 @@ describe 'WpscanOptions' do describe '#option_to_instance_variable_setter' do after :each do - WpscanOptions.option_to_instance_variable_setter(@argument).should === @expected + expect(WpscanOptions.option_to_instance_variable_setter(@argument)).to be === @expected end it 'should return :url=' do @@ -277,12 +277,12 @@ describe 'WpscanOptions' do describe '#is_long_option?' do it 'should return true' do - WpscanOptions.is_long_option?('--url').should be_true + expect(WpscanOptions.is_long_option?('--url')).to be_truthy end it 'should return false' do - WpscanOptions.is_long_option?('hello').should be_false - WpscanOptions.is_long_option?('--enumerate').should be_false + expect(WpscanOptions.is_long_option?('hello')).to be_falsey + expect(WpscanOptions.is_long_option?('--enumerate')).to be_falsey end end @@ -291,7 +291,7 @@ describe 'WpscanOptions' do if @argument wpscan_options = WpscanOptions.new wpscan_options.enumerate_options_from_string(@argument) - wpscan_options.to_h.should === @expected_hash + expect(wpscan_options.to_h).to be === @expected_hash end end @@ -341,20 +341,20 @@ describe 'WpscanOptions' do it 'should set @url to example.com' do @wpscan_options.set_option_from_cli('--url', 'example.com') - @wpscan_options.url.should === 'http://example.com' + expect(@wpscan_options.url).to be === 'http://example.com' end it 'should set @enumerate_plugins to true' do @wpscan_options.set_option_from_cli('--enumerate', 'p') - @wpscan_options.enumerate_plugins.should be_true - @wpscan_options.enumerate_only_vulnerable_plugins.should be_nil + expect(@wpscan_options.enumerate_plugins).to be_truthy + expect(@wpscan_options.enumerate_only_vulnerable_plugins).to be_nil end it 'should set @enumerate_only_vulnerable_plugins, @enumerate_timthumbs and @enumerate_usernames to true if no argument is given' do @wpscan_options.set_option_from_cli('--enumerate', '') - @wpscan_options.enumerate_only_vulnerable_plugins.should be_true - @wpscan_options.enumerate_timthumbs.should be_true - @wpscan_options.enumerate_usernames.should be_true + expect(@wpscan_options.enumerate_only_vulnerable_plugins).to be_truthy + expect(@wpscan_options.enumerate_timthumbs).to be_truthy + expect(@wpscan_options.enumerate_usernames).to be_truthy end end @@ -362,7 +362,7 @@ describe 'WpscanOptions' do after :each do set_argv(@argv) wpscan_options = WpscanOptions.load_from_arguments - wpscan_options.to_h.should === @expected_hash + expect(wpscan_options.to_h).to be === @expected_hash end it 'should return {}' do diff --git a/spec/lib/wpstools/plugins/stats/stats_plugin_spec.rb b/spec/lib/wpstools/plugins/stats/stats_plugin_spec.rb index e08b8a73..18d59f25 100644 --- a/spec/lib/wpstools/plugins/stats/stats_plugin_spec.rb +++ b/spec/lib/wpstools/plugins/stats/stats_plugin_spec.rb @@ -11,37 +11,37 @@ describe 'StatsPlugin' do describe '#vuln_plugin_count' do it 'returns the correct number' do - stats.vuln_plugin_count(plugins_vulns).should == 2 + expect(stats.vuln_plugin_count(plugins_vulns)).to eq 2 end end describe '#vuln_theme_count' do it 'returns the correct number' do - stats.vuln_theme_count(themes_vulns).should == 2 + expect(stats.vuln_theme_count(themes_vulns)).to eq 2 end end describe '#plugin_vulns_count' do it 'returns the correct number' do - stats.plugin_vulns_count(plugins_vulns).should == 3 + expect(stats.plugin_vulns_count(plugins_vulns)).to eq 3 end end describe '#theme_vulns_count' do it 'returns the correct number' do - stats.theme_vulns_count(themes_vulns).should == 3 + expect(stats.theme_vulns_count(themes_vulns)).to eq 3 end end describe '#total_plugins' do it 'returns the correct numer' do - stats.total_plugins(plugins_file).should == 3 + expect(stats.total_plugins(plugins_file)).to eq 3 end end describe '#total_themes' do it 'returns the correct numer' do - stats.total_themes(themes_file).should == 3 + expect(stats.total_themes(themes_file)).to eq 3 end end end diff --git a/spec/shared_examples/browser/actions.rb b/spec/shared_examples/browser/actions.rb index 7142797c..376b91e6 100644 --- a/spec/shared_examples/browser/actions.rb +++ b/spec/shared_examples/browser/actions.rb @@ -15,8 +15,8 @@ shared_examples 'Browser::Actions' do #body: { login: 'master', password: 'hello' } # It's should be this line, but it fails ) - response.should be_a Typhoeus::Response - response.body.should == 'Welcome Master' + expect(response).to be_a Typhoeus::Response + expect(response.body).to eq 'Welcome Master' end end @@ -29,8 +29,8 @@ shared_examples 'Browser::Actions' do response = Browser.get(url) - response.should be_a Typhoeus::Response - response.body.should == 'Hello World !' + expect(response).to be_a Typhoeus::Response + expect(response.body).to eq 'Hello World !' end end diff --git a/spec/shared_examples/browser/options.rb b/spec/shared_examples/browser/options.rb index 8e21f9da..e9558620 100644 --- a/spec/shared_examples/browser/options.rb +++ b/spec/shared_examples/browser/options.rb @@ -8,7 +8,7 @@ shared_examples 'Browser::Options' do after do if @expected browser.basic_auth = @auth - browser.basic_auth.should == @expected + expect(browser.basic_auth).to eq @expected else expect { browser.basic_auth = @auth }.to raise_error(exception) end @@ -47,7 +47,7 @@ shared_examples 'Browser::Options' do after do if @expected browser.max_threads = @max_threads - browser.max_threads.should == @expected + expect(browser.max_threads).to eq @expected else expect { browser.max_threads = @max_threads }.to raise_error(exception) end @@ -77,7 +77,7 @@ shared_examples 'Browser::Options' do after do if @expected browser.proxy = @proxy - browser.proxy.should == @expected + expect(browser.proxy).to eq @expected else expect { browser.proxy = @proxy }.to raise_error(exception) end @@ -101,7 +101,7 @@ shared_examples 'Browser::Options' do after :each do if @expected browser.proxy_auth = @proxy_auth - browser.proxy_auth.should === @expected + expect(browser.proxy_auth).to be === @expected else expect { browser.proxy_auth = @proxy_auth }.to raise_error end @@ -163,7 +163,7 @@ shared_examples 'Browser::Options' do let(:override_options) { { max_threads: nil } } it 'does not set it' do - browser.should_not_receive(:max_threads=) + expect(browser).not_to receive(:max_threads=) end end @@ -171,7 +171,7 @@ shared_examples 'Browser::Options' do let(:override_options) { { not_allowed: 'owned' } } it 'does not set it' do - browser.should_not_receive(:not_allowed=) + expect(browser).not_to receive(:not_allowed=) end end @@ -179,7 +179,7 @@ shared_examples 'Browser::Options' do let(:override_options) { { max_threads: 30 } } it 'sets it' do - browser.should_receive(:max_threads=).with(30) + expect(browser).to receive(:max_threads=).with(30) end end @@ -189,9 +189,9 @@ shared_examples 'Browser::Options' do } it 'sets @max_threads, @proxy' do - browser.should_not_receive(:not_allowed=) - browser.should_receive(:max_threads=).with(10) - browser.should_receive(:proxy=).with('host:port') + expect(browser).not_to receive(:not_allowed=) + expect(browser).to receive(:max_threads=).with(10) + expect(browser).to receive(:proxy=).with('host:port') end end end diff --git a/spec/shared_examples/web_site/interesting_headers.rb b/spec/shared_examples/web_site/interesting_headers.rb index 75c73d53..2ad92586 100644 --- a/spec/shared_examples/web_site/interesting_headers.rb +++ b/spec/shared_examples/web_site/interesting_headers.rb @@ -9,26 +9,26 @@ shared_examples 'WebSite::InterestingHeaders' do it 'returns MyTestHeader' do stub_request(:head, web_site.url). to_return(status: 200, headers: { 'Mytestheader' => 'Mytestheadervalue' }) - web_site.interesting_headers.should =~ [ [ 'MYTESTHEADER', 'Mytestheadervalue' ] ] + expect(web_site.interesting_headers).to match_array [ [ 'MYTESTHEADER', 'Mytestheadervalue' ] ] end it 'removes known headers' do stub_request(:head, web_site.url). to_return(status: 200, headers: { 'Location' => 'a', 'Connection' => 'Close' }) - web_site.interesting_headers.should be_empty + expect(web_site.interesting_headers).to be_empty end it 'returns nothing' do stub_request(:head, web_site.url). to_return(status: 200, headers: { }) - web_site.interesting_headers.should be_empty + expect(web_site.interesting_headers).to be_empty end end describe '#known_headers' do it 'does not contain duplicates' do - known_headers.flatten.uniq.length.should == known_headers.length + expect(known_headers.flatten.uniq.length).to eq known_headers.length end end diff --git a/spec/shared_examples/web_site/robots_txt.rb b/spec/shared_examples/web_site/robots_txt.rb index abef2f54..84ceb6cd 100644 --- a/spec/shared_examples/web_site/robots_txt.rb +++ b/spec/shared_examples/web_site/robots_txt.rb @@ -5,19 +5,19 @@ shared_examples 'WebSite::RobotsTxt' do describe '#robots_url' do it 'returns the correct url' do - web_site.robots_url.should === 'http://example.localhost/robots.txt' + expect(web_site.robots_url).to be === 'http://example.localhost/robots.txt' end end describe '#has_robots?' do it 'returns true' do stub_request(:get, web_site.robots_url).to_return(status: 200) - web_site.has_robots?.should be_true + expect(web_site.has_robots?).to be_truthy end it 'returns false' do stub_request(:get, web_site.robots_url).to_return(status: 404) - web_site.has_robots?.should be_false + expect(web_site.has_robots?).to be_falsey end end @@ -27,7 +27,7 @@ shared_examples 'WebSite::RobotsTxt' do after :each do stub_request_to_fixture(url: web_site.robots_url, fixture: @fixture) robots = web_site.parse_robots_txt - robots.should =~ @expected + expect(robots).to match_array @expected end it 'returns an empty Array (empty robots.txt)' do @@ -74,14 +74,14 @@ shared_examples 'WebSite::RobotsTxt' do ) stub_request_to_fixture(url: web_site_sub.robots_url, fixture: fixture) robots = web_site_sub.parse_robots_txt - robots.should =~ expected + expect(robots).to match_array expected end end end describe '#known_dirs' do it 'does not contain duplicates' do - known_dirs.flatten.uniq.length.should == known_dirs.length + expect(known_dirs.flatten.uniq.length).to eq known_dirs.length end end diff --git a/spec/shared_examples/wp_item_existable.rb b/spec/shared_examples/wp_item_existable.rb index 6a589beb..e1f1c897 100644 --- a/spec/shared_examples/wp_item_existable.rb +++ b/spec/shared_examples/wp_item_existable.rb @@ -8,19 +8,19 @@ shared_examples 'WpItem::Existable' do let(:response) { Typhoeus::Response.new } it 'does not create a request' do - Browser.should_not_receive(:get) - subject.stub(:exists_from_response?).and_return(true) + expect(Browser).not_to receive(:get) + allow(subject).to receive(:exists_from_response?).and_return(true) - subject.exists?({}, response).should be_true + expect(subject.exists?({}, response)).to be_truthy end end context 'when the response is not supplied' do it 'creates a request' do - Browser.should_receive(:get) - subject.stub(:exists_from_response?).and_return(false) + expect(Browser).to receive(:get) + allow(subject).to receive(:exists_from_response?).and_return(false) - subject.exists?.should be_false + expect(subject.exists?).to be_falsey end end end @@ -31,7 +31,7 @@ shared_examples 'WpItem::Existable' do after do response = Typhoeus::Response.new(@resp_opt) - subject.send(:exists_from_response?, response, exists_options).should == @expected + expect(subject.send(:exists_from_response?, response, exists_options)).to eq @expected end context 'when invalid response.code' do diff --git a/spec/shared_examples/wp_item_findable_found_from.rb b/spec/shared_examples/wp_item_findable_found_from.rb index ae124aab..82edcf73 100644 --- a/spec/shared_examples/wp_item_findable_found_from.rb +++ b/spec/shared_examples/wp_item_findable_found_from.rb @@ -5,7 +5,7 @@ shared_examples 'WpItem::Findable#Found_From=' do describe '#found_from=' do after do subject.found_from = @method - subject.found_from.should == @expected + expect(subject.found_from).to eq @expected end context 'when the pattern is not found' do it 'returns nil' do diff --git a/spec/shared_examples/wp_item_infos.rb b/spec/shared_examples/wp_item_infos.rb index 575add79..28049993 100644 --- a/spec/shared_examples/wp_item_infos.rb +++ b/spec/shared_examples/wp_item_infos.rb @@ -8,7 +8,7 @@ shared_examples 'WpItem::Infos' do # let(:error_log_url) { } describe '#readme_url' do - after { subject.readme_url.should === @expected } + after { expect(subject.readme_url).to be === @expected } it 'returns nil' do stub_request(:get, /.*/).to_return(status: 404) @@ -30,8 +30,8 @@ shared_examples 'WpItem::Infos' do describe '#has_readme?' do after do - subject.stub(readme_url: @stub) - subject.has_readme?.should === @expected + allow(subject).to receive_messages(readme_url: @stub) + expect(subject.has_readme?).to be === @expected end context 'when readme_url is nil' @@ -49,14 +49,14 @@ shared_examples 'WpItem::Infos' do describe '#changelog_url' do it 'returns the correct url' do - subject.changelog_url.should == changelog_url + expect(subject.changelog_url).to eq changelog_url end end describe '#has_changelog?' do after :each do stub_request(:get, subject.changelog_url).to_return(status: @status) - subject.has_changelog?.should === @expected + expect(subject.has_changelog?).to be === @expected end it 'returns true on a 200' do @@ -73,7 +73,7 @@ shared_examples 'WpItem::Infos' do describe '#has_directory_listing?' do after do stub_request(:get, subject.uri.to_s).to_return(@stub_return) - subject.has_directory_listing?.should === @expected + expect(subject.has_directory_listing?).to be === @expected end context 'when the body contains