Rspec 3.0 support
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user