Use 1.9 hash syntax also for specs

This commit is contained in:
Markus Schirp 2013-09-08 22:12:23 +02:00
parent 251fe68175
commit f1b4dc2c2f
32 changed files with 88 additions and 89 deletions

View file

@ -64,7 +64,6 @@ module Mutant
OPERATOR_METHODS = OPERATOR_METHODS =
OPERATOR_EXPANSIONS.keys + INDEX_OPERATORS + UNARY_METHOD_OPERATORS OPERATOR_EXPANSIONS.keys + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
# Hopefully all types parser does generate # Hopefully all types parser does generate
NODE_TYPES = [ NODE_TYPES = [
:lvasgn, :ivasgn, :cvasgn, :gvasgn, :lvasgn, :ivasgn, :cvasgn, :gvasgn,

View file

@ -24,7 +24,7 @@ describe Mutant::CLI, '.new' do
let(:time) { Time.now } let(:time) { Time.now }
before do before do
Time.stub(:now => time) Time.stub(now: time)
end end
# Defaults # Defaults

View file

@ -5,16 +5,16 @@ require 'spec_helper'
describe Mutant::CLI, '.run' do describe Mutant::CLI, '.run' do
subject { object.run(argv) } subject { object.run(argv) }
let(:object) { described_class } let(:object) { described_class }
let(:argv) { double('ARGV') } let(:argv) { double('ARGV') }
let(:attributes) { double('Options') } let(:attributes) { double('Options') }
let(:runner) { double('Runner', :success? => success) } let(:runner) { double('Runner', success?: success) }
let(:config) { double('Config') } let(:config) { double('Config') }
let(:instance) { double(described_class.name, :config => config) } let(:instance) { double(described_class.name, config: config) }
before do before do
described_class.stub(:new => instance) described_class.stub(new: instance)
Mutant::Runner::Config.stub(:run => runner) Mutant::Runner::Config.stub(run: runner)
end end
context 'when runner is successful' do context 'when runner is successful' do

View file

@ -18,24 +18,24 @@ describe Mutant::Killer::Rspec, '.new' do
let(:mutation) do let(:mutation) do
double( double(
'Mutation', 'Mutation',
:subject => mutation_subject, subject: mutation_subject,
:should_survive? => false should_survive?: false
) )
end end
let(:strategy) do let(:strategy) do
double( double(
'Strategy', 'Strategy',
:spec_files => ['foo'], spec_files: ['foo'],
:error_stream => $stderr, error_stream: $stderr,
:output_stream => $stdout output_stream: $stdout
) )
end end
before do before do
mutation.stub(:insert) mutation.stub(:insert)
mutation.stub(:reset) mutation.stub(:reset)
RSpec::Core::Runner.stub(:run => exit_status) RSpec::Core::Runner.stub(run: exit_status)
end end
context 'when run exits zero' do context 'when run exits zero' do

View file

@ -5,13 +5,13 @@ require 'spec_helper'
describe Mutant::Killer, '#success?' do describe Mutant::Killer, '#success?' do
subject { object.success? } subject { object.success? }
let(:object) { class_under_test.new(strategy, mutation) } let(:object) { class_under_test.new(strategy, mutation) }
let(:strategy) { double('Strategy') } let(:strategy) { double('Strategy') }
let(:mutation) { double('Mutation', :success? => kill_state) } let(:mutation) { double('Mutation', success?: kill_state) }
let(:kill_state) { double('Kill State') } let(:kill_state) { double('Kill State') }
before do before do
kill_state.stub(:freeze => kill_state, :dup => kill_state) kill_state.stub(freeze: kill_state, dup: kill_state)
end end
let(:class_under_test) do let(:class_under_test) do

View file

@ -11,7 +11,7 @@ describe Mutant::Loader::Eval, '.run' do
let(:line) { 1 } let(:line) { 1 }
let(:mutation_subject) do let(:mutation_subject) do
double('Subject', :source_path => path, :source_line => line) double('Subject', source_path: path, source_line: line)
end end
let(:source) do let(:source) do

View file

@ -10,10 +10,10 @@ describe Mutant::Matcher::Namespace, '#each' do
let(:cache) { Mutant::Cache.new } let(:cache) { Mutant::Cache.new }
let(:singleton_a) { double('SingletonA', :name => 'TestApp::Literal') } let(:singleton_a) { double('SingletonA', name: 'TestApp::Literal') }
let(:singleton_b) { double('SingletonB', :name => 'TestApp::Foo') } let(:singleton_b) { double('SingletonB', name: 'TestApp::Foo') }
let(:subject_a) { double('SubjectA') } let(:subject_a) { double('SubjectA') }
let(:subject_b) { double('SubjectB') } let(:subject_b) { double('SubjectB') }
before do before do
Mutant::Matcher::Methods::Singleton.stub(:each) Mutant::Matcher::Methods::Singleton.stub(:each)
@ -22,7 +22,7 @@ describe Mutant::Matcher::Namespace, '#each' do
Mutant::Matcher::Methods::Instance.stub(:each) Mutant::Matcher::Methods::Instance.stub(:each)
.with(cache, singleton_a) .with(cache, singleton_a)
.and_yield(subject_b) .and_yield(subject_b)
ObjectSpace.stub(:each_object => [singleton_a, singleton_b]) ObjectSpace.stub(each_object: [singleton_a, singleton_b])
end end
context 'with no block' do context 'with no block' do

View file

@ -19,7 +19,7 @@ describe Mutant::Mutator, '.each' do
end end
before do before do
Mutant::Random.stub(:hex_string => random_string) Mutant::Random.stub(hex_string: random_string)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -20,7 +20,7 @@ describe Mutant::Mutator::Node::OpAsgn, 'and_asgn' do
end end
before do before do
Mutant::Random.stub(:fixnum => random_fixnum, :hex_string => random_string) Mutant::Random.stub(fixnum: random_fixnum, hex_string: random_string)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -26,7 +26,7 @@ describe Mutant::Mutator, 'block' do
let(:source) { 'foo { |a, b| }' } let(:source) { 'foo { |a, b| }' }
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:mutations) do let(:mutations) do
@ -47,7 +47,7 @@ describe Mutant::Mutator, 'block' do
context 'with block pattern args' do context 'with block pattern args' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:source) { 'foo { |(a, b), c| }' } let(:source) { 'foo { |(a, b), c| }' }

