2013-12-07 19:07:18 +01:00
|
|
|
# encoding: UTF-8
|
|
|
|
|
2013-10-30 09:06:39 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Mutant::Subject::Method::Instance do
|
|
|
|
include Mutant::NodeHelpers
|
|
|
|
|
|
|
|
let(:object) { described_class.new(context, node) }
|
|
|
|
let(:context) { double }
|
|
|
|
|
|
|
|
let(:node) do
|
|
|
|
s(:def, :foo, s(:args))
|
|
|
|
end
|
|
|
|
|
2014-03-14 21:34:21 +00:00
|
|
|
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
|
|
|
|
|
2013-10-30 09:06:39 +01:00
|
|
|
describe '#source' do
|
|
|
|
subject { object.source }
|
|
|
|
|
|
|
|
it { should eql("def foo\nend") }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe Mutant::Subject::Method::Instance::Memoized do
|
|
|
|
include Mutant::NodeHelpers
|
|
|
|
|
|
|
|
let(:object) { described_class.new(context, node) }
|
|
|
|
let(:context) { double }
|
|
|
|
|
|
|
|
let(:node) do
|
|
|
|
s(:def, :foo, s(:args))
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#source' do
|
|
|
|
subject { object.source }
|
|
|
|
|
|
|
|
it { should eql("def foo\nend\nmemoize(:foo)") }
|
|
|
|
end
|
|
|
|
end
|