Sha256: 16cb3a764514f9d026b0336239808032464cf77db2b0b536135458a2c6fed6e3

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe Proc do
  describe '#compose' do
    subject { Proc.new{|x| x.to_s} }

    it_should_behave_like 'composable'
  end

  describe '#with_args' do
    subject { Proc.new{|x, y, *z| [x, y] + z.to_a } }
    it_should_behave_like 'with_args'
  end

  describe '#flip' do
    context 'arity = 1' do
      subject { Proc.new{|x| [x] } }

      it_should_behave_like 'flip(arity=1)'
    end

    context 'arity > 1' do
      subject { Proc.new{|x, y| [x, y] } }

      it_should_behave_like 'flip'
    end

    context 'varargs' do
      subject { Proc.new{|*x| x } }

      it_should_behave_like 'flip(varargs)'
    end
  end

  describe '#curry' do
    subject { Proc.new{|x, y| [x, y] } }

    it_should_behave_like 'curry'

    context 'varargs' do
      subject { Proc.new{|*x| x } }

      it_should_behave_like 'curry(varargs)'
    end
  end

  describe '#call' do
    subject { Proc.new{|x| x.to_s + "_f"} }

    it_should_behave_like 'call'
  end

  describe 'ailases' do
    subject { Proc.new{|x| x.to_s + "_f"} }

    it_should_behave_like 'aliases'
    it_should_behave_like 'aliases(varargs)' do
      subject { Proc.new{|*x| x } }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lambda_driver-1.1.2 spec/proc_spec.rb
lambda_driver-1.1.1 spec/proc_spec.rb
lambda_driver-1.1.0 spec/proc_spec.rb
lambda_driver-1.0.0 spec/proc_spec.rb