Sha256: 864883f543a1047426c7ef065a051c310e81b9ecb1e26b9440011231a066cfbb

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Tuple, '.coerce' do
  subject { object.coerce(header, argument) }

  let(:header) { Relation::Header.coerce([[:id, Integer]]) }
  let(:object) { described_class                           }
  let(:tuple)  { object.new(header, [1])                   }

  context 'when the argument is a Tuple' do
    let(:argument) { tuple }

    it { should be(argument) }
  end

  context 'when the argument responds to #to_ary' do
    let(:argument) { [1] }

    it { should be_instance_of(object) }

    it { should eql(tuple) }
  end

  context 'when the argument is not a Tuple and does not respond to #to_ary' do
    let(:argument) { { id: 1 } }

    specify { expect { subject }.to raise_error(NoMethodError) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/tuple/class_methods/coerce_spec.rb