Rspec 3.0 support

This commit is contained in:
erwanlr
2014-06-02 22:06:49 +02:00
parent c12b1d0670
commit c8c126d444
55 changed files with 338 additions and 336 deletions

View File

@@ -7,7 +7,7 @@ shared_examples 'WpTarget::Malwares' do
describe '#malwares_file' do
it "returns the correct file path" do
WpTarget::Malwares.malwares_file(malwares_file).should === malwares_file
expect(WpTarget::Malwares.malwares_file(malwares_file)).to be === malwares_file
end
end
@@ -19,8 +19,8 @@ shared_examples 'WpTarget::Malwares' do
malwares = wp_target.malwares(@malwares_file_path)
malwares.sort.should === @expected.sort
wp_target.has_malwares?.should === (@expected.empty? ? false : true)
expect(malwares.sort).to be === @expected.sort
expect(wp_target.has_malwares?).to be === (@expected.empty? ? false : true)
end
it 'returns an empty array on a 404' do

View File

@@ -17,7 +17,7 @@ shared_examples 'WpTarget::WpConfigBackup' do
end
it 'shoud return an empty array if no config backup is present' do
wp_target.config_backup.should be_empty
expect(wp_target.config_backup).to be_empty
end
it 'returns an array with 1 backup file' do
@@ -31,8 +31,8 @@ shared_examples 'WpTarget::WpConfigBackup' do
end
wp_config_backup = wp_target.config_backup
wp_config_backup.should_not be_empty
wp_config_backup.should === expected
expect(wp_config_backup).not_to be_empty
expect(wp_config_backup).to be === expected
end
# Is there a way to factorise that one with the previous test ?
@@ -47,14 +47,14 @@ shared_examples 'WpTarget::WpConfigBackup' do
end
wp_config_backup = wp_target.config_backup
wp_config_backup.should_not be_empty
wp_config_backup.sort.should === expected.sort
expect(wp_config_backup).not_to be_empty
expect(wp_config_backup.sort).to be === expected.sort
end
end
describe '#config_backup_files' do
it 'does not contain duplicates' do
config_backup_files.flatten.uniq.length.should == config_backup_files.length
expect(config_backup_files.flatten.uniq.length).to eq config_backup_files.length
end
end

View File

@@ -12,7 +12,7 @@ shared_examples 'WpTarget::WpCustomDirectories' do
stub_request(:get, /.*\/wp-content\/?$/).to_return(:status => 200, :body => '') # default dir request
stub_request(:get, /.*\.html$/).to_return(:status => 200, :body => '') # 404 hash request
@wp_target.wp_content_dir.should === @expected
expect(@wp_target.wp_content_dir).to be === @expected
end
it 'returns the string set in the initialize method' do
@@ -80,7 +80,7 @@ shared_examples 'WpTarget::WpCustomDirectories' do
@wp_target = WpTarget.new('http://lamp.localhost/')
stub_request(:get, @wp_target.url).to_return(:status => 200, :body => 'homepage') # homepage request
@wp_target.default_wp_content_dir_exists?.should === @expected
expect(@wp_target.default_wp_content_dir_exists?).to be === @expected
end
it 'returns false if wp-content returns an invalid response code' do
@@ -110,7 +110,7 @@ shared_examples 'WpTarget::WpCustomDirectories' do
describe '#wp_plugins_dir' do
after :each do
@wp_target.wp_plugins_dir.should === @expected
expect(@wp_target.wp_plugins_dir).to be === @expected
end
it 'returns the string set in the initialize method' do
@@ -131,12 +131,12 @@ shared_examples 'WpTarget::WpCustomDirectories' do
it 'returns true' do
stub_request(:get, url).to_return(status: 200)
wp_target.wp_plugins_dir_exists?.should == true
expect(wp_target.wp_plugins_dir_exists?).to eq true
end
it 'returns false' do
stub_request(:get, url).to_return(status: 404)
wp_target.wp_plugins_dir_exists?.should == false
expect(wp_target.wp_plugins_dir_exists?).to eq false
end
end

View File

