diff --git a/lib/puppet/face/module_tool/generate.rb b/lib/puppet/face/module_tool/generate.rb new file mode 100644 index 000000000..c02febe38 --- /dev/null +++ b/lib/puppet/face/module_tool/generate.rb @@ -0,0 +1,30 @@ +Puppet::Face.define(:module_tool, '0.0.1') do + action(:generate) do + summary "Generate boilerplate for a new module." + description <<-EOT + Generate boilerplate for a new module by creating a directory + pre-populated with a directory structure and files recommended for + Puppet best practices. + EOT + + returns "Array of Pathname objects representing paths of generated files." + + examples <<-EOT + Generate a new module in the current directory: + + $ puppet module_tool generate username-modulename + EOT + + arguments "" + + when_invoked do |name, options| + Puppet::Module::Tool::Applications::Generator.run(name, options) + end + + when_rendering :console do |return_value| + return_value.map do |generated_file| + "#{generated_file}" + end.join("\n") + end + end +end diff --git a/spec/unit/face/module_tool/generate_spec.rb b/spec/unit/face/module_tool/generate_spec.rb new file mode 100644 index 000000000..3f0219731 --- /dev/null +++ b/spec/unit/face/module_tool/generate_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' +require 'puppet/face' + +describe "puppet module_tool generate" do + subject { Puppet::Face[:module_tool, :current] } + + describe "option validation" do + context "without any options" do + it "should require name" do + pattern = /wrong number of arguments/ + expect { subject.generate }.to raise_error ArgumentError, pattern + end + end + end + + describe "inline documentation" do + subject { Puppet::Face[:module_tool, :current].get_action :generate } + + its(:summary) { should =~ /generate.*module/im } + its(:description) { should =~ /generate.*module/im } + its(:returns) { should =~ /array/i } + its(:examples) { should_not be_empty } + + %w{ license copyright summary description returns examples }.each do |doc| + context "of the" do + its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ } + end + end + end +end