Sha256: 1a0d6f8553cc8aea3ebf340da1f9a47c1521474b157d5c704e5f8967d047f8ff

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 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 equal(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.0 spec/unit/axiom/tuple/class_methods/coerce_spec.rb