diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-07 15:53:17 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-07 15:53:17 -0700 |
commit | a35fa519c85a761ac8bed3be8fde2d6523cae474 (patch) | |
tree | 36f3583ee364ba1d68467a2b614a8dfcf9ed43ae /spec/unit/interface/action_builder_spec.rb | |
parent | 3d5ec4f61fee08552767e950ac021752c202a599 (diff) | |
parent | 87ed3188e65d3f5f9c2c32a409b271d1b39684b9 (diff) | |
download | puppet-a35fa519c85a761ac8bed3be8fde2d6523cae474.tar.gz puppet-a35fa519c85a761ac8bed3be8fde2d6523cae474.tar.xz puppet-a35fa519c85a761ac8bed3be8fde2d6523cae474.zip |
Merge branch 'refactor/master/7012-rename-strings-to-interfaces-and-faces'
Diffstat (limited to 'spec/unit/interface/action_builder_spec.rb')
-rwxr-xr-x | spec/unit/interface/action_builder_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb new file mode 100755 index 000000000..ae9cc83d4 --- /dev/null +++ b/spec/unit/interface/action_builder_spec.rb @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require 'puppet/interface/action_builder' + +describe Puppet::Interface::ActionBuilder do + describe "::build" do + it "should build an action" do + action = Puppet::Interface::ActionBuilder.build(nil, :foo) do + end + action.should be_a(Puppet::Interface::Action) + action.name.should == :foo + end + + it "should define a method on the face which invokes the action" do + face = Puppet::Interface.new(:action_builder_test_interface, '0.0.1') + action = Puppet::Interface::ActionBuilder.build(face, :foo) do + when_invoked do + "invoked the method" + end + end + + face.foo.should == "invoked the method" + end + + it "should require a block" do + expect { Puppet::Interface::ActionBuilder.build(nil, :foo) }. + should raise_error("Action :foo must specify a block") + end + + describe "when handling options" do + let :face do Puppet::Interface.new(:option_handling, '0.0.1') end + + it "should have a #option DSL function" do + method = nil + Puppet::Interface::ActionBuilder.build(face, :foo) do + method = self.method(:option) + end + method.should be + end + + it "should define an option without a block" do + action = Puppet::Interface::ActionBuilder.build(face, :foo) do + option "--bar" + end + action.should be_option :bar + end + + it "should accept an empty block" do + action = Puppet::Interface::ActionBuilder.build(face, :foo) do + option "--bar" do + # This space left deliberately blank. + end + end + action.should be_option :bar + end + end + end +end |