Sha256: 8a4e0669827668ecb764deef907b1d437c2191812af046f57aed97491b59395b

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe "Formatters::Base" do

  class Formatters::Sample; include Formatters::Base; end

  let (:parsed_file) { ParsedFile.new(class_name: "Foo", path_to_file: "lib/foo.rb") }
  let (:formatter) { Formatters::Sample.new(parsed_file) }

  before do
    allow(formatter).to receive(:header) { "class,method,complexity" }
    allow(formatter).to receive(:rows) { "Foo,#initialize,24" }
    allow(formatter).to receive(:footer) { "TOTAL,,24" }
  end

  describe "#columns" do
    it "returns default columns" do
      expect(formatter.columns).to eq(["class", "method", "complexity"])
    end
  end

  describe "#content" do
    it "returns expected content" do
      expect(formatter.content).to eq "class,method,complexity\r\nFoo,#initialize,24\r\nTOTAL,,24"
    end
  end

  describe "#filename" do
    it "builds a filename" do
      allow(formatter).to receive(:file_extension) { '.doc' }
      expect(formatter.filename).to eq "foo.rb.doc"
    end
  end

  describe "#output_path" do
    it "builds a path" do
      allow(FileUtils).to receive(:mkpath)
      expect(formatter.output_path).to eq "doc/fukuzatsu/lib"
    end
  end

  describe "#path_to_results" do
    it "builds a path" do
      allow(formatter).to receive(:file_extension) { '.doc' }
      allow(formatter).to receive(:output_path) { 'doc/fukuzatsu/lib' }
      expect(formatter.path_to_results).to eq "doc/fukuzatsu/lib/foo.rb.doc"
    end
  end

  describe "#root_path" do
    it "returns the expected path" do
      expect(formatter.root_path).to eq "doc/fukuzatsu"
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fukuzatsu-1.0.4 spec/formatters/base_spec.rb
fukuzatsu-1.0.3 spec/formatters/base_spec.rb
fukuzatsu-1.0.2 spec/formatters/base_spec.rb
fukuzatsu-1.0.1 spec/formatters/base_spec.rb
fukuzatsu-1.0.0 spec/formatters/base_spec.rb
fukuzatsu-0.10.1 spec/formatters/base_spec.rb
fukuzatsu-0.9.16 spec/formatters/base_spec.rb
fukuzatsu-0.9.15 spec/formatters/base_spec.rb
fukuzatsu-0.9.14 spec/formatters/base_spec.rb