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_EXPANSIONS.keys + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
# Hopefully all types parser does generate
NODE_TYPES = [
:lvasgn, :ivasgn, :cvasgn, :gvasgn,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,9 +10,9 @@ describe Mutant::Runner::Config, '#success?' do
let(:config) do
double(
'Config',
:reporter => reporter,
:strategy => strategy,
:subjects => [subject_a, subject_b]
reporter: reporter,
strategy: strategy,
subjects: [subject_a, subject_b]
)
end
@ -22,15 +22,15 @@ describe Mutant::Runner::Config, '#success?' do
let(:subject_b) { double('Subject B') }
let(:runner_a) do
double('Runner A', :stop? => stop_a, :success? => success_a)
double('Runner A', stop?: stop_a, success?: success_a)
end
let(:runner_b) do
double('Runner B', :stop? => stop_b, :success? => success_b)
double('Runner B', stop?: stop_b, success?: success_b)
end
before do
reporter.stub(:report => reporter)
reporter.stub(report: reporter)
strategy.stub(:setup)
strategy.stub(:teardown)
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
double(
'Config',
:fail_fast => fail_fast,
:reporter => reporter,
:strategy => strategy
fail_fast: fail_fast,
reporter: reporter,
strategy: strategy
)
end
let(:reporter) { double('Reporter') }
let(:mutation) { double('Mutation', :class => Mutant::Mutation) }
let(:strategy) { double('Strategy') }
let(:killer) { double('Killer', :success? => success) }
let(:fail_fast) { false }
let(:success) { false }
let(:reporter) { double('Reporter') }
let(:mutation) { double('Mutation', class: Mutant::Mutation) }
let(:strategy) { double('Strategy') }
let(:killer) { double('Killer', success?: success) }
let(:fail_fast) { false }
let(:success) { false }
subject { object.killer }
before do
reporter.stub(:report => reporter)
strategy.stub(:kill => killer)
reporter.stub(report: reporter)
strategy.stub(kill: killer)
end
it 'should call configuration to identify strategy' do

View file

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

View file

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