Sha256: a85fbc336eb1ed7b378eb0f32aab8117dd76285ed0214d9263db301babaf9725

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Function::Numeric::Binary, '#type' do
  subject { object.type }

  let(:described_class) { Class.new(Function::Numeric) { include Function::Numeric::Binary } }
  let(:object)          { described_class.new(operand, operand)                              }
  let(:operand)         { mock('Operand')                                                    }

  before do
    operand.stub!(:freeze).and_return(operand)
  end

  context 'when the operands are from the same class' do
    it 'delegates to Attribute.infer_type' do
      type = mock('Type')
      Attribute.should_receive(:infer_type).with(operand).twice.and_return(type)
      should equal(type)
    end
  end

  context 'when the operands are from a different class class' do
    it 'delegates to Attribute.infer_type' do
      type_a = mock('Type A')
      type_b = mock('Type B')
      Attribute.should_receive(:infer_type).with(operand).ordered.and_return(type_a)
      Attribute.should_receive(:infer_type).with(operand).ordered.and_return(type_b)
      should equal(Attribute::Numeric)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-0.0.7 spec/unit/veritas/function/numeric/binary/type_spec.rb
veritas-0.0.6 spec/unit/veritas/function/numeric/binary/type_spec.rb
veritas-0.0.5 spec/unit/veritas/function/numeric/binary/type_spec.rb
veritas-0.0.4 spec/unit/veritas/function/numeric/binary/type_spec.rb