View file

@ -6,7 +6,7 @@ describe Mutant::Mutator::Node::Case do
let(:random_string) { 'random' } let(:random_string) { 'random' }
before do before do
Mutant::Random.stub(:hex_string => random_string) Mutant::Random.stub(hex_string: random_string)
end end
context 'with multiple when branches' do context 'with multiple when branches' do

View file

@ -43,7 +43,7 @@ describe Mutant::Mutator, 'def' do
let(:source) { 'def foo(a, b); end' } let(:source) { 'def foo(a, b); end' }
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:mutations) do let(:mutations) do
@ -83,7 +83,7 @@ describe Mutant::Mutator, 'def' do
let(:source) { 'def foo(a = true); end' } let(:source) { 'def foo(a = true); end' }
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:mutations) do let(:mutations) do
@ -127,7 +127,7 @@ describe Mutant::Mutator, 'def' do
context 'define on singleton with argument' do context 'define on singleton with argument' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:source) { 'def self.foo(a, b); end' } let(:source) { 'def self.foo(a, b); end' }

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::Dstr, 'dstr' do describe Mutant::Mutator::Node::Dstr, 'dstr' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:source) { '"foo#{bar}baz"' } let(:source) { '"foo#{bar}baz"' }

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::Generic, 'dsum' do describe Mutant::Mutator::Node::Generic, 'dsum' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:source) { ':"foo#{bar}baz"' } let(:source) { ':"foo#{bar}baz"' }

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe Mutant::Mutator, 'if' do describe Mutant::Mutator, 'if' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
context 'with if and else branches' do context 'with if and else branches' do

View file

