Sha256: c9647ce7d7c7287768c62716102bb39d2494407db0a930da32c97f82ec7b426a

Contents?: true

Size: 1.02 KB

Versions: 33

Compression:

Stored size: 1.02 KB

Contents

# RSpec matcher to spec delegations.
RSpec::Matchers.define :belong_to_associated_active_fedora_object do |association_name|
  match do |subject|
    @association_name = association_name
    if @association_name.nil? || @expected_object.nil?
      raise(
        ArgumentError,
        "expect(subject).to belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)"
      )
    end

    @subject = subject.class.find(subject.id)
    @actual_object = @subject.send(@association_name)

    @expected_object == @actual_object
  end

  chain(:with_object) { |object| @expected_object = object }


  description do
    "#{@subject.class} ID=#{@subject.id} association: #{@association_name.inspect} matches ActiveFedora"
  end

  failure_message do |text|
    "expected #{@subject.class} ID=#{@subject.id} association: #{@association_name.inspect} to match"
  end

  failure_message_when_negated do |text|
    "expected #{@subject.class} ID=#{@subject.id} association: #{@association_name.inspect} to NOT match"
  end

end

Version data entries

33 entries across 33 versions & 1 rubygems

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