Class: BeValidAsset::BeValidMarkup
- Inherits:
-
BeValidBase
- Object
- BeValidBase
- BeValidAsset::BeValidMarkup
- Defined in:
- lib/be_valid_asset/be_valid_markup.rb
Direct Known Subclasses
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(options = {}) ⇒ BeValidMarkup
constructor
A new instance of BeValidMarkup.
-
#matches?(fragment) ⇒ Boolean
Assert that markup (html/xhtml) is valid according the W3C validator web service.
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ BeValidMarkup
Returns a new instance of BeValidMarkup.
16 17 18 |
# File 'lib/be_valid_asset/be_valid_markup.rb', line 16 def initialize( = {}) @fragment = [:fragment] end |
Instance Method Details
#description ⇒ Object
46 47 48 |
# File 'lib/be_valid_asset/be_valid_markup.rb', line 46 def description "be valid markup" end |
#failure_message ⇒ Object
50 51 52 |
# File 'lib/be_valid_asset/be_valid_markup.rb', line 50 def " expected markup to be valid, but validation produced these errors:\n#{@message}" end |
#matches?(fragment) ⇒ Boolean
Assert that markup (html/xhtml) is valid according the W3C validator web service.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/be_valid_asset/be_valid_markup.rb', line 22 def matches?(fragment) if fragment.respond_to? :source fragment = fragment.source.to_s elsif fragment.respond_to? :body fragment = fragment.body.to_s end fragment = apply_modifiers_to_fragment(fragment) if fragment.empty? @message = "Response was blank (maybe a missing integrate_views)" return false end query_params = { :fragment => fragment } if @fragment query_params[:prefill] = '1' query_params[:prefill_doctype] = 'xhtml10' end return validate(query_params) end |
#negative_failure_message ⇒ Object
54 55 56 |
# File 'lib/be_valid_asset/be_valid_markup.rb', line 54 def " expected to not be valid, but was (missing validation?)" end |