From jed.hurt at gmail.com Sat Mar 1 00:10:54 2008 From: jed.hurt at gmail.com (Jed Hurt) Date: Fri, 29 Feb 2008 22:10:54 -0700 Subject: [rspec-users] Quiet Backtrace in RSpec In-Reply-To: <57c63afe0802291352na6db27x99b501815383c30e@mail.gmail.com> References: <8d961d900801190039x7c973fb3xad1052df557c2e45@mail.gmail.com> <57c63afe0802210521x625ad9efg1c87a37f2c113cf8@mail.gmail.com> <57c63afe0802291352na6db27x99b501815383c30e@mail.gmail.com> Message-ID: Ahh, I see. Cool, cool :) On Fri, Feb 29, 2008 at 2:52 PM, David Chelimsky wrote: > On Fri, Feb 29, 2008 at 1:08 PM, Jed Hurt wrote: > > > > > > > > On Thu, Feb 21, 2008 at 6:21 AM, David Chelimsky > > wrote: > > > > > > On Thu, Feb 21, 2008 at 12:52 AM, Jed Hurt wrote: > > > > Ahh, I see. Is Spec::Runner::QuietBacktraceTweaker configurable for > more > > > > quietness? > > > > > > Nope. > > > > Haha. Is that a terse form of PDI? > > Not intentional. I think I was responding on my phone, which makes > everything more terse. > > Cheers, > David > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080229/155713f8/attachment-0001.html From bryansray at gmail.com Sat Mar 1 01:15:34 2008 From: bryansray at gmail.com (Bryan Ray) Date: Sat, 1 Mar 2008 00:15:34 -0600 Subject: [rspec-users] how do i get color with autotest on XP? In-Reply-To: <81d544a3ff8319219dfb3518d2aa3d61@ruby-forum.com> References: <71166b3b0802291708t52b6aac6v564faa4133e4d82b@mail.gmail.com> <81d544a3ff8319219dfb3518d2aa3d61@ruby-forum.com> Message-ID: <29a0119e0802292215o5443230cp1927a0afa45a4b9f@mail.gmail.com> A colleague of mine says he got his working, but I have yet to see it. I will ask him on Monday and report back with what I find. On Fri, Feb 29, 2008 at 9:15 PM, Spencer Roan wrote: > @Luis Lavena > ok, thank you! i'll stop beating my head against it then and keep an eye > out on the updates of win32console. > spencer > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Bryan Ray http://www.bryanray.net "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080301/01ecee1e/attachment.html From gilesb at gmail.com Sat Mar 1 12:37:19 2008 From: gilesb at gmail.com (Giles Bowkett) Date: Sat, 1 Mar 2008 09:37:19 -0800 Subject: [rspec-users] rspec with continuations: very strange Message-ID: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> I appear to have written code which travels backwards through time: http://www.vimeo.com/742590 This disturbs me immensely. If anyone can explain it, that would be cool. I think it's an illusion brought about by how RSpec wraps the code it executes, and by the sheer weirdness of continuations. -- Giles Bowkett Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com Podcast: http://hollywoodgrit.blogspot.com From omen.king at gmail.com Sat Mar 1 12:55:11 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Sat, 1 Mar 2008 12:55:11 -0500 Subject: [rspec-users] rspec with continuations: very strange In-Reply-To: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> References: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> Message-ID: Wow, thats reminds of when micheal jay fox flew back in time and he almost broke his specs by going out with his mom."should_not be_nil" LawL Couldn't you On Sat, Mar 1, 2008 at 12:37 PM, Giles Bowkett wrote: > I appear to have written code which travels backwards through time: > > http://www.vimeo.com/742590 > > This disturbs me immensely. If anyone can explain it, that would be cool. > > I think it's an illusion brought about by how RSpec wraps the code it > executes, and by the sheer weirdness of continuations. > > -- > Giles Bowkett > > Blog: http://gilesbowkett.blogspot.com > Portfolio: http://www.gilesgoatboy.org > Tumblelog: http://giles.tumblr.com > Podcast: http://hollywoodgrit.blogspot.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080301/5a9b78e8/attachment.html From dchelimsky at gmail.com Sat Mar 1 12:59:46 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Mar 2008 11:59:46 -0600 Subject: [rspec-users] rspec with continuations: very strange In-Reply-To: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> References: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> Message-ID: <57c63afe0803010959o6b587b9dvf8890be4cd8c617d@mail.gmail.com> On Sat, Mar 1, 2008 at 11:37 AM, Giles Bowkett wrote: > I appear to have written code which travels backwards through time: > > http://www.vimeo.com/742590 > > This disturbs me immensely. If anyone can explain it, that would be cool. > > I think it's an illusion brought about by how RSpec wraps the code it > executes, and by the sheer weirdness of continuations. This has absolutely nothing to do with RSpec. Do the same thing in test/unit and you'll find the same result (http://pastie.caboo.se/159803) Continuations ARE time machines. So when you called the continuation again, it does in fact go back to where it exited the loop (from the interrupt). Now I haven't looked to see why the second time "through time" it's not working, but it actually makes perfect sense that it goes back in time. FWIW, David > > -- > Giles Bowkett > > Blog: http://gilesbowkett.blogspot.com > Portfolio: http://www.gilesgoatboy.org > Tumblelog: http://giles.tumblr.com > Podcast: http://hollywoodgrit.blogspot.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From srogers1 at gmail.com Sat Mar 1 13:04:33 2008 From: srogers1 at gmail.com (Steven Rogers) Date: Sat, 1 Mar 2008 12:04:33 -0600 Subject: [rspec-users] rspec with continuations: very strange In-Reply-To: References: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> Message-ID: On Mar 1, 2008, at 11:55 AM, Andrew WC Brown wrote: > Wow, thats reminds of when micheal jay fox flew back in time and he > almost broke his specs by going out with his mom. > "should_not be_nil" LawL set whiny_exceeding_lightspeed => true SR From rick.denatale at gmail.com Sat Mar 1 15:53:03 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 1 Mar 2008 15:53:03 -0500 Subject: [rspec-users] rspec with continuations: very strange In-Reply-To: <57c63afe0803010959o6b587b9dvf8890be4cd8c617d@mail.gmail.com> References: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> <57c63afe0803010959o6b587b9dvf8890be4cd8c617d@mail.gmail.com> Message-ID: On 3/1/08, David Chelimsky wrote: > On Sat, Mar 1, 2008 at 11:37 AM, Giles Bowkett wrote: > > I appear to have written code which travels backwards through time: > > > > http://www.vimeo.com/742590 > > > > This disturbs me immensely. If anyone can explain it, that would be cool. > > > > I think it's an illusion brought about by how RSpec wraps the code it > > executes, and by the sheer weirdness of continuations. > > > This has absolutely nothing to do with RSpec. Do the same thing in > test/unit and you'll find the same result > (http://pastie.caboo.se/159803) > > Continuations ARE time machines. So when you called the continuation > again, it does in fact go back to where it exited the loop (from the > interrupt). > > Now I haven't looked to see why the second time "through time" it's > not working, but it actually makes perfect sense that it goes back in > time. I can't read all of the code, but it appears that the up_to method in ContinuationLooper looks like this: 1: def up_to(interrupt) 2: accumulator = "" 3: continuation = nil 4: for i in 1..100 do 5: accumulator += "Value of i: #{i}
\n" 6: callcc {|continuation| return accumulator, continuation} if i == interrupt 7: accumulator 8: end 9: end Ok now in the test we have: 10: it "resumes its continuation, returning a string" do 11: accumulator, continuation = ContinuationLooper.up_to(50) 12: continuation.class.should == Continuation 13: puts accumulator 14: puts continuation.call Now, when we first encounter line 11, we get to the point in the loop in the ContinuationLooper.up_to method where i == 50 and invoke callcc. This evaluates it's block argument which returns the accumulator and the continuation, returning them to line 12. So continuation here is a Continuation and the expectation is met. Now, we go on, and when we get to line 14, the continuation gets called, which puts us back at line 7 inside the loop, which continues until i gets to 100. The callcc doesn't get invoked again because i is now always > interrupt. Then the method returns the last expression in the loop which is simply: accumulator which is what gets returned as the value of the call in line 11 (i.e. the second time we've gotten there), and substituting the return value, the effect is as if line 11 were: accumulator, continuation = "Value of i: (1)
\n...Value of i: (100)
\n" Which because of the way Ruby parallel assignment works when there are not enough RHS values to go around sets the local continuation to nil. No mystery here at all. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From mhennemeyer at googlemail.com Sun Mar 2 06:37:36 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Sun, 2 Mar 2008 12:37:36 +0100 Subject: [rspec-users] rspec with continuations: very strange In-Reply-To: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> References: <2d81dedb0803010937m797765aeqfb6f3a8bd7e0a9e0@mail.gmail.com> Message-ID: Hey Giles, i think that the problem is not that continuations are weird, but that computerscientists are not very creative at inventing helpful names. So i would call it a frozen_computation_state or frozen_environment because that is what a continuation object represents. And the call-with-current-continuation (callcc) really makes no exception when a part of the environment is dedicated to rspec. When you send 'call' to the continuation object, the environment will be set to the state that is represented by the continuation object - the variable with the name continuation points to nil and the next step in evaluation is line 13 in your spec file. Matthias Hennemeyer Am 01.03.2008 um 18:37 schrieb Giles Bowkett: > I appear to have written code which travels backwards through time: > > http://www.vimeo.com/742590 > > This disturbs me immensely. If anyone can explain it, that would be > cool. > > I think it's an illusion brought about by how RSpec wraps the code it > executes, and by the sheer weirdness of continuations. > > -- > Giles Bowkett > > Blog: http://gilesbowkett.blogspot.com > Portfolio: http://www.gilesgoatboy.org > Tumblelog: http://giles.tumblr.com > Podcast: http://hollywoodgrit.blogspot.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080302/156353e9/attachment.html From dbitsolutions at gmail.com Sun Mar 2 20:34:59 2008 From: dbitsolutions at gmail.com (David Beckwith) Date: Sun, 2 Mar 2008 17:34:59 -0800 Subject: [rspec-users] outside-in = integration tests on views? In-Reply-To: <57c63afe0802291606i322b68f1t1dbc3873fb573e4f@mail.gmail.com> References: <93ddac20802291533y167fcc58p4e1e2bbf017c39e7@mail.gmail.com> <57c63afe0802291606i322b68f1t1dbc3873fb573e4f@mail.gmail.com> Message-ID: <93ddac20803021734k5ce20b42qac1db87965b657c5@mail.gmail.com> Hi, 1. What is :steps_for for? 2. Is the GWT form of tests meant to replace it "should . . . . ." style of tests? I heard that GWT are written for your customer to represent a set of acceptance criteria, and it-should tests are more for programmers. Is that how we should think about the difference these two kinds of tests? Or are they really the same thing? BTW, Are the PeepCode rSpec tutorials worth buying? Thanks, David :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080302/a4303f8a/attachment-0001.html From ben at benmabey.com Sun Mar 2 21:49:29 2008 From: ben at benmabey.com (Ben Mabey) Date: Sun, 02 Mar 2008 19:49:29 -0700 Subject: [rspec-users] outside-in = integration tests on views? In-Reply-To: <93ddac20803021734k5ce20b42qac1db87965b657c5@mail.gmail.com> References: <93ddac20802291533y167fcc58p4e1e2bbf017c39e7@mail.gmail.com> <57c63afe0802291606i322b68f1t1dbc3873fb573e4f@mail.gmail.com> <93ddac20803021734k5ce20b42qac1db87965b657c5@mail.gmail.com> Message-ID: <47CB6739.9090005@benmabey.com> > > > BTW, Are the PeepCode rSpec tutorials worth buying? > They are a steal. I watched them after I had already been using rSpec for a couple months and I still learned a lot and felt like they were a great investment. I haven't watched the Story one yet but the general rspec ones were great. -Ben From lists at ruby-forum.com Sun Mar 2 22:38:34 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Mon, 3 Mar 2008 04:38:34 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> Message-ID: <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> Bryan Ray wrote: > It has to do with your "find_city" method. You spec is expecting it to > be > called from controller, hence: > > controller.should_receive(:find_city) > > Where is that method and why isn't it being called should be your next > questions based on the code and spec you've pasted. > The method find_city is in application controller. I think the method 'find_city' is being called but its expecting some args. Thanks, Namrata. -- Posted via http://www.ruby-forum.com/. From mhennemeyer at googlemail.com Mon Mar 3 04:46:58 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Mon, 3 Mar 2008 10:46:58 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> Message-ID: <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> Am 03.03.2008 um 04:38 schrieb Namrata Tiwari: > The method find_city is in application controller. I think the method > 'find_city' is being called but its expecting some args. > The message: Mock 'ArticlesController' expected :find_city with (any args) once, but received it 0 times means that the method find_city was *not* called. If the original method expects args or not doesn't matter. Because should_receive works as both an expectation and a stub, the original method will not be called and no ArgumentError will be raised. > Thanks, > Namrata. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rob.holland at gmail.com Mon Mar 3 05:02:01 2008 From: rob.holland at gmail.com (Rob Holland) Date: Mon, 3 Mar 2008 10:02:01 +0000 Subject: [rspec-users] outside-in = integration tests on views? In-Reply-To: <93ddac20803021734k5ce20b42qac1db87965b657c5@mail.gmail.com> References: <93ddac20802291533y167fcc58p4e1e2bbf017c39e7@mail.gmail.com> <57c63afe0802291606i322b68f1t1dbc3873fb573e4f@mail.gmail.com> <93ddac20803021734k5ce20b42qac1db87965b657c5@mail.gmail.com> Message-ID: <6ea3a1b80803030202v5a34a7ffheae4ddb5f7029c10@mail.gmail.com> > BTW, Are the PeepCode rSpec tutorials worth buying? Anything from PeepCode is worth buying imho, but the specifically, the three rspec ones I have watched have been excellent. From lists at ruby-forum.com Mon Mar 3 06:04:43 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Mon, 3 Mar 2008 12:04:43 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> Message-ID: <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> Matthias Hennemeyer wrote: > Am 03.03.2008 um 04:38 schrieb Namrata Tiwari: > >> The method find_city is in application controller. I think the method >> 'find_city' is being called but its expecting some args. >> > The message: > > Mock 'ArticlesController' expected :find_city with (any args) once, but > received > it 0 times > > means that the method find_city was *not* called. > > If the original method expects args or not doesn't matter. > Because should_receive works as both an expectation and a stub, the > original method will not be called and no ArgumentError will be raised. Okaayyy! Then can you also please say why its not calling this :find_city method? Thx, Namrata. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Mar 3 06:15:38 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Mar 2008 05:15:38 -0600 Subject: [rspec-users] rspec controller action list In-Reply-To: <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> Message-ID: <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> On Mon, Mar 3, 2008 at 5:04 AM, Namrata Tiwari wrote: > Matthias Hennemeyer wrote: > > Am 03.03.2008 um 04:38 schrieb Namrata Tiwari: > > > >> The method find_city is in application controller. I think the method > >> 'find_city' is being called but its expecting some args. > >> > > The message: > > > > Mock 'ArticlesController' expected :find_city with (any args) once, but > > received > > it 0 times > > > > means that the method find_city was *not* called. > > > > If the original method expects args or not doesn't matter. > > Because should_receive works as both an expectation and a stub, the > > original method will not be called and no ArgumentError will be raised. > > Okaayyy! > Then can you also please say why its not calling this :find_city method? If the code is the same as it was in the first post in this thread, it's because the action is taking place before setting the expectations. > > Thx, > > > Namrata. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Mar 3 06:22:45 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Mon, 3 Mar 2008 12:22:45 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> Message-ID: <7317f1371334b517a72ad383e8425fed@ruby-forum.com> > > If the code is the same as it was in the first post in this thread, > it's because the action is taking place before setting the > expectations. Yes, it is the same. As you have suggested earlier. I am pasting the spec again. #list it "should list all articles" do articles = mock("articles") articles.should_receive(:paginate).with(:order => "live_on DESC", :conditions => { :type_for => "blog" }) controller.should_receive(:find_city).and_return(articles) response.should be_success get :list end Thx, Namrata. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Mar 3 06:32:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Mar 2008 05:32:32 -0600 Subject: [rspec-users] rspec controller action list In-Reply-To: <7317f1371334b517a72ad383e8425fed@ruby-forum.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> <7317f1371334b517a72ad383e8425fed@ruby-forum.com> Message-ID: <57c63afe0803030332y5ff467e7j7baa284813d0efb9@mail.gmail.com> On Mon, Mar 3, 2008 at 5:22 AM, Namrata Tiwari wrote: > > > > > If the code is the same as it was in the first post in this thread, > > it's because the action is taking place before setting the > > expectations. > > Yes, it is the same. As you have suggested earlier. > I am pasting the spec again. > > > #list > it "should list all articles" do > articles = mock("articles") > articles.should_receive(:paginate).with(:order => "live_on DESC", > :conditions => { :type_for => "blog" }) > controller.should_receive(:find_city).and_return(articles) > response.should be_success > get :list > > end That is NOT the same :) In the initial post the first line was 'get :list' - now that is the last line. So while you're at it, please post the action again as well. > > > > Thx, > Namrata. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From abroad-crawford at within3.com Mon Mar 3 12:08:25 2008 From: abroad-crawford at within3.com (Anthony Broad-Crawford) Date: Mon, 3 Mar 2008 12:08:25 -0500 Subject: [rspec-users] Rspec and plugins Message-ID: I have a question regarding best practices around module and plugin testing for rails applications. In our application we have created several plugins that extend ActiveRecord::Base with class methods, that when invoked in a model add behavior to that model. For example ... class SomeModel < ActiveRecord::Base adds_some_cool_behavior adds_another_wicked_sweet_behavior end My initial thoughts are that any model that add these behaviors "should" have this specified in their spec. With that in mind, I was leaning towards creating a module that when included inside a model spec adds the necessary specifications to ensure the behavior is there and is executing as intended. However, before proceeding too far I wanted to run it by the collective to hear your thoughts as I am sure this has been tackled by others in the community already (although google didn't yield anything noteworthy). Thanks, Anthony Broad-Crawford -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080303/8c9796e3/attachment-0001.html From mhennemeyer at googlemail.com Mon Mar 3 12:52:43 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Mon, 3 Mar 2008 18:52:43 +0100 Subject: [rspec-users] Rspec and plugins In-Reply-To: References: Message-ID: <5720E0AE-7DA3-4F33-ACEB-DB6DB7873BB5@googlemail.com> I would prefer two independent steps: 1) Specify (or test) the plugin so that you can trust that it works as intended. 2) Write a custom matcher (behave_in_a_cool_way) that lets you express that you want to have added some_cool_behavior to SomeModel: describe SomeModel it "should show some_cool_behavior" do SomeModel.should behave_in_a_cool_way end end This: http://stevetooke.karmatrading.co.uk/2007/8/10/simple-rails- association-matching-with-rspec may be an example. Matthias Am 03.03.2008 um 18:08 schrieb Anthony Broad-Crawford: > I have a question regarding best practices around module and plugin > testing for rails applications. In our application we have created > several plugins that extend ActiveRecord::Base with class methods, > that when invoked in a model add behavior to that model. For > example ... > > class SomeModel < ActiveRecord::Base > > adds_some_cool_behavior > adds_another_wicked_sweet_behavior > > end > > My initial thoughts are that any model that add these behaviors > "should" have this specified in their spec. With that in mind, I > was leaning towards creating a module that when included inside a > model spec adds the necessary specifications to ensure the behavior > is there and is executing as intended. However, before proceeding > too far I wanted to run it by the collective to hear your thoughts > as I am sure this has been tackled by others in the community > already (although google didn't yield anything noteworthy). > > Thanks, > Anthony Broad-Crawford > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080303/f1bd9dc4/attachment-0001.html From lists at ruby-forum.com Mon Mar 3 18:17:53 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Tue, 4 Mar 2008 00:17:53 +0100 Subject: [rspec-users] Testing Plugins + Lib Code Message-ID: <546d58d7c0adaac217a4c2e783bd61ad@ruby-forum.com> Hi, I'm quite new to Rspec and I'm embarking on a new project. One thing I'm really not sure about is how to test plugins and code in your 'lib/' folder. Where would these specs actually live in the dir structure? Should you test plugins by creating specs within the plugin's dir? Or by adding a spec to the main '/specs' folder - and if so where? Any info/best practice advice greatly appreciated. ~ Mark -- Posted via http://www.ruby-forum.com/. From oli.azevedo.barnes at gmail.com Mon Mar 3 18:24:57 2008 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Mon, 3 Mar 2008 20:24:57 -0300 Subject: [rspec-users] stuck on testing validation Message-ID: <6466d9040803031524x42f2583ajb4776880b4a21fd8@mail.gmail.com> Hello, I must be doing something dumb, but here it goes... why does this work? before(:each) do @work = Work.new end #for testing validates_presence_of :title it "should require a title" do @work.title = nil @work.should_not be_valid end while this doesn't: def valid_work_attributes { :title => "guernica", :description => "lorem ipsum lorem ipsum", :date => Date.today, :category => Category.new(:name => "belle epoque") } end before(:each) do @work = Work.new end it "should require a title" do @work.attributes = valid_work_attributes.except(:title) @work.should_not be_valid end the latter example fails with "expected valid? to return false, got true" for @work.should_not be_valid doesn't make sense to me, and I've been stuck for a while already :P any help greatly appreciated, please bear with the newbie :) Oliver From pergesu at gmail.com Mon Mar 3 19:46:28 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 3 Mar 2008 16:46:28 -0800 Subject: [rspec-users] Testing Plugins + Lib Code In-Reply-To: <546d58d7c0adaac217a4c2e783bd61ad@ruby-forum.com> References: <546d58d7c0adaac217a4c2e783bd61ad@ruby-forum.com> Message-ID: <810a540e0803031646l2ff666bcj28b1523e54e3d4d6@mail.gmail.com> On Mon, Mar 3, 2008 at 3:17 PM, Mark Dodwell wrote: > Hi, > > I'm quite new to Rspec and I'm embarking on a new project. One thing I'm > really not sure about is how to test plugins and code in your 'lib/' > folder. Where would these specs actually live in the dir structure? > > Should you test plugins by creating specs within the plugin's dir? Or by > adding a spec to the main '/specs' folder - and if so where? > > Any info/best practice advice greatly appreciated. > > ~ Mark > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > For stuff in lib, I create a spec/lib dir and put my specs in there. For plugins, I use my nifty http://evang.eli.st/blog/2007/4/4/rspec_plugin-generator Pat From abroad-crawford at within3.com Mon Mar 3 22:42:36 2008 From: abroad-crawford at within3.com (Anthony Broad-Crawford) Date: Mon, 3 Mar 2008 22:42:36 -0500 Subject: [rspec-users] Matchers tutorial ... Message-ID: <16095B35-A25F-4BEA-A296-05349BED5016@within3.com> I am looking for a good a - z matchers tutorial . Anyone got a url for one? Thanks Anthony Broad-Crawford -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080303/fd652444/attachment-0001.html From dchelimsky at gmail.com Mon Mar 3 22:46:47 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Mar 2008 21:46:47 -0600 Subject: [rspec-users] Matchers tutorial ... In-Reply-To: <16095B35-A25F-4BEA-A296-05349BED5016@within3.com> References: <16095B35-A25F-4BEA-A296-05349BED5016@within3.com> Message-ID: <57c63afe0803031946i63e482cdvcb7c7b420a421d9e@mail.gmail.com> On Mon, Mar 3, 2008 at 9:42 PM, Anthony Broad-Crawford wrote: > I am looking for a good a - z matchers tutorial . Anyone got a url for one? There are many. Here's mine: http://blog.davidchelimsky.net/articles/2007/02/18/custom-expectation-matchers > > Thanks > > > Anthony Broad-Crawford > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From abroad-crawford at within3.com Mon Mar 3 22:49:11 2008 From: abroad-crawford at within3.com (Anthony Broad-Crawford) Date: Mon, 3 Mar 2008 22:49:11 -0500 Subject: [rspec-users] Matchers tutorial ... In-Reply-To: <57c63afe0803031946i63e482cdvcb7c7b420a421d9e@mail.gmail.com> References: <16095B35-A25F-4BEA-A296-05349BED5016@within3.com> <57c63afe0803031946i63e482cdvcb7c7b420a421d9e@mail.gmail.com> Message-ID: <4143C646-7A2A-429D-B3A7-3E348FB1DFD8@within3.com> thank you! On Mar 3, 2008, at 10:46 PM, David Chelimsky wrote: > On Mon, Mar 3, 2008 at 9:42 PM, Anthony Broad-Crawford > wrote: >> I am looking for a good a - z matchers tutorial . Anyone got a url >> for one? > > There are many. Here's mine: > http://blog.davidchelimsky.net/articles/2007/02/18/custom-expectation-matchers > >> >> Thanks >> >> >> Anthony Broad-Crawford >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue Mar 4 00:21:26 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Tue, 4 Mar 2008 06:21:26 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <57c63afe0803030332y5ff467e7j7baa284813d0efb9@mail.gmail.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> <7317f1371334b517a72ad383e8425fed@ruby-forum.com> <57c63afe0803030332y5ff467e7j7baa284813d0efb9@mail.gmail.com> Message-ID: Here is the action - def list @articles = find_city.articles.paginate :all, :page => params[:page] , :order => "live_on DESC", :conditions => { :type_for => "blog" } end and the spec - it "should list all articles 2" do articles = mock("articles") get :list controller.should_receive(:find_city).and_return(articles) controller.should_receive(:articles) articles.should_receive(:paginate).with(:order => "live_on DESC", :conditions => { :type_for => "blog" }) response.should render_template('articles/list') end I am stubbing find_city and articles during set up before_post do controller.stub!(:find_city) controller.stub!(:articles) end Is this right? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Mar 4 00:36:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Mar 2008 23:36:53 -0600 Subject: [rspec-users] rspec controller action list In-Reply-To: References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> <7317f1371334b517a72ad383e8425fed@ruby-forum.com> <57c63afe0803030332y5ff467e7j7baa284813d0efb9@mail.gmail.com> Message-ID: <57c63afe0803032136p7d98c14pbc6f6a662c8e22c6@mail.gmail.com> On Mon, Mar 3, 2008 at 11:21 PM, Namrata Tiwari wrote: > Here is the action - > > def list > @articles = find_city.articles.paginate :all, :page => > params[:page] , :order => "live_on DESC", :conditions => { :type_for > => "blog" } > end > > and the spec - > > it "should list all articles 2" do > articles = mock("articles") > get :list Whoa. A couple of posts ago you said the action (get :list) was the last thing. Now it's not anymore. When dealing with mocks and stubs, order is very important, which is why I asked you where the action was. Message expectations (mocks) and stub values MUST be set before the action. > controller.should_receive(:find_city).and_return(articles) The implementation is find_city.articles, so find_city needs to return something that owns articles. > controller.should_receive(:articles) This one is just wrong - it's the return value of find_city that should receive articles. > articles.should_receive(:paginate).with(:order => "live_on DESC", > :conditions => { :type_for => "blog" }) This one is right, but again, needs to happen before the action. > > response.should render_template('articles/list') This one is correct, and in the correct place (after the action). > end > > > I am stubbing find_city and articles during set up > > before_post do > controller.stub!(:find_city) Here find_city will not return anything, so it'll blow up on find_city.articles .... > controller.stub!(:articles) > end > > Is this right? Here's what you want: http://pastie.caboo.se/161001 HTH, David > -- > > > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From george at benevolentcode.com Tue Mar 4 00:41:52 2008 From: george at benevolentcode.com (George Anderson) Date: Tue, 4 Mar 2008 00:41:52 -0500 Subject: [rspec-users] Pretty story output for non-Rails project Message-ID: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> I'm taking my first fledgling steps driving a new ruby (non-rails) project with BDD. I've got a (test) story working. However, when I run the story in TextMate (via command-r), the output is plain text. See: http://skitch.com/georgeanderson/8grg/run-examples How do I get the output to look pretty (formatted)? rspec-1.1.3 OS X 10.5.2 TextMate v1.5.7 (1455) Thanks, /g -- George Anderson BenevolentCode LLC O: (410) 461-7553 C: (410) 218-5185 george at benevolentcode.com From dchelimsky at gmail.com Tue Mar 4 01:19:29 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Mar 2008 00:19:29 -0600 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> Message-ID: <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> On Mon, Mar 3, 2008 at 11:41 PM, George Anderson wrote: > I'm taking my first fledgling steps driving a new ruby (non-rails) > project with BDD. I've got a (test) story working. However, when I > run the story in TextMate (via command-r), the output is plain text. > > See: http://skitch.com/georgeanderson/8grg/run-examples > > How do I get the output to look pretty (formatted)? There's no textmate formatter for stories yet. In the mean time, you can do it on the command line with --format html and open the resulting file in a browser. Cheers, David > > rspec-1.1.3 > OS X 10.5.2 > TextMate v1.5.7 (1455) > > Thanks, > > /g > > -- > > George Anderson > > BenevolentCode LLC > O: (410) 461-7553 > C: (410) 218-5185 > > george at benevolentcode.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Mar 4 01:42:38 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Tue, 4 Mar 2008 07:42:38 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <57c63afe0803032136p7d98c14pbc6f6a662c8e22c6@mail.gmail.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> <40a3a0f9880ab0dddaab44675cb0c637@ruby-forum.com> <70B93E65-D33C-430F-A3E7-7A8D50EA94A9@googlemail.com> <997cd6a508b3f825a5e1ab9c922f8a50@ruby-forum.com> <57c63afe0803030315g3f4ff229r497649dc9b7ac490@mail.gmail.com> <7317f1371334b517a72ad383e8425fed@ruby-forum.com> <57c63afe0803030332y5ff467e7j7baa284813d0efb9@mail.gmail.com> <57c63afe0803032136p7d98c14pbc6f6a662c8e22c6@mail.gmail.com> Message-ID: Followed your example! Still getting the following error - Spec::Mocks::MockExpectationError in 'ArticlesController should list all article s' Mock 'ArticlesController' expected :find_city with (any args) once, but received it 0 times spec/controllers/articles_controller_spec.rb:3: Thanks, Namrata -- Posted via http://www.ruby-forum.com/. From cwdinfo at gmail.com Tue Mar 4 02:03:09 2008 From: cwdinfo at gmail.com (s.ross) Date: Mon, 3 Mar 2008 23:03:09 -0800 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> Message-ID: <24E8AEAD-6829-49BF-9A47-337261DD0DCB@gmail.com> On Mar 3, 2008, at 10:19 PM, David Chelimsky wrote: > In the mean time, you > can do it on the command line with --format html and open the > resulting file in a browser. Er... stories? How do you format story output as html? From aslak.hellesoy at gmail.com Tue Mar 4 02:45:41 2008 From: aslak.hellesoy at gmail.com (=?UTF-8?Q?Aslak_Helles=C3=B8y?=) Date: Tue, 4 Mar 2008 08:45:41 +0100 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <24E8AEAD-6829-49BF-9A47-337261DD0DCB@gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <24E8AEAD-6829-49BF-9A47-337261DD0DCB@gmail.com> Message-ID: <4AF92DB0-BAF9-41E6-904F-B51B129F8C88@gmail.com> Like David said. Not working for you? Aslak On Mar 4, 2008, at 8:03, "s.ross" wrote: > On Mar 3, 2008, at 10:19 PM, David Chelimsky wrote: > >> In the mean time, you >> can do it on the command line with --format html and open the >> resulting file in a browser. > > Er... stories? How do you format story output as html? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue Mar 4 07:11:17 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Tue, 4 Mar 2008 13:11:17 +0100 Subject: [rspec-users] stuck on testing validation In-Reply-To: <6466d9040803031524x42f2583ajb4776880b4a21fd8@mail.gmail.com> References: <6466d9040803031524x42f2583ajb4776880b4a21fd8@mail.gmail.com> Message-ID: Here is a very good example by Luke, which I think you should follow - http://www.lukeredpath.co.uk/2006/8/29/developing-a-rails-model-using-bdd-and-rspec-part-1 fyi, Namrata -- Posted via http://www.ruby-forum.com/. From mlangenberg at gmail.com Tue Mar 4 08:13:26 2008 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Tue, 4 Mar 2008 14:13:26 +0100 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. Message-ID: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> I really would like to know how people are using the Story and Example runner to write their software.It would be great to get some direction on it, because I think I'm missing some points. Taking the outside-in approach in thought: At first we write a high-level customer-facing story, this story fails. Then we start using mocks at object level to use them as a design tool, and so we implement the different layers of the system. After implementing the inner layer, the story should pass. When that happens we could remove the mocks and replace it with calls to the real code, making the suite less brittle (except for calls to external services/databases/file systems). So if the story passes all acceptance tests, why is there a need for examples at a lower level? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080304/84d32aee/attachment.html From ed.howland at gmail.com Tue Mar 4 08:18:01 2008 From: ed.howland at gmail.com (Ed Howland) Date: Tue, 4 Mar 2008 07:18:01 -0600 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> Message-ID: <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> On Tue, Mar 4, 2008 at 12:19 AM, David Chelimsky wrote: > On Mon, Mar 3, 2008 at 11:41 PM, George Anderson > wrote: > > I'm taking my first fledgling steps driving a new ruby (non-rails) > > project with BDD. I've got a (test) story working. However, when I > > run the story in TextMate (via command-r), the output is plain text. > > > > See: http://skitch.com/georgeanderson/8grg/run-examples > > > > How do I get the output to look pretty (formatted)? > > There's no textmate formatter for stories yet. In the mean time, you > can do it on the command line with --format html and open the > resulting file in a browser. > > Cheers, > David > David, Is this something in trunk? all.rb does not except any arguments, and there is no argument to the run command for this. Also, the svn server seems to be offline this morning. Ed > > > > > > rspec-1.1.3 > > OS X 10.5.2 > > TextMate v1.5.7 (1455) > > > > Thanks, > > > > /g > > > > -- > > > > George Anderson > > > > BenevolentCode LLC > > O: (410) 461-7553 > > C: (410) 218-5185 > > > > george at benevolentcode.com > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Ed Howland http://greenprogrammer.blogspot.com "The information transmitted is intended only for the person or entity to which it is addressed and may contain proprietary, confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." From aslak.hellesoy at gmail.com Tue Mar 4 08:24:15 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 4 Mar 2008 14:24:15 +0100 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> Message-ID: <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> On Tue, Mar 4, 2008 at 2:18 PM, Ed Howland wrote: > On Tue, Mar 4, 2008 at 12:19 AM, David Chelimsky wrote: > > On Mon, Mar 3, 2008 at 11:41 PM, George Anderson > > wrote: > > > I'm taking my first fledgling steps driving a new ruby (non-rails) > > > project with BDD. I've got a (test) story working. However, when I > > > run the story in TextMate (via command-r), the output is plain text. > > > > > > See: http://skitch.com/georgeanderson/8grg/run-examples > > > > > > How do I get the output to look pretty (formatted)? > > > > There's no textmate formatter for stories yet. In the mean time, you > > can do it on the command line with --format html and open the > > resulting file in a browser. > > > > Cheers, > > David > > > > David, > > Is this something in trunk? all.rb does not except any arguments, and > there is no argument to the run command for this. Also, the svn server > seems to be offline this morning. > This is in the latest release. Just pass --format html on the ocmmand line. ARGS is read by one of the internal files in RSpec - not all.rb. Try --help too. Aslak > > Ed > > > > > > > > > > > > rspec-1.1.3 > > > OS X 10.5.2 > > > TextMate v1.5.7 (1455) > > > > > > Thanks, > > > > > > /g > > > > > > -- > > > > > > George Anderson > > > > > > BenevolentCode LLC > > > O: (410) 461-7553 > > > C: (410) 218-5185 > > > > > > george at benevolentcode.com > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > "The information transmitted is intended only for the person or entity > to which it is addressed and may contain proprietary, confidential > and/or legally privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance > upon, this information by persons or entities other than the intended > recipient is prohibited. If you received this in error, please contact > the sender and delete the material from all computers." > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From chris at edendevelopment.co.uk Tue Mar 4 08:43:09 2008 From: chris at edendevelopment.co.uk (Chris Parsons) Date: Tue, 4 Mar 2008 13:43:09 +0000 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> Message-ID: On 4 Mar 2008, at 13:13, Matthijs Langenberg wrote: > Taking the outside-in approach in thought: > > At first we write a high-level customer-facing story, this story > fails. > Then we start using mocks at object level to use them as a design > tool, > and so we implement the different layers of the system. > After implementing the inner layer, the story should pass. > When that happens we could remove the mocks and replace it with > calls to the real code, making the suite less brittle (except for > calls to external services/databases/file systems). Don't use mocks at the story level. IMHO stories should always be using the full stack. This includes your database, but you might be permitted to exclude external services such as credit card billing systems. However, if you can set up a sandbox to test against (such as the Paypal sandbox), all to the good. We proceed based on two principles: A failure in a story means you change specs not code. A failure in a spec means you change the code. This is how we do it (assuming a rails application): 1. Write customer story, all steps are pending: Scenario: Viewing the front page When I view the front page Then I see the text 'welcome to the app' 2. Write the first step in the story: When "I view the front page" do get "/" end This then fails, as I don't have a front page yet! 3. Pay attention to the error given by the story, and fix that *by writing a spec*. In this case it'll be complaining that the controller doesn't exist. At this point I drop down to the specs as a failing story means we need a spec: describe MainController do end 4. Make your specs pass. 'rake spec' then fails, as MainController doesn't exist. In this case, I add a controller and a route (by hand, none of that scaffold business): class MainController < ApplicationController end 5. Run the story again if you need to, and use that as a guide to write more specs. Repeat steps 4 and 5. To continue the example - in this case it'll probably complain about no index action: describe MainController do it "should handle an index action" do get :index end end and then, to fix the spec: class MainController < ApplicationController def index end end Then it'll most likely complain about not having an index.html.erb. Because controller specs don't render the page, you'll need an an index.html.erb_spec.rb to test the view properly. And so on. Sound like a lot of work, but given practice you can zip through these steps very quickly. You also get a free 'focusing tool' (lose sight of where you are? just run the story test and write more specs). Hope this is helpful. Maybe I should write up an extended example as a blog post, including mocking etc, as it seems to come up a lot. Thanks Chris PS: Excuse the spelling/coding mistakes in the (untested) code :) Corrections and comments as to the methodology here most welcome. -- Chris Parsons Managing Director Eden Development (UK) Ltd chris at edendevelopment.co.uk www.edendevelopment.co.uk 0845 0097 094 po box 425, winchester, so23 0wy, uk Map: http://pininthemap.com/edendevelopment Tried Pin in the Map? Mark a map location, add text, send to friends. http://pininthemap.com This electronic message and all contents contain information from the sender which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee(s) only. If you are not an addressee, any copying, disclosure, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify the sender by reply e-mail and destroy the original message and all copies. The sender does not accept liability for any errors or omissions. From dchelimsky at gmail.com Tue Mar 4 09:13:50 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Mar 2008 08:13:50 -0600 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> Message-ID: <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> On Tue, Mar 4, 2008 at 7:13 AM, Matthijs Langenberg wrote: > I really would like to know how people are using the Story and Example > runner to write their software. > It would be great to get some direction on it, because I think I'm missing > some points. > > Taking the outside-in approach in thought: > > At first we write a high-level customer-facing story, this story fails. > Then we start using mocks at object level to use them as a design tool, > and so we implement the different layers of the system. > After implementing the inner layer, the story should pass. > When that happens we could remove the mocks and replace it with calls to the > real code, I do this sometimes - removing the mocks - as long as the objects are trivial to set up and they don't have dependencies that I don't want to expose. There's no one way to do this, and I'll sometimes remove mocks and reintroduce them over the life of a project. > making the suite less brittle What brittle means is a bit subjective here. Just a lengthy conversation about this in irc last night. The guy with whom I was chatting prefers to not use mocks because he'd rather see a change cause a bunch of lower level examples to fail than stories. From what I can tell, he doesn't like to use mocks even temporarily, in process. His approach has the benefit that you learn about side effects of your changes faster, and the cost that it means you sometimes have more "red bar" to wade through while you get things right. My approach has the benefit that you can address side effects of your changes with a green bar helping you know that the smaller bits (objects and methods) are functioning, and the cost that you sometimes don't learn about side effects until you run your stories (or integration suite). Neither solution is perfect. You just have to pick your poison. > (except for calls to external > services/databases/file systems). This is a funny thing about ruby, specifically rails. One of the hallmarks of OO is a high level of decoupling - especially decoupling your code from 3rd party code through adapters. There are a couple of reasons for this. One is that having an adapter lets you write exactly the code that you want to write throughout most of your system, rather than being subject to the naming conventions of the 3rd party library that might clash with those in your system or even with your domain. The other is that if you decide to switch to a different library, you're pretty well hosed unless you have adapters. If you look at the competitors to ActiveRecord, like Og and Datamapper, they are all VERY similar syntactically. Why? Two reasons I think. One is that AR got a lot of things right from a domain perspective. The other is that calls to AR internals have leaked out to a lot of controllers and even views: Person.find(:all, :conditions => ['active = ?', true]) In spite of guidelines all over the web that say that this should be wrapped in a #find_active method in the model, these sorts of things pop up all over the place anyhow. > So if the story passes all acceptance tests, why is there a need for > examples at a lower level? So that you can get things working one step at a time, and then change things as needed one step at a time, with green bars keeping you sane, stress free, and even happy all the way through. HTH, David From dchelimsky at gmail.com Tue Mar 4 09:17:30 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Mar 2008 08:17:30 -0600 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> Message-ID: <57c63afe0803040617h9ce5f15sa991f7337a2b8133@mail.gmail.com> On Tue, Mar 4, 2008 at 8:13 AM, David Chelimsky wrote: > On Tue, Mar 4, 2008 at 7:13 AM, Matthijs Langenberg > wrote: > > I really would like to know how people are using the Story and Example > > runner to write their software. > > It would be great to get some direction on it, because I think I'm missing > > some points. > > > > Taking the outside-in approach in thought: > > > > At first we write a high-level customer-facing story, this story fails. > > Then we start using mocks at object level to use them as a design tool, > > and so we implement the different layers of the system. > > After implementing the inner layer, the story should pass. > > When that happens we could remove the mocks and replace it with calls to the > > real code, > > I do this sometimes - removing the mocks - as long as the objects are > trivial to set up and they don't have dependencies that I don't want > to expose. There's no one way to do this, and I'll sometimes remove > mocks and reintroduce them over the life of a project. > > > > making the suite less brittle > > What brittle means is a bit subjective here. Just a lengthy > conversation about this in irc last night. The guy with whom I was > chatting prefers to not use mocks because he'd rather see a change > cause a bunch of lower level examples to fail than stories. From what > I can tell, he doesn't like to use mocks even temporarily, in process. > > His approach has the benefit that you learn about side effects of your > changes faster, and the cost that it means you sometimes have more > "red bar" to wade through while you get things right. > > My approach has the benefit that you can address side effects of your > changes with a green bar helping you know that the smaller bits > (objects and methods) are functioning, and the cost that you sometimes > don't learn about side effects until you run your stories (or > integration suite). > > Neither solution is perfect. You just have to pick your poison. > > > > (except for calls to external > > services/databases/file systems). > > This is a funny thing about ruby, specifically rails. > > One of the hallmarks of OO is a high level of decoupling - especially > decoupling your code from 3rd party code through adapters. There are a > couple of reasons for this. > > One is that having an adapter lets you write exactly the code that you > want to write throughout most of your system, rather than being > subject to the naming conventions of the 3rd party library that might > clash with those in your system or even with your domain. > > The other is that if you decide to switch to a different library, > you're pretty well hosed unless you have adapters. If you look at the > competitors to ActiveRecord, like Og and Datamapper, they are all VERY > similar syntactically. Why? Two reasons I think. One is that AR got a > lot of things right from a domain perspective. The other is that calls > to AR internals have leaked out to a lot of controllers and even > views: > > Person.find(:all, :conditions => ['active = ?', true]) > > In spite of guidelines all over the web that say that this should be > wrapped in a #find_active method in the model, these sorts of things > pop up all over the place anyhow. Finishing up that thought - find_active is an adapter - just at the method level instead of the object level. > > So if the story passes all acceptance tests, why is there a need for > > examples at a lower level? > > So that you can get things working one step at a time, and then change > things as needed one step at a time, with green bars keeping you sane, > stress free, and even happy all the way through. > > HTH, > David > From ed.howland at gmail.com Tue Mar 4 09:32:12 2008 From: ed.howland at gmail.com (Ed Howland) Date: Tue, 4 Mar 2008 08:32:12 -0600 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> Message-ID: <3df642dd0803040632s793d725byfd4509202d6312ed@mail.gmail.com> On Tue, Mar 4, 2008 at 7:24 AM, aslak hellesoy wrote: > > This is in the latest release. Just pass --format html on the ocmmand > line. ARGS is read by one of the internal files in RSpec - not all.rb. > Try --help too. > > Aslak Thanks, Aslak. Seems I was consuming ARGV prematurely in my own story runner. The output seems a bit crude. I have to drop the output in public and copy the css there, or put it in vendors/plugins/rspec/story_server/prototype. Also, I can't seem to get the summarized output like the example in there. Ed -- Ed Howland http://greenprogrammer.blogspot.com From aslak.hellesoy at gmail.com Tue Mar 4 10:24:43 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 4 Mar 2008 16:24:43 +0100 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <3df642dd0803040632s793d725byfd4509202d6312ed@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> <3df642dd0803040632s793d725byfd4509202d6312ed@mail.gmail.com> Message-ID: <8d961d900803040724i53bf6c05xbc201cecbda4984e@mail.gmail.com> On Tue, Mar 4, 2008 at 3:32 PM, Ed Howland wrote: > On Tue, Mar 4, 2008 at 7:24 AM, aslak hellesoy wrote: > > > > > This is in the latest release. Just pass --format html on the ocmmand > > line. ARGS is read by one of the internal files in RSpec - not all.rb. > > Try --help too. > > > > Aslak > > Thanks, Aslak. Seems I was consuming ARGV prematurely in my own story runner. > > The output seems a bit crude. I have to drop the output in public and > copy the css there, or put it in > vendors/plugins/rspec/story_server/prototype. > > Also, I can't seem to get the summarized output like the example in there. > Yeah, it's only a start. Patches are welcome as usual. Aslak > Ed > > -- > > Ed Howland > http://greenprogrammer.blogspot.com > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Tue Mar 4 11:43:01 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Mar 2008 08:43:01 -0800 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> Message-ID: <810a540e0803040843o5a082292u67e67826748bc727@mail.gmail.com> On Tue, Mar 4, 2008 at 6:13 AM, David Chelimsky wrote: > What brittle means is a bit subjective here. Just a lengthy > conversation about this in irc last night. The guy with whom I was > chatting prefers to not use mocks because he'd rather see a change > cause a bunch of lower level examples to fail than stories. Do you happen to have a log of that convo? Pat From dchelimsky at gmail.com Tue Mar 4 11:46:11 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Mar 2008 10:46:11 -0600 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <810a540e0803040843o5a082292u67e67826748bc727@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> <810a540e0803040843o5a082292u67e67826748bc727@mail.gmail.com> Message-ID: <57c63afe0803040846q2dc3a2k8bd695c8e2a2be86@mail.gmail.com> On Tue, Mar 4, 2008 at 10:43 AM, Pat Maddox wrote: > On Tue, Mar 4, 2008 at 6:13 AM, David Chelimsky wrote: > > > What brittle means is a bit subjective here. Just a lengthy > > conversation about this in irc last night. The guy with whom I was > > chatting prefers to not use mocks because he'd rather see a change > > cause a bunch of lower level examples to fail than stories. > > Do you happen to have a log of that convo? It was in caboose - are those public? > > Pat > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mhennemeyer at googlemail.com Tue Mar 4 11:51:15 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Tue, 4 Mar 2008 17:51:15 +0100 Subject: [rspec-users] rspec vs. test::more Message-ID: <68F9669F-5D69-415E-96CD-B0A679DC0E0C@googlemail.com> Hey all, you HAVE to read this blog post: http://blog.jrock.us/articles/RSpec%20vs.%20Test::More.pod#comments My favorite parts are: 1) ... some rspec code ... > For the sake of comparison lets translate this directly into perl: ... some perl code ... 2) >First, notice that the rspec-version isn't actually ruby code. It's not any real language. For the sake of comparison i have translated this blog post in Amiga Assembler and investigated that its actually a cheat for MonkeyIsland (SMI) . Cheers From pergesu at gmail.com Tue Mar 4 12:11:26 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Mar 2008 09:11:26 -0800 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <57c63afe0803040846q2dc3a2k8bd695c8e2a2be86@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> <810a540e0803040843o5a082292u67e67826748bc727@mail.gmail.com> <57c63afe0803040846q2dc3a2k8bd695c8e2a2be86@mail.gmail.com> Message-ID: <810a540e0803040911i467aac50v5af6340a0921f8e5@mail.gmail.com> On Tue, Mar 4, 2008 at 8:46 AM, David Chelimsky wrote: > > On Tue, Mar 4, 2008 at 10:43 AM, Pat Maddox wrote: > > On Tue, Mar 4, 2008 at 6:13 AM, David Chelimsky wrote: > > > > > What brittle means is a bit subjective here. Just a lengthy > > > conversation about this in irc last night. The guy with whom I was > > > chatting prefers to not use mocks because he'd rather see a change > > > cause a bunch of lower level examples to fail than stories. > > > > Do you happen to have a log of that convo? > > It was in caboose - are those public? Nope From cwdinfo at gmail.com Tue Mar 4 12:11:26 2008 From: cwdinfo at gmail.com (s.ross) Date: Tue, 4 Mar 2008 09:11:26 -0800 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> Message-ID: <7B14FCE3-7789-48B2-BE9B-52025666057E@gmail.com> On Mar 4, 2008, at 5:24 AM, aslak hellesoy wrote: > This is in the latest release. Just pass --format html on the ocmmand > line. ARGS is read by one of the internal files in RSpec - not all.rb. > Try --help too. > > Aslak I must be dense: RSpec-1.1.3 (build 20080131122909) - BDD for Ruby ruby stories/all.rb --format html and this outputs text. Where would the html go? From aslak.hellesoy at gmail.com Tue Mar 4 12:26:10 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 4 Mar 2008 18:26:10 +0100 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <7B14FCE3-7789-48B2-BE9B-52025666057E@gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> <7B14FCE3-7789-48B2-BE9B-52025666057E@gmail.com> Message-ID: <8d961d900803040926y59a6a5dv12d6ae57000190b3@mail.gmail.com> On Tue, Mar 4, 2008 at 6:11 PM, s.ross wrote: > On Mar 4, 2008, at 5:24 AM, aslak hellesoy wrote: > > > This is in the latest release. Just pass --format html on the ocmmand > > line. ARGS is read by one of the internal files in RSpec - not all.rb. > > Try --help too. > > > > Aslak > > I must be dense: > > RSpec-1.1.3 (build 20080131122909) - BDD for Ruby > > ruby stories/all.rb --format html > > and this outputs text. Where would the html go? > I forgot - this is an old bug - not working with rails, only "vanilla" http://rspec.lighthouseapp.com/projects/5645/tickets/113-13547-story-runner-html-formatted-output Aslak > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Tue Mar 4 12:52:41 2008 From: cwdinfo at gmail.com (s.ross) Date: Tue, 4 Mar 2008 09:52:41 -0800 Subject: [rspec-users] Pretty story output for non-Rails project In-Reply-To: <8d961d900803040926y59a6a5dv12d6ae57000190b3@mail.gmail.com> References: <782d66f30803032141o7d2d8ca1v56f24573a0eeb55d@mail.gmail.com> <57c63afe0803032219q3f6f532dmce3f30caa2f320b0@mail.gmail.com> <3df642dd0803040518q11bdba2fj1eac2a73f467669b@mail.gmail.com> <8d961d900803040524k37da5bdw58000689a89b0cb0@mail.gmail.com> <7B14FCE3-7789-48B2-BE9B-52025666057E@gmail.com> <8d961d900803040926y59a6a5dv12d6ae57000190b3@mail.gmail.com> Message-ID: <0ECB8EDB-3FF9-42CF-9908-93AA70953181@gmail.com> On Mar 4, 2008, at 9:26 AM, aslak hellesoy wrote: > I forgot - this is an old bug - not working with rails, only "vanilla" > http://rspec.lighthouseapp.com/projects/5645/tickets/113-13547-story-runner-html-formatted-output Ok, I feel a little less dense now :) From coreyhaines at gmail.com Tue Mar 4 15:04:50 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 4 Mar 2008 15:04:50 -0500 Subject: [rspec-users] textmate bundle Message-ID: <6bdacb70803041204g4814bc43p4bf823cebab10429@mail.gmail.com> Hi, I'm just getting e set up on my machine, and I was wondering if someone could point me to the current rspec bundle for textmate? I googled and found a million of them, I think. Thanks. -Corey -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080304/3484d010/attachment.html From dchelimsky at gmail.com Tue Mar 4 15:13:46 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 4 Mar 2008 14:13:46 -0600 Subject: [rspec-users] textmate bundle In-Reply-To: <6bdacb70803041204g4814bc43p4bf823cebab10429@mail.gmail.com> References: <6bdacb70803041204g4814bc43p4bf823cebab10429@mail.gmail.com> Message-ID: <57c63afe0803041213x53d2aa77q20aa531c94e128f1@mail.gmail.com> On Tue, Mar 4, 2008 at 2:04 PM, Corey Haines wrote: > Hi, > > I'm just getting e set up on my machine, and I was wondering if someone > could point me to the current rspec bundle for textmate? I googled and found > a million of them, I think. It's in the rspec repos: http://rspec.rubyforge.org/svn/trunk git://github.com/dchelimsky/rspec.git git://gitorious.org/rspec/mainline.git > > Thanks. > -Corey > > -- > http://www.coreyhaines.com > The Internet's Premiere source of information about Corey Haines > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From coreyhaines at gmail.com Tue Mar 4 15:18:52 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 4 Mar 2008 15:18:52 -0500 Subject: [rspec-users] textmate bundle In-Reply-To: <57c63afe0803041213x53d2aa77q20aa531c94e128f1@mail.gmail.com> References: <6bdacb70803041204g4814bc43p4bf823cebab10429@mail.gmail.com> <57c63afe0803041213x53d2aa77q20aa531c94e128f1@mail.gmail.com> Message-ID: <6bdacb70803041218v7cc09156sc0148871b78b6048@mail.gmail.com> Thanks, David. On Tue, Mar 4, 2008 at 3:13 PM, David Chelimsky wrote: > On Tue, Mar 4, 2008 at 2:04 PM, Corey Haines > wrote: > > Hi, > > > > I'm just getting e set up on my machine, and I was wondering if someone > > could point me to the current rspec bundle for textmate? I googled and > found > > a million of them, I think. > > It's in the rspec repos: > > http://rspec.rubyforge.org/svn/trunk > git://github.com/dchelimsky/rspec.git > git://gitorious.org/rspec/mainline.git > > > > > Thanks. > > -Corey > > > > -- > > http://www.coreyhaines.com > > The Internet's Premiere source of information about Corey Haines > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080304/31114379/attachment.html From korny at sietsma.com Tue Mar 4 15:22:54 2008 From: korny at sietsma.com (Korny Sietsma) Date: Wed, 5 Mar 2008 07:22:54 +1100 Subject: [rspec-users] rspec vs. test::more In-Reply-To: <68F9669F-5D69-415E-96CD-B0A679DC0E0C@googlemail.com> References: <68F9669F-5D69-415E-96CD-B0A679DC0E0C@googlemail.com> Message-ID: <8e15872b0803041222p6ababf83mb96fd7510853a257@mail.gmail.com> Wow - both funny and a little tragic. He really doesn't understand what "readable" means, does he? "you keep using that word - I do not think it means what you think it means" - Korny On Wed, Mar 5, 2008 at 3:51 AM, Matthias Hennemeyer < mhennemeyer at googlemail.com> wrote: > Hey all, > you HAVE to read this blog post: > > http://blog.jrock.us/articles/RSpec%20vs.%20Test::More.pod#comments > > My favorite parts are: > > 1) > ... some rspec code ... > > For the sake of comparison lets translate this directly into perl: > ... some perl code ... > 2) > >First, notice that the rspec-version isn't actually ruby code. It's > not any real language. > > For the sake of comparison i have translated this blog post in Amiga > Assembler and investigated that its actually a cheat for MonkeyIsland > (SMI) . > > Cheers > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Kornelis Sietsma korny at my surname dot com kornys at gmail dot com on google chat -- kornys on skype "we do what we must, because we can" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/ce4c16f7/attachment.html From coreyhaines at gmail.com Tue Mar 4 16:28:17 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 4 Mar 2008 16:28:17 -0500 Subject: [rspec-users] rspec vs. test::more In-Reply-To: <8e15872b0803041222p6ababf83mb96fd7510853a257@mail.gmail.com> References: <68F9669F-5D69-415E-96CD-B0A679DC0E0C@googlemail.com> <8e15872b0803041222p6ababf83mb96fd7510853a257@mail.gmail.com> Message-ID: <6bdacb70803041328l658dba89j71b76a997c21bed5@mail.gmail.com> I like this line: "That sounds like something I should pay you a lot of money for! Sign me up!" David, I didn't realize that I was racking up a huge monetary debt to you. -Corey On Tue, Mar 4, 2008 at 3:22 PM, Korny Sietsma wrote: > Wow - both funny and a little tragic. > He really doesn't understand what "readable" means, does he? > > "you keep using that word - I do not think it means what you think it > means" > > - Korny > > > On Wed, Mar 5, 2008 at 3:51 AM, Matthias Hennemeyer < > mhennemeyer at googlemail.com> wrote: > > > Hey all, > > you HAVE to read this blog post: > > > > http://blog.jrock.us/articles/RSpec%20vs.%20Test::More.pod#comments > > > > My favorite parts are: > > > > 1) > > ... some rspec code ... > > > For the sake of comparison lets translate this directly into perl: > > ... some perl code ... > > 2) > > >First, notice that the rspec-version isn't actually ruby code. It's > > not any real language. > > > > For the sake of comparison i have translated this blog post in Amiga > > Assembler and investigated that its actually a cheat for MonkeyIsland > > (SMI) . > > > > Cheers > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Kornelis Sietsma korny at my surname dot com > kornys at gmail dot com on google chat -- kornys on skype > "we do what we must, because we can" > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080304/cb680ff1/attachment-0001.html From pergesu at gmail.com Tue Mar 4 17:28:47 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Mar 2008 14:28:47 -0800 Subject: [rspec-users] What is your workflow? Or how to use the story runner the right way. In-Reply-To: <810a540e0803040911i467aac50v5af6340a0921f8e5@mail.gmail.com> References: <27c0ac6d0803040513l7b4fba44nfb3b314aae1bdcc3@mail.gmail.com> <57c63afe0803040613xa3e6fd8wdc4a4a227ec494bc@mail.gmail.com> <810a540e0803040843o5a082292u67e67826748bc727@mail.gmail.com> <57c63afe0803040846q2dc3a2k8bd695c8e2a2be86@mail.gmail.com> <810a540e0803040911i467aac50v5af6340a0921f8e5@mail.gmail.com> Message-ID: <810a540e0803041428o6aa78595w8ed9f40a86fa7a66@mail.gmail.com> On Tue, Mar 4, 2008 at 9:11 AM, Pat Maddox wrote: > On Tue, Mar 4, 2008 at 8:46 AM, David Chelimsky wrote: > > > > On Tue, Mar 4, 2008 at 10:43 AM, Pat Maddox wrote: > > > On Tue, Mar 4, 2008 at 6:13 AM, David Chelimsky wrote: > > > > > > > What brittle means is a bit subjective here. Just a lengthy > > > > conversation about this in irc last night. The guy with whom I was > > > > chatting prefers to not use mocks because he'd rather see a change > > > > cause a bunch of lower level examples to fail than stories. > > > > > > Do you happen to have a log of that convo? > > > > It was in caboose - are those public? > > Nope Nevermind, turns out that I work with this nutcase From pergesu at gmail.com Tue Mar 4 18:22:45 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 4 Mar 2008 15:22:45 -0800 Subject: [rspec-users] rspec vs. test::more In-Reply-To: <6bdacb70803041328l658dba89j71b76a997c21bed5@mail.gmail.com> References: <68F9669F-5D69-415E-96CD-B0A679DC0E0C@googlemail.com> <8e15872b0803041222p6ababf83mb96fd7510853a257@mail.gmail.com> <6bdacb70803041328l658dba89j71b76a997c21bed5@mail.gmail.com> Message-ID: <810a540e0803041522o71f73042o975759de8f1a72ae@mail.gmail.com> On 3/4/08, Corey Haines wrote: > I like this line: > > "That sounds like something I should pay you a lot of money for! Sign me > up!" > > David, I didn't realize that I was racking up a huge monetary debt to you. > > -Corey You'll pay up if you value your kneecaps. Pat From lists at ruby-forum.com Wed Mar 5 05:25:05 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Wed, 5 Mar 2008 11:25:05 +0100 Subject: [rspec-users] having trouble specing an ajax request Message-ID: <00b87bf2a68372c30f941e500c91ed10@ruby-forum.com> Do I need to spec an AR. If yes, what is the best way to spec this. here is the code - def index @deals = Deal.paginate(:all, :conditions => prepare_search_conditions, :order => 'created_at DESC', :page => params[:page] ) if request.xhr? render :update do |page| page.replace_html "table", :partial => "/deals/front/listing" end end I am new to Rspec. Is this the right way? it "should list all deals" do controller.stub!(:prepare_search_conditions).and_return(true) Deal.should_receive(:paginate).with(:all, {:conditions=>true, :order=>"created_at DESC", :page=>nil}).and_return(@deals) get :list controller.expect_render(:partial => '/deals/cms/list') end Thanks, Namrata. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Mar 5 05:27:49 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Wed, 5 Mar 2008 11:27:49 +0100 Subject: [rspec-users] having trouble specing an ajax request In-Reply-To: <00b87bf2a68372c30f941e500c91ed10@ruby-forum.com> References: <00b87bf2a68372c30f941e500c91ed10@ruby-forum.com> Message-ID: Sorry I pasted the wrong spec. Here is correct one - it "should show deals listing" do controller.stub!(:prepare_search_conditions).and_return(true) Deal.should_receive(:paginate).and_return(@deals) get :index controller.expect_render(:partial => '/deals/front/listing') end > Thanks, > Namrata. -- Posted via http://www.ruby-forum.com/. From toastkid.williams at gmail.com Wed Mar 5 05:40:10 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 5 Mar 2008 10:40:10 +0000 Subject: [rspec-users] has_many_polymorphs is breaking my spec file Message-ID: Hey folks I have a bunch of classes that are polymorphs, with has_many_polymorphs (they are all 'labellable', which is similar to being 'taggable' in the acts_as_taggable scheme). I have a couple of modules, LabellableInstanceMethods and LabellableClassMethods in a file called labellable_methods.rb. The classes all get labelled with 'properties', and i set out to write the Property class first, using bdd of course. This all went fine. However, when i came to start testing that the labelling was working properly, i added the following code: POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, :lessons, :courses] #this is breaking tests currently has_many_polymorphs :labellables, :from => POLYMORPHIC_TABLENAMES, :through => :labellings, :dependent => :destroy Now, whenever i run the spec file, it bombs out as soon as it hits a reference to the Property class (at the start of my main describe block), saying "/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in `load_missing_constant': Expected /home/jars/rails/lesson_planner/branches/max/app/models/property.rb to define Property (LoadError)" If i play around with the labelling system in the console, it seems to work fine: ie, the above code works 'normally', but is totally breaking the spec file. Does anyone have any ideas about this? It's driving me crazy and stopping me speccing other aspects of my labelling system. thanks max -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/aa9ececa/attachment.html From dchelimsky at gmail.com Wed Mar 5 08:37:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Mar 2008 07:37:09 -0600 Subject: [rspec-users] has_many_polymorphs is breaking my spec file In-Reply-To: References: Message-ID: <57c63afe0803050537h79c41ed1qa810f4bc55b144ed@mail.gmail.com> On Wed, Mar 5, 2008 at 4:40 AM, Max Williams wrote: > Hey folks > > I have a bunch of classes that are polymorphs, with has_many_polymorphs > (they are all 'labellable', which is similar to being 'taggable' in the > acts_as_taggable scheme). I have a couple of modules, > LabellableInstanceMethods and LabellableClassMethods in a file called > labellable_methods.rb. > > The classes all get labelled with 'properties', and i set out to write the > Property class first, using bdd of course. This all went fine. However, > when i came to start testing that the labelling was working properly, i > added the following code: > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, :lessons, > :courses] > #this is breaking tests currently > has_many_polymorphs :labellables, > :from => POLYMORPHIC_TABLENAMES, > :through => :labellings, > :dependent => :destroy > > Now, whenever i run the spec file, it bombs out as soon as it hits a > reference to the Property class (at the start of my main describe block), > saying > "/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in > `load_missing_constant': Expected > /home/jars/rails/lesson_planner/branches/max/app/models/property.rb to > define Property (LoadError)" This error is coming from Rails. Keep in mind that RSpec wrap Rails' built-in test infrastructure. Can you try writing the same examples in test/unit and see if they work? > > If i play around with the labelling system in the console, it seems to work > fine: ie, the above code works 'normally', but is totally breaking the spec > file. > > Does anyone have any ideas about this? It's driving me crazy and stopping > me speccing other aspects of my labelling system. > > thanks > max > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Wed Mar 5 08:53:16 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 5 Mar 2008 13:53:16 +0000 Subject: [rspec-users] has_many_polymorphs is breaking my spec file In-Reply-To: <57c63afe0803050537h79c41ed1qa810f4bc55b144ed@mail.gmail.com> References: <57c63afe0803050537h79c41ed1qa810f4bc55b144ed@mail.gmail.com> Message-ID: Hmm, the results are exactly the same, down to the error message. And, as before, if i remove the has_many_polymorphs declaration there's no problem. So its not rspec's fault. But i'm still no closer to finding out what it is about my has_many_polymorphs declaration that the tests don't like. :( On 05/03/2008, David Chelimsky wrote: > > On Wed, Mar 5, 2008 at 4:40 AM, Max Williams > wrote: > > Hey folks > > > > I have a bunch of classes that are polymorphs, with has_many_polymorphs > > (they are all 'labellable', which is similar to being 'taggable' in the > > acts_as_taggable scheme). I have a couple of modules, > > LabellableInstanceMethods and LabellableClassMethods in a file called > > labellable_methods.rb. > > > > The classes all get labelled with 'properties', and i set out to write > the > > Property class first, using bdd of course. This all went > fine. However, > > when i came to start testing that the labelling was working properly, i > > added the following code: > > > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, > :lessons, > > :courses] > > #this is breaking tests currently > > has_many_polymorphs :labellables, > > :from => POLYMORPHIC_TABLENAMES, > > :through => :labellings, > > :dependent => :destroy > > > > Now, whenever i run the spec file, it bombs out as soon as it hits a > > reference to the Property class (at the start of my main describe > block), > > saying > > > "/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in > > `load_missing_constant': Expected > > /home/jars/rails/lesson_planner/branches/max/app/models/property.rb to > > define Property (LoadError)" > > > This error is coming from Rails. Keep in mind that RSpec wrap Rails' > built-in test infrastructure. Can you try writing the same examples in > test/unit and see if they work? > > > > > > If i play around with the labelling system in the console, it seems to > work > > fine: ie, the above code works 'normally', but is totally breaking the > spec > > file. > > > > Does anyone have any ideas about this? It's driving me crazy and > stopping > > me speccing other aspects of my labelling system. > > > > thanks > > max > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/517b1527/attachment.html From dchelimsky at gmail.com Wed Mar 5 09:01:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Mar 2008 08:01:25 -0600 Subject: [rspec-users] has_many_polymorphs is breaking my spec file In-Reply-To: References: <57c63afe0803050537h79c41ed1qa810f4bc55b144ed@mail.gmail.com> Message-ID: <57c63afe0803050601l2aa292abtb4eeb9e364db31@mail.gmail.com> On Wed, Mar 5, 2008 at 7:53 AM, Max Williams wrote: > Hmm, the results are exactly the same, down to the error message. And, as > before, if i remove the has_many_polymorphs declaration there's no problem. > > So its not rspec's fault. But i'm still no closer to finding out what it is > about my has_many_polymorphs declaration that the tests don't like. :( Have you posted to the rails list? > > > > On 05/03/2008, David Chelimsky wrote: > > On Wed, Mar 5, 2008 at 4:40 AM, Max Williams > > wrote: > > > Hey folks > > > > > > I have a bunch of classes that are polymorphs, with has_many_polymorphs > > > (they are all 'labellable', which is similar to being 'taggable' in the > > > acts_as_taggable scheme). I have a couple of modules, > > > LabellableInstanceMethods and LabellableClassMethods in a file called > > > labellable_methods.rb. > > > > > > The classes all get labelled with 'properties', and i set out to write > the > > > Property class first, using bdd of course. This all went fine. > However, > > > when i came to start testing that the labelling was working properly, i > > > added the following code: > > > > > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, > :lessons, > > > :courses] > > > #this is breaking tests currently > > > has_many_polymorphs :labellables, > > > :from => POLYMORPHIC_TABLENAMES, > > > :through => :labellings, > > > :dependent => :destroy > > > > > > Now, whenever i run the spec file, it bombs out as soon as it hits a > > > reference to the Property class (at the start of my main describe > block), > > > saying > > > > "/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in > > > `load_missing_constant': Expected > > > /home/jars/rails/lesson_planner/branches/max/app/models/property.rb to > > > define Property (LoadError)" > > > > > > This error is coming from Rails. Keep in mind that RSpec wrap Rails' > > built-in test infrastructure. Can you try writing the same examples in > > test/unit and see if they work? > > > > > > > > > > If i play around with the labelling system in the console, it seems to > work > > > fine: ie, the above code works 'normally', but is totally breaking the > spec > > > file. > > > > > > Does anyone have any ideas about this? It's driving me crazy and > stopping > > > me speccing other aspects of my labelling system. > > > > > > thanks > > > max > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Wed Mar 5 09:17:55 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 5 Mar 2008 14:17:55 +0000 Subject: [rspec-users] has_many_polymorphs is breaking my spec file In-Reply-To: <57c63afe0803050601l2aa292abtb4eeb9e364db31@mail.gmail.com> References: <57c63afe0803050537h79c41ed1qa810f4bc55b144ed@mail.gmail.com> <57c63afe0803050601l2aa292abtb4eeb9e364db31@mail.gmail.com> Message-ID: no, just the ruby forum. I'll try the rails list next. thanks On 05/03/2008, David Chelimsky wrote: > > On Wed, Mar 5, 2008 at 7:53 AM, Max Williams > > wrote: > > > Hmm, the results are exactly the same, down to the error message. And, > as > > before, if i remove the has_many_polymorphs declaration there's no > problem. > > > > So its not rspec's fault. But i'm still no closer to finding out what > it is > > about my has_many_polymorphs declaration that the tests don't like. :( > > > Have you posted to the rails list? > > > > > > > > > > On 05/03/2008, David Chelimsky wrote: > > > On Wed, Mar 5, 2008 at 4:40 AM, Max Williams > > > wrote: > > > > Hey folks > > > > > > > > I have a bunch of classes that are polymorphs, with > has_many_polymorphs > > > > (they are all 'labellable', which is similar to being 'taggable' in > the > > > > acts_as_taggable scheme). I have a couple of modules, > > > > LabellableInstanceMethods and LabellableClassMethods in a file > called > > > > labellable_methods.rb. > > > > > > > > The classes all get labelled with 'properties', and i set out to > write > > the > > > > Property class first, using bdd of course. This all went fine. > > However, > > > > when i came to start testing that the labelling was working > properly, i > > > > added the following code: > > > > > > > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, > > :lessons, > > > > :courses] > > > > #this is breaking tests currently > > > > has_many_polymorphs :labellables, > > > > :from => POLYMORPHIC_TABLENAMES, > > > > :through => :labellings, > > > > :dependent => :destroy > > > > > > > > Now, whenever i run the spec file, it bombs out as soon as it hits a > > > > reference to the Property class (at the start of my main describe > > block), > > > > saying > > > > > > > "/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in > > > > `load_missing_constant': Expected > > > > /home/jars/rails/lesson_planner/branches/max/app/models/property.rb > to > > > > define Property (LoadError)" > > > > > > > > > This error is coming from Rails. Keep in mind that RSpec wrap Rails' > > > built-in test infrastructure. Can you try writing the same examples in > > > test/unit and see if they work? > > > > > > > > > > > > > > If i play around with the labelling system in the console, it seems > to > > work > > > > fine: ie, the above code works 'normally', but is totally breaking > the > > spec > > > > file. > > > > > > > > Does anyone have any ideas about this? It's driving me crazy and > > stopping > > > > me speccing other aspects of my labelling system. > > > > > > > > thanks > > > > max > > > > > > > > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/7ea9a9ed/attachment.html From rick.denatale at gmail.com Wed Mar 5 12:28:17 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 5 Mar 2008 12:28:17 -0500 Subject: [rspec-users] ActiveRecord, spec'ing find has right :order parameter Message-ID: I'm wanting to write a spec that a model is applying an :order option to a find call, but I don't want to completely specify all of the find parameters. So I want to write something like this, say in a controller spec User.should_receive(:find).with(:all, hash_with_at_least(:order => 'user.name ASC')) get 'index', :sort => 'up' This ability to partially specify the contents of a hash argument seems to be generally useful, particularly for Rails, and was wondering if anyone had done this. I don't think it would be too hard. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From doug+rspecuser at netinlet.com Wed Mar 5 12:30:14 2008 From: doug+rspecuser at netinlet.com (Doug Bryant) Date: Wed, 5 Mar 2008 12:30:14 -0500 Subject: [rspec-users] mocking successive return values Message-ID: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> I'm having a problems mocking successive return values. I don't know if I'm doing something wrong or if this is a limitation of rspec mocks. Any ideas of what I may be doing wrong? I'm trying to test the generate_quote_number method. It generates a quote number, looks to see if it is in the db already. If it is, it calls itself to try again. I want to test that it looks in the database for matching numbers until it finds one which does not exist already. ## The code def generate_quote_number quote_num = "MMQ#{self.random_string}-001" if Policy.find(:first, :conditions => ["quote_number = ?", quote_num]) quote_num = generate_quote_number end quote_num end def random_string(size=8) # return a random string end For the test, I simply lookup 3 existing quote numbers, append nil to the end (for a total of 4) ## The test it "should not generate a duplicate quote number" do existing_quote_numbers = Policy.find(:all).map{|p| p.quote_number}[0,3] @policy_service.should_receive(:random_string).with(:no_args).exactly(4).times.and_return(existing_quote_numbers.concat([nil])) @policy_service.generate_quote_number end ## The result should not generate a duplicate quote number Mock 'Service::Base' expected :random_string with (no args) 4 times, but received it once I verified "and_return" is actually returning the array rather than an individual element of the existing_quote_numbers array which makes sense, but what about this? http://rspec.rubyforge.org/svn/branches/dogfood/spec/spec/mocks/mock_spec.rb specify "should use a list of return values for successive calls" do @mock.should_receive(:multi_call).twice.with(:no_args).and_return([8, 12]) @mock.multi_call.should_equal 8 @mock.multi_call.should_equal 12 @mock.__verify end Any feedback on how to properly test this is much appreciated. Thanks, Doug -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/c36fbd5f/attachment.html From rick.denatale at gmail.com Wed Mar 5 12:43:45 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 5 Mar 2008 12:43:45 -0500 Subject: [rspec-users] ActiveRecord, spec'ing find has right :order parameter In-Reply-To: References: Message-ID: On Wed, Mar 5, 2008 at 12:28 PM, Rick DeNatale wrote: > I'm wanting to write a spec that a model is applying an :order option > to a find call, but I don't want to completely specify all of the find > parameters. > > So I want to write something like this, say in a controller spec > > User.should_receive(:find).with(:all, hash_with_at_least(:order => > 'user.name ASC')) > get 'index', :sort => 'up' > > This ability to partially specify the contents of a hash argument > seems to be generally useful, particularly for Rails, and was > wondering if anyone had done this. I don't think it would be too hard. And by the way, here's my sketch of how to do this, just looking not to reinvent the wheel: class HashWithAtLeast def initialize(aHash) @expected = aHash end def ==(other) @expected.each do |key, value| return false unless other[key] == value end true end def to_s "Hash with at least (@expected.inspect)" end end def hash_with_at_least(hash) HashWithAtLeast.new(hash) end describe HashWithAtLeast do it "should match the same hash" do hash_with_at_least(:a => 2).should == {:a => 2} end it "should match a hash with an extra key/value" do hash_with_at_least(:a => 2).should == {:a => 2, :b => 3} end it "should not match a hash with a missing key" do hash_with_at_least(:a => 2).should_not == {:b => 2} hash_with_at_least(:a => 2, :b => 3).should_not == {:a => 2} end it "should not match a hash with the wrong value for a key" do hash_with_at_least(:a => 2).should_not == {:a => 3} hash_with_at_least(:a => 2, :b => 3).should_not == {:a => 0, :b => 3} end end describe HashWithAtLeast, "in a message expectation" do before(:all) do @foo = Object.new end it "should match exact" do @foo.should_receive(:bar).with(hash_with_at_least(:a => 2)) @foo.bar(:a => 2) end it "should allow extra keys" do @foo.should_receive(:bar).with(hash_with_at_least(:a => 2)) @foo.bar(:a => 2, :b => 3) end end -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From coreyhaines at gmail.com Wed Mar 5 13:05:34 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 5 Mar 2008 13:05:34 -0500 Subject: [rspec-users] Testing that a model helper method is called Message-ID: <6bdacb70803051005i7ba9ca24t1415a008f5c18f5d@mail.gmail.com> So, I have a plugin that adds a method to ActiveRecord::Base, let's call the method is_encrypted. class MyModel < ActiveRecord::Base is_encrypted end So, my question is, how do I write a spec to show that is_encrypted is called here? I would rather not write specs that say that the behavior is there, since I have tested the behavior already in my plugin. Thanks. -Corey -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/606e21ff/attachment.html From pergesu at gmail.com Wed Mar 5 13:10:52 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 5 Mar 2008 10:10:52 -0800 Subject: [rspec-users] Testing that a model helper method is called In-Reply-To: <6bdacb70803051005i7ba9ca24t1415a008f5c18f5d@mail.gmail.com> References: <6bdacb70803051005i7ba9ca24t1415a008f5c18f5d@mail.gmail.com> Message-ID: <810a540e0803051010k4661202en177e6bc1ee93ae6d@mail.gmail.com> On Wed, Mar 5, 2008 at 10:05 AM, Corey Haines wrote: > So, I have a plugin that adds a method to ActiveRecord::Base, let's call the > method is_encrypted. > > class MyModel < ActiveRecord::Base > > is_encrypted > > end > > So, my question is, how do I write a spec to show that is_encrypted is > called here? I would rather not write specs that say that the behavior is > there, since I have tested the behavior already in my plugin. MyModel.should_receive(:is_encrypted) load "my_model.rb" Pat From ben at benmabey.com Wed Mar 5 13:18:37 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 05 Mar 2008 11:18:37 -0700 Subject: [rspec-users] having trouble specing an ajax request In-Reply-To: References: <00b87bf2a68372c30f941e500c91ed10@ruby-forum.com> Message-ID: <47CEE3FD.6050205@benmabey.com> Namrata Tiwari wrote: > Sorry I pasted the wrong spec. > Here is correct one - > > it "should show deals listing" do > controller.stub!(:prepare_search_conditions).and_return(true) > Deal.should_receive(:paginate).and_return(@deals) > > get :index > controller.expect_render(:partial => '/deals/front/listing') > end > > >> Thanks, >> Namrata. >> > > Try setting your headers before your get request.. Like so: @request.env["HTTP_ACCEPT"] = "application/javascript" -Ben From coreyhaines at gmail.com Wed Mar 5 13:22:27 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 5 Mar 2008 13:22:27 -0500 Subject: [rspec-users] Testing that a model helper method is called In-Reply-To: <810a540e0803051010k4661202en177e6bc1ee93ae6d@mail.gmail.com> References: <6bdacb70803051005i7ba9ca24t1415a008f5c18f5d@mail.gmail.com> <810a540e0803051010k4661202en177e6bc1ee93ae6d@mail.gmail.com> Message-ID: <6bdacb70803051022o353f50edg994eda3e2e7b2e4c@mail.gmail.com> Thanks, Pat, that appeared to work. -Corey On Wed, Mar 5, 2008 at 1:10 PM, Pat Maddox wrote: > On Wed, Mar 5, 2008 at 10:05 AM, Corey Haines > wrote: > > So, I have a plugin that adds a method to ActiveRecord::Base, let's call > the > > method is_encrypted. > > > > class MyModel < ActiveRecord::Base > > > > is_encrypted > > > > end > > > > So, my question is, how do I write a spec to show that is_encrypted is > > called here? I would rather not write specs that say that the behavior > is > > there, since I have tested the behavior already in my plugin. > > MyModel.should_receive(:is_encrypted) > load "my_model.rb" > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/0dafab7c/attachment.html From ben at benmabey.com Wed Mar 5 13:25:43 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 05 Mar 2008 11:25:43 -0700 Subject: [rspec-users] mocking successive return values In-Reply-To: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> References: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> Message-ID: <47CEE5A7.1040703@benmabey.com> Doug Bryant wrote: > I'm having a problems mocking successive return values. I don't know > if I'm doing something wrong or if this is a limitation of rspec > mocks. Any ideas of what I may be doing wrong? > > > For the test, I simply lookup 3 existing quote numbers, append nil to > the end (for a total of 4) > ## The test > it "should not generate a duplicate quote number" do > existing_quote_numbers = Policy.find(:all).map{|p| > p.quote_number}[0,3] > > @policy_service.should_receive(:random_string).with(:no_args).exactly(4).times.and_return(existing_quote_numbers.concat([nil])) > @policy_service.generate_quote_number > end > You will need to have one expectation per return. Try this: it "should not generate a duplicate quote number" do #expect Policy.find(:all).map{|p| p.quote_number}[0,3].concat([nil]).each do |existing_quote_number| @policy_service.should_receive(:random_string).with(:no_args).once.and_return(existing_quote_number)) end #when @policy_service.generate_quote_number end -Ben From cwdinfo at gmail.com Wed Mar 5 13:26:37 2008 From: cwdinfo at gmail.com (s.ross) Date: Wed, 5 Mar 2008 10:26:37 -0800 Subject: [rspec-users] ActiveRecord, spec'ing find has right :order parameter In-Reply-To: References: Message-ID: On Mar 5, 2008, at 9:43 AM, Rick DeNatale wrote: > And by the way, here's my sketch of how to do this, just looking not > to reinvent the wheel: Are you aware that Rails extends Hash with a few extra methods: mymac:~/rails/myproj $ script/console Loading development environment (Rails 2.0.2) >> a = {:foo=>'bar', :zoo => 'zar'} => {:foo=>"bar", :zoo=>"zar"} >> a.except(:foo) => {:zoo=>"zar"} >> What's cool about this is that you can specify a fully valid hash once in a before block, then reuse it, omitting k/v pairs in order to verify behavior of missing-value conditions. This doesn't exactly answer your need, but perhaps it will help. From dchelimsky at gmail.com Wed Mar 5 13:31:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Mar 2008 12:31:23 -0600 Subject: [rspec-users] ActiveRecord, spec'ing find has right :order parameter In-Reply-To: References: Message-ID: <2D5C0532-49A3-4B42-8098-CD25FDB3D778@gmail.com> On Mar 5, 2008, at 11:43 AM, "Rick DeNatale" wrote: > On Wed, Mar 5, 2008 at 12:28 PM, Rick DeNatale > wrote: >> I'm wanting to write a spec that a model is applying an :order option >> to a find call, but I don't want to completely specify all of the >> find >> parameters. >> >> So I want to write something like this, say in a controller spec >> >> User.should_receive(:find).with(:all, hash_with_at_least(:order => >> 'user.name ASC')) >> get 'index', :sort => 'up' I really like this idea. What about something more general that can handle the first n args too? >> >> >> This ability to partially specify the contents of a hash argument >> seems to be generally useful, particularly for Rails, and was >> wondering if anyone had done this. I don't think it would be too >> hard. > > And by the way, here's my sketch of how to do this, just looking not > to reinvent the wheel: > > class HashWithAtLeast > > def initialize(aHash) > @expected = aHash > end > > def ==(other) > @expected.each do |key, value| > return false unless other[key] == value > end > true > end > > def to_s > "Hash with at least (@expected.inspect)" > end > end > > def hash_with_at_least(hash) > HashWithAtLeast.new(hash) > end > > describe HashWithAtLeast do > it "should match the same hash" do > hash_with_at_least(:a => 2).should == {:a => 2} > end > > it "should match a hash with an extra key/value" do > hash_with_at_least(:a => 2).should == {:a => 2, :b => 3} > end > > it "should not match a hash with a missing key" do > hash_with_at_least(:a => 2).should_not == {:b => 2} > hash_with_at_least(:a => 2, :b => 3).should_not == {:a => 2} > end > > it "should not match a hash with the wrong value for a key" do > hash_with_at_least(:a => 2).should_not == {:a => 3} > hash_with_at_least(:a => 2, :b => 3).should_not == {:a => 0, :b > => 3} > end > > end > > describe HashWithAtLeast, "in a message expectation" do > before(:all) do > @foo = Object.new > end > > it "should match exact" do > @foo.should_receive(:bar).with(hash_with_at_least(:a => 2)) > @foo.bar(:a => 2) > end > > it "should allow extra keys" do > @foo.should_receive(:bar).with(hash_with_at_least(:a => 2)) > @foo.bar(:a => 2, :b => 3) > end > end > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From doug+rspecuser at netinlet.com Wed Mar 5 13:36:44 2008 From: doug+rspecuser at netinlet.com (Doug Bryant) Date: Wed, 5 Mar 2008 13:36:44 -0500 Subject: [rspec-users] mocking successive return values In-Reply-To: <47CEE5A7.1040703@benmabey.com> References: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> <47CEE5A7.1040703@benmabey.com> Message-ID: <177c686f0803051036me6e276cjc1a8a7994a2a5414@mail.gmail.com> Thanks Ben. I appreciate it. Doug On Wed, Mar 5, 2008 at 1:25 PM, Ben Mabey wrote: > Doug Bryant wrote: > > I'm having a problems mocking successive return values. I don't know > > if I'm doing something wrong or if this is a limitation of rspec > > mocks. Any ideas of what I may be doing wrong? > > > > > > For the test, I simply lookup 3 existing quote numbers, append nil to > > the end (for a total of 4) > > ## The test > > it "should not generate a duplicate quote number" do > > existing_quote_numbers = Policy.find(:all).map{|p| > > p.quote_number}[0,3] > > > > > @policy_service.should_receive(:random_string).with(:no_args).exactly(4).times.and_return(existing_quote_numbers.concat([nil])) > > @policy_service.generate_quote_number > > end > > > > You will need to have one expectation per return. Try this: > > it "should not generate a duplicate quote number" do > #expect > Policy.find(:all).map{|p| p.quote_number}[0,3].concat([nil]).each do > |existing_quote_number| > > > @policy_service.should_receive(:random_string).with(:no_args).once.and_return(existing_quote_number)) > end > #when > @policy_service.generate_quote_number > end > > > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/24144d0d/attachment.html From pergesu at gmail.com Wed Mar 5 14:17:27 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 5 Mar 2008 11:17:27 -0800 Subject: [rspec-users] mocking successive return values In-Reply-To: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> References: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> Message-ID: <810a540e0803051117h6ea0e565me905c704ae9d742b@mail.gmail.com> On Wed, Mar 5, 2008 at 9:30 AM, Doug Bryant wrote: @policy_service.should_receive(:random_string).with(:no_args).exactly(4).times.and_return(existing_quote_numbers.concat([nil])) > @policy_service.generate_quote_number > end > > ## The result > should not generate a duplicate quote number > Mock 'Service::Base' expected :random_string with (no args) 4 times, but > received it once > > I verified "and_return" is actually returning the array rather than an > individual element of the existing_quote_numbers array which makes sense You need to splat em out: and_return(*existing_quote_numbers.concat([nil])) Pat From coreyhaines at gmail.com Wed Mar 5 15:06:20 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 5 Mar 2008 15:06:20 -0500 Subject: [rspec-users] mocking successive return values In-Reply-To: <810a540e0803051117h6ea0e565me905c704ae9d742b@mail.gmail.com> References: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> <810a540e0803051117h6ea0e565me905c704ae9d742b@mail.gmail.com> Message-ID: <6bdacb70803051206m288be403i70905aa4ebd2e841@mail.gmail.com> On Wed, Mar 5, 2008 at 2:17 PM, Pat Maddox wrote: > > You need to splat em out: > > and_return(*existing_quote_numbers.concat([nil])) > > Pat > Hi, Pat, Just for my own edification and education, if you have a minute, could you explain what this means and why you have to do it? Thanks, -Corey -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/20670b70/attachment.html From doug at netinlet.com Wed Mar 5 12:27:16 2008 From: doug at netinlet.com (Doug Bryant) Date: Wed, 5 Mar 2008 12:27:16 -0500 Subject: [rspec-users] mocking successive return values Message-ID: <4F74242D-0CB4-47A1-927F-4A0E2623BC5C@netinlet.com> I'm having a problems mocking successive return values. I don't know if I'm doing something wrong or if this is a limitation of rspec mocks. Any ideas of what I may be doing wrong? I'm trying to test the generate_quote_number method. It generates a quote number, looks to see if it is in the db already. If it is, it calls itself to try again. I want to test that it looks in the database for matching numbers until it finds one which does not exist already. ## The code def generate_quote_number quote_num = "MMQ#{self.random_string}-001" if Policy.find(:first, :conditions => ["quote_number = ?", quote_num]) quote_num = generate_quote_number end quote_num end def random_string(size=8) # return a random string end For the test, I simply lookup 3 existing quote numbers, append nil to the end (for a total of 4) ## The test it "should not generate a duplicate quote number" do existing_quote_numbers = Policy.find(:all).map{|p| p.quote_number} [0,3] @policy_service .should_receive (:random_string ).with (:no_args ).exactly(4).times.and_return(existing_quote_numbers.concat([nil])) @policy_service.generate_quote_number end ## The result should not generate a duplicate quote number Mock 'Service::Base' expected :random_string with (no args) 4 times, but received it once I verified "and_return" is actually returning the array rather than an individual element of the existing_quote_numbers array which makes sense, but what about this? http://rspec.rubyforge.org/svn/branches/dogfood/spec/spec/mocks/mock_spec.rb specify "should use a list of return values for successive calls" do @mock.should_receive(:multi_call).twice.with(:no_args).and_return([8, 12]) @mock.multi_call.should_equal 8 @mock.multi_call.should_equal 12 @mock.__verify end Any feedback on how to properly test this is much appreciated. Thanks, Doug -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/71cfbcb4/attachment-0001.html From pergesu at gmail.com Wed Mar 5 15:40:57 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 5 Mar 2008 12:40:57 -0800 Subject: [rspec-users] mocking successive return values In-Reply-To: <6bdacb70803051206m288be403i70905aa4ebd2e841@mail.gmail.com> References: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> <810a540e0803051117h6ea0e565me905c704ae9d742b@mail.gmail.com> <6bdacb70803051206m288be403i70905aa4ebd2e841@mail.gmail.com> Message-ID: <810a540e0803051240l4ef277c6na2c6ee0702ce69a5@mail.gmail.com> On Wed, Mar 5, 2008 at 12:06 PM, Corey Haines wrote: > > On Wed, Mar 5, 2008 at 2:17 PM, Pat Maddox wrote: > > > > > > You need to splat em out: > > > > > > and_return(*existing_quote_numbers.concat([nil])) > > > > Pat > > > > Hi, Pat, > > Just for my own edification and education, if you have a minute, could you > explain what this means and why you have to do it? Basically it takes an array and splits it up. Here's a little irb session that ought to demonstrate it. >> def foo(val); p val; end => nil >> a = [1,2,3] => [1, 2, 3] >> foo(a) [1, 2, 3] => nil >> foo(*a) ArgumentError: wrong number of arguments (3 for 1) from (irb):4:in `foo' from (irb):4 The method expects one argument. When I pass it an array, everything is fine because it only has one object. However when I splat the array, it splits it up into three distinct objects and tries to pass it in, causing the method to blow up. In RSpec, you specify multiple values to return by passing in multiple objects. An array is just one object, so the mock just returns it. Splat it out and you've passed multiple values to and_return, causing it to return them in succession. * is called the splat operator and can be used to collect stuff in addition to splitting stuff up. Just google for "ruby splat operator" to get lots of info. Also you can define #to_splat on any object. Pat From rick.denatale at gmail.com Wed Mar 5 15:57:30 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 5 Mar 2008 15:57:30 -0500 Subject: [rspec-users] ActiveRecord, spec'ing find has right :order parameter In-Reply-To: <2D5C0532-49A3-4B42-8098-CD25FDB3D778@gmail.com> References: <2D5C0532-49A3-4B42-8098-CD25FDB3D778@gmail.com> Message-ID: On Wed, Mar 5, 2008 at 1:31 PM, David Chelimsky wrote: > On Mar 5, 2008, at 11:43 AM, "Rick DeNatale" > > wrote: > > > On Wed, Mar 5, 2008 at 12:28 PM, Rick DeNatale > > wrote: > >> I'm wanting to write a spec that a model is applying an :order option > >> to a find call, but I don't want to completely specify all of the > >> find > >> parameters. > >> > >> So I want to write something like this, say in a controller spec > >> > >> User.should_receive(:find).with(:all, hash_with_at_least(:order => > >> 'user.name ASC')) > >> get 'index', :sort => 'up' > > I really like this idea. What about something more general that can > handle the first n args too? That's a horse of a different color I think. It would need to dig into MessageExpectation#with and/or the way ArgumentExpectations are built. Dealing with it an argument at a time is easy since it just needs == to 'do the right thing' on an argument 'proxy'. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From coreyhaines at gmail.com Wed Mar 5 16:09:03 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 5 Mar 2008 16:09:03 -0500 Subject: [rspec-users] mocking successive return values In-Reply-To: <810a540e0803051240l4ef277c6na2c6ee0702ce69a5@mail.gmail.com> References: <177c686f0803050930p7479ffecia5fa670df75a4817@mail.gmail.com> <810a540e0803051117h6ea0e565me905c704ae9d742b@mail.gmail.com> <6bdacb70803051206m288be403i70905aa4ebd2e841@mail.gmail.com> <810a540e0803051240l4ef277c6na2c6ee0702ce69a5@mail.gmail.com> Message-ID: <6bdacb70803051309u3a4bc096v4a1f6563ed92e67b@mail.gmail.com> Wow! That is really cool. Thanks for the explanation, Pat. -Corey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/52f09ef4/attachment.html From dchelimsky at gmail.com Wed Mar 5 16:12:15 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Mar 2008 15:12:15 -0600 Subject: [rspec-users] ActiveRecord, spec'ing find has right :order parameter In-Reply-To: References: <2D5C0532-49A3-4B42-8098-CD25FDB3D778@gmail.com> Message-ID: <3C842788-806E-4B90-8948-B8DA5DCC4DAF@gmail.com> On Mar 5, 2008, at 2:57 PM, "Rick DeNatale" wrote: > On Wed, Mar 5, 2008 at 1:31 PM, David Chelimsky > wrote: >> On Mar 5, 2008, at 11:43 AM, "Rick DeNatale" >> >> >> wrote: >> >>> On Wed, Mar 5, 2008 at 12:28 PM, Rick DeNatale >>> wrote: >>>> I'm wanting to write a spec that a model is applying an :order >>>> option >>>> to a find call, but I don't want to completely specify all of the >>>> find >>>> parameters. >>>> >>>> So I want to write something like this, say in a controller spec >>>> >>>> User.should_receive(:find).with(:all, hash_with_at_least(:order => >>>> 'user.name ASC')) >>>> get 'index', :sort => 'up' >> >> I really like this idea. What about something more general that can >> handle the first n args too? > > That's a horse of a different color I think. It would need to dig > into MessageExpectation#with and/or the way ArgumentExpectations are > built. > > Dealing with it an argument at a time is easy since it just needs == > to 'do the right thing' on an argument 'proxy'. Agreed. I think hash_with would be clear enough and a bit more terse