spec/shared/composable_spec.rb in lambda_driver-1.2.0 vs spec/shared/composable_spec.rb in lambda_driver-1.2.1

- old
+ new

@@ -1,5 +1,6 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' shared_examples_for 'composable' do it { should respond_to :to_proc} it { should respond_to :>> } @@ -91,11 +92,11 @@ it(' f.flip returns itself'){ subject.flip.should == subject } it(' f.flip.call(x) returns proc ') { - subject.flip.call(y) == subject.call(y) + subject.flip.to_proc.call(y) == subject.to_proc.call(y) } end shared_examples_for 'flip(varargs)' do let(:x) { :foo } @@ -104,11 +105,11 @@ it('f.flip returns itself'){ subject.flip.should == subject } it('f.flip(2).call(x) returns proc ') { - subject.flip(2).call(y) == subject.call(y) + subject.flip(2).call(y) == subject.to_proc.call(y) } it('~f.flip(2).call(x).call(y) should be f.call(y,x)'){ subject.flip(2).call(y).call(x).should == subject.to_proc.call(x, y) } @@ -149,29 +150,34 @@ } end shared_examples_for 'call' do it { should respond_to :call} - it { should respond_to :<} let(:x) { :foo } it('f.call(x) == f.call(x)'){ subject.call(x).should == subject.call(x) } +end +shared_examples_for 'call(<)' do + it { should respond_to :<} + + let(:x) { :foo } + it('(f < x) == f.call(x)'){ - (subject < x).should == subject.call(x) + (subject < x).should == subject.to_proc.call(x) } end shared_examples_for 'aliases' do let(:x) { :foo } let(:y) { 12 } let(:g) { lambda{|x| (x.to_s * 2).to_s + "_g" } } it('(~f < x) should be f.flip.call(x)'){ - (~subject < x).should == subject.flip.call(x) + (~subject < x).should == subject.flip.to_proc.call(x) } it('(f << g < x) should f.compose(g).call(x)'){ (subject << g < x).should == subject.compose(g).call(x) }