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

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 <title>Index of' do
@@ -96,14 +96,14 @@ shared_examples 'WpItem::Infos' do
describe '#error_log_url' do
it 'returns the correct url' do
subject.error_log_url.should == error_log_url
expect(subject.error_log_url).to eq error_log_url
end
end
describe '#has_error_log?' do
after do
stub_request(:get, subject.error_log_url).to_return(@stub_return)
subject.has_error_log?.should === @expected
expect(subject.has_error_log?).to be === @expected
end
it 'returns true if the pattern is detected' do

View File

@@ -9,14 +9,14 @@ shared_examples 'WpItem::Versionable' do
context 'when the version is already set' do
it 'returns it' do
subject.version = '1.2'
subject.version.should == '1.2'
expect(subject.version).to eq '1.2'
end
end
context 'otherwise' do
after do
stub_request_to_fixture(url: readme_url, fixture: fixtures_dir + @file)
subject.version.should == @expected
expect(subject.version).to eq @expected
end
context 'when version is "trunk"' do
@@ -37,10 +37,10 @@ shared_examples 'WpItem::Versionable' do
describe '#to_s' do
after do
subject.stub(:version).and_return(@version)
allow(subject).to receive(:version).and_return(@version)
subject.name = 'some-name'
subject.to_s.should == @expected
expect(subject.to_s).to eq @expected
end
context 'when the version does not exist' do

View File

@@ -22,8 +22,8 @@ shared_examples 'WpItem::Vulnerable' do
subject.vulns_xpath = vulns_xpath if defined?(vulns_xpath)
result = subject.vulnerabilities
result.should be_a Vulnerabilities
result.should == @expected
expect(result).to be_a Vulnerabilities
expect(result).to eq @expected
end
context 'when the vulns_file is empty' do
@@ -41,8 +41,8 @@ shared_examples 'WpItem::Vulnerable' do
describe '#vulnerable?' do
after do
subject.stub(:vulnerabilities).and_return(@stub)
subject.vulnerable?.should == @expected
allow(subject).to receive(:vulnerabilities).and_return(@stub)
expect(subject.vulnerable?).to eq @expected
end
it 'returns false when no vulnerabilities' do
@@ -72,23 +72,23 @@ shared_examples 'WpItem::Vulnerable' do
context 'check basic version comparing' do
it 'returns true because checked version is newer' do
subject.version.should == version_orig
subject.vulnerable_to?(newer).should be_true
expect(subject.version).to eq version_orig
expect(subject.vulnerable_to?(newer)).to be_truthy
end
it 'returns false because checked version is older' do
subject.version.should == version_orig
subject.vulnerable_to?(older).should be_false
expect(subject.version).to eq version_orig
expect(subject.vulnerable_to?(older)).to be_falsey
end
it 'returns false because checked version is the fixed version' do
subject.version.should == version_orig
subject.vulnerable_to?(same).should be_false
expect(subject.version).to eq version_orig
expect(subject.vulnerable_to?(same)).to be_falsey
end
it 'returns true because no fixed_in version is provided' do
subject.version.should == version_orig
subject.vulnerable_to?(no_fixed_info).should be_true
expect(subject.version).to eq version_orig
expect(subject.vulnerable_to?(no_fixed_info)).to be_truthy
end
end
@@ -99,9 +99,9 @@ shared_examples 'WpItem::Vulnerable' do
end
it 'returns true because no version can be detected' do
subject.vulnerable_to?(newer).should be_true
subject.vulnerable_to?(older).should be_true
subject.vulnerable_to?(same).should be_true
expect(subject.vulnerable_to?(newer)).to be_truthy
expect(subject.vulnerable_to?(older)).to be_truthy
expect(subject.vulnerable_to?(same)).to be_truthy
end
end
end

View File

