On 18/02/11 18:26, Luke Kanies wrote: > Thanks a ton for doing this. > > I really only have one comment below, and it's about stubs vs. real objects, > which we've changed our tune on recently. [snip] >> + @resource = stub 'resource' >> + @provider = provider_class.new(@resource) >> + >> + @resource.stubs(:[]).returns(nil) >> + @resource.stubs(:[]).with(:name).returns "/system/myservice" >> + @resource.stubs(:[]).with(:ensure).returns :enabled >> + @resource.stubs(:[]).with(:enable).returns :true >> + @resource.stubs(:name).returns "/system/myservice" >> + @resource.stubs(:ref).returns "Service[/system/myservice]" >> + @provider.stubs(:resource).returns @resource > > We have a bunch of tests that do exactly this (where 'this' is using complete > stubs), but over time we've moved away from it, because it tends to make very > fragile tests. Instead we stick to stubbing either external systems (like > Facter) or systems that muck with the disk or network. > > You should be able to create a normal resource here: > > @resource = Puppet::Type.type(:service).new(:name => "/system/myservice")
Sure, thanks for the feedback (Daniel too). I've updated the test to create the resource object directly. That's made it much easier, I'd discovered earlier it was fairly brittle trying to stub the whole thing. While changing the test I found an error message for importing manifests was calling a non-existent method, so that's fixed too and is tested. Commits are here: https://github.com/domcleal/puppet/tree/tickets/master/6324 -- Dominic Cleal Red Hat Consulting m: +44 (0)7818 512168 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.