Sha256: 39912fdc656c7e660e0d6904b9be3991041af30f31cfe4e4476b7898aa8bec91

Contents?: true

Size: 797 Bytes

Versions: 11

Compression:

Stored size: 797 Bytes

Contents

RSpec::Matchers.define :have_xpath do |xpath|
  match do |actual|
    namespaces = {
      "NameFormat": Saml::Kit::Namespaces::ATTR_SPLAT,
      "ds": ::Xml::Kit::Namespaces::XMLDSIG,
      "md": Saml::Kit::Namespaces::METADATA,
      "saml": Saml::Kit::Namespaces::ASSERTION,
      "samlp": Saml::Kit::Namespaces::PROTOCOL,
    }
    xml_document(actual).xpath(xpath, namespaces).any?
  end

  failure_message do |actual|
    "Expected xpath: #{xpath.inspect} to match in:\n #{xml_pretty_print(actual)}"
  end

  failure_message_when_negated do |actual|
    "Expected xpath: #{xpath.inspect} not to match in:\n #{xml_pretty_print(actual)}"
  end

  def xml_pretty_print(raw_xml)
    xml_document(raw_xml).to_xml(indent: 2)
  end

  def xml_document(raw_xml)
    Nokogiri::XML(raw_xml)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
saml-kit-1.0.9 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.8 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.7 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.6 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.5 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.4 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.3 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.2 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.1 lib/saml/kit/rspec/have_xpath.rb
saml-kit-1.0.0 lib/saml/kit/rspec/have_xpath.rb
saml-kit-0.3.6 lib/saml/kit/rspec/have_xpath.rb