Created
March 28, 2012 19:33
-
-
Save jperry/2229720 to your computer and use it in GitHub Desktop.
Chefspec example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spec_helper.rb | |
Rspec.configure do |config| | |
def converge(recipe_name) | |
chef_run = ChefSpec::ChefRunner.new(:cookbook_path => File.dirname(__FILE__)) | |
chef_run.coverge recipe_name | |
chef_run | |
end | |
end | |
default.rb (attribute file) | |
default[:tmpreaper][:time] = "7d" | |
if search(:node, "role:rails_utility").length > 0 | |
default[:tmpreaper][:time] = "3d" | |
end | |
default_spec.rb | |
describe 'tmpreaper::default' do | |
before(:all) do | |
@chef_run = converge "tmpreaper::default" | |
end | |
describe "attributes" do | |
it "should set the correct values by default" do | |
#pending("Waiting for response back from gem author why mocks aren't working") | |
@chef_run.node.tmpreaper[:time].should == "7d" | |
end | |
it "should set the correct values when there are nodes with the rails_utility role" do | |
@chef_run.node.tmpreaper[:time].should == "3d" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment