Sha256: fc62f5f68e68c843d1f01a78376c39418c950a835dbf4b912797e8e7127e8f28

Contents?: true

Size: 638 Bytes

Versions: 16

Compression:

Stored size: 638 Bytes

Contents

RSpec::Matchers.define :have_node do |selector|
  chain(:with_attributes) { |attributes| @attributes = attributes }
  match do |document|
    node = document.at_css(selector)
    if @attributes
      node && match_attributes(node.attributes)
    else
      node
    end
  end

  failure_message { "expected document to #{name_to_sentence}#{expected_to_sentence}"}
  failure_message_when_negated { "expected document to not #{name_to_sentence}#{expected_to_sentence}"}

  def match_attributes(node_attributes)
    attributes = Hash[node_attributes.map { |name, attribute| [name, attribute.value] }]
    @attributes == attributes
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
roadie-3.5.1 spec/support/have_node_matcher.rb
roadie-3.5.0 spec/support/have_node_matcher.rb
roadie-3.4.0 spec/support/have_node_matcher.rb
roadie-3.3.0 spec/support/have_node_matcher.rb
roadie-3.2.2 spec/support/have_node_matcher.rb
roadie-3.2.1 spec/support/have_node_matcher.rb
roadie-3.2.0 spec/support/have_node_matcher.rb
roadie-3.1.1 spec/support/have_node_matcher.rb
roadie-3.1.0 spec/support/have_node_matcher.rb
roadie-3.1.0.rc1 spec/support/have_node_matcher.rb
roadie-3.0.5 spec/support/have_node_matcher.rb
roadie-3.0.4 spec/support/have_node_matcher.rb
roadie-3.0.3 spec/support/have_node_matcher.rb
roadie-3.0.2 spec/support/have_node_matcher.rb
roadie-3.0.1 spec/support/have_node_matcher.rb
roadie-3.0.0 spec/support/have_node_matcher.rb