Sha256: 90b8b5c774827a7f62400d54d185b1f5fee85da2426f79ff9f0c0d8127e7499b

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require 'chef/rewind'

describe Chef::Recipe do
  
  before(:each) do
    @cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
    cl = Chef::CookbookLoader.new(@cookbook_repo)
    cl.load_cookbooks
    @cookbook_collection = Chef::CookbookCollection.new(cl)
    @node = Chef::Node.new
    @node.normal[:tags] = Array.new
    @events = Chef::EventDispatch::Dispatcher.new
    @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
    @recipe = Chef::Recipe.new("hjk", "test", @run_context)
  end


  describe "unwind" do
    it "should remove resource when unwind is called" do
      @recipe.zen_master "foobar" do
        peace false
      end
      
      @recipe.unwind "zen_master[foobar]"

      resources = @run_context.resource_collection.all_resources
      resources.length.should == 0
    end

    it "should throw an error when unwinding a nonexistent resource" do
      lambda do 
        @recipe.unwind "zen_master[foobar]"
      end.should raise_error(Chef::Exceptions::ResourceNotFound)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chef-rewind-0.0.7 spec/unwind_recipe_spec.rb