Sha256: e7bb4fe5e7213aab69be9e22175c02c5bb6a79261894f6c068ed44309d7e5709

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

require 'spec_helper'

describe 'Veritas::Attribute.coerce' do
  subject { object.coerce(argument) }

  let(:object) { Attribute }

  context 'when the argument is an Attribute' do
    let(:argument) { Attribute::Integer.new(:id) }

    it { should equal(argument) }
  end

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

    it { should be_kind_of(Attribute::Integer) }

    its(:name) { should == :id }
  end

  context 'when the argument does not respond to #to_ary, but does respond to #to_sym' do
    let(:argument) { :id }

    it { should be_kind_of(Attribute::Object) }

    its(:name) { should == :id }
  end

  context 'when the argument does not respond to #to_ary or #to_sym' do
    let(:argument) { Integer }

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/attribute/class_methods/coerce_spec.rb