Sha256: c4737a052a6ac9dcd23caa9f1d8d5ff07d37f1cad9278579add88a62605ab776
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require 'spec_helper' require File.expand_path('../../fixtures/classes', __FILE__) shared_examples_for 'memoizes method' do it 'memoizes the instance method' do subject instance = object.new instance.send(method).should equal(instance.send(method)) end specification = proc do object.send(:define_method, method) do caller end subject file, line = object.new.send(method).first.split(':')[0, 2] File.expand_path(file).should == File.expand_path('../../../../../../lib/veritas/support/immutable.rb', __FILE__) line.to_i.should == 156 end it 'sets the file and line number properly' do if RUBY_PLATFORM[/java/] pending('Kernel#caller returns the incorrect line number in JRuby', &specification) else instance_eval(&specification) end end end describe 'Veritas::Immutable::ModuleMethods#memoize' do subject { object.memoize(method) } let(:object) { Class.new(ImmutableSpecs::Object) } context 'public method' do let(:method) { :public_method } it { should equal(object) } it_should_behave_like 'memoizes method' it 'is still a public method' do should be_public_method_defined(method) end end context 'protected method' do let(:method) { :protected_method } it { should equal(object) } it_should_behave_like 'memoizes method' it 'is still a protected method' do should be_protected_method_defined(method) end end context 'private method' do let(:method) { :private_method } it { should equal(object) } it_should_behave_like 'memoizes method' it 'is still a private method' do should be_private_method_defined(method) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | spec/unit/veritas/immutable/module_methods/memoize_spec.rb |