diff options
author | danielsdeleo <dan@opscode.com> | 2012-12-21 11:29:29 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-12-27 09:37:44 -0700 |
commit | 1fbf3f48454ae47e13cdb502ad5d040865a9989a (patch) | |
tree | b9f0c608334605c3479c1de53de9939c329ab18c /spec/unit/lwrp_spec.rb | |
parent | 76a1a65943fd80e9e05f37c0f7e19fe673819675 (diff) | |
download | chef-1fbf3f48454ae47e13cdb502ad5d040865a9989a.tar.gz |
[CHEF-3681] Test LWPs with inline compilation
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
-rw-r--r-- | spec/unit/lwrp_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index b28fd812a2..a158bce440 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -226,6 +226,48 @@ describe "LWRP" do provider.enclosed_resource.monkey.should == 'bob, the monkey' end + describe "when using inline compilation" do + before do + # Behavior in these examples depends on implementation of fixture provider. + # See spec/data/lwrp/providers/inline_compiler + + # Side effect of lwrp_inline_compiler provider for testing notifications. + $interior_ruby_block_2 = nil + # resource type doesn't matter, so make an existing resource type work with provider. + @resource = Chef::Resource::LwrpFoo.new("morpheus", @run_context) + @resource.allowed_actions << :test + @resource.action(:test) + @resource.provider(:lwrp_inline_compiler) + end + + it "does not add interior resources to the exterior resource collection" do + @resource.run_action(:test) + @run_context.resource_collection.should be_empty + end + + context "when interior resources are updated" do + it "processes notifications within the LWRP provider's action" do + @resource.run_action(:test) + $interior_ruby_block_2.should == "executed" + end + + it "marks the parent resource updated" do + @resource.run_action(:test) + @resource.should be_updated + @resource.should be_updated_by_last_action + end + end + + context "when interior resources are not updated" do + it "does not mark the parent resource updated" do + @resource.run_action(:no_updates) + @resource.should_not be_updated + @resource.should_not be_updated_by_last_action + end + end + + end + end end |