@ -12,7 +12,7 @@ describe Mutant::Mutator::Node::Literal, 'fixnum' do
end end
before do before do
Mutant::Random.stub(:fixnum => random_fixnum) Mutant::Random.stub(fixnum: random_fixnum)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -20,7 +20,7 @@ describe Mutant::Mutator::Node::Literal, 'float' do
let(:random_float) { 7.123 } let(:random_float) { 7.123 }
before do before do
Mutant::Random.stub(:float => random_float) Mutant::Random.stub(float: random_float)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -5,7 +5,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::Literal, 'range' do describe Mutant::Mutator::Node::Literal, 'range' do
before :each do before :each do
Mutant::Random.stub(:fixnum => random_fixnum) Mutant::Random.stub(fixnum: random_fixnum)
end end
let(:random_fixnum) { 5 } let(:random_fixnum) { 5 }

View file

@ -12,7 +12,7 @@ describe Mutant::Mutator::Node::Literal, 'string' do
end end
before do before do
Mutant::Random.stub(:hex_string => random_string) Mutant::Random.stub(hex_string: random_string)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -12,7 +12,7 @@ describe Mutant::Mutator::Node::Literal, 'symbol' do
end end
before do before do
Mutant::Random.stub(:hex_string => random_string) Mutant::Random.stub(hex_string: random_string)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
context 'global variable' do context 'global variable' do

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
let(:source) { 'A = true' } let(:source) { 'A = true' }

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
context 'global variable' do context 'global variable' do

View file

@ -20,7 +20,7 @@ describe Mutant::Mutator::Node::Generic, 'op_asgn' do
end end
before do before do
Mutant::Random.stub(:fixnum => random_fixnum) Mutant::Random.stub(fixnum: random_fixnum)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -20,7 +20,7 @@ describe Mutant::Mutator::Node::OpAsgn, 'or_asgn' do
end end
before do before do
Mutant::Random.stub(:fixnum => random_fixnum, :hex_string => random_string) Mutant::Random.stub(fixnum: random_fixnum, hex_string: random_string)
end end
it_should_behave_like 'a mutator' it_should_behave_like 'a mutator'

View file

@ -15,7 +15,7 @@ describe Mutant::Mutator::Node::Generic, 'rescue' do
end end
before do before do
Mutant::Random.stub(:hex_string => 'random') Mutant::Random.stub(hex_string: 'random')
end end
pending do pending do

View file

@ -1,8 +1,8 @@
require 'spec_helper' require 'spec_helper'
filter_helpers = proc do filter_helpers = proc do
let(:input_a) { double('Input A', :foo => 'bar') } let(:input_a) { double('Input A', foo: 'bar') }
let(:input_b) { double('Input B', :foo => 'baz') } let(:input_b) { double('Input B', foo: 'baz') }
let(:filter_a) do let(:filter_a) do
input_a = self.input_a input_a = self.input_a

View file

@ -10,24 +10,24 @@ describe Mutant::Runner::Config, '#subjects' do
let(:config) do let(:config) do
double( double(
'Config', 'Config',
:class => Mutant::Config, class: Mutant::Config,
:subjects => [subject_a, subject_b], subjects: [subject_a, subject_b],
:strategy => strategy, strategy: strategy,
:reporter => reporter reporter: reporter
) )
end end
let(:reporter) { double('Reporter') } let(:reporter) { double('Reporter') }
let(:strategy) { double('Strategy') } let(:strategy) { double('Strategy') }
let(:subject_a) { double('Subject A') } let(:subject_a) { double('Subject A') }
let(:subject_b) { double('Subject B') } let(:subject_b) { double('Subject B') }
let(:runner_a) { double('Runner A', :stop? => stop_a) } let(:runner_a) { double('Runner A', stop?: stop_a) }
let(:runner_b) { double('Runner B', :stop? => stop_b) } let(:runner_b) { double('Runner B', stop?: stop_b) }
before do before do
strategy.stub(:setup) strategy.stub(:setup)
strategy.stub(:teardown) strategy.stub(:teardown)
reporter.stub(:report => reporter) reporter.stub(report: reporter)
Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a) Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)
Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b) Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b)
end end

View file

