Created
March 10, 2014 22:26
-
-
Save bytheway/9475815 to your computer and use it in GitHub Desktop.
Stubbing LWRP in chefspec
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
# 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