Sha256: eae7c6fd750e6a01027567e8b69aefa7043bc52dc7711056a51adf514dbda60a

Contents?: true

Size: 804 Bytes

Versions: 9

Compression:

Stored size: 804 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 =~ 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

9 entries across 9 versions & 1 rubygems

Version Path
attributor-5.0.2 spec/types/ids_spec.rb
attributor-5.0.1 spec/types/ids_spec.rb
attributor-5.0 spec/types/ids_spec.rb
attributor-4.2.0 spec/types/ids_spec.rb
attributor-4.1.0 spec/types/ids_spec.rb
attributor-4.0.1 spec/types/ids_spec.rb
attributor-4.0.0 spec/types/ids_spec.rb
attributor-3.0.1 spec/types/ids_spec.rb
attributor-3.0 spec/types/ids_spec.rb