Sha256: 8ff611c8dd17db22a203a0d98d8f67a55cf041b884f40375c07053b505b591f4

Contents?: true

Size: 811 Bytes

Versions: 12

Compression:

Stored size: 811 Bytes

Contents

require 'nokogiri'

def check_html_matches(file, selector_list, selector_type)
  prep_for_fs_check do
    content = IO.read(file)
    doc = Nokogiri::HTML(content)
    selector_list.each do |selector, description|
      check_doc_matches(doc, selector, description, selector_type)
    end
  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}'"
  fail 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

12 entries across 12 versions & 1 rubygems

Version Path
reveal-ck-3.2.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.1.0 features/step_definitions/html_match_steps.rb
reveal-ck-3.0.1 features/step_definitions/html_match_steps.rb
reveal-ck-3.0.0 features/step_definitions/html_match_steps.rb
reveal-ck-0.6.2 features/step_definitions/html_match_steps.rb
reveal-ck-0.6.1 features/step_definitions/html_match_steps.rb
reveal-ck-0.6.0 features/step_definitions/html_match_steps.rb
reveal-ck-0.5.1 features/step_definitions/html_match_steps.rb
reveal-ck-0.5.0 features/step_definitions/html_match_steps.rb
reveal-ck-0.4.2 features/step_definitions/html_match_steps.rb
reveal-ck-0.4.1 features/step_definitions/html_match_steps.rb
reveal-ck-0.4.0 features/step_definitions/html_match_steps.rb