Sha256: a0b9387fd1e017b0ddbf2c9b4226b9f5aaa2cc6b714786090ff0a09f81114c44

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe LambdaDriver::Revapply do
  let(:object) { "foobarbaz" }
  let(:f) { lambda{|x| x * 2 } }

  describe '#revapply'do
    context 'given none' do
      subject { object.revapply }

      it { should be_a_kind_of Method }
      it('obj.revapply.call(f) should be f.call(obj)'){
        subject.call(f).should == f.call(object)
      }
      it('obj.revapply.call{block} should be result of execute block with obj'){
        subject.call{|x| x * 3 }.should == (object * 3)
      }
      it('obj.revapply.call(f){block} should be result of execute block with obj'){
        subject.call(f){|x| x * 3 }.should == (object * 3)
      }
    end

    context 'block given' do
      it('obj.revapply{block} should be result of execute block with obj'){
        object.revapply{|x| x * 3 }.should == (object * 3)
      }
    end

    context 'proc object given' do
      it('obj.revapply(f) should be f.call(obj)'){
        object.revapply(f).should == f.call(object)
      }
    end

    context 'block given and proc object given' do
      it('obj.revapply.call(f){block} should be result of execute block with obj'){
        object.revapply(f){|x| x * 3 }.should == (object * 3)
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lambda_driver-1.2.0 spec/revapply_spec.rb
lambda_driver-1.1.2 spec/revapply_spec.rb
lambda_driver-1.1.1 spec/revapply_spec.rb