class BeValidAsset::BeValidMarkup
Public Class Methods
new(options = {})
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 16 def initialize(options = {}) @fragment = options[:fragment] end
Public Instance Methods
description()
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 46 def description "be valid markup" end
failure_message()
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 50 def failure_message " expected markup to be valid, but validation produced these errors:\n#{@message}" end
failure_message_when_negated()
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 54 def failure_message_when_negated " expected to not be valid, but was (missing validation?)" end
Also aliased as: negative_failure_message
matches?(fragment)
click to toggle source
Assert that markup (html/xhtml) is valid according the W3C validator web service.
# 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
Private Instance Methods
apply_modifiers_to_fragment(fragment)
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 62 def apply_modifiers_to_fragment(fragment) if (Configuration.enable_caching && ! Configuration.markup_cache_modifiers.empty?) or ! Configuration.markup_modifiers.empty? fragment = fragment.dup end if Configuration.enable_caching && ! Configuration.markup_cache_modifiers.empty? Configuration.markup_cache_modifiers.each do |replacement| fragment.gsub!(replacement[0], replacement[1]) end end if ! Configuration.markup_modifiers.empty? Configuration.markup_modifiers.each do |replacement| fragment.gsub!(replacement[0], replacement[1]) end end fragment end
error_line_prefix()
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 89 def error_line_prefix 'Invalid markup' end
validator_host()
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 81 def validator_host Configuration.markup_validator_host end
validator_path()
click to toggle source
# File lib/be_valid_asset/be_valid_markup.rb, line 85 def validator_path Configuration.markup_validator_path end