2014-08-10 21:04:05 +00:00
|
|
|
RSpec.describe Mutant::Mutation do
|
2014-05-11 14:38:07 +00:00
|
|
|
class TestMutation < Mutant::Mutation
|
2014-06-02 11:09:49 +00:00
|
|
|
SYMBOL = 'test'.freeze
|
2014-05-11 14:38:07 +00:00
|
|
|
end
|
|
|
|
|
2014-10-23 11:37:53 +00:00
|
|
|
let(:object) { TestMutation.new(mutation_subject, Mutant::AST::Nodes::N_NIL) }
|
2015-10-31 01:27:57 +00:00
|
|
|
let(:context) { instance_double(Mutant::Context) }
|
2014-10-23 11:37:53 +00:00
|
|
|
|
|
|
|
let(:mutation_subject) do
|
2015-10-31 01:27:57 +00:00
|
|
|
instance_double(
|
|
|
|
Mutant::Subject,
|
2014-10-23 11:37:53 +00:00
|
|
|
identification: 'subject',
|
2015-10-31 01:27:57 +00:00
|
|
|
context: context,
|
|
|
|
source: 'original'
|
2014-10-23 11:37:53 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2015-10-31 01:27:57 +00:00
|
|
|
let(:test_a) { instance_double(Mutant::Test) }
|
|
|
|
let(:test_b) { instance_double(Mutant::Test) }
|
|
|
|
|
|
|
|
describe '#insert' do
|
|
|
|
subject { object.insert }
|
|
|
|
|
|
|
|
let(:root_node) { s(:foo) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
expect(context).to receive(:root)
|
|
|
|
.with(object.node)
|
|
|
|
.and_return(root_node)
|
|
|
|
|
|
|
|
expect(mutation_subject).to receive(:prepare)
|
|
|
|
.ordered
|
|
|
|
.and_return(mutation_subject)
|
|
|
|
|
|
|
|
expect(Mutant::Loader::Eval).to receive(:call)
|
|
|
|
.ordered
|
|
|
|
.with(root_node, mutation_subject)
|
|
|
|
.and_return(Mutant::Loader::Eval)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'a command method'
|
|
|
|
end
|
2014-10-23 11:37:53 +00:00
|
|
|
|
2013-09-14 01:01:11 +02:00
|
|
|
describe '#code' do
|
|
|
|
subject { object.code }
|
|
|
|
|
|
|
|
it { should eql('8771a') }
|
|
|
|
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#original_source' do
|
|
|
|
subject { object.original_source }
|
|
|
|
|
|
|
|
it { should eql('original') }
|
|
|
|
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#source' do
|
|
|
|
subject { object.source }
|
|
|
|
|
|
|
|
it { should eql('nil') }
|
|
|
|
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#identification' do
|
|
|
|
|
|
|
|
subject { object.identification }
|
|
|
|
|
2014-05-11 14:38:07 +00:00
|
|
|
it { should eql('test:subject:8771a') }
|
2013-09-14 01:01:11 +02:00
|
|
|
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
|
|
end
|
|
|
|
end
|