Skip to content

Commit

Permalink
Adding test coverage
Browse files Browse the repository at this point in the history
to make sure we're testing validation of invalid files.

Related to #1351.
  • Loading branch information
flavorjones committed Sep 15, 2015
1 parent 66fcc00 commit ebdb95b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/xml/test_schema.rb
Expand Up @@ -94,9 +94,22 @@ def test_validate_file
end

def test_validate_invalid_document
read_doc = File.read(PO_XML_FILE).gsub(/<city>[^<]*<\/city>/, '')
doc = Nokogiri::XML File.read(PO_XML_FILE)
doc.css("city").unlink

assert errors = @xsd.validate(Nokogiri::XML(read_doc))
assert errors = @xsd.validate(doc)
assert_equal 2, errors.length
end

def test_validate_invalid_file
tempfile = Tempfile.new("xml")

doc = Nokogiri::XML File.read(PO_XML_FILE)
doc.css("city").unlink
tempfile.write doc.to_xml
tempfile.close

assert errors = @xsd.validate(tempfile.path)

This comment has been minimized.

Copy link
@twalpole

twalpole Sep 22, 2015

Contributor

passing a filename as a string here causes test failures under jruby versions. Potential fix is PR #1355

assert_equal 2, errors.length
end

Expand Down

0 comments on commit ebdb95b

Please sign in to comment.