RSpec soft failure for pending test cases

Posted by Gregg Kellogg Mon, 26 Oct 2009 18:40:00 GMT

 Recently, I've been playing with RSpec to run RDFa test cases. The suite has accepted and unreviewed test cases. My general way of testing is to parse the suite, and run each test through a generated spec as follows:

test_cases.each do |tc|
  specify "test #{tc.name}" do
    tc.run_test do |input|
      RdfaParser::RdfaParser.new.parse(input, tc.informationResourceInput)
    end
  end
end

The problem is, some tests are pending, so that a failure should be soft, and not hard. The way to do this is to catch Spec::Expectations::ExpectationNotMetError. This this, we can modify the above test as follows:

test_cases.each do |tc|
  specify "test #{tc.name}" do
    tc.run_test do |input|
      begin
        RdfaParser::RdfaParser.new.parse(input, tc.informationResourceInput)
      rescue Spec::Expectations::ExpectationNotMetError => e
        if tc.status == "unreviewed
          pending(e.message) {  raise }
        else
          raise
        end
      end
    end
  end
end

rdfa_parser gem released

Posted by Gregg Kellogg Sun, 18 Oct 2009 20:11:00 GMT

I just released version 0.1.0 of the rdfa_parser_gem. This parser is written in pure Ruby and uses Nokogiri XML parsing. It passes all XHTML1 test cases and most of the existing test cases for HTML4 and HTML5.

The gem is based on previous work done by Ben Adida and some libraries borrowed from the Reddy Gem.

The project is hosted on GitHub, feel free to clone. You can try out the parser through a distiller.