From 37c97cdca07fd8c446e924547239c8f09eda8810 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Fri, 1 Apr 2011 12:47:32 -0700 Subject: (#6749) clean up various testing bits... This cleans up a whole bunch of bits of the testing code around the place; nothing revolutionary, just nicer and more robust code. Reviewed-By: Pieter van de Bruggen --- spec/unit/application/string_base_spec.rb | 30 +++++++++++++++++++----------- spec/unit/string/indirector_spec.rb | 8 ++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/spec/unit/application/string_base_spec.rb b/spec/unit/application/string_base_spec.rb index 37f6fddcb..20185b526 100755 --- a/spec/unit/application/string_base_spec.rb +++ b/spec/unit/application/string_base_spec.rb @@ -38,24 +38,32 @@ describe Puppet::Application::StringBase do app.command_line.stubs(:args).returns %w{} end - it "should set the string based on the type" - it "should set the format based on the string default" - describe "parsing the command line" do before :all do Puppet::String[:basetest, '0.0.1'].action :foo do option "--foo" - invoke do |options| - options - end + invoke { |options| options } end end - it "should find the action" do - app.command_line.stubs(:args).returns %w{foo} - app.preinit - app.action.should be - app.action.name.should == :foo + context "with just an action" do + before :all do + app.command_line.stubs(:args).returns %w{foo} + app.preinit + end + + it "should set the string based on the type" do + app.string.name.should == :basetest + end + + it "should set the format based on the string default" do + app.format.should == :pson + end + + it "should find the action" do + app.action.should be + app.action.name.should == :foo + end end it "should fail if no action is given" do diff --git a/spec/unit/string/indirector_spec.rb b/spec/unit/string/indirector_spec.rb index 29e8e7086..cb85eaa05 100755 --- a/spec/unit/string/indirector_spec.rb +++ b/spec/unit/string/indirector_spec.rb @@ -41,13 +41,13 @@ describe Puppet::String::Indirector do end it "should be able to override its indirection name" do - @instance.set_indirection_name :foo - @instance.indirection_name.should == :foo + subject.set_indirection_name :foo + subject.indirection_name.should == :foo end it "should be able to set its terminus class" do - @instance.indirection.expects(:terminus_class=).with(:myterm) - @instance.set_terminus(:myterm) + subject.indirection.expects(:terminus_class=).with(:myterm) + subject.set_terminus(:myterm) end it "should define a class-level 'info' action" do -- cgit