Sha256: 5f696e9b857397aa280042d584ff18f31ad2e945d2f3d6493bdebee4fba2406a

Contents?: true

Size: 1.17 KB

Versions: 76

Compression:

Stored size: 1.17 KB

Contents

# RSpec matcher to spec delegations.

RSpec::Matchers.define :match_fedora_datastream do |method|
  match do |object|
    @method = method
    @object = object
    if @expected_xml.nil?
      raise(
        ArgumentError,
        "match_fedora_datastream(<datastream_name>).with(<expected_xml>)"
      )
    end
    expected = Nokogiri::XML(@expected_xml)

    base_url = ActiveFedora.config.credentials[:url]
    @fedora_datastream_url = File.join(
      base_url, 'objects', @object.pid.to_s,'datastreams', @method, 'content'
    )

    response = RestClient.get(@fedora_datastream_url)

    actual = Nokogiri::XML(response.body)

    EquivalentXml.equivalent?(expected, actual, :normalize_whitespace => true)
  end

  chain(:with) { |expected_xml| @expected_xml = expected_xml }

  description do
    "#{@object.class} PID=#{@object.pid} datastream: #{@method.inspect} matches Fedora"
  end

  failure_message_for_should do |text|
    "expected #{@object.class} PID=#{@object.pid} datastream: #{@method.inspect} to match Fedora"
  end

  failure_message_for_should_not do |text|
    "expected #{@object.class} PID=#{@object.pid} datastream: #{@method.inspect} to NOT match Fedora"
  end

end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
active-fedora-8.7.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.6.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.5.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.4.2 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.4.1 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-7.3.1 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-7.3.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.4.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.3.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.2.2 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.2.1 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.2.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-7.2.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-6.8.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.1.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.0.1 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.0.0 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.0.0.rc3 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.0.0.rc2 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb
active-fedora-8.0.0.rc1 lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb