parent
3edf37e0dd
commit
85061dee96
4 changed files with 49 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
# v0.5.11 2014-04-xx
|
||||
# v0.5.11 2014-04-21
|
||||
|
||||
Changes:
|
||||
|
||||
|
@ -6,6 +6,8 @@ Changes:
|
|||
* Better require highjack based zombifier
|
||||
* Do not mutate nthref $1 to gvar $0
|
||||
* Use faster duplicate guarding hashing AST::Node intances
|
||||
* Fix lots of shadowed invalid ASTs
|
||||
* Fix undefine initialize warnings, Closes #175
|
||||
|
||||
# v0.5.10 2014-04-06
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ module Mutant
|
|||
#
|
||||
def insert
|
||||
subject.public?
|
||||
Loader::Eval.call(root, subject)
|
||||
subject.warning_expectation.execute do
|
||||
Loader::Eval.call(root, subject)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,15 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def prepare
|
||||
scope.send(:undef_method, name)
|
||||
expected_warnings =
|
||||
if name.equal?(:initialize)
|
||||
["#{__FILE__}:#{__LINE__ + 5}: warning: undefining `initialize' may cause serious problems\n"]
|
||||
else
|
||||
[]
|
||||
end
|
||||
WarningExpectation.new(expected_warnings).execute do
|
||||
scope.send(:undef_method, name)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ describe Mutant::Subject::Method::Instance do
|
|||
|
||||
let(:scope) do
|
||||
Class.new do
|
||||
attr_reader :bar
|
||||
|
||||
def initialize
|
||||
@bar = :boo
|
||||
end
|
||||
|
||||
def foo
|
||||
end
|
||||
end
|
||||
|
@ -27,11 +33,36 @@ describe Mutant::Subject::Method::Instance do
|
|||
|
||||
subject { object.prepare }
|
||||
|
||||
it 'undefines method on scope' do
|
||||
expect { subject }.to change { scope.instance_methods.include?(:foo) }.from(true).to(false)
|
||||
context 'on non initialize methods' do
|
||||
|
||||
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
|
||||
|
||||
it_should_behave_like 'a command method'
|
||||
context 'on initialize method' do
|
||||
|
||||
let(:node) do
|
||||
s(:def, :initialize, s(:args))
|
||||
end
|
||||
|
||||
it 'does not write warnings' do
|
||||
warnings = Mutant::WarningFilter.use do
|
||||
subject
|
||||
end
|
||||
expect(warnings).to eql([])
|
||||
end
|
||||
|
||||
it 'undefines method on scope' do
|
||||
subject
|
||||
expect { scope.new }.to raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it_should_behave_like 'a command method'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#source' do
|
||||
|
|
Loading…
Add table
Reference in a new issue