Sha256: 8ce04f921fb9bbea3b21743720a23164af43f63e781c83577889ab2db6f405b1

Contents?: true

Size: 867 Bytes

Versions: 2

Compression:

Stored size: 867 Bytes

Contents

require 'test/unit'
require 'libxml'
require 'open-uri'
require 'simplecov-cobertura'

class CoberturaFormatterTest < Test::Unit::TestCase

  def setup
    @result = SimpleCov::Result.new("#{__FILE__}" => [1,2])
    @formatter = SimpleCov::Formatter::CoberturaFormatter.new
  end

  def teardown
    # Do nothing
  end

  def test_format_save_file
    xml = @formatter.format(@result)
    result_path = File.join(SimpleCov.coverage_path, SimpleCov::Formatter::CoberturaFormatter::RESULT_FILE_NAME)
    assert_not_empty(xml)
    assert_equal(xml, IO.read(result_path))
  end
  
  def test_format_dtd_validates
    xml = @formatter.format(@result)
    
    dtd_text = open(SimpleCov::Formatter::CoberturaFormatter::DTD_URL) { |io| io.read }
    dtd = LibXML::XML::Dtd.new(dtd_text)
    doc = LibXML::XML::Document.string(xml)
    assert_true doc.validate(dtd)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simplecov-cobertura-1.0.2 test/simplecov-cobertura_test.rb
simplecov-cobertura-1.0.0 test/simplecov-cobertura_test.rb