Sha256: dd705040c0eb33822f52ddd1b2e671917698d15e09b4d7c2e3880ee6191b0612
Contents?: true
Size: 1.74 KB
Versions: 6
Compression:
Stored size: 1.74 KB
Contents
require File.join(File.dirname(__FILE__), 'spec_helper') require 'schematron' require 'libxml' include LibXML describe Schematron::Schema do it "should load a schema from a libxml document" do file = File.join "spec", "schema", "pim.sch" parser = XML::Parser.file file doc = parser.parse XML.default_line_numbers = true lambda { Schematron::Schema.new doc }.should_not raise_error end it "should validate a good instance doc" do schema_file = File.join 'spec', 'schema', 'fda_sip.sch' instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example1.xml' schema_doc = XML::Parser.file(schema_file).parse instance_doc = XML::Parser.file(instance_file).parse stron = Schematron::Schema.new schema_doc results = stron.validate instance_doc results.should be_empty end it "should detect errors for a bad document" do schema_file = File.join 'spec', 'schema', 'fda_sip.sch' instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example2.xml' schema_doc = XML::Parser.file(schema_file).parse instance_doc = XML::Parser.file(instance_file).parse stron = Schematron::Schema.new schema_doc results = stron.validate instance_doc results.should_not be_empty end it "should log report rules in the results" do schema_file = File.join 'spec', 'schema', 'pim.sch' instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example1.xml' schema_doc = XML::Parser.file(schema_file).parse instance_doc = XML::Parser.file(instance_file).parse stron = Schematron::Schema.new schema_doc results = stron.validate instance_doc results.length.should == 1 results.first[:rule_type].should == 'report' end end
Version data entries
6 entries across 6 versions & 2 rubygems