Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add virtual recipe support #298

Closed
wants to merge 1 commit into from
Closed

Add virtual recipe support #298

wants to merge 1 commit into from

Conversation

geraud
Copy link
Contributor

@geraud geraud commented Jan 3, 2014

This patch enables the creation of inlined virtual recipes. It is useful to test definitions.

runner = ChefSpec::Runner.new    
runner.define_recipe('cookbook::virtual_recipe') do
  mydefinition 'test' do
    ...
  end    
end

runner.converge('cookbook::virtual_recipe')

or

runner = ChefSpec::Runner.new    
runner.converge_virtual_recipe('cookbook') do
  mydefinition 'test' do
    ...
  end    
end

@sethvargo
Copy link
Contributor

Ohai @geraud. Thank you for the Pull Request. Unfortunately this is not a feature I want to support in ChefSpec. The notion of creating virtual recipes is cool, but the general best practice for testing definitions (and LWRPs) it to make a separate cookbook (like mycookbook_test) that has recipes utilizing the definition. These "fixtures" can be shared with other testing frameworks, like Test Kitchen.

@sethvargo sethvargo closed this Jan 3, 2014
@geraud
Copy link
Contributor Author

geraud commented Jan 3, 2014

Ok, no problem.

@sethvargo
Copy link
Contributor

I feel bad, but this is a fairly large feature to support and comes with many edge cases to test. Might I suggest writing a blog post about this pattern? I can link to it in the README.

@geraud
Copy link
Contributor Author

geraud commented Jan 6, 2014

Don't worry about it, I will just use a monkey patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants