Sha256: 10c0b0884dae7bb04001ea76bf7259bdfd963839b60d71664d98af236b661067

Contents?: true

Size: 1022 Bytes

Versions: 4

Compression:

Stored size: 1022 Bytes

Contents

require "spec_helper"
require "teabag/coverage"

describe Teabag::Coverage do

  subject { Teabag::Coverage.new({"foo" => "bar"}) }

  describe "#reports" do

    before do
      Teabag.configuration.should_receive(:coverage_reports).and_return(["text", "text-summary", "html"])
      subject.stub(:generate_report) { |i, f| "_#{f}_report_" }
      File.stub(:write)

      path = nil
      Dir.mktmpdir { |p| path = p }
      Dir.stub(:mktmpdir).and_yield(path)
      @output = File.join(path, "coverage.json")
    end

    it "writes the data to a file" do
      File.should_receive(:write).with(@output, '{"foo":"bar"}')
      subject.reports
    end

    it "collects the results and returns them" do
      subject.should_receive(:generate_report).with(@output, "text")
      subject.should_receive(:generate_report).with(@output, "text-summary")
      subject.should_receive(:generate_report).with(@output, "html")
      expect(subject.reports).to eq("\n_text_report_\n\n_text-summary_report_\n")
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
teabag-0.7.2 spec/teabag/coverage_spec.rb
teabag-0.7.1 spec/teabag/coverage_spec.rb
teabag-0.7.0 spec/teabag/coverage_spec.rb
teabag-0.6.0 spec/teabag/coverage_spec.rb