Delete memoizer on Subject#prepare
This commit is contained in:
parent
019d8813d9
commit
df7de1ee86
2 changed files with 41 additions and 0 deletions
|
@ -52,6 +52,18 @@ module Mutant
|
|||
end
|
||||
memoize :source
|
||||
|
||||
# Prepare subject for mutation insertion
|
||||
#
|
||||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def prepare
|
||||
scope.send(:memoized_methods).instance_variable_get(:@memory).delete(name)
|
||||
scope.send(:undef_method, name)
|
||||
self
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Return mutations
|
||||
|
|
|
@ -51,6 +51,35 @@ describe Mutant::Subject::Method::Instance::Memoized do
|
|||
s(:def, :foo, s(:args))
|
||||
end
|
||||
|
||||
describe '#prepare' do
|
||||
|
||||
let(:context) do
|
||||
Mutant::Context::Scope.new(scope, double('Source Path'))
|
||||
end
|
||||
|
||||
let(:scope) do
|
||||
Class.new do
|
||||
include Memoizable
|
||||
def foo
|
||||
end
|
||||
memoize :foo
|
||||
end
|
||||
end
|
||||
|
||||
subject { object.prepare }
|
||||
|
||||
it 'undefines memoizer' do
|
||||
expect { subject }.to change { scope.memoized?(:foo) }.from(true).to(false)
|
||||
end
|
||||
|
||||
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
|
||||
subject { object.source }
|
||||
|
||||
|
|
Loading…
Reference in a new issue