Sha256: 88b95bbfdd455de86fa5937fbd55da90818ac52b57fc2f6fb688ac9aa8c8980a

Contents?: true

Size: 924 Bytes

Versions: 9

Compression:

Stored size: 924 Bytes

Contents

require "xml"
require 'test/unit'

class TestRelaxNG < Test::Unit::TestCase
  def setup
    xp = XML::Parser.new
    @doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xml'))
  end
  
  def teardown
    @doc = nil
  end
  
  def relaxng
    document = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.rng'))
    relaxng = XML::RelaxNG.document(document)
  end

  def test_from_doc
    assert_instance_of(XML::RelaxNG, relaxng)
  end
  
  def test_valid
    assert(@doc.validate_relaxng(relaxng))
  end
  
  def test_invalid
    new_node = XML::Node.new('invalid', 'this will mess up validation')
    @doc.root.child_add(new_node)
    
    messages = Hash.new
    assert(!@doc.validate_relaxng(relaxng) do |message, error|
      messages[message] = error
    end)

    expected = {"Did not expect element invalid there\n" => true}
    assert_equal(expected, messages)
  end
end

Version data entries

9 entries across 9 versions & 5 rubygems

Version Path
libxml-jruby-modified-1.0.2-jruby test/tc_relaxng.rb
libxml-jruby-modified-1.0.1-jruby test/tc_relaxng.rb
libxml-fixed-jruby-1.0.0-jruby test/tc_relaxng.rb
libxml-jruby-fixed-1.0.0-jruby test/tc_relaxng.rb
libxml-jruby-1.0.0 test/tc_relaxng.rb
libxml-ruby-0.8.2 test/tc_relaxng.rb
libxml-ruby-0.8.2-x86-mswin32-60 test/tc_relaxng.rb
libxml-ruby-0.8.3-x86-mswin32-60 test/tc_relaxng.rb
libxml-ruby-0.8.3 test/tc_relaxng.rb