forked from txus/mutant
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Josep M. Bach
committed
Feb 25, 2012
1 parent
8793c9e
commit 30fd1da
Showing
3 changed files
with
332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Mutating calls' do | ||
context 'for an instance method' do | ||
context 'that contains a method call without arguments' do | ||
before do | ||
write_file 'life.rb', """ | ||
class Life | ||
def helper | ||
42 | ||
end | ||
def answer | ||
helper | ||
end | ||
end | ||
""" | ||
end | ||
|
||
context 'with an expectation that the answer is 42' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life#answer' do | ||
specify { Life.new.answer.should eq(42) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life#answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation passes' do | ||
all_output.should include('passed') | ||
end | ||
end | ||
|
||
context 'with an expectation that life respond to :answer' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life#answer' do | ||
specify { Life.new.should respond_to(:answer) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life#answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation fails' do | ||
all_output.should include('failed') | ||
end | ||
end | ||
end | ||
|
||
context 'that contains a method call with arguments' do | ||
before do | ||
write_file 'life.rb', """ | ||
class Life | ||
def helper(num) | ||
num + 2 | ||
end | ||
def answer | ||
helper(40) | ||
end | ||
end | ||
""" | ||
end | ||
|
||
context 'with an expectation that the answer is 42' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life#answer' do | ||
specify { Life.new.answer.should eq(42) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life#answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation passes' do | ||
all_output.should include('passed') | ||
end | ||
end | ||
|
||
context 'with an expectation that life respond to :answer' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life#answer' do | ||
specify { Life.new.should respond_to(:answer) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life#answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation fails' do | ||
all_output.should include('failed') | ||
end | ||
end | ||
end | ||
|
||
context 'that contains a method call with a block' do | ||
before do | ||
write_file 'life.rb', """ | ||
class Life | ||
def helper | ||
yield | ||
end | ||
def answer | ||
helper { 42 } | ||
end | ||
end | ||
""" | ||
end | ||
|
||
context 'with an expectation that the answer is 42' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life#answer' do | ||
specify { Life.new.answer.should eq(42) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life#answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation passes' do | ||
all_output.should include('passed') | ||
end | ||
end | ||
|
||
context 'with an expectation that life respond to :answer' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life#answer' do | ||
specify { Life.new.should respond_to(:answer) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life#answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation fails' do | ||
all_output.should include('failed') | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Mutating calls' do | ||
context 'for an instance method' do | ||
context 'that contains a method call without arguments' do | ||
before do | ||
write_file 'life.rb', """ | ||
class Life | ||
def self.helper | ||
42 | ||
end | ||
def self.answer | ||
helper | ||
end | ||
end | ||
""" | ||
end | ||
|
||
context 'with an expectation that the answer is 42' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life.answer' do | ||
specify { Life.answer.should eq(42) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life.answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation passes' do | ||
all_output.should include('passed') | ||
end | ||
end | ||
|
||
context 'with an expectation that life respond to :answer' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life.answer' do | ||
specify { Life.should respond_to(:answer) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life.answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation fails' do | ||
all_output.should include('failed') | ||
end | ||
end | ||
end | ||
|
||
context 'that contains a method call with arguments' do | ||
before do | ||
write_file 'life.rb', """ | ||
class Life | ||
def self.helper(num) | ||
num + 2 | ||
end | ||
def self.answer | ||
helper(40) | ||
end | ||
end | ||
""" | ||
end | ||
|
||
context 'with an expectation that the answer is 42' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life.answer' do | ||
specify { Life.answer.should eq(42) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life.answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation passes' do | ||
all_output.should include('passed') | ||
end | ||
end | ||
|
||
context 'with an expectation that life respond to :answer' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life.answer' do | ||
specify { Life.should respond_to(:answer) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life.answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation fails' do | ||
all_output.should include('failed') | ||
end | ||
end | ||
end | ||
|
||
context 'that contains a method call with a block' do | ||
before do | ||
write_file 'life.rb', """ | ||
class Life | ||
def self.helper | ||
yield | ||
end | ||
def self.answer | ||
helper { 42 } | ||
end | ||
end | ||
""" | ||
end | ||
|
||
context 'with an expectation that the answer is 42' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life.answer' do | ||
specify { Life.answer.should eq(42) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life.answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation passes' do | ||
all_output.should include('passed') | ||
end | ||
end | ||
|
||
context 'with an expectation that life respond to :answer' do | ||
before do | ||
write_file 'spec/life_spec.rb', """ | ||
$: << '.' | ||
require 'life' | ||
describe 'Life.answer' do | ||
specify { Life.should respond_to(:answer) } | ||
end | ||
""" | ||
run_simple '../../bin/mutate Life.answer spec/life_spec.rb' | ||
end | ||
|
||
specify 'the mutation fails' do | ||
all_output.should include('failed') | ||
end | ||
end | ||
end | ||
end | ||
end |