Sha256: dc7d7eec40b5e243990430d84d5284f357748c0a92b0bf9e8926aae79bded5ad

Contents?: true

Size: 1.41 KB

Versions: 33

Compression:

Stored size: 1.41 KB

Contents

require "spec_helper"
require 'ostruct'
require "active_fedora/rspec_matchers/have_predicate_matcher"

describe RSpec::Matchers, "have_predicate_matcher" do
  subject { OpenStruct.new(:id => id )}
  let(:id) { 123 }
  let(:object1) { Object.new }
  let(:object2) { Object.new }
  let(:object3) { Object.new }
  let(:predicate) { :predicate }

  it 'should match when relationship is "what we have in Fedora"' do
    expect(subject.class).to receive(:find).with(id).and_return(subject)
    expect(subject).to receive(:relationships).with(predicate).and_return([object1,object2])
    expect(subject).to have_predicate(predicate).with_objects([object1, object2])
  end

  it 'should not match when relationship is different' do
    expect(subject.class).to receive(:find).with(id).and_return(subject)
    expect(subject).to receive(:relationships).with(predicate).and_return([object1,object3])
    expect {
      expect(subject).to have_predicate(predicate).with_objects([object1, object2])
    }.to (
      raise_error(
        RSpec::Expectations::ExpectationNotMetError,
        /expected #{subject.class} ID=#{id} relationship: #{predicate.inspect}/
      )
    )
  end

  it 'should require :with_objects option' do
    expect {
      expect(subject).to have_predicate(predicate)
    }.to(
      raise_error(
        ArgumentError,
          "expect(subject).to have_predicate(<predicate>).with_objects(<objects[]>)"
      )
    )
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
active-fedora-9.0.8 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.5.0 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.4.3 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.4.2 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.4.1 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.4.0 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.3.0 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.2.1 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.2.0 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.2.0.rc2 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.2.0.rc1 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.1.2 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.1.1 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.1.0 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.1.0.rc1 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.0.6 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.0.5 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.0.4 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.0.3 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
active-fedora-9.0.2 spec/unit/rspec_matchers/have_predicate_matcher_spec.rb