Class: PageValidations::HaveValidHTML
- Inherits:
-
Object
- Object
- PageValidations::HaveValidHTML
- Defined in:
- lib/html_validation/have_valid_html.rb
Constant Summary collapse
- @@html_in_failures =
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
false
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object (also: #failure_message)
- #failure_message_for_should_not ⇒ Object (also: #failure_message_when_negated)
- #matches?(page) ⇒ Boolean
Class Method Details
.show_html_in_failures=(val) ⇒ Object
11 12 13 |
# File 'lib/html_validation/have_valid_html.rb', line 11 def self.show_html_in_failures=(val) @@html_in_failures = val end |
Instance Method Details
#description ⇒ Object
21 22 23 |
# File 'lib/html_validation/have_valid_html.rb', line 21 def description "have valid HTML" end |
#failure_message_for_should ⇒ Object Also known as: failure_message
25 26 27 |
# File 'lib/html_validation/have_valid_html.rb', line 25 def "#{@v.resource} Invalid html (fix or run 'html_validation review' to add exceptions)\n#{@v.resource} exceptions:\n #{@v.exceptions}\n\n #{@v.html if @@html_in_failures}" end |
#failure_message_for_should_not ⇒ Object Also known as: failure_message_when_negated
30 31 32 |
# File 'lib/html_validation/have_valid_html.rb', line 30 def "#{@v.resource} Expected valid? to fail but didn't. Did you accidentally accept these validation errors? \n#{@v.resource} exceptions:\n #{@v.exceptions}\n\n #{@v.html if @@html_in_failures}" end |
#matches?(page) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/html_validation/have_valid_html.rb', line 15 def matches?(page) h = HTMLValidation.new @v = h.validation(page.body, page.current_url) @v.valid? end |