Sha256: 144e7a40e6398da6c2d82cea1fa7a648b5eacda617a4b08ee63a29bca6c4e4b1

Contents?: true

Size: 800 Bytes

Versions: 7

Compression:

Stored size: 800 Bytes

Contents

require 'html_acceptance'

# This is a sample matcher for use with Rspec and Capybara. 
# https://github.com/jnicklas/capybara 
# keep this in spec/support/matchers

class HaveValidHTML

  # This is the matching method called by RSpec
  # The response is passed in as an argument when you do this:
  # page.should have_valid_html
  
  def matches?(page)
    path=File.join(File.dirname(__FILE__), '../validation' )
    h=HTMLAcceptance.new(path)
    @v=h.validator(page.body, page.current_url)
    @v.valid?
  end
  
  def description
    "Have valid html"
  end

  def failure_message
   "#{@v.resource} Invalid html (fix or run rake html_acceptance task to add exceptions)\n#{@v.resource} exceptions:\n #{@v.exceptions}\n\n #{@v.html}"
  end
  
end
    
def have_valid_html
  HaveValidHTML.new
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
html_acceptance-0.1.19 samples/have_valid_html.rb
html_acceptance-0.1.18 samples/have_valid_html.rb
html_acceptance-0.1.17 samples/have_valid_html.rb
html_acceptance-0.1.16 samples/have_valid_html.rb
html_acceptance-0.1.15 samples/have_valid_html.rb
html_acceptance-0.1.9 samples/have_valid_html.rb
html_acceptance-0.1.8 samples/have_valid_html.rb