@ -10,9 +10,9 @@ describe Mutant::Runner::Config, '#success?' do
let(:config) do let(:config) do
double( double(
'Config', 'Config',
:reporter => reporter, reporter: reporter,
:strategy => strategy, strategy: strategy,
:subjects => [subject_a, subject_b] subjects: [subject_a, subject_b]
) )
end end
@ -22,15 +22,15 @@ describe Mutant::Runner::Config, '#success?' do
let(:subject_b) { double('Subject B') } let(:subject_b) { double('Subject B') }
let(:runner_a) do let(:runner_a) do
double('Runner A', :stop? => stop_a, :success? => success_a) double('Runner A', stop?: stop_a, success?: success_a)
end end
let(:runner_b) do let(:runner_b) do
double('Runner B', :stop? => stop_b, :success? => success_b) double('Runner B', stop?: stop_b, success?: success_b)
end end
before do before do
reporter.stub(:report => reporter) reporter.stub(report: reporter)
strategy.stub(:setup) strategy.stub(:setup)
strategy.stub(:teardown) strategy.stub(:teardown)
Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a) Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)

View file

@ -8,24 +8,24 @@ describe Mutant::Runner::Mutation, '#killer' do
let(:config) do let(:config) do
double( double(
'Config', 'Config',
:fail_fast => fail_fast, fail_fast: fail_fast,
:reporter => reporter, reporter: reporter,
:strategy => strategy strategy: strategy
) )
end end
let(:reporter) { double('Reporter') } let(:reporter) { double('Reporter') }
let(:mutation) { double('Mutation', :class => Mutant::Mutation) } let(:mutation) { double('Mutation', class: Mutant::Mutation) }
let(:strategy) { double('Strategy') } let(:strategy) { double('Strategy') }
let(:killer) { double('Killer', :success? => success) } let(:killer) { double('Killer', success?: success) }
let(:fail_fast) { false } let(:fail_fast) { false }
let(:success) { false } let(:success) { false }
subject { object.killer } subject { object.killer }
before do before do
reporter.stub(:report => reporter) reporter.stub(report: reporter)
strategy.stub(:kill => killer) strategy.stub(kill: killer)
end end
it 'should call configuration to identify strategy' do it 'should call configuration to identify strategy' do

View file

@ -10,26 +10,26 @@ describe Mutant::Runner::Subject, '#success?' do
let(:mutation_subject) do let(:mutation_subject) do
double( double(
'Subject', 'Subject',
:class => Mutant::Subject, class: Mutant::Subject,
:mutations => [mutation_a, mutation_b] mutations: [mutation_a, mutation_b]
) )
end end
let(:reporter) { double('Reporter') } let(:reporter) { double('Reporter') }
let(:config) { double('Config', :reporter => reporter) } let(:config) { double('Config', reporter: reporter) }
let(:mutation_a) { double('Mutation A') } let(:mutation_a) { double('Mutation A') }
let(:mutation_b) { double('Mutation B') } let(:mutation_b) { double('Mutation B') }
let(:runner_a) do let(:runner_a) do
double('Runner A', :success? => success_a, :stop? => stop_a) double('Runner A', success?: success_a, stop?: stop_a)
end end
let(:runner_b) do let(:runner_b) do
double('Runner B', :success? => success_b, :stop? => stop_b) double('Runner B', success?: success_b, stop?: stop_b)
end end
before do before do
reporter.stub(:report => reporter) reporter.stub(report: reporter)
Mutant::Runner.stub(:run).with(config, mutation_a).and_return(runner_a) Mutant::Runner.stub(:run).with(config, mutation_a).and_return(runner_a)
Mutant::Runner.stub(:run).with(config, mutation_b).and_return(runner_b) Mutant::Runner.stub(:run).with(config, mutation_b).and_return(runner_b)
end end

View file

@ -2,7 +2,7 @@
shared_examples_for 'a method filter parse result' do shared_examples_for 'a method filter parse result' do
before do before do
expected_class.stub(:new => response) expected_class.stub(new: response)
end end
let(:response) { double('Response') } let(:response) { double('Response') }