I'm trying to figure out a way to test resources that use the "action: nothing/end.run_action(:create)" pattern. I don't think they're currently testable with chefspec as chefspec expects "action :create".
1. Is my understanding correct?
2. Would it be possible to test these by writing specs against the state of the resources (rather than using the chefspec matchers)?
3. Is it feasible to add matchers for this pattern? If it is and someone can point me in the right direction I'm willing to take a crack at it.
My first instinct - this isn't possible with chefspec. Because chefspec actually runs a converge (combined with some magical monkey patching), and resource.run_action(:blah) happens at compile time, I'm not sure we could capture that.
You could, however, unit test this directly with rspec:
it 'does something' do
Disclaimer: Totally untested and highly theoretical.
@jimhopp any luck on this?
Apologies @sethvargo. I missed your question.
I couldn't get the stubbing to work (I think it needed to be Chef::Resource::GemPackage anyway) so I reverted to this
it 'installs lookout-stats in pre-0.10.10' do
chef_run.resources.each do |resource|
resource.package_name.should == "lookout-statsd" if resource.class == Chef::Resource::GemPacka
resource.action.should == [:nothing] if resource.class == Chef::Resource::GemPackage