Sha256: 1dd896da184e7e676536335e2b728993506c0e05c796393e5ece33cd6b9ee228

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require "w3c_rspec_validators"
include W3CValidators

module RSpec
  module Matchers
    def fail
      raise_error(RSpec::Expectations::ExpectationNotMetError)
    end

    def fail_with(message)
      raise_error(RSpec::Expectations::ExpectationNotMetError, message)
    end

    def fail_matching(regex)
      raise_error(RSpec::Expectations::ExpectationNotMetError, regex)
    end
  end
end



describe "be_valid_html" do
  it "should be valid" do
    "<!DOCTYPE HTML SYSTEM>
      <html>
        <head>
          <title>dd</title>
        </head>
        <body>
        </body>
      </html>".should be_valid_html
  end

  it "should not be valid" do
    "<!DOCTYPE HTML SYSTEM>
      <html>
        <head>
          <titled>dd</title>
        </head>
        <body></body>
      </html>".should_not be_valid_html
  end

  it "should complain about an missing src attribute" do
    lambda {
      "<!DOCTYPE HTML SYSTEM>
      <html>
        <head>
          <title>dd</title>
        </head>
        <body>
          <img />
        </body>
      </html>".should be_valid_html
    }.should fail_matching(/line 7: required attribute "SRC" not specified.*<img \/>/m)
  end

  it "should use a custom uri if provided" do
    W3cRspecValidators::Config.stub(:get).and_return("w3c_service_uri" => "http://blubb.de")
    
    validator = MarkupValidator.new
    MarkupValidator.should_receive(:new).with(:validator_uri => "http://blubb.de").and_return validator

    "dummy".should_not be_valid_html
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
w3c_rspec_validators-0.1.0 spec/matchers_spec.rb