spec/unit/berkshelf/config_spec.rb in berkshelf-7.0.0 vs spec/unit/berkshelf/config_spec.rb in berkshelf-7.0.1
- old
+ new
@@ -1,18 +1,8 @@
require "spec_helper"
describe Berkshelf::Config do
- describe "::file" do
- context "when the file does not exist" do
- before { allow(File).to receive(:exist?).and_return(false) }
-
- it "is nil" do
- expect(Berkshelf::Config.file).to be_nil
- end
- end
- end
-
describe "::instance" do
it "should be a Berkshelf::Config" do
expect(Berkshelf::Config.instance).to be_an_instance_of(Berkshelf::Config)
end
@@ -72,14 +62,10 @@
describe "::path" do
it "is a string" do
expect(Berkshelf::Config.path).to be_a(String)
end
- before do
- allow(File).to receive(:exist?).and_return(false)
- end
-
after do
Berkshelf::Config.instance_variable_set(:@path, nil)
end
context "when ENV['BERKSHELF_CONFIG'] is used" do
@@ -88,9 +74,19 @@
allow(File).to receive(:exist?).with("/tmp/config.json").and_return(true)
end
it "points to a location within it" do
expect(Berkshelf::Config.path).to match(%r{/tmp/config.json})
+ end
+ end
+
+ it "reads json from a path" do
+ Tempfile.open(["berkstest", ".json"]) do |t|
+ t.write JSON.generate({ "ssl" => { "verify" => false } })
+ t.close
+ expect(Berkshelf::Config).to receive(:local_location).at_least(:once).and_return(t.path)
+ Berkshelf::Config.reload
+ expect( Berkshelf::Config.instance[:ssl][:verify] ).to be false
end
end
end
describe "::set_path" do