diff options
author | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
---|---|---|
committer | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
commit | d4b83be375ac1dead058e091191ee7c7b7c24c8a (patch) | |
tree | dc825687392ae3068de5b764be60c53122d9e02a /spec/unit/util/command_line_spec.rb | |
parent | 229cbb976fe0f70f5f30548b83517b415840f9bb (diff) | |
parent | 1681684857c6e39d60d87b0b3520d8783977ceff (diff) | |
download | puppet-upstream/3.7.0.tar.gz |
Imported Upstream version 3.7.0upstream/3.7.0
Diffstat (limited to 'spec/unit/util/command_line_spec.rb')
-rwxr-xr-x | spec/unit/util/command_line_spec.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb index 6ba8077c2..9eb61b077 100755 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -70,7 +70,7 @@ describe Puppet::Util::CommandLine do it "should print the version and exit if #{arg} is given" do expect do described_class.new("puppet", [arg]).execute - end.to have_printed(/^#{Puppet.version}$/) + end.to have_printed(/^#{Regexp.escape(Puppet.version)}$/) end end end @@ -93,35 +93,39 @@ describe Puppet::Util::CommandLine do end describe "and an external implementation cannot be found" do + before :each do + Puppet::Util::CommandLine::UnknownSubcommand.any_instance.stubs(:console_has_color?).returns false + end + it "should abort and show the usage message" do - commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument']) Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) + commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument']) commandline.expects(:exec).never expect { commandline.execute - }.to have_printed(/Unknown Puppet subcommand 'whatever'/) + }.to have_printed(/Unknown Puppet subcommand 'whatever'/).and_exit_with(1) end it "should abort and show the help message" do - commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument']) Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) + commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument']) commandline.expects(:exec).never expect { commandline.execute - }.to have_printed(/See 'puppet help' for help on available puppet subcommands/) + }.to have_printed(/See 'puppet help' for help on available puppet subcommands/).and_exit_with(1) end %w{--version -V}.each do |arg| it "should abort and display #{arg} information" do - commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', arg]) Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) + commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', arg]) commandline.expects(:exec).never expect { commandline.execute - }.to have_printed(/^#{Puppet.version}$/) + }.to have_printed(%r[^#{Regexp.escape(Puppet.version)}$]).and_exit_with(1) end end end |