Sha256: 241ccfe70eed42e26bfc96c13f095204948b020f48b9d2fffe4c8f02cb08fe11

Contents?: true

Size: 1.63 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
berkshelf-5.5.0 spec/unit/berkshelf_spec.rb
berkshelf-5.4.0 spec/unit/berkshelf_spec.rb
berkshelf-5.3.0 spec/unit/berkshelf_spec.rb
berkshelf-5.2.0 spec/unit/berkshelf_spec.rb
berkshelf-5.1.0 spec/unit/berkshelf_spec.rb
berkshelf-5.0.0 spec/unit/berkshelf_spec.rb