Sha256: 895c0aaddc915ec93838477ed4e63fb005aa88ad1ccdacf4bb07b1f206f7daea

Contents?: true

Size: 1.53 KB

Versions: 24

Compression:

Stored size: 1.53 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
require 'json'

describe Slather::CoverageService::CoberturaXmlOutput do

  let(:fixtures_project) do
    proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
    proj.build_directory = TEMP_DERIVED_DATA_PATH
    proj.input_format = "profdata"
    proj.coverage_service = "cobertura_xml"
    proj.configure
    proj
  end

  describe '#coverage_file_class' do
    it "should return CoverageFile" do
      expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::ProfdataCoverageFile)
    end
  end

  describe '#post' do
    it "should create an XML report spanning all coverage files" do
      fixtures_project.post

      file = File.open(FIXTURES_XML_PATH)
      fixture_xml_doc = Nokogiri::XML(file)
      file.close

      file = File.open('cobertura.xml')
      current_xml_doc = Nokogiri::XML(file)
      file.close

      [current_xml_doc, fixture_xml_doc].each do |xml_doc|
        xml_doc.root['timestamp'] = ''
        xml_doc.root['version'] = ''
        source_node = xml_doc.at_css "source"
        source_node.content = ''
      end

      expect(EquivalentXml.equivalent?(current_xml_doc, fixture_xml_doc)).to be_truthy
    end

    it "should create an XML report in the given output directory" do
      fixtures_project.output_directory = "./output"
      fixtures_project.post

      filepath = "#{fixtures_project.output_directory}/cobertura.xml"
      expect(File.exists?(filepath)).to be_truthy

      FileUtils.rm_rf(fixtures_project.output_directory)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
slather-2.7.3 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.7.2 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.7.1 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.7.0 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.6.1 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.6.0 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.5.0 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.9 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.8 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.7 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.6 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.5 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.4 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.3 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.2 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.1 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.4.0 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.3.0 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.2.1 spec/slather/coverage_service/cobertura_xml_spec.rb
slather-2.2.0 spec/slather/coverage_service/cobertura_xml_spec.rb