summaryrefslogtreecommitdiff
path: root/spec/unit/config_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/config_spec.rb')
-rw-r--r--spec/unit/config_spec.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 1b4241b7c8..cb48ab5bcc 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -202,6 +202,70 @@ describe Chef::Config do
Chef::Config[:environment_path].should == environment_path
end
+
+ describe "joining platform specific paths" do
+
+ context "on UNIX" do
+ before do
+ Chef::Config.stub(:on_windows?).and_return(false)
+ end
+
+ it "joins components when some end with separators" do
+ Chef::Config.path_join("/foo/", "bar", "baz").should == "/foo/bar/baz"
+ end
+
+ it "joins components that don't end in separators" do
+ Chef::Config.path_join("/foo", "bar", "baz").should == "/foo/bar/baz"
+ end
+
+ end
+
+ context "on Windows" do
+ before do
+ Chef::Config.stub(:on_windows?).and_return(true)
+ end
+
+ it "joins components with the windows separator" do
+ Chef::Config.path_join('c:\\foo\\', 'bar', "baz").should == 'c:\\foo\\bar\\baz'
+ end
+ end
+ end
+
+ describe "setting the config dir" do
+
+ before do
+ Chef::Config.stub(:on_windows?).and_return(false)
+ Chef::Config.config_file = "/etc/chef/client.rb"
+ end
+
+ context "by default" do
+ it "is the parent dir of the config file" do
+ Chef::Config.config_dir.should == "/etc/chef"
+ end
+ end
+
+ context "when chef is running in local mode" do
+ before do
+ Chef::Config.local_mode = true
+ Chef::Config.user_home = "/home/charlie"
+ end
+
+ it "is in the user's home dir" do
+ Chef::Config.config_dir.should == "/home/charlie/.chef/"
+ end
+ end
+
+ context "when explicitly set" do
+ before do
+ Chef::Config.config_dir = "/other/config/dir/"
+ end
+
+ it "uses the explicit value" do
+ Chef::Config.config_dir.should == "/other/config/dir/"
+ end
+ end
+
+ end
end
describe "Chef::Config[:user_home]" do