Reduce public interface of Subject

This commit is contained in:
Markus Schirp 2014-11-17 21:40:39 +00:00
parent 87f4d0bd15
commit 84b259ab6a
3 changed files with 5 additions and 16 deletions

View file

@ -99,7 +99,7 @@ module Mutant
# @api private # @api private
# #
def root def root
subject.root(node) subject.context.root(node)
end end
# Evil mutation that should case mutations to fail tests # Evil mutation that should case mutations to fail tests

View file

@ -88,18 +88,6 @@ module Mutant
end end
memoize :source memoize :source
# Return root AST for node
#
# @param [Parser::AST::Node] node
#
# @return [Parser::AST::Node]
#
# @api private
#
def root(node)
context.root(node)
end
# Return match expression # Return match expression
# #
# @return [Expression] # @return [Expression]

View file

@ -4,8 +4,9 @@ RSpec.describe Mutant::Mutation do
SYMBOL = 'test'.freeze SYMBOL = 'test'.freeze
end end
let(:object) { TestMutation.new(mutation_subject, Mutant::AST::Nodes::N_NIL) } let(:object) { TestMutation.new(mutation_subject, Mutant::AST::Nodes::N_NIL) }
let(:mutation_subject) { double('Subject', identification: 'subject', source: 'original') } let(:mutation_subject) { double('Subject', identification: 'subject', context: context, source: 'original') }
let(:context) { double('Context') }
describe '#code' do describe '#code' do
subject { object.code } subject { object.code }
@ -31,7 +32,7 @@ RSpec.describe Mutant::Mutation do
before do before do
expect(mutation_subject).to receive(:public?).ordered.and_return(true) expect(mutation_subject).to receive(:public?).ordered.and_return(true)
expect(mutation_subject).to receive(:prepare).ordered expect(mutation_subject).to receive(:prepare).ordered
expect(mutation_subject).to receive(:root).ordered.with(s(:nil)).and_return(wrapped_node) expect(context).to receive(:root).ordered.with(s(:nil)).and_return(wrapped_node)
expect(Mutant::Loader::Eval).to receive(:call).ordered.with(wrapped_node, mutation_subject).and_return(nil) expect(Mutant::Loader::Eval).to receive(:call).ordered.with(wrapped_node, mutation_subject).and_return(nil)
end end