Sha256: 20992a8e4f1e935a34f787a54cc9eeafd15645a26664a54eb282c24f85893b30

Contents?: true

Size: 601 Bytes

Versions: 3

Compression:

Stored size: 601 Bytes

Contents

RSpec.describe ROM::AssociationSet do
  describe '#try' do
    it 'returns association when it exists' do
      assoc = spy(:assoc)
      assoc_set = ROM::AssociationSet.new(users: assoc)

      assoc_set.try(:users, &:done)

      expect(assoc).to have_received(:done)
    end

    it 'returns false when assoc is not found' do
      assoc = spy(:assoc)
      fallback = spy(:fallback)
      assoc_set = ROM::AssociationSet.new({})

      assoc_set.try(:users, &:done) or fallback.done

      expect(assoc).to_not have_received(:done)
      expect(fallback).to have_received(:done)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-2.0.2 spec/unit/rom/association_set_spec.rb
rom-2.0.1 spec/unit/rom/association_set_spec.rb
rom-2.0.0 spec/unit/rom/association_set_spec.rb