Sha256: 4ac3b7b3dd5e4ceb8b180391c5cb20cb9c3f8d5d69e53c90c6e3b316cf1f5d2b

Contents?: true

Size: 787 Bytes

Versions: 5

Compression:

Stored size: 787 Bytes

Contents

require 'nokogiri'

def check_html_matches(file, selector_list, selector_type)
  content = IO.read(expand_path(file))
  doc = Nokogiri::HTML(content)
  selector_list.each do |selector, description|
    check_doc_matches(doc, selector, description, selector_type)
  end
end

def check_doc_matches(doc, selector, description, type)
  search_result = doc.send(type, selector)
  return unless search_result.empty?

  message = "Could not find #{description}. "
  message += "No match for #{type} '#{selector}'"
  raise message
end

Then(/^the file "(.*?)" should have html matching the css:$/) do |file, table|
  check_html_matches(file, table.raw, :css)
end

Then(/^the file "(.*?)" should have html matching the xpath:$/) do |file, table|
  check_html_matches(file, table.raw, :xpath)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reveal-ck-4.0.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.9.2 features/step_definitions/html_match_steps.rb
reveal-ck-3.9.1 features/step_definitions/html_match_steps.rb
reveal-ck-3.9.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.8.1 features/step_definitions/html_match_steps.rb