Sha256: 3e60a4d2161d76203704a9db28b1b4e068b7ff5ee9415ec21f4ae208521c318f

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Function::Predicate::Enumerable, '#call' do
  subject { object.call(tuple) }

  let(:described_class) { Class.new(Function) { include Function::Binary } }
  let(:header)          { Relation::Header.coerce([[:id, Integer]])        }
  let(:tuple)           { Tuple.new(header, [1])                           }

  before do
    described_class.class_eval { include Function::Predicate::Enumerable }
  end

  context 'with an enumerable of non-callable objects' do
    let(:object) { described_class.new(header[:id], [1]) }

    it 'sends the left and right value to self.class.call' do
      response = double('#call response')
      described_class.should_receive(:call).with(1, [1]).and_return(response)
      should be(response)
    end
  end

  context 'with an enumerable of callable objects' do
    let(:callable) { proc { 1 }                                   }
    let(:object)   { described_class.new(header[:id], [callable]) }

    it 'sends the left and right value to self.class.call' do
      response = double('#call response')
      described_class.should_receive(:call).with(1, [1]).and_return(response)
      should be(response)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/function/predicate/enumerable/call_spec.rb