diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-18 14:41:01 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-19 10:53:39 -0700 |
| commit | 5258e06a39e11c2cc1951af9235605a29a155c36 (patch) | |
| tree | 7bfb24aff4014770182769fa6f2b323fc8705b58 /spec/unit/interface | |
| parent | 86801b580101315706b1b02a00a36840eabd75cd (diff) | |
| download | puppet-5258e06a39e11c2cc1951af9235605a29a155c36.tar.gz puppet-5258e06a39e11c2cc1951af9235605a29a155c36.tar.xz puppet-5258e06a39e11c2cc1951af9235605a29a155c36.zip | |
(#7013) Return bound methods for when_rendering hooks.
We can return a method bound to the current face instance when we access the
'when_rendering' hook, which allows us to directly call them. Make that
change, and add appropriate testing.
Reviewed-By: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'spec/unit/interface')
| -rwxr-xr-x | spec/unit/interface/action_builder_spec.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb index 38a23a64e..c122d3eb1 100755 --- a/spec/unit/interface/action_builder_spec.rb +++ b/spec/unit/interface/action_builder_spec.rb @@ -121,7 +121,7 @@ describe Puppet::Interface::ActionBuilder do action = Puppet::Interface::ActionBuilder.build(face, :foo) do when_rendering :json do |a| true end end - action.when_rendering(:json).should be_an_instance_of UnboundMethod + action.when_rendering(:json).should be_an_instance_of Method end it "should fail if you try to set the same rendering twice" do @@ -138,8 +138,15 @@ describe Puppet::Interface::ActionBuilder do when_rendering :json do |a| true end when_rendering :yaml do |a| true end end - action.when_rendering(:json).should be_an_instance_of UnboundMethod - action.when_rendering(:yaml).should be_an_instance_of UnboundMethod + action.when_rendering(:json).should be_an_instance_of Method + action.when_rendering(:yaml).should be_an_instance_of Method + end + + it "should be bound to the face when called" do + action = Puppet::Interface::ActionBuilder.build(face, :foo) do + when_rendering :json do |a| self end + end + action.when_rendering(:json).call(true).should == face end end |
