spec/unit/berkshelf/config_spec.rb in berkshelf-0.6.0.beta4 vs spec/unit/berkshelf/config_spec.rb in berkshelf-1.0.0.rc1
- old
+ new
@@ -1,91 +1,51 @@
require 'spec_helper'
describe Berkshelf::Config do
- subject { config }
-
- let(:config) { klass.new }
let(:klass) { described_class }
- it { should be_valid }
+ describe "ClassMethods" do
+ subject { klass }
- its(:present?) { should be_false }
+ describe "::file" do
+ subject { klass.file }
- it "set and gets hash keys" do
- config[:a] = 1
- config[:a].should == 1
- end
+ context "when the file does not exist" do
+ before :each do
+ File.stub exists?: false
+ end
- it "does not raise an error for nested hash keys that have not been set" do
- config[:d][:e]
- end
-
- it "has indifferent access" do
- config[:a] = 1
- config['b'] = 2
-
- config['a'].should == 1
- config[:b].should == 2
- end
-
- describe ".file" do
- subject { klass.file }
-
- context "when the file does not exist" do
- before :each do
- File.stub exists?: false
+ it { should be_nil }
end
-
- it { should be_nil }
end
- end
- describe ".from_json" do
- subject(:config) { klass.from_json json }
+ describe "::instance" do
+ subject { klass.instance }
- let(:json) {
- <<-JSON
- {
- "a": 1,
- "b": {
- "c": 2
- }
- }
- JSON
- }
-
- it "has data" do
- config[:a].should == 1
+ it { should be_a klass }
end
- it "has nested data" do
- config[:b][:c].should == 2
- end
+ describe "::path" do
+ subject { klass.path }
- it "does not raise an error for nested hash keys that have not been set" do
- config[:d][:e]
- end
+ it { should be_a String }
- it "has indifferent access" do
- config['a'].should == 1
- config[:a].should == 1
+ it "points to a location within ENV['BERKSHELF_PATH']" do
+ ENV.stub(:[]).with('BERKSHELF_PATH').and_return('/tmp')
+
+ subject.should eql("/tmp/config.json")
+ end
end
- context "with an invalid configuration" do
- let(:json) { '{ "wat": 1 }' }
-
- it { should_not be_valid }
+ describe "::chef_config" do
+ it "returns the Chef::Config" do
+ subject.chef_config.should eql(Chef::Config)
+ end
end
- end
- describe ".instance" do
- subject { klass.instance }
+ describe "::chef_config_path" do
+ subject { klass.chef_config_path }
- it { should be_a klass }
- end
-
- describe ".path" do
- subject { klass.path }
-
- it { should be_a String }
+ it { should be_a String }
+ end
end
end