Skip to content

Instantly share code, notes, and snippets.

@bytheway
Created March 10, 2014 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytheway/9475815 to your computer and use it in GitHub Desktop.
Save bytheway/9475815 to your computer and use it in GitHub Desktop.
Stubbing LWRP in chefspec
# Very contrived example, but...
# Given an LWRP called my_lwrp that looks something like:
action :create do
file '/tmp/foo' do
content custom_content
end
end
def custom_content
"Some content"
end
# Lets say you need to change the return value of custom_content in ChefSpec for some test:
ChefSpec::Runner.new().converge('recipe_name') do
Chef::Provider::MyLwrp.any_instance.stub(custom_content: "Test content")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment