Skip to content

Commit

Permalink
adding xhtml strict validations
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jun 12, 2009
1 parent f601a66 commit 918bfeb
Show file tree
Hide file tree
Showing 6 changed files with 2,298 additions and 46 deletions.
7 changes: 7 additions & 0 deletions lib/markup_validity.rb
Expand Up @@ -9,6 +9,7 @@ class Validator # :nodoc:
XHTML1_TRANSITIONAL = Nokogiri::XML::Schema(
File.read('xhtml1-transitional.xsd')
)
XHTML1_STRICT = Nokogiri::XML::Schema(File.read('xhtml1-strict.xsd'))
end

attr_reader :errors
Expand Down Expand Up @@ -40,4 +41,10 @@ def assert_xhtml_transitional xhtml
validator = Validator.new xhtml
assert validator.valid?, validator.inspect
end
alias :assert_xhtml :assert_xhtml_transitional

def assert_xhtml_strict xhtml
validator = Validator.new xhtml
assert validator.valid?, validator.inspect
end
end
17 changes: 17 additions & 0 deletions lib/markup_validity/rspec.rb
Expand Up @@ -13,5 +13,22 @@ def be_xhtml_transitional
end
end
end

def be_xhtml_strict
Matcher.new :be_xhtml_strict do
validator = nil
match do |xhtml|
validator = MarkupValidity::Validator.new(
xhtml,
MarkupValidity::Validator::XHTML1_STRICT
)
validator.valid?
end

failure_message_for_should do |actual|
validator.inspect
end
end
end
end
end

0 comments on commit 918bfeb

Please sign in to comment.