Sha256: 7bfb170b55bbf8469981d205a475f39aaff03413d0a1d5b4e096b77704fc2776

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:header) { Relation::Header.new([ [ :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_kind_of(object) }

    it { should == 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
veritas-0.0.4 spec/unit/veritas/tuple/class_methods/coerce_spec.rb