summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2012-08-28 15:19:44 -0400
committerBryan McLellan <btm@loftninjas.org>2012-08-28 15:19:44 -0400
commit036295b9aa94d0e711a770ff72cddad76d5f5f22 (patch)
treebcc7c77fbb6edfb3e968aaa6464833dde08627e7
parentd2f836d34dcbd02baa5a3bb775e6bca454d4d6dd (diff)
downloadchef-036295b9aa94d0e711a770ff72cddad76d5f5f22.tar.gz
Force binary mode for cookbook_file Tempfile
the cookbook_file tests compare a file created with Tempfile to one that ships in the repository. The included file has unix line endings, but when we run the tests on windows the Tempfile is created with Windows line endings (CRLF). Setting binmode works around this.
-rw-r--r--chef/spec/unit/provider/cookbook_file_spec.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/chef/spec/unit/provider/cookbook_file_spec.rb b/chef/spec/unit/provider/cookbook_file_spec.rb
index 5cae0e2691..79b700347d 100644
--- a/chef/spec/unit/provider/cookbook_file_spec.rb
+++ b/chef/spec/unit/provider/cookbook_file_spec.rb
@@ -131,6 +131,8 @@ EXPECTED
describe "when the file exists but has incorrect content" do
before do
@tempfile = Tempfile.open('cookbook_file_spec')
+ # Use binary mode to avoid CRLF on windows
+ @tempfile.binmode
@new_resource.path(@target_file = @tempfile.path)
@tempfile.puts "the wrong content"
@tempfile.close
@@ -180,6 +182,8 @@ EXPECTED
before do
Chef::FileAccessControl.any_instance.stub(:modified?).and_return(false)
@tempfile = Tempfile.open('cookbook_file_spec')
+ # Use binary mode to avoid CRLF on windows
+ @tempfile.binmode
@new_resource.path(@target_file = @tempfile.path)
@tempfile.write(@file_content)
@tempfile.close