Sha256: 89df7743c732dd0b9db19e58e61d92e59313981c9b643b2bb40523636f23a23b

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require "spec_helper"
require "teaspoon/coverage"

describe Teaspoon::Coverage do

  subject { Teaspoon::Coverage.new({"foo" => "bar"}, "default") }

  describe "#reports" do

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

      @check_coverage = double('check_coverage')
      Teaspoon::CheckCoverage.stub(:new).and_return(@check_coverage)

      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 = double('file')
      File.should_receive(:open).with(@output, "w").and_yield(file)
      file.should_receive(:write).with('{"foo":"bar"}')
      @check_coverage.should_receive(:check_coverage)
      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")
      @check_coverage.should_receive(:check_coverage)
      expect(subject.reports).to eq("\n_text_report_\n\n_text-summary_report_\n")
    end

    it "executes coverage checks" do
      Teaspoon::CheckCoverage.should_receive(:new).with(@output)
      @check_coverage.should_receive(:check_coverage)
      subject.reports
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teaspoon-0.7.9 spec/teaspoon/coverage_spec.rb