summaryrefslogtreecommitdiffstats
path: root/spec/unit/application/string_base_spec.rb
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-03-26 00:12:17 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-03-28 10:45:34 -0700
commitb859baa04737644e40002f511c5941d002a956e3 (patch)
treef8f4d581c3b0445df836d5e55945f62547239598 /spec/unit/application/string_base_spec.rb
parent88aeb04a50d8997b5e1e0ed7a5a2239508b174ee (diff)
downloadpuppet-b859baa04737644e40002f511c5941d002a956e3.tar.gz
puppet-b859baa04737644e40002f511c5941d002a956e3.tar.xz
puppet-b859baa04737644e40002f511c5941d002a956e3.zip
MAINT: the API is officially named "string" as of this moment.
Now that we have settled on the final public name for the API, "Puppet::String", mass-rename and mass-edit all the files to follow. Reviewed-By: Randall Hansen <randall@puppetlabs.com>
Diffstat (limited to 'spec/unit/application/string_base_spec.rb')
-rwxr-xr-xspec/unit/application/string_base_spec.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/unit/application/string_base_spec.rb b/spec/unit/application/string_base_spec.rb
new file mode 100755
index 000000000..bc563e11d
--- /dev/null
+++ b/spec/unit/application/string_base_spec.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
+require 'puppet/application/string_base'
+
+describe Puppet::Application::StringBase do
+ before :all do
+ @dir = Dir.mktmpdir
+ $LOAD_PATH.push(@dir)
+ FileUtils.mkdir_p(File.join @dir, 'puppet', 'string', 'v0.0.1')
+ FileUtils.touch(File.join @dir, 'puppet', 'string', 'v0.0.1', 'basetest.rb')
+ end
+
+ after :all do
+ FileUtils.remove_entry_secure @dir
+ $LOAD_PATH.pop
+ end
+
+ base_string = Puppet::String.define(:basetest, '0.0.1')
+ class Puppet::Application::StringBase::Basetest < Puppet::Application::StringBase
+ end
+
+ before do
+ @app = Puppet::Application::StringBase::Basetest.new
+ @app.stubs(:string).returns base_string
+ @app.stubs(:exit)
+ @app.stubs(:puts)
+ Puppet::Util::Log.stubs(:newdestination)
+ end
+
+ describe "when calling main" do
+ before do
+ @app.verb = :find
+ @app.arguments = ["myname", "myarg"]
+ @app.string.stubs(:find)
+ end
+
+ it "should send the specified verb and name to the string" do
+ @app.string.expects(:find).with("myname", "myarg")
+
+ @app.main
+ end
+
+ it "should use its render method to render any result"
+
+ it "should exit with the current exit code"
+ end
+
+ describe "during setup" do
+ before do
+ @app.command_line.stubs(:args).returns(["find", "myname", "myarg"])
+ @app.stubs(:validate)
+ end
+
+ it "should set the verb from the command line arguments" do
+ @app.setup
+ @app.verb.should == "find"
+ end
+
+ it "should make sure arguments are an array" do
+ @app.command_line.stubs(:args).returns(["find", "myname", "myarg"])
+ @app.setup
+ @app.arguments.should == ["myname", "myarg"]
+ end
+
+ it "should set the options on the string" do
+ @app.options[:foo] = "bar"
+ @app.setup
+
+ @app.string.options.should == @app.options
+ end
+ end
+end