summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@getchef.com>2014-08-26 14:44:48 -0700
committerChris Doherty <cdoherty@getchef.com>2014-09-12 11:54:40 -0700
commit29dc176d6b8b631d1efe469f12f05a4f2343046b (patch)
treef7d07ad7d880b43ce84fc4b657a08c4afbd4dab9 /spec/functional
parente76a6a4e55d3c59d76da38cad828ef50f8ea236b (diff)
downloadchef-29dc176d6b8b631d1efe469f12f05a4f2343046b.tar.gz
Test for github issue 1842: handle relative paths correctly on Windows.
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/file_spec.rb29
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index d6f56db3e9..2b7361de0b 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -24,11 +24,19 @@ describe Chef::Resource::File do
let(:file_base) { "file_spec" }
let(:expected_content) { "Don't fear the ruby." }
- def create_resource
+ def create_resource(opts={})
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
run_context = Chef::RunContext.new(node, {}, events)
- resource = Chef::Resource::File.new(path, run_context)
+
+ use_path = if opts[:use_relative_path]
+ Dir.chdir(test_file_dir)
+ File.basename(path)
+ else
+ path
+ end
+
+ resource = Chef::Resource::File.new(use_path, run_context)
resource
end
@@ -42,6 +50,10 @@ describe Chef::Resource::File do
create_resource
end
+ let(:resource_with_relative_path) do
+ create_resource(:use_relative_path => true)
+ end
+
let(:unmanaged_content) do
"This is file content that is not managed by chef"
end
@@ -74,6 +86,19 @@ describe Chef::Resource::File do
end
end
+ # github issue 1842.
+ describe "when running action :create on a relative path" do
+ before do
+ resource_with_relative_path.run_action(:create)
+ end
+
+ context "and the file exists" do
+ it "should run without an exception" do
+ resource_with_relative_path.run_action(:create)
+ end
+ end
+ end
+
describe "when running action :touch" do
context "and the target file does not exist" do
before do