[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at puppetlabs.com
Tue May 10 08:13:17 UTC 2011
The following commit has been merged in the experimental branch:
commit 4eccd53da90593fad1b929eeea3b5d7d252c553e
Author: Daniel Pittman <daniel at puppetlabs.com>
Date: Sun Apr 10 19:58:43 2011 -0700
(#6962) Implement Face#summary support for the help face.
We now use the summary information available in other faces as part of
emitting a list our list of available subcommands. This is seldom used in
faces, but enough emit the information to prove the concept.
Reviewed-By: Matt Robinson <matt at puppetlabs.com>
diff --git a/lib/puppet/faces/help.rb b/lib/puppet/faces/help.rb
index e986d19..229a0dc 100644
--- a/lib/puppet/faces/help.rb
+++ b/lib/puppet/faces/help.rb
@@ -27,10 +27,10 @@ Puppet::Faces.define(:help, '0.0.1') do
if args.length == 0 then
message << "Use: puppet [options] <subcommand> <action>"
message << ""
- message << "Available commands, from Puppet Faces:"
+ message << "Available subcommands, from Puppet Faces:"
Puppet::Faces.faces.sort.each do |name|
face = Puppet::Faces[name, :current]
- message << format(" %-15s %s", face.name, 'REVISIT: face.desc')
+ message << format(" %-15s %s", face.name, face.summary)
end
else
face = Puppet::Faces[args[0].to_sym, version]
diff --git a/spec/lib/puppet/faces/huzzah.rb b/spec/lib/puppet/faces/huzzah.rb
index 7350044..e867302 100644
--- a/spec/lib/puppet/faces/huzzah.rb
+++ b/spec/lib/puppet/faces/huzzah.rb
@@ -1,4 +1,5 @@
require 'puppet/faces'
Puppet::Faces.define(:huzzah, '2.0.1') do
+ summary "life is a thing for celebration"
action :bar do "is where beer comes from" end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d28cb25..1187c1c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -7,6 +7,7 @@ ARGV.clear
require 'puppet'
require 'mocha'
gem 'rspec', '>=2.0.0'
+require 'rspec/expectations'
# So everyone else doesn't have to include this base constant.
module PuppetSpec
@@ -65,3 +66,9 @@ RSpec.configure do |config|
GC.enable
end
end
+
+RSpec::Matchers.define :have_matching_element do |expected|
+ match do |actual|
+ actual.any? { |item| item =~ expected }
+ end
+end
diff --git a/spec/unit/faces/help_spec.rb b/spec/unit/faces/help_spec.rb
index 5b611a0..ad553dc 100644
--- a/spec/unit/faces/help_spec.rb
+++ b/spec/unit/faces/help_spec.rb
@@ -41,4 +41,25 @@ describe Puppet::Faces[:help, '0.0.1'] do
face = Puppet::Faces[:huzzah, :current]
subject.help(:huzzah, face.version).should == subject.help(:huzzah, :current)
end
+
+ context "when listing subcommands" do
+ subject { Puppet::Faces[:help, :current].help }
+
+ # Check a precondition for the next block; if this fails you have
+ # something odd in your set of faces, and we skip testing things that
+ # matter. --daniel 2011-04-10
+ it "should have at least one face with a summary" do
+ Puppet::Faces.faces.should be_any do |name|
+ Puppet::Faces[name, :current].summary
+ end
+ end
+
+ Puppet::Faces.faces.each do |name|
+ 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
+ end
+ end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list