Sha256: a9aa0d522c4b3ea16c3d44feb90935c061e886991997fb4ca84d2fedf712821a

Contents?: true

Size: 786 Bytes

Versions: 7

Compression:

Stored size: 786 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

7 entries across 7 versions & 1 rubygems

Version Path
reveal-ck-3.8.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.7.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.6.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.5.1 features/step_definitions/html_match_steps.rb
reveal-ck-3.5.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.4.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.3.1 features/step_definitions/html_match_steps.rb