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
- #failure_message_for_should_not ⇒ Object
- #matches?(page) ⇒ Boolean
Class Method Details
.show_html_in_failures=(val) ⇒ Object
13 14 15 |
# File 'lib/html_validation/have_valid_html.rb', line 13 def self.show_html_in_failures=(val) @@html_in_failures = val end |
Instance Method Details
#description ⇒ Object
23 24 25 |
# File 'lib/html_validation/have_valid_html.rb', line 23 def description "Have valid html" end |
#failure_message_for_should ⇒ Object
27 28 29 |
# File 'lib/html_validation/have_valid_html.rb', line 27 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
31 32 33 |
# File 'lib/html_validation/have_valid_html.rb', line 31 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
17 18 19 20 21 |
# File 'lib/html_validation/have_valid_html.rb', line 17 def matches?(page) h = HTMLValidation.new @v = h.validation(page.body, page.current_url) @v.valid? end |