@@ -14,19 +14,19 @@ shared_examples 'WpItems::Detectable' do
before do
if class_vulns_file = subject.vulns_file
class_vulns_file.should == expected[:vulns_file]
expect(class_vulns_file).to eq expected[:vulns_file]
end
subject.stub(:vulns_file).and_return(vulns_file)
allow(subject).to receive(:vulns_file).and_return(vulns_file)
unless subject.item_xpath
subject.stub(:item_xpath).and_return('//item')
allow(subject).to receive(:item_xpath).and_return('//item')
end
end
describe '::request_params' do
it 'returns the default params' do
subject.send(:request_params).should == expected[:request_params]
expect(subject.send(:request_params)).to eq expected[:request_params]
end
end
@@ -34,8 +34,8 @@ shared_examples 'WpItems::Detectable' do
it 'returns the correct item class' do
klass = subject.send(:item_class)
klass.should be_a Class
klass.should == item_class
expect(klass).to be_a Class
expect(klass).to eq item_class
end
end
@@ -43,11 +43,11 @@ shared_examples 'WpItems::Detectable' do
after do
results = subject.send(:targets_items_from_file, file, wp_target, item_class, vulns_file)
results.map { |i| i.name }.should == @expected.map { |i| i.name }
expect(results.map { |i| i.name }).to eq @expected.map { |i| i.name }
unless results.empty?
results.each do |item|
item.should be_a item_class
expect(item).to be_a item_class
end
end
end
@@ -73,11 +73,11 @@ shared_examples 'WpItems::Detectable' do
after do
results = subject.send(:vulnerable_targets_items, wp_target, item_class, vulns_file)
results.map { |i| i.name }.should == @expected.map { |i| i.name }
expect(results.map { |i| i.name }).to eq @expected.map { |i| i.name }
unless results.empty?
results.each do |item|
item.should be_a item_class
expect(item).to be_a item_class
end
end
end
@@ -104,7 +104,7 @@ shared_examples 'WpItems::Detectable' do
if @expected
results = subject.send(:targets_items, wp_target, options)
results.sort.map { |i| i.name }.should == @expected.sort.map { |i| i.name }
expect(results.sort.map { |i| i.name }).to eq @expected.sort.map { |i| i.name }
end
end
@@ -139,8 +139,8 @@ shared_examples 'WpItems::Detectable' do
results = subject.passive_detection(wp_target)
results.should be_a subject
results.map { |i| i.name }.should == @expected.sort.map { |i| i.name }
expect(results).to be_a subject
expect(results.map { |i| i.name }).to eq @expected.sort.map { |i| i.name }
end
context 'when the page is empty' do
@@ -160,7 +160,7 @@ shared_examples 'WpItems::Detectable' do
describe '::aggressive_detection' do
def stub_targets_dont_exist(targets)
targets.each { |t| t.stub(:exists?).and_return(false) }
targets.each { |t| allow(t).to receive(:exists?).and_return(false) }
end
let(:options) { {} }
@@ -170,8 +170,8 @@ shared_examples 'WpItems::Detectable' do
result = subject.aggressive_detection(wp_target, options)
result.should be_a subject
result.sort.map { |i| i.name }.should == @expected.sort.map { |i| i.name }
expect(result).to be_a subject
expect(result.sort.map { |i| i.name }).to eq @expected.sort.map { |i| i.name }
end
context 'when :only_vulnerable' do
@@ -185,21 +185,21 @@ shared_examples 'WpItems::Detectable' do
stub_targets_dont_exist(targets)
vulnerable_target.stub(:exists?).and_return(true)
vulnerable_target.stub(:vulnerable?).and_return(true)
allow(vulnerable_target).to receive(:exists?).and_return(true)
allow(vulnerable_target).to receive(:vulnerable?).and_return(true)
fixed_target.stub(:exists?).and_return(true)
fixed_target.stub(:vulnerable?).and_return(false)
allow(fixed_target).to receive(:exists?).and_return(true)
allow(fixed_target).to receive(:vulnerable?).and_return(false)
@expected = subject.new << vulnerable_target
subject.should_receive(:targets_items).and_return(targets)
expect(subject).to receive(:targets_items).and_return(targets)
end
context 'when all targets dont exist' do
it 'returns an empty WpItems' do
stub_targets_dont_exist(targets)
subject.should_receive(:targets_items).and_return(targets)
expect(subject).to receive(:targets_items).and_return(targets)
@expected = subject.new
end
end
@@ -213,10 +213,10 @@ shared_examples 'WpItems::Detectable' do
@expected = expected[:passive_detection] << target
stub_targets_dont_exist(targets)
target.stub(:exists?).and_return(true)
allow(target).to receive(:exists?).and_return(true)
subject.should_receive(:targets_items).and_return(targets)
subject.should_receive(:passive_detection).and_return(expected[:passive_detection])
expect(subject).to receive(:targets_items).and_return(targets)
expect(subject).to receive(:passive_detection).and_return(expected[:passive_detection])
end
context 'when all targets dont exist' do
@@ -224,8 +224,8 @@ shared_examples 'WpItems::Detectable' do
@expected = expected[:passive_detection]
stub_targets_dont_exist(targets)
subject.should_receive(:targets_items).and_return(targets)
subject.should_receive(:passive_detection).and_return(@expected)
expect(subject).to receive(:targets_items).and_return(targets)
expect(subject).to receive(:passive_detection).and_return(@expected)
end
end
end

