Sha256: a50a5363da10e92c1ee83737f80215652bec0cf9b2d5bc0ddb4f7fa78507a79e
Contents?: true
Size: 1.64 KB
Versions: 5
Compression:
Stored size: 1.64 KB
Contents
require 'spec_helper' shared_examples_for 'method_or_lambda' do |label| let(:method_name) { :+ } context 'given method name (is reciever object responds)' do subject { method } it { should be_a_kind_of Method } it("#{label}.call(args) should be obj.send(method_name, args)"){ subject.call('bar').should == object.send(method_name, 'bar') } end context 'given method name (is not reciever object responds)' do subject { lambda_proc } before { def object.method_missing(method, *args) method == :foo ? args : super(method, *args) end } it { should be_a_kind_of Proc } it("#{label}.call(args) should be obj.send(method_name, args)"){ lambda_proc.call('bar', 'baz').should == object.send(:foo, 'bar', 'baz') } end end describe LambdaDriver::Op do describe '#_' do let(:object) { "foobarbaz" } context 'given nil' do subject { object._ } it { subject.class.should be_a_kind_of LambdaDriver::Op::Proxy } end it_should_behave_like 'method_or_lambda', 'obj._(method_name)' do let(:method){ object._(:+) } let(:lambda_proc){ object._(:foo) } end end end describe LambdaDriver::Op::Proxy do let(:object) { "foobarbaz" } describe '#call' do it_should_behave_like 'method_or_lambda', 'obj._(method_name)' do let(:method){ object._.call(:+) } let(:lambda_proc){ object._.call(:foo) } end end describe '#method_missing' do it_should_behave_like 'method_or_lambda', 'obj._.method_name' do let(:method){ object._.index } let(:method_name) { :index } let(:lambda_proc){ object._.foo } end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
lambda_driver-1.2.0 | spec/op_spec.rb |
lambda_driver-1.1.2 | spec/op_spec.rb |
lambda_driver-1.1.1 | spec/op_spec.rb |
lambda_driver-1.1.0 | spec/op_spec.rb |
lambda_driver-1.0.0 | spec/op_spec.rb |