summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-11 17:24:38 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-12 16:12:09 -0700
commitacbbd52e0e876afa62f9c6098f0f40504b993dce (patch)
treefb5b07fa2a185d81bd6b18400c6737fa39cc2d8b
parent648e3c0dd0fb671b01e54cc0bca202bafc5ae934 (diff)
downloadpuppet-acbbd52e0e876afa62f9c6098f0f40504b993dce.tar.gz
puppet-acbbd52e0e876afa62f9c6098f0f40504b993dce.tar.xz
puppet-acbbd52e0e876afa62f9c6098f0f40504b993dce.zip
(#6962) Clean up testing further.
This refactors common code in the tests out, and takes advantage of the implicit and explicit subject support in rspec2 to make the testing more expressive and more efficient. Paired-With: Matt Robinson <matt@puppetlabs.com>
-rw-r--r--spec/unit/faces/help_spec.rb36
1 files changed, 11 insertions, 25 deletions
diff --git a/spec/unit/faces/help_spec.rb b/spec/unit/faces/help_spec.rb
index aa811c4b3..f2aeb44e9 100644
--- a/spec/unit/faces/help_spec.rb
+++ b/spec/unit/faces/help_spec.rb
@@ -59,46 +59,32 @@ describe Puppet::Faces[:help, '0.0.1'] do
face = Puppet::Faces[name, :current]
summary = face.summary
- it { should have_matching_element %r{ #{name} } }
- it { should have_matching_element %r{ #{name} +#{summary}} } if summary
+ it { should =~ %r{ #{name} } }
+ it { should =~ %r{ #{name} +#{summary}} } if summary
end
- Puppet::Util::CommandLine.available_subcommands do |name|
- it { should have_matching_element %r{ #{name} } }
+ Puppet::Faces[:help, :current].legacy_applications.each do |appname|
+ it { should =~ %r{ #{appname} } }
+
+ summary = Puppet::Faces[:help, :current].horribly_extract_summary_from(appname)
+ summary and it { should =~ %r{ #{summary}\b} }
end
end
- context "when listing legacy applications" do
- let :help do Puppet::Faces[:help, :current] end
+ context "#legacy_applications" do
+ subject { Puppet::Faces[:help, :current].legacy_applications }
# If we don't, these tests are ... less than useful, because they assume
# it. When this breaks you should consider ditching the entire feature
# and tests, but if not work out how to fake one. --daniel 2011-04-11
- it "should have at least one legacy application" do
- help.legacy_applications.should have_at_least(1).item
- end
+ it { should have_at_least(1).item }
# Meh. This is nasty, but we can't control the other list; the specific
# bug that caused these to be listed is annoyingly subtle and has a nasty
# fix, so better to have a "fail if you do something daft" trigger in
# place here, I think. --daniel 2011-04-11
%w{faces_base indirection_base}.each do |name|
- it "should not list the #{name} application" do
- help.legacy_applications.should_not include name
- end
- end
-
- Puppet::Faces[:help, :current].legacy_applications.each do |appname|
- it "should list #{appname} in the help output" do
- help.help.should have_matching_element %r{ #{appname} }
- end
-
- summary = Puppet::Faces[:help, :current].horribly_extract_summary_from(appname)
- if summary then
- it "should display the summary of #{appname}" do
- help.help.should have_matching_element %r{ #{summary}\b}
- end
- end
+ it { should_not include name }
end
end
end