-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next commits will provide config object from callsides. The config object is currently empty. The config object is passed to all children mutators. Currently no mutator public interface was modified so no spec changes. With next commits we have public visible stuff so specs will be adjusted.
- Loading branch information
Showing
5 changed files
with
145 additions
and
126 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,94 @@ | ||
# encoding: utf-8 | ||
|
||
require 'spec_helper' | ||
|
||
describe Mutant::Mutator do | ||
|
||
let(:object) { class_under_test.new(context, block) } | ||
|
||
let(:context) { described_class::Context.new(config, parent, input) } | ||
let(:block) { Block.new } | ||
let(:input) { :input } | ||
let(:parent) { :parent } | ||
let(:config) { double('Config') } | ||
|
||
|
||
class Block | ||
attr_reader :arguments | ||
|
||
def called? | ||
defined?(@arguments) | ||
end | ||
|
||
def call(*arguments) | ||
@arguments = arguments | ||
end | ||
end | ||
|
||
let(:class_under_test) do | ||
Class.new(described_class) do | ||
def dispatch | ||
# noop | ||
end | ||
end | ||
end | ||
|
||
describe '#emit' do | ||
|
||
subject { object.send(:emit, generated) } | ||
|
||
context 'with generated that is not equal to input' do | ||
let(:generated) { :generated } | ||
|
||
it 'should call block' do | ||
subject | ||
block.should be_called | ||
end | ||
|
||
it 'should call block with generated' do | ||
subject | ||
block.arguments.should eql([generated]) | ||
end | ||
end | ||
|
||
context 'with generated object that is equal to input' do | ||
let(:generated) { input } | ||
|
||
it 'should not call block' do | ||
subject | ||
block.should_not be_called | ||
end | ||
end | ||
end | ||
|
||
describe '#emit_new' do | ||
subject { object.send(:emit_new) { generated } } | ||
|
||
context 'when new object generated' do | ||
let(:generated) { :generated } | ||
|
||
it 'should call block' do | ||
subject | ||
block.should be_called | ||
end | ||
|
||
it 'should call block with generated object' do | ||
subject | ||
block.arguments.should eql([generated]) | ||
end | ||
end | ||
|
||
context 'when new AST could not be generated' do | ||
let(:generated) { input } | ||
|
||
it 'should raise error' do | ||
expect do | ||
subject | ||
end.to raise_error( | ||
RuntimeError, | ||
'New AST could not be generated after 3 attempts' | ||
) | ||
end | ||
end | ||
end | ||
end |