Sha256: 38adae9891472bdaf2da8a4ca1207fa8ba8fff92b222bdc2ae91abdb8e436e5b

Contents?: true

Size: 851 Bytes

Versions: 56

Compression:

Stored size: 851 Bytes

Contents

RSpec::Matchers.define :have_content do |xpath, content|
  match do |document|
    @elements = document.search(xpath)

    if @elements.empty?
      false
    else
      element_with_content = document.at("#{xpath}[contains(.,'#{content}')]")

      if element_with_content.nil?
        @found = @elements.collect { |element| element.content }

        false
      else
        true
      end
    end
  end

  failure_message_for_should do |document|
    if @elements.empty?
      "In XML:\n#{document}\nNo element at #{xpath}"
    else
      "In XML:\n#{document}\nGot content #{@found.inspect} at #{xpath} instead of #{content.inspect}"
    end
  end

  failure_message_for_should_not do |document|
    unless @elements.empty?
      "In XML:\n#{document}\nExpcted no content #{content.inspect} at #{xpath}"
    end
  end
end

World(RSpec::Matchers)

Version data entries

56 entries across 56 versions & 6 rubygems

Version Path
airbrakeV4rails5-4.3.8 features/support/matchers.rb
airbrake-4.3.8 features/support/matchers.rb
airbrake-4.3.7 features/support/matchers.rb
airbrake-4.3.6 features/support/matchers.rb
airbrake-4.3.5 features/support/matchers.rb
airbrake-4.3.4 features/support/matchers.rb
airbrake-4.3.3 features/support/matchers.rb
airbrake-4.3.2 features/support/matchers.rb
airbrake-4.3.1 features/support/matchers.rb
airbrake-4.3.0 features/support/matchers.rb
airbrake-4.2.1 features/support/matchers.rb
airbrake-4.2.0 features/support/matchers.rb
airbrake-4.1.0 features/support/matchers.rb
airbrake-4.0.0 features/support/matchers.rb
airbrake-3.2.1 features/support/matchers.rb
airbrake-3.2.0 features/support/matchers.rb
airbrake-3.1.17 features/support/matchers.rb
airbrake-3.1.16 features/support/matchers.rb
airbrake-3.1.15 features/support/matchers.rb
airbrake-3.1.14 features/support/matchers.rb