diff options
author | danielsdeleo <dan@opscode.com> | 2013-10-16 17:52:06 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-10-17 14:03:53 -0700 |
commit | f732bbb1e264b6ccc4fc2c1e9b99a8b9838d2199 (patch) | |
tree | 488f4e589997e34ce73c33bf25de52d309b1ff24 /spec/unit/config_spec.rb | |
parent | c1bbc0df02f618f907833f7efe686453e732c61e (diff) | |
download | chef-f732bbb1e264b6ccc4fc2c1e9b99a8b9838d2199.tar.gz |
Add a root config_dir config option
Also, refactor path joins in Config to a method that will support
components containing a trailing separator or not.
Diffstat (limited to 'spec/unit/config_spec.rb')
-rw-r--r-- | spec/unit/config_spec.rb | 64 |
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 |