summaryrefslogtreecommitdiffstats
path: root/spec/unit/interface_spec.rb
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-17 18:51:09 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-19 10:33:08 -0700
commit32c667c79bc0d5151580ea79719f28739945bfb1 (patch)
treeed3857858710603fc771e9183b7155b91708bab4 /spec/unit/interface_spec.rb
parent0d0318f9f0eadff7f9934d3d02a7081bba05164c (diff)
downloadpuppet-32c667c79bc0d5151580ea79719f28739945bfb1.tar.gz
puppet-32c667c79bc0d5151580ea79719f28739945bfb1.tar.xz
puppet-32c667c79bc0d5151580ea79719f28739945bfb1.zip
(#7132) Reject 'summary' text with newlines embedded.
Our summary documentation is used to provide single-line context to faces, actions, and other items. To support this we hard-fail if someone tries to use the summary to embed the long documentation, and point them to the right place to add the extended text. Reviewed-By: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'spec/unit/interface_spec.rb')
-rwxr-xr-xspec/unit/interface_spec.rb43
1 files changed, 25 insertions, 18 deletions
diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb
index e52b45d8a..036372e6a 100755
--- a/spec/unit/interface_spec.rb
+++ b/spec/unit/interface_spec.rb
@@ -50,24 +50,6 @@ describe Puppet::Interface do
subject.new(:foo, '1.0.0').should respond_to(:summary).with(0).arguments
subject.new(:foo, '1.0.0').should respond_to(:summary=).with(1).arguments
end
-
- it "should set the summary text" do
- text = "hello, freddy, my little pal"
- subject.define(:face_test_summary, '1.0.0') do
- summary text
- end
- subject[:face_test_summary, '1.0.0'].summary.should == text
- end
-
- it "should support mutating the summary" do
- text = "hello, freddy, my little pal"
- subject.define(:face_test_summary, '1.0.0') do
- summary text
- end
- subject[:face_test_summary, '1.0.0'].summary.should == text
- subject[:face_test_summary, '1.0.0'].summary = text + text
- subject[:face_test_summary, '1.0.0'].summary.should == text + text
- end
end
describe "#initialize" do
@@ -204,4 +186,29 @@ describe Puppet::Interface do
end
end
end
+
+ context "documentation" do
+ subject do
+ Puppet::Interface.new(:face_documentation, '0.0.1')
+ end
+
+ describe "#summary" do
+ it "should accept a summary" do
+ text = "this is my summary"
+ expect { subject.summary = text }.not_to raise_error
+ subject.summary.should == text
+ end
+
+ it "should accept a long, long, long summary" do
+ text = "I never know when to stop with the word banana" + ("na" * 1000)
+ expect { subject.summary = text }.not_to raise_error
+ subject.summary.should == text
+ end
+
+ it "should reject a summary with a newline" do
+ expect { subject.summary = "with \n embedded \n newlines" }.
+ to raise_error ArgumentError, /summary should be a single line/
+ end
+ end
+ end
end