View File

@@ -3,7 +3,7 @@
shared_examples 'WpPlugin::Vulnerable' do
describe '#vulns_file' do
after { subject.vulns_file.should == @expected }
after { expect(subject.vulns_file).to eq @expected }
context 'when :vulns_file is no set' do
it 'returns the default one' do
@@ -20,7 +20,7 @@ shared_examples 'WpPlugin::Vulnerable' do
end
describe '#vulns_xpath' do
its(:vulns_xpath) { should == "//plugin[@name='plugin-name']/vulnerability" }
its(:vulns_xpath) { is_expected.to eq "//plugin[@name='plugin-name']/vulnerability" }
end
end

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

View File

@@ -10,7 +10,7 @@ shared_examples 'WpTheme::Versionable' do
stub_request(:get, subject.style_url).to_return(status: 200, body: body)
end
subject.version.should == @expected
expect(subject.version).to eq @expected
end
context 'the version is already set' do
@@ -35,7 +35,7 @@ shared_examples 'WpTheme::Versionable' do
context 'from both style & readme' do
it 'returns nil' do
subject.stub(readme_url: readme_url)
allow(subject).to receive_messages(readme_url: readme_url)
stub_request(:get, readme_url).to_return(status: 404)
@file = file

View File

@@ -3,7 +3,7 @@
shared_examples 'WpTheme::Vulnerable' do
describe '#vulns_file' do
after { subject.vulns_file.should == @expected }
after { expect(subject.vulns_file).to eq @expected }
context 'when :vulns_file is not set' do
it 'returns the default one' do
@@ -20,7 +20,7 @@ shared_examples 'WpTheme::Vulnerable' do
end
describe '#vulns_xpath' do
its(:vulns_xpath) { should == "//theme[@name='theme-name']/vulnerability" }
its(:vulns_xpath) { is_expected.to eq "//theme[@name='theme-name']/vulnerability" }
end
end

View File

@@ -5,7 +5,7 @@ shared_examples 'WpTimthumb::Existable' do
describe 'exists_from_response?' do
after do
response = Typhoeus::Response.new(@resp_opt)
subject.send(:exists_from_response?, response).should == @expected
expect(subject.send(:exists_from_response?, response)).to eq @expected
end
context 'when the status is not a 400' do

View File

@@ -6,7 +6,7 @@ shared_examples 'WpTimthumb::Versionable' do
after do
stub_request(:get, subject.url).to_return(status: 200, body: @body)
subject.version.should === @expected
expect(subject.version).to be === @expected
end
context 'when a version is already set' do
@@ -32,7 +32,7 @@ shared_examples 'WpTimthumb::Versionable' do
end
describe '#to_s' do
after { subject.to_s.should == @expected }
after { expect(subject.to_s).to eq @expected }
context 'when there is a version' do
it 'returns it with the url' do
@@ -43,7 +43,7 @@ shared_examples 'WpTimthumb::Versionable' do
context 'when there is not a version' do
it 'returns only the url' do
subject.stub(:version).and_return(nil)
allow(subject).to receive(:version).and_return(nil)
@expected = uri.merge(options[:path]).to_s
end
end

View File

@@ -14,7 +14,7 @@ shared_examples 'WpUser::BruteForcable' do
let(:resp_options) { {} }
after do
wp_user.valid_password?(response, 'password', redirect_url).should == @expected
expect(wp_user.valid_password?(response, 'password', redirect_url)).to eq @expected
end
context 'when 302 and valid return_to parameter' do
@@ -73,7 +73,7 @@ shared_examples 'WpUser::BruteForcable' do
[wordlist_utf8, wordlist_iso].each do |wordlist|
wp_user.login = login
wp_user.brute_force(wordlist, {}, redirect_url)
wp_user.password.should == @expected
expect(wp_user.password).to eq @expected
end
end

View File

