Sha256: ed9132b27f6514a1adc505a3991d751dbf4c26615cbeb9151ec52edeab7be74e

Contents?: true

Size: 805 Bytes

Versions: 5

Compression:

Stored size: 805 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')

describe Attributor::Ids do

  context '.for' do
    let(:chickens) { 10.times.collect { Chicken.example } }

    let(:emails) { chickens.collect(&:email) }
    let(:value) { emails.join(',') }

    subject!(:ids) { Attributor::Ids.for(Chicken) }

    its(:member_attribute) { should be(Chicken.attributes[:email]) }

    it 'loads' do
      ids.load(value).should eq(emails)
    end

    it 'generates valid, loadable examples' do
      ids.validate(ids.load(ids.example)).should be_empty
    end

  end

  context 'attempting to define it as a collection using .of(type)' do
    it 'raises an error' do
      expect{
        Attributor::Ids.of(Chicken)
      }.to raise_error(/Defining Ids.of\(type\) is not allowed/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attributor-2.6.1 spec/types/ids_spec.rb
attributor-2.6.0 spec/types/ids_spec.rb
attributor-2.5.0 spec/types/ids_spec.rb
attributor-2.4.0 spec/types/ids_spec.rb
attributor-2.3.0 spec/types/ids_spec.rb