From nick at pivotalsf.com Wed Aug 13 23:45:23 2008 From: nick at pivotalsf.com (Nick Kallen) Date: Wed, 13 Aug 2008 20:45:23 -0700 Subject: [mocha-developer] Mocha Koan Message-ID: <82c457760808132045w102c75ffjc111bdce3796ce9d@mail.gmail.com> try this in a test: def test_foo foo = Object.new foo.stubs(:verified?).returns(false) assert !foo.verified? end The test will fail (it should not). The way #verified? is implemented is unsafe, clearly. (the test is nicely paradoxical, since the assertion passes only if the test will fail!) From tinney at gmail.com Thu Aug 14 14:09:05 2008 From: tinney at gmail.com (Dustin Tinney) Date: Thu, 14 Aug 2008 14:09:05 -0400 Subject: [mocha-developer] Named Scope Message-ID: <447E626E-CCB0-45EE-BDC8-2A7FC7821360@gmail.com> With the introduction of named scope in rails does anyone have mocha testing suggestions for something like this: @person .completed_moves .in_locaiton(params[:location]).in_site(params[:site]).find(:first) .dustin From duncanbeevers at gmail.com Thu Aug 14 17:25:11 2008 From: duncanbeevers at gmail.com (Duncan Beevers) Date: Thu, 14 Aug 2008 14:25:11 -0700 Subject: [mocha-developer] Named Scope In-Reply-To: <447E626E-CCB0-45EE-BDC8-2A7FC7821360@gmail.com> References: <447E626E-CCB0-45EE-BDC8-2A7FC7821360@gmail.com> Message-ID: <6a2b4fd00808141425w1809eb3ct306d91f121504bbf@mail.gmail.com> You can use #proxy_options on each scope to unit test the find options applied by that scope. As far as testing chains of scopes, I've found this is simply more appropriate to test all the way through to the database. On Thu, Aug 14, 2008 at 11:09 AM, Dustin Tinney wrote: > With the introduction of named scope in rails does anyone have mocha testing > suggestions for something like this: > > @person.completed_moves.in_locaiton(params[:location]).in_site(params[:site]).find(:first) > > .dustin > > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > From jamesmead44 at gmail.com Fri Aug 22 11:20:35 2008 From: jamesmead44 at gmail.com (James Mead) Date: Fri, 22 Aug 2008 16:20:35 +0100 Subject: [mocha-developer] stubs! method In-Reply-To: <1db558f00801220121s55a6da6bs3e1dcbad69f816d6@mail.gmail.com> References: <1db558f00801211252i50306219n1031e432c82eff5e@mail.gmail.com> <1db558f00801220121s55a6da6bs3e1dcbad69f816d6@mail.gmail.com> Message-ID: <1db558f00808220820y601d89e8l70debc5fac769bca@mail.gmail.com> 2008/1/22 James Mead > On 21/01/2008, Jay Fields wrote: > >> I think a warning is perfect for me on both scenarios. >> > > Cool. This is rather a belated reply to your original message [1] on the old mailing list. I don't know whether you've already seen it, but since version 0.9.0, you have been able to do this... Mocha::Configuration.warn_when(:stubbing_method_unnecessarily) OR Mocha::Configuration.prevent(:stubbing_method_unnecessarily) More details here [2]. I hope that does what you need. -- James. http://blog.floehopper.org [1] http://rubyforge.org/pipermail/mocha-developer/2008-January/000506.html [2] http://mocha.rubyforge.org/classes/Mocha/Configuration.html