Sha256: e1ebc17bba03f80a1fa53dc8662700a4659d508e376c65940d78552833c07421

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module Spec
  module Matchers
    ###
    # Assert that something is XHTML transitional
    def be_xhtml_transitional
      Matcher.new :be_xhtml_transitional do
        validator = nil
        match do |xhtml|
          validator = MarkupValidity::Validator.new xhtml
          validator.valid?
        end

        failure_message_for_should do |actual|
          validator.inspect
        end
      end
    end
    alias :be_xhtml :be_xhtml_transitional

    ###
    # Assert that something is XHTML strict
    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

    ###
    # Assert that something validates given +schema+
    def be_valid_with_schema schema
      Matcher.new :be_valid_with_schema, schema do |_schema_|
        validator = nil
        match do |xhtml|
          validator = MarkupValidity::Validator.new(
            xhtml,
            Nokogiri::XML::Schema(_schema_)
          )
          validator.valid?
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markup_validity-1.0.0 lib/markup_validity/rspec.rb