summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2013-05-30 13:38:32 -0700
committersersut <serdar@opscode.com>2013-05-30 13:44:50 -0700
commit32172b48de16b884a539ee4358b52d711f86b368 (patch)
tree79613bb71025a7a46f4b8ce8b868e6d56a628e44 /spec/functional
parentaeee4bf96582769207780311b7b882c387656567 (diff)
downloadchef-32172b48de16b884a539ee4358b52d711f86b368.tar.gz
Make sure that windows line endings are protected during template rendering.
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/template_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 6d42eeceac..f73f239b41 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -183,4 +183,59 @@ describe Chef::Resource::Template do
end
end
+
+ describe "when template source contains windows style line endings" do
+
+ include_context "diff disabled"
+
+ let (:expected_content) {
+ "Template rendering libraries\r\nshould support\r\ndifferent line endings\r\n\r\n"
+ }
+
+ context "for all lines" do
+ let!(:resource) do
+ r = create_resource
+ r.source "all_windows_line_endings.erb"
+ r
+ end
+
+ it "output should contain windows line endings" do
+ resource.run_action(:create)
+ IO.read(path).each_line do |line|
+ line.should end_with("\r\n")
+ end
+ end
+ end
+
+ context "for some lines" do
+ let!(:resource) do
+ r = create_resource
+ r.source "some_windows_line_endings.erb"
+ r
+ end
+
+ it "output should contain windows line endings" do
+ resource.run_action(:create)
+ IO.read(path).each_line do |line|
+ line.should end_with("\r\n")
+ end
+ end
+ end
+
+ context "for no lines" do
+ let!(:resource) do
+ r = create_resource
+ r.source "no_windows_line_endings.erb"
+ r
+ end
+
+ it "output should not contain windows line endings" do
+ resource.run_action(:create)
+ IO.read(path).each_line do |line|
+ line.should_not end_with("\r\n")
+ end
+ end
+ end
+ end
+
end