@@ -6,7 +6,7 @@ shared_examples 'WpTarget::WpFullPathDisclosure' do
describe '#full_path_disclosure_url' do
it 'returns http://example.localhost/wp-includes/rss-functions.php' do
wp_target.full_path_disclosure_url.should === 'http://example.localhost/wp-includes/rss-functions.php'
expect(wp_target.full_path_disclosure_url).to be === 'http://example.localhost/wp-includes/rss-functions.php'
end
end
@@ -15,7 +15,7 @@ shared_examples 'WpTarget::WpFullPathDisclosure' do
stub_request(:get, wp_target.full_path_disclosure_url).
to_return(@stub)
wp_target.has_full_path_disclosure?.should === @expected
expect(wp_target.has_full_path_disclosure?).to be === @expected
end
it 'returns false on a 404' do

View File

@@ -4,7 +4,7 @@ shared_examples 'WpTarget::WpLoginProtection' do
let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR + '/wp_login_protection' }
before { wp_target.stub(:wp_plugins_dir).and_return('wp-content/plugins') }
before { allow(wp_target).to receive(:wp_plugins_dir).and_return('wp-content/plugins') }
# It will test all protected methods has_.*_protection with each fixtures to be sure that
# there is not false positive : for example the login-lock must not be detected as login-lockdown
@@ -33,7 +33,7 @@ shared_examples 'WpTarget::WpLoginProtection' do
stub_request(:get, wp_target.send(special_plugin_call_url_symbol).to_s).to_return(status: status_code)
end
wp_target.send(@symbol_to_call).should === @expected
expect(wp_target.send(@symbol_to_call)).to be === @expected
end
self.protected_instance_methods.grep(pattern).each do |symbol_to_call|
@@ -63,8 +63,8 @@ shared_examples 'WpTarget::WpLoginProtection' do
stub_request(:get, wp_target.send(:limit_login_attempts_url).to_s).to_return(status: 404)
stub_request(:get, wp_target.send(:bluetrait_event_viewer_url).to_s).to_return(status: 404)
wp_target.login_protection_plugin().should == @plugin_expected
wp_target.has_login_protection?.should === @has_protection_expected
expect(wp_target.login_protection_plugin()).to eq @plugin_expected
expect(wp_target.has_login_protection?).to be === @has_protection_expected
end
it 'returns nil if no protection is present' do

View File

@@ -6,7 +6,7 @@ shared_examples 'WpTarget::WpReadme' do
describe '#readme_url' do
it 'returns http://example.localhost/readme.html' do
wp_target.readme_url.should === "#{wp_target.uri}readme.html"
expect(wp_target.readme_url).to be === "#{wp_target.uri}readme.html"
end
end
@@ -14,7 +14,7 @@ shared_examples 'WpTarget::WpReadme' do
after do
stub_request(:get, wp_target.readme_url).to_return(@stub)
wp_target.has_readme?.should === @expected
expect(wp_target.has_readme?).to be === @expected
end
it 'returns false on a 404' do

View File

@@ -5,11 +5,11 @@ shared_examples 'WpTarget::WpRegistrable' do
let(:signup_url) { wp_target.uri.merge('wp-signup.php').to_s }
describe '#registration_url' do
after { wp_target.registration_url.should === @expected }
after { expect(wp_target.registration_url).to be === @expected }
context 'when multisite' do
it 'returns the signup url' do
wp_target.stub(:multisite?).and_return(true)
allow(wp_target).to receive(:multisite?).and_return(true)
@expected = signup_url
end
@@ -17,7 +17,7 @@ shared_examples 'WpTarget::WpRegistrable' do
context 'when not multisite' do
it 'returns the login url with ?action=register' do
wp_target.stub(:multisite?).and_return(false)
allow(wp_target).to receive(:multisite?).and_return(false)
@expected = login_url + '?action=register'
end
@@ -26,10 +26,10 @@ shared_examples 'WpTarget::WpRegistrable' do
describe '#registration_enabled?' do
after do
wp_target.stub(:multisite?).and_return(multisite)
allow(wp_target).to receive(:multisite?).and_return(multisite)
stub_request(:get, wp_target.registration_url).to_return(@stub)
wp_target.registration_enabled?.should === @expected
expect(wp_target.registration_enabled?).to be === @expected
end
context 'when multisite' do
@@ -69,7 +69,7 @@ shared_examples 'WpTarget::WpRegistrable' do
after do
stub_request(:get, signup_url).to_return(@stub)
wp_target.multisite?.should === @expected
expect(wp_target.multisite?).to be === @expected
end
it 'returns false' do