On Apr 12, 2011, at 3:24 AM, Stefan Schulte <stefan.schu...@taunusstein.net> wrote:
> Hi, > > 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? Well, we'd need to know the code you're testing and all of the 'before' blocks to really know. There's a decent chance you're throwing and catching an error - you're not checking return codes or anything. If possible, I recommend dropping these mocks and mucking directly with the filesystem. We've been moving much more toward that style, for exactly this reason. -- 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.