Sha256: 13facd61d0cf77b4077311fb99084d85138e2e4e3cd05ccb79938149b5a93ea4

Contents?: true

Size: 1.45 KB

Versions: 67

Compression:

Stored size: 1.45 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
    subject.class.should_receive(:find).with(pid).and_return(subject)
    subject.should_receive(association).and_return(object1)
    subject.should belong_to_associated_active_fedora_object(association).with_object(object1)
  end

  it 'should not match when association is different' do
    subject.class.should_receive(:find).with(pid).and_return(subject)
    subject.should_receive(association).and_return(object1)
    lambda {
      subject.should belong_to_associated_active_fedora_object(association).with_object(object2)
    }.should (
      raise_error(
        RSpec::Expectations::ExpectationNotMetError,
        /expected #{subject.class} PID=#{pid} association: #{association.inspect}/
      )
    )
  end

  it 'should require :with_object option' do
    lambda {
      subject.should belong_to_associated_active_fedora_object(association)
    }.should(
      raise_error(
        ArgumentError,
        "subject.should belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)"
      )
    )
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
active-fedora-7.3.1 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.3.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.2.1 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.2.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.2.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.1.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.0.1 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.0.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.0.0.rc3 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.0.0.rc2 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-8.0.0.rc1 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.1.2 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.1.1 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.1.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-6.7.8 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.0.4 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.0.3 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.0.2 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.0.1 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb
active-fedora-7.0.0 spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb