From 0ae4732fd9058c2ae67f664c545dbd1846cef2df Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 7 Jun 2011 16:52:39 -0700 Subject: (#7828) Fix whitespace in synopsis generator. We accidentally omitted whitespace between multiple options while building the synopsis. This fixes that, by introducing a breakable space in the right location. Additionally, we extract the code that was 99 percent identical from the face and action synopsis generators, push it down into the documentation module, and then invoke it from both places. This eliminates the duplicate code, allowing me to fix that bug once and have it apply to both parts of the code; this is pretty much assured to be true any time we change the synopsis generation. Reviewed-By: Nick Fagerlund --- spec/unit/interface/documentation_spec.rb | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 spec/unit/interface/documentation_spec.rb (limited to 'spec/unit/interface') diff --git a/spec/unit/interface/documentation_spec.rb b/spec/unit/interface/documentation_spec.rb new file mode 100755 index 000000000..6865b9073 --- /dev/null +++ b/spec/unit/interface/documentation_spec.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env rspec +require 'spec_helper' +require 'puppet/interface' +require 'puppet/interface/option' +require 'puppet/interface/documentation' + +class Puppet::Interface::TinyDocs::Test + include Puppet::Interface::TinyDocs + attr_accessor :name, :options + def initialize + self.name = "tinydoc-test" + self.options = [] + end + + def get_option(name) + Puppet::Interface::Option.new(nil, "--#{name}") + end +end + +describe Puppet::Interface::TinyDocs do + subject { Puppet::Interface::TinyDocs::Test.new } + + context "#build_synopsis" do + before :each do + subject.options = [:foo, :bar] + end + + it { should respond_to :build_synopsis } + + it "should put a space between options (#7828)" do + subject.build_synopsis('baz').should =~ /#{Regexp.quote('[--foo] [--bar]')}/ + end + end +end -- cgit