From 399f3523289cf6ca702c10ed3f398735846aa9d2 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sun, 19 Jan 2014 21:42:21 +0100 Subject: [PATCH] Consistently use expect syntax --- spec/integration/mutant/rspec_spec.rb | 10 +++++----- spec/integration/mutant/zombie_spec.rb | 2 +- spec/shared/method_matcher_behavior.rb | 12 ++++++------ spec/spec_helper.rb | 2 +- spec/unit/mutant/context/scope/root_spec.rb | 2 +- spec/unit/mutant/loader/eval_spec.rb | 4 ++-- spec/unit/mutant/matcher/chain_spec.rb | 2 +- .../unit/mutant/matcher/methods/instance_spec.rb | 2 +- .../mutant/matcher/methods/singleton_spec.rb | 2 +- spec/unit/mutant/matcher/namespace_spec.rb | 2 +- spec/unit/mutant_spec.rb | 16 +++++++--------- 11 files changed, 27 insertions(+), 29 deletions(-) diff --git a/spec/integration/mutant/rspec_spec.rb b/spec/integration/mutant/rspec_spec.rb index 623f9220..d4c84dd4 100644 --- a/spec/integration/mutant/rspec_spec.rb +++ b/spec/integration/mutant/rspec_spec.rb @@ -13,21 +13,21 @@ describe Mutant, 'rspec integration' do let(:base_cmd) { 'bundle exec mutant -I lib --require test_app --use rspec' } specify 'it allows to kill mutations' do - Kernel.system("#{base_cmd} ::TestApp::Literal#string").should be(true) + expect(Kernel.system("#{base_cmd} ::TestApp::Literal#string")).to be(true) end specify 'it allows to exclude mutations' do - cli = "#{base_cmd} ::TestApp::Literal#string --ignore-subject ::TestApp::Literal#uncovered_string" - Kernel.system(cli).should be(true) + cli = "#{base_cmd} ::TestApp::Literal#string ::TestApp::Literal#uncovered_string --ignore-subject ::TestApp::Literal#uncovered_string" + expect(Kernel.system(cli)).to be(true) end specify 'fails to kill mutations when they are not covered' do cli = "#{base_cmd} ::TestApp::Literal#uncovered_string" - Kernel.system(cli).should be(false) + expect(Kernel.system(cli)).to be(false) end specify 'fails when some mutations are not covered' do cli = "#{base_cmd} ::TestApp::Literal" - Kernel.system(cli).should be(false) + expect(Kernel.system(cli)).to be(false) end end diff --git a/spec/integration/mutant/zombie_spec.rb b/spec/integration/mutant/zombie_spec.rb index d6e73e36..d138705b 100644 --- a/spec/integration/mutant/zombie_spec.rb +++ b/spec/integration/mutant/zombie_spec.rb @@ -5,6 +5,6 @@ require 'spec_helper' describe Mutant, 'as a zombie' do specify 'it allows to create zombie from mutant' do Mutant::Zombifier.run('mutant') - Zombie.constants.should include(:Mutant) + expect(Zombie.constants).to include(:Mutant) end end diff --git a/spec/shared/method_matcher_behavior.rb b/spec/shared/method_matcher_behavior.rb index 903baf22..afd5be36 100644 --- a/spec/shared/method_matcher_behavior.rb +++ b/spec/shared/method_matcher_behavior.rb @@ -9,28 +9,28 @@ shared_examples_for 'a method matcher' do let(:mutation_subject) { yields.first } it 'should return one subject' do - yields.size.should be(1) + expect(yields.size).to be(1) end it_should_behave_like 'an #each method' it 'should have correct method name' do - name.should eql(method_name) + expect(name).to eql(method_name) end it 'should have correct line number' do - (node.location.expression.line - base).should eql(method_line) + expect(node.location.expression.line - base).to eql(method_line) end it 'should have correct arity' do - arguments.children.length.should eql(method_arity) + expect(arguments.children.length).to eql(method_arity) end it 'should have correct scope in context' do - context.send(:scope).should eql(scope) + expect(context.scope).to eql(scope) end it 'should have the correct node type' do - node.type.should be(type) + expect(node.type).to be(type) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 64d37230..baa2e23d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -48,6 +48,6 @@ RSpec.configure do |config| config.include(ParserHelper) config.include(Mutant::NodeHelpers) config.expect_with :rspec do |rspec| - rspec.syntax = [:expect, :should] + rspec.syntax = :expect end end diff --git a/spec/unit/mutant/context/scope/root_spec.rb b/spec/unit/mutant/context/scope/root_spec.rb index 5559c873..dccef233 100644 --- a/spec/unit/mutant/context/scope/root_spec.rb +++ b/spec/unit/mutant/context/scope/root_spec.rb @@ -31,6 +31,6 @@ describe Mutant::Context::Scope, '#root' do end it 'should create correct source' do - generated_source.should eql(expected_source) + expect(generated_source).to eql(expected_source) end end diff --git a/spec/unit/mutant/loader/eval_spec.rb b/spec/unit/mutant/loader/eval_spec.rb index f67ede14..8194a9e7 100644 --- a/spec/unit/mutant/loader/eval_spec.rb +++ b/spec/unit/mutant/loader/eval_spec.rb @@ -41,8 +41,8 @@ describe Mutant::Loader::Eval, '.call' do it 'should set file and line correctly' do subject - ::SomeNamespace::Bar + expect(::SomeNamespace::Bar .instance_method(:some_method) - .source_location.should eql([__FILE__, 3]) + .source_location).to eql([__FILE__, 3]) end end diff --git a/spec/unit/mutant/matcher/chain_spec.rb b/spec/unit/mutant/matcher/chain_spec.rb index ed2eccc2..27970548 100644 --- a/spec/unit/mutant/matcher/chain_spec.rb +++ b/spec/unit/mutant/matcher/chain_spec.rb @@ -32,7 +32,7 @@ describe Mutant::Matcher::Chain do pending 'FIX RBX rspec? BUG HERE' else it 'yields the expected values' do - subject.to_a.should eql(object.to_a) + expect(subject.to_a).to eql(object.to_a) end end end diff --git a/spec/unit/mutant/matcher/methods/instance_spec.rb b/spec/unit/mutant/matcher/methods/instance_spec.rb index b2d1b80e..f6be0a70 100644 --- a/spec/unit/mutant/matcher/methods/instance_spec.rb +++ b/spec/unit/mutant/matcher/methods/instance_spec.rb @@ -58,7 +58,7 @@ describe Mutant::Matcher::Methods::Instance, '#each' do it 'should yield expected subjects' do subject - yields.should eql(subjects) + expect(yields).to eql(subjects) end it_should_behave_like 'an #each method' diff --git a/spec/unit/mutant/matcher/methods/singleton_spec.rb b/spec/unit/mutant/matcher/methods/singleton_spec.rb index 1c8edca2..7508b0b9 100644 --- a/spec/unit/mutant/matcher/methods/singleton_spec.rb +++ b/spec/unit/mutant/matcher/methods/singleton_spec.rb @@ -52,7 +52,7 @@ describe Mutant::Matcher::Methods::Singleton, '#each' do it 'should yield expected subjects' do subject - yields.should eql(subjects) + expect(yields).to eql(subjects) end it_should_behave_like 'an #each method' diff --git a/spec/unit/mutant/matcher/namespace_spec.rb b/spec/unit/mutant/matcher/namespace_spec.rb index 8891db1e..4b74a0b4 100644 --- a/spec/unit/mutant/matcher/namespace_spec.rb +++ b/spec/unit/mutant/matcher/namespace_spec.rb @@ -34,7 +34,7 @@ describe Mutant::Matcher::Namespace, '#each' do pending 'FIX RBX rspec? BUG HERE' else it 'yields the expected values' do - subject.to_a.should eql(object.to_a) + expect(subject.to_a).to eql(object.to_a) end end end diff --git a/spec/unit/mutant_spec.rb b/spec/unit/mutant_spec.rb index 91a8e34e..d5779655 100644 --- a/spec/unit/mutant_spec.rb +++ b/spec/unit/mutant_spec.rb @@ -8,9 +8,7 @@ describe Mutant do subject { object.singleton_subclass_instance(name, superclass, &block) } - before do - subject - end + before { subject } let(:name) { 'Test' } let(:block) { proc { def foo; end } } @@ -22,22 +20,22 @@ describe Mutant do it 'sets expected name' do name = generated.class.name - name.should eql("::#{self.name}") - name.should be_frozen + expect(name).to eql("::#{self.name}") + expect(name).to be_frozen end it 'stores instance of subclass' do - generated.should be_kind_of(superclass) + expect(generated).to be_kind_of(superclass) end it 'evaluates the context of proc inside subclass' do - generated.should respond_to(:foo) + expect(generated).to respond_to(:foo) end it 'generates nice #inspect' do inspect = generated.inspect - inspect.should eql("::#{self.name}") - inspect.should be_frozen + expect(inspect).to eql("::#{self.name}") + expect(inspect).to be_frozen end end end