Sha256: 627bc7e634f1beb0908c55b3d939fcc3804b9d3a436a7286150c7b177b54b889
Contents?: true
Size: 1.48 KB
Versions: 41
Compression:
Stored size: 1.48 KB
Contents
require "spec_helper" require 'ostruct' require "active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher" describe RSpec::Matchers, ".belong_to_associated_active_fedora_object" do let(:open_struct) { OpenStruct.new(id: id) } let(:id) { 123 } let(:object1) { Object.new } let(:object2) { Object.new } let(:association) { :association } it 'matches when association is properly stored in fedora' do expect(open_struct.class).to receive(:find).with(id).and_return(open_struct) expect(open_struct).to receive(association).and_return(object1) expect(open_struct).to belong_to_associated_active_fedora_object(association).with_object(object1) end it 'does not match when association is different' do expect(open_struct.class).to receive(:find).with(id).and_return(open_struct) expect(open_struct).to receive(association).and_return(object1) expect { expect(open_struct).to belong_to_associated_active_fedora_object(association).with_object(object2) }.to raise_error RSpec::Expectations::ExpectationNotMetError, /expected #{open_struct.class} ID=#{id} association: #{association.inspect}/ end it 'requires :with_object option' do expect { expect(open_struct).to belong_to_associated_active_fedora_object(association) }.to( raise_error( ArgumentError, "expect(subject).to belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)" ) ) end end
Version data entries
41 entries across 41 versions & 1 rubygems