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