spec/unit/chef/config_spec.rb in berkshelf-1.4.6 vs spec/unit/chef/config_spec.rb in berkshelf-2.0.0.beta
- old
+ new
@@ -1,36 +1,34 @@
require 'spec_helper'
describe Berkshelf::Chef::Config do
- subject { described_class }
-
- describe '::path' do
+ describe '.path' do
let(:path) { '/fake/path/for/.chef' }
let(:config) { File.join(path, 'knife.rb') }
before do
ENV.stub(:[]).and_return(nil)
File.stub(:exists?).with(any_args()).and_return(false)
File.stub(:exists?).with(config).and_return(true)
- subject.instance_variable_set(:@path, nil)
+ Berkshelf::Chef::Config.instance_variable_set(:@path, nil)
end
it 'uses $BERKSHELF_CHEF_CONFIG' do
ENV.stub(:[]).with('BERKSHELF_CHEF_CONFIG').and_return(config)
- expect(subject.path).to eq(config)
+ expect(Berkshelf::Chef::Config.path).to eq(config)
end
it 'uses $KNIFE_HOME' do
ENV.stub(:[]).with('KNIFE_HOME').and_return(path)
- expect(subject.path).to eq(config)
+ expect(Berkshelf::Chef::Config.path).to eq(config)
end
it 'uses ::working_dir' do
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
- expect(subject.path).to eq(config)
+ expect(Berkshelf::Chef::Config.path).to eq(config)
end
context 'an ascending search' do
context 'with multiple .chef directories' do
let(:path) { '/fake/.chef/path/with/multiple/.chef/directories' }
@@ -41,11 +39,11 @@
File.stub(:exists?).with('/fake/.chef/knife.rb').and_return(true)
File.stub(:exists?).with('/fake/.chef/path/with/multiple/.chef/knife.rb').and_return(true)
end
it 'chooses the closest path' do
- expect(subject.path).to eq('/fake/.chef/path/with/multiple/.chef/knife.rb')
+ expect(Berkshelf::Chef::Config.path).to eq('/fake/.chef/path/with/multiple/.chef/knife.rb')
end
end
context 'with the current directory as .chef' do
let(:path) { '/fake/.chef' }
@@ -55,11 +53,11 @@
File.stub(:exists?).and_return(false)
File.stub(:exists?).with('/fake/.chef/knife.rb').and_return(true)
end
it 'uses the current directory' do
- expect(subject.path).to eq('/fake/.chef/knife.rb')
+ expect(Berkshelf::Chef::Config.path).to eq('/fake/.chef/knife.rb')
end
end
context 'with .chef at the top-level' do
let(:path) { '/.chef/some/random/sub/directories' }
@@ -69,16 +67,16 @@
File.stub(:exists?).and_return(false)
File.stub(:exists?).with('/.chef/knife.rb').and_return(true)
end
it 'uses the top-level directory' do
- expect(subject.path).to eq('/.chef/knife.rb')
+ expect(Berkshelf::Chef::Config.path).to eq('/.chef/knife.rb')
end
end
end
it 'uses $HOME' do
ENV.stub(:[]).with('HOME').and_return(File.join(path, '..'))
- expect(subject.path).to eq(config)
+ expect(Berkshelf::Chef::Config.path).to eq(config)
end
end
end