On Tue, Apr 12, 2011 at 05:38:54AM -0700, Luke Kanies wrote:
> 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.
> 

I was looking at the current master branch:

https://github.com/puppetlabs/puppet/blob/af792351a62399f8bbeba0d2425f2b88eabb3dff/spec/unit/provider/ssh_authorized_key/parsed_spec.rb#L150

Line 150 to 160

> 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.
> 


Attachment: pgpt8MzeKwRsE.pgp
Description: PGP signature

Reply via email to