parent
fd5fd42125
commit
df9207cad4
5 changed files with 48 additions and 0 deletions
|
@ -15,6 +15,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def call
|
def call
|
||||||
|
subject.prepare
|
||||||
eval(
|
eval(
|
||||||
source,
|
source,
|
||||||
TOPLEVEL_BINDING,
|
TOPLEVEL_BINDING,
|
||||||
|
|
|
@ -29,6 +29,16 @@ module Mutant
|
||||||
context.source_path
|
context.source_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Prepare the subject for the insertion of mutation
|
||||||
|
#
|
||||||
|
# @return [self]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def prepare
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
# Return source line
|
# Return source line
|
||||||
#
|
#
|
||||||
# @return [Fixnum]
|
# @return [Fixnum]
|
||||||
|
|
|
@ -27,6 +27,17 @@ module Mutant
|
||||||
node.children[self.class::NAME_INDEX]
|
node.children[self.class::NAME_INDEX]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Prepare subject for mutation insertion
|
||||||
|
#
|
||||||
|
# @return [self]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def prepare
|
||||||
|
scope.send(:undef_method, name)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
# Return match expression
|
# Return match expression
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
|
|
|
@ -14,6 +14,10 @@ describe Mutant::Loader::Eval, '.call' do
|
||||||
double('Subject', source_path: path, source_line: line)
|
double('Subject', source_path: path, source_line: line)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
expect(mutation_subject).to receive(:prepare).and_return(mutation_subject)
|
||||||
|
end
|
||||||
|
|
||||||
let(:source) do
|
let(:source) do
|
||||||
<<-RUBY
|
<<-RUBY
|
||||||
class SomeNamespace
|
class SomeNamespace
|
||||||
|
|
|
@ -12,6 +12,28 @@ describe Mutant::Subject::Method::Instance do
|
||||||
s(:def, :foo, s(:args))
|
s(:def, :foo, s(:args))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#prepare' do
|
||||||
|
|
||||||
|
let(:context) do
|
||||||
|
Mutant::Context::Scope.new(scope, double('Source Path'))
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:scope) do
|
||||||
|
Class.new do
|
||||||
|
def foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { object.prepare }
|
||||||
|
|
||||||
|
it 'undefines method on scope' do
|
||||||
|
expect { subject }.to change { scope.instance_methods.include?(:foo) }.from(true).to(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'a command method'
|
||||||
|
end
|
||||||
|
|
||||||
describe '#source' do
|
describe '#source' do
|
||||||
subject { object.source }
|
subject { object.source }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue