Sha256: bf9ad88691ab8b46e5897268fd6fb3b6a3b3fec620db9ff4aa48d0b1cd8a3c09
Contents?: true
Size: 1.47 KB
Versions: 8
Compression:
Stored size: 1.47 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_matcher" do subject { OpenStruct.new(:pid => pid )} let(:pid) { 123 } let(:object1) { Object.new } let(:object2) { Object.new } let(:association) { :association } it 'should match when association is properly stored in fedora' do expect(subject.class).to receive(:find).with(pid).and_return(subject) expect(subject).to receive(association).and_return(object1) expect(subject).to belong_to_associated_active_fedora_object(association).with_object(object1) end it 'should not match when association is different' do expect(subject.class).to receive(:find).with(pid).and_return(subject) expect(subject).to receive(association).and_return(object1) expect { expect(subject).to belong_to_associated_active_fedora_object(association).with_object(object2) }.to ( raise_error( RSpec::Expectations::ExpectationNotMetError, /expected #{subject.class} PID=#{pid} association: #{association.inspect}/ ) ) end it 'should require :with_object option' do expect { expect(subject).to belong_to_associated_active_fedora_object(association) }.to( raise_error( ArgumentError, "subject.should belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)" ) ) end end
Version data entries
8 entries across 8 versions & 1 rubygems