Sha256: 7b30f5861f271e27910bccea101eb973798f834292ca49be2f367702fb404726
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'spec_helper' describe Sinclair::MethodDefinition do let(:klass) { Class.new } let(:instance) { klass.new } describe '#build' do let(:method_name) { :the_method } context 'when method was defined with an string' do let(:code) { '"Self ==> " + self.to_s' } subject { described_class.new(method_name, code) } before do subject.build(klass) end it 'adds the method to the klass instance' do expect(instance).to respond_to(method_name) end it 'evaluates return of the method within the instance context' do expect(instance.the_method).to eq("Self ==> #{instance}") end end context 'when method was defined with a block' do subject do described_class.new(method_name) do "Self ==> " + self.to_s end end before do subject.build(klass) end it 'adds the method to the klass instance' do expect(instance).to respond_to(method_name) end it 'evaluates return of the method within the instance context' do expect(instance.the_method).to eq("Self ==> #{instance}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinclair-1.1.1 | spec/lib/sinclair/method_definition_spec.rb |