Sha256: d9d3f90ea3eee9a9a2c6b4520e93f453ff5bdf93d825610f1fcdd9fc1cc87e3b

Contents?: true

Size: 820 Bytes

Versions: 17

Compression:

Stored size: 820 Bytes

Contents

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

describe Attributor::Ids do
  context '.for' do
    let(:chickens) { Array.new(10) { 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
      expect(ids.load(value)).to match_array emails
    end

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

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
attributor-8.0 spec/types/ids_spec.rb
attributor-7.1 spec/types/ids_spec.rb
attributor-7.0 spec/types/ids_spec.rb
attributor-6.5 spec/types/ids_spec.rb
attributor-6.4 spec/types/ids_spec.rb
attributor-6.3 spec/types/ids_spec.rb
attributor-6.2 spec/types/ids_spec.rb
attributor-6.1 spec/types/ids_spec.rb
attributor-6.0 spec/types/ids_spec.rb
attributor-5.7 spec/types/ids_spec.rb
attributor-5.6 spec/types/ids_spec.rb
attributor-5.5 spec/types/ids_spec.rb
attributor-5.4 spec/types/ids_spec.rb
attributor-5.3 spec/types/ids_spec.rb
attributor-5.2.1 spec/types/ids_spec.rb
attributor-5.2.0 spec/types/ids_spec.rb
attributor-5.1.0 spec/types/ids_spec.rb