When I rewrote the runit_service definition to be a service resource,
I made it "heavyweight" for two reasons:
1. I wanted to subclass Chef's service resource, to reuse some of its
functionality and have runit_service behave like other services.
2. It was easier to do unit testing of it this way. You can see the
unit tests here:
https://github.com/hw-cookbooks/runit/blob/master/test/spec/libraries/provider_runit_service_spec.rb
For testing LWRPs, you can use the step_into feature of ChefSpec.
Documentation is on the ChefSpec site.
http://code.sethvargo.com/chefspec/
Hope this helps.
-Joshua
--> I have a cookbook that uses LWRPs to configure some weblogic domains. The
> LWRP is getting really complex and deserves (I think) to be made into an
> HWRP with more complete unit tests, etc.
>
> Does anyone know of best practices for unit testing HRWPs like this?
>
> I found that the dsh cookbook (https://github.com/rcbops-cookbooks/dsh) does
> have a spec tested HWRP, which ends up stubbing method calls on the chef
> providers used to prevent them from converging on the test machine. Is this
> the best approach to take?
>
> Anyone have suggestions or places to start digging?
>
> Thanks,
>
> Ben
Joshua Timberman, Chef.
Archive powered by MHonArc 2.6.16.