@@ -6,7 +6,7 @@ shared_examples 'WpUser::Existable' do
describe '::login_from_author_pattern' do
after do
mod.login_from_author_pattern(@text).should == @expected
expect(mod.login_from_author_pattern(@text)).to eq @expected
end
context 'when no trailing slash' do
@@ -32,13 +32,13 @@ shared_examples 'WpUser::Existable' do
end
describe '::login_from_body' do
after { mod.login_from_body(body).should == @expected }
after { expect(mod.login_from_body(body)).to eq @expected }
context 'when the author pattern is in the body' do
let(:body) { '/author/admin' }
it 'returns it' do
mod.stub(:login_from_body).with(body).and_return('admin')
allow(mod).to receive(:login_from_body).with(body).and_return('admin')
@expected = 'admin'
end
end
@@ -53,7 +53,7 @@ shared_examples 'WpUser::Existable' do
end
describe '::display_name_from_body' do
after { mod.display_name_from_body(@body).should == @expected }
after { expect(mod.display_name_from_body(@body)).to eq @expected }
context 'when pattern not found' do
it 'returns nil' do
@@ -110,8 +110,8 @@ shared_examples 'WpUser::Existable' do
response = Typhoeus::Response.new(@resp_opt || resp_opt)
subject.send(:load_from_response, response)
subject.login.should == @login
subject.display_name.should == @display_name
expect(subject.login).to eq @login
expect(subject.display_name).to eq @display_name
end
context 'with a 301' do
@@ -147,7 +147,7 @@ shared_examples 'WpUser::Existable' do
describe '#exists_from_response?' do
after do
response = Typhoeus::Response.new(@resp_opt || resp_opt)
subject.exists_from_response?(response).should == @expected
expect(subject.exists_from_response?(response)).to eq @expected
end
context 'login not found' do

View File

@@ -10,7 +10,7 @@ shared_examples 'WpUsers::BruteForcable' do
it 'calls #brute_force on each wp_user' do
range.each do |id|
wp_user = WpUser.new(uri, id: id)
wp_user.should_receive(:brute_force).with(wordlist, brute_force_opt)
expect(wp_user).to receive(:brute_force).with(wordlist, brute_force_opt)
wp_users << wp_user
end

View File

@@ -3,7 +3,7 @@
shared_examples 'WpVersion::Vulnerable' do
describe '#vulns_file' do
after { subject.vulns_file.should == @expected }
after { expect(subject.vulns_file).to eq @expected }
context 'when :vulns_file is no set' do
it 'returns the default one' do
@@ -20,7 +20,7 @@ shared_examples 'WpVersion::Vulnerable' do
end
describe '#vulns_xpath' do
its(:vulns_xpath) { should == "//wordpress[@version='1.2']/vulnerability" }
its(:vulns_xpath) { is_expected.to eq "//wordpress[@version='1.2']/vulnerability" }
end
end

View File

@@ -64,5 +64,5 @@ end
# :` for `` or %x
# :system for system()
def stub_system_command(object, command, return_value, system_method = :`)
object.should_receive(system_method).with(command).and_return(return_value)
expect(object).to receive(system_method).with(command).and_return(return_value)
end

View File

@@ -6,7 +6,7 @@ describe 'wpscan main checks' do
it 'should check for errors on running the mainscript' do
a = %x[ruby #{ROOT_DIR}/wpscan.rb]
a.should =~ /No argument supplied/
expect(a).to match /No argument supplied/
end
it 'should check for valid syntax' do

View File

@@ -5,7 +5,7 @@ require 'spec_helper'
describe 'XSD checks' do
after :each do
FileTest.exists?(@file).should be_true
expect(FileTest.exists?(@file)).to be_truthy
xsd = Nokogiri::XML::Schema(File.read(@xsd))
doc = Nokogiri::XML(File.read(@file))
@@ -48,7 +48,7 @@ end
describe 'Well formed XML checks' do
after :each do
FileTest.exists?(@file).should be_true
expect(FileTest.exists?(@file)).to be_truthy
begin
Nokogiri::XML(File.open(@file)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
@@ -85,7 +85,7 @@ describe 'XML content' do
end
after :each do
@result.should have(0).items, "Items:\n#{@result.join("\n")}"
expect(@result.size).to eq(0), "Items:\n#{@result.join("\n")}"
end
it 'each plugin vuln needs a type node' do