On 12/04/11 18:22, Jacob Helwig wrote: > On Tue, 12 Apr 2011 08:39:57 -0700, Markus Roberts wrote: >> >> I'm currrently looking at the specs for the ssh_authorized_key provider. >>>> There are two tests that give me a headache: >>>> >>>> it "should create the directory if it doesn't exist" do >>>> File.stubs(:exist?).with(@dir).returns false >>>> Dir.expects(:mkdir).with(@dir,0700) >>>> @provider.flush >>>> end >>>> >>>> it "should not create or chown the directory if it already exist" do >>>> File.stubs(:exist?).with(@dir).returns false >>>> Dir.expects(:mkdir).never >>>> @provider.flush >>>> end >>>> >>>> Both tests stub exist? to return false (which is obviously wrong in the >>>> second case) but both tests are expecting different results. Nevertheless >>>> both tests will pass. Am I overlooking something? How can this happen? >>>> >>> >>> Wow. I'll deffer to Luke on the "what to do about it" issue but apart from >>> that this look like another rspec bug (along the lines of the >>> be_any/all/none... bug, http://www.ruby-forum.com/topic/197643) but I'm >>> not seeing the mechanism off the top of my head. >>> >>> It's probably worth figuring out if only to identify other tests that might >>> not be doing what they look like, >>> >> >> It looks like 1) the tests are stubbing Dir.mkdir and 2) expects are >> silently ignored on stubs so 3) the problematic lines simply aren't doing >> what they look like. >> > > If Dir.mkdir is being stubbed, then this is almost certainly the > problem. I ran into this scenario recently, which was the entire reason > for removing the stubbing of save_last_run_summary in > http://projects.puppetlabs.com/issues/4339#note-20
I happen to do that quite frequently I'm afraid. Sorry if it created some issues. I didn't expect (no pun intended) that it wasn't working (and I'm positive this used to work). > Expecting a stubbed method never wasn't working, however expecting a > stubbed method >= once behaved as expected. Definitely an rspec bug. Or a mocha bug? Or a combination of rspec+mocha? -- Brice Figureau My Blog: http://www.masterzen.fr/ -- 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.