summaryrefslogtreecommitdiff
path: root/spec/functional/resource/template_spec.rb
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2013-06-07 16:50:48 -0700
committerDaniel DeLeo <dan@opscode.com>2013-06-07 16:50:48 -0700
commit4f6fcc52e34e20fcb476b393c34b11f73ee89615 (patch)
tree522d51650b204c0dd8187c485359601e075f0ebf /spec/functional/resource/template_spec.rb
parent445463410f9acf4a1f839a892323897f54860f67 (diff)
downloadchef-4f6fcc52e34e20fcb476b393c34b11f73ee89615.tar.gz
Improve line separator conversion on windows
* Unconditionally convert \r\n or \n to \r\n. This fixes cases where double converversion would result in \r\r\n * Use binmode to avoid double conversion in IO streams * Use binmode in tests to make sure we're not processing content before testing it.
Diffstat (limited to 'spec/functional/resource/template_spec.rb')
-rw-r--r--spec/functional/resource/template_spec.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index e40292e965..7a533776ea 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -20,6 +20,10 @@ require 'spec_helper'
describe Chef::Resource::Template do
+ def binread(file)
+ File.open(file,"rb") {|f| f.read }
+ end
+
include_context Chef::Resource::File
let(:file_base) { "template_spec" }
@@ -87,12 +91,12 @@ describe Chef::Resource::Template do
r
end
- let(:expected_content) { "value from helper method\n" }
+ let(:expected_content) { "value from helper method" }
shared_examples "a template with helpers" do
it "generates expected content by calling helper methods" do
resource.run_action(:create)
- IO.read(path).should == expected_content
+ IO.binread(path).strip.should == expected_content
end
end
@@ -201,7 +205,7 @@ describe Chef::Resource::Template do
it "output should contain windows line endings" do
resource.run_action(:create)
- IO.read(path).each_line do |line|
+ binread(path).each_line do |line|
line.should end_with("\r\n")
end
end
@@ -216,7 +220,7 @@ describe Chef::Resource::Template do
it "output should contain windows line endings" do
resource.run_action(:create)
- IO.read(path).each_line do |line|
+ binread(path).each_line do |line|
line.should end_with("\r\n")
end
end