parent
c22f3d5d60
commit
681b51f6ac
2 changed files with 46 additions and 0 deletions
|
@ -30,6 +30,17 @@ module Mutant
|
|||
class Memoized < self
|
||||
include NodeHelpers
|
||||
|
||||
# Return source
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source
|
||||
Unparser.unparse(memoizer_node(node))
|
||||
end
|
||||
memoize :source
|
||||
|
||||
private
|
||||
|
||||
# Return mutations
|
||||
|
|
35
spec/unit/mutant/subject/method/instance_spec.rb
Normal file
35
spec/unit/mutant/subject/method/instance_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
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
|
||||
|
||||
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
|
Loading…
Add table
Reference in a new issue