Sha256: 5154f5d3cebb8bbcdef1b4d4a555a2c85024c950d4711c5c506f3352db391a69

Contents?: true

Size: 1.63 KB

Versions: 42

Compression:

Stored size: 1.63 KB

Contents

require "spec_helper"

module Berkshelf
  describe ".formatter" do
    context "with default formatter" do
      before { Berkshelf.instance_variable_set(:@formatter, nil) }

      it "is human readable" do
        expect(Berkshelf.formatter).to be_an_instance_of(HumanFormatter)
      end
    end

    context "with a custom formatter" do
      before(:all) do
        Berkshelf.instance_eval { @formatter = nil }
      end

      class CustomFormatter < BaseFormatter; end

      before do
        Berkshelf.set_format :custom
      end

      it "is custom class" do
        expect(Berkshelf.formatter).to be_an_instance_of(CustomFormatter)
      end
    end
  end

  describe ".berkshelf_path" do
    before { Berkshelf.instance_variable_set(:@berkshelf_path, nil) }

    context "with default path" do
      before do
        @berkshelf_path = ENV["BERKSHELF_PATH"]
        ENV["BERKSHELF_PATH"] = nil
      end

      after do
        ENV["BERKSHELF_PATH"] = @berkshelf_path
      end

      it "is ~/.berkshelf" do
        expect(Berkshelf.berkshelf_path).to eq File.expand_path("~/.berkshelf")
        expect(Berkshelf.instance_variable_get(:@berkshelf_path)).to eq File.expand_path("~/.berkshelf")
      end
    end

    context 'with ENV["BERKSHELF_PATH"]' do
      it 'is ENV["BERKSHELF_PATH"]' do
        expect(Berkshelf.berkshelf_path).to eq File.expand_path(ENV["BERKSHELF_PATH"])
        expect(Berkshelf.instance_variable_get(:@berkshelf_path)).to eq File.expand_path(ENV["BERKSHELF_PATH"])
      end
    end
  end

  describe "::log" do
    it "returns Berkshelf::Logger" do
      expect(Berkshelf.log).to be_a(Berkshelf::Logger)
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
berkshelf-8.0.15 spec/unit/berkshelf_spec.rb
berkshelf-8.0.13 spec/unit/berkshelf_spec.rb
berkshelf-8.0.12 spec/unit/berkshelf_spec.rb
berkshelf-8.0.9 spec/unit/berkshelf_spec.rb
berkshelf-8.0.7 spec/unit/berkshelf_spec.rb
berkshelf-8.0.5 spec/unit/berkshelf_spec.rb
berkshelf-8.0.2 spec/unit/berkshelf_spec.rb
berkshelf-8.0.1 spec/unit/berkshelf_spec.rb
berkshelf-8.0.0 spec/unit/berkshelf_spec.rb
berkshelf-7.2.2 spec/unit/berkshelf_spec.rb
berkshelf-7.2.1 spec/unit/berkshelf_spec.rb
berkshelf-7.2.0 spec/unit/berkshelf_spec.rb
berkshelf-7.1.0 spec/unit/berkshelf_spec.rb
berkshelf-7.0.10 spec/unit/berkshelf_spec.rb
berkshelf-7.0.9 spec/unit/berkshelf_spec.rb
berkshelf-7.0.8 spec/unit/berkshelf_spec.rb
berkshelf-7.0.7 spec/unit/berkshelf_spec.rb
berkshelf-6.3.4 spec/unit/berkshelf_spec.rb
berkshelf-7.0.6 spec/unit/berkshelf_spec.rb
berkshelf-7.0.5 spec/unit/berkshelf_spec.rb