From dchelimsky at gmail.com Fri Feb 1 00:00:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 31 Jan 2008 23:00:32 -0600 Subject: [rspec-users] [ANN] RSpec-1.1.3 In-Reply-To: <200802010648.39065.qpadla@gmail.com> References: <57c63afe0801310442r7cbf7494we006ba5ef4571eec@mail.gmail.com> <200802010648.39065.qpadla@gmail.com> Message-ID: <57c63afe0801312100i4a3fc868rd1fa5186ed1a22a2@mail.gmail.com> On Jan 31, 2008 10:48 PM, Nikolay Pavlov wrote: > > On Thursday 31 January 2008 14:42:55 David Chelimsky wrote: > > RSpec-1.1.3 has been released. > > > > If you're using RSpec and autotest, you'll have to upgrade to > > RSpec-1.1.3 and ZenTest-3.9.0 at the same time. > > > > == Version 1.1.3 > > > > Maintenance release. > > > > * Tightened up exceptions list in autotest/rails_spec. Closes #264. > > * Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility > > * Applied patch from Kero to add step_upcoming to story listeners. > > Closes #253. * Fixed bug where the wrong named error was not always > > caught by "should raise_error" > > * Applied patch from Luis Lavena: No coloured output on Windows due > > missing RUBYOPT. Closes #244. > > * Applied patch from Craig Demyanovich to add support for "should_not > > render_template" to rspec_on_rails. Closes #241. > > * Added --pattern (-p for short) option to control what files get > > loaded. Defaults to '**/*_spec.rb' > > * Exit with non-0 exit code if examples *or tests* (in test/unit > > interop mode) fail. Closes #203. > > * Moved at_exit hook to a method in Spec::Runner which only runs if > > specs get loaded. Closes #242. > > * Applied patch from kakutani ensuring that base_view_path gets > > cleared after each view example. Closes #235. > > * More tweaks to regexp step names > > * Fixed focused specs in nested ExampleGroups. Closes #225. > > Hello all, hello David. > I am not sure were to go with this, but after upgrading to RSpec-1.1.3 and > ZenTest-3.9.0 i am observing memory leaks in autotest process: http://blog.zenspider.com/archives/2008/01/zentest_version_391_has_been_released.html > 32001 quetzal 18 0 97472 93m 1464 S 25 9.2 1:43.28 autotest > After 5 minutes: > 32001 quetzal 18 0 102m 100m 1464 S 13 9.9 2:07.35 autotest > A few minutes later: > 32001 quetzal 18 0 112m 110m 1464 R 29 11.0 2:40.67 autotest > And so on... > > There are only two requirements in my .autotest file: > require 'autotest/redgreen' > require 'autotest/timestamp' > > Could some one confirm this behavior? > > -- > ====================================================================== > - Best regards, Nikolay Pavlov. <<<----------------------------------- > ====================================================================== > > From qpadla at gmail.com Fri Feb 1 00:07:26 2008 From: qpadla at gmail.com (Nikolay Pavlov) Date: Fri, 1 Feb 2008 07:07:26 +0200 Subject: [rspec-users] [ANN] RSpec-1.1.3 In-Reply-To: <57c63afe0801312100i4a3fc868rd1fa5186ed1a22a2@mail.gmail.com> References: <57c63afe0801310442r7cbf7494we006ba5ef4571eec@mail.gmail.com> <200802010648.39065.qpadla@gmail.com> <57c63afe0801312100i4a3fc868rd1fa5186ed1a22a2@mail.gmail.com> Message-ID: <200802010707.26860.qpadla@gmail.com> On Friday 01 February 2008 07:00:32 wrote: > On Jan 31, 2008 10:48 PM, Nikolay Pavlov wrote: > > On Thursday 31 January 2008 14:42:55 David Chelimsky wrote: > > > RSpec-1.1.3 has been released. > > > > > > If you're using RSpec and autotest, you'll have to upgrade to > > > RSpec-1.1.3 and ZenTest-3.9.0 at the same time. > > > > > > == Version 1.1.3 > > > > > > Maintenance release. > > > > > > * Tightened up exceptions list in autotest/rails_spec. Closes #264. > > > * Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility > > > * Applied patch from Kero to add step_upcoming to story listeners. > > > Closes #253. * Fixed bug where the wrong named error was not always > > > caught by "should raise_error" > > > * Applied patch from Luis Lavena: No coloured output on Windows due > > > missing RUBYOPT. Closes #244. > > > * Applied patch from Craig Demyanovich to add support for > > > "should_not render_template" to rspec_on_rails. Closes #241. > > > * Added --pattern (-p for short) option to control what files get > > > loaded. Defaults to '**/*_spec.rb' > > > * Exit with non-0 exit code if examples *or tests* (in test/unit > > > interop mode) fail. Closes #203. > > > * Moved at_exit hook to a method in Spec::Runner which only runs if > > > specs get loaded. Closes #242. > > > * Applied patch from kakutani ensuring that base_view_path gets > > > cleared after each view example. Closes #235. > > > * More tweaks to regexp step names > > > * Fixed focused specs in nested ExampleGroups. Closes #225. > > > > Hello all, hello David. > > I am not sure were to go with this, but after upgrading to RSpec-1.1.3 > > and ZenTest-3.9.0 i am observing memory leaks in autotest process: > > http://blog.zenspider.com/archives/2008/01/zentest_version_391_has_been_ >released.html > WOW. Thanks for quick response. :) Fixed. -- ====================================================================== - Best regards, Nikolay Pavlov. <<<----------------------------------- ====================================================================== From stefan.landro at gmail.com Fri Feb 1 05:03:54 2008 From: stefan.landro at gmail.com (=?ISO-8859-1?Q?Stefan_Magnus_Landr=F8?=) Date: Fri, 1 Feb 2008 11:03:54 +0100 Subject: [rspec-users] loading fixtures? In-Reply-To: References: <6bdacb70801311556l3967255fr2e3355d52ef6047f@mail.gmail.com> <6bdacb70801311603x26d65dd8h217349e9ff32b078@mail.gmail.com> Message-ID: <921ca2f80802010203rd357919lc93d34a03d33cf11@mail.gmail.com> try this instead: rake spec:db:fixtures:load HTH 2008/2/1, Andrew WC Brown : > > loads the test fixtures, instead of the spec fixtures directory.Does it > work for you? > > On Jan 31, 2008 7:03 PM, Corey Haines wrote: > > > rake db:fixtures:load doesn't work? > > > > > > On Jan 31, 2008 6:57 PM, Andrew WC Brown wrote: > > > > > no, just database > > > > > > > > > On Jan 31, 2008 6:56 PM, Corey Haines wrote: > > > > > > > Do you want to load them in your controller? You can put > > > > > > > > class MyController > > > > fixtures :fixturename > > > > > > > > end > > > > > > > > > > > > -Corey > > > > > > > > On Jan 31, 2008 5:52 PM, Andrew WC Brown > > > > wrote: > > > > > > > > > How do you load fixtures from specs as you would test? > > > > > > > > > > eg. rake db:fixtures:load RAILS_ENV=development > > > > > > > > > > _______________________________________________ > > > > > 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 > > > > _______________________________________________ > > > > 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 > > > > _______________________________________________ > > 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 > -- Bekk Open Source http://boss.bekk.no -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080201/b977f819/attachment.html From gilesb at gmail.com Fri Feb 1 14:16:49 2008 From: gilesb at gmail.com (Giles Bowkett) Date: Fri, 1 Feb 2008 11:16:49 -0800 Subject: [rspec-users] non-pending spec returning pending Message-ID: <2d81dedb0802011116r1e009a67yfd7d2f95b9aec2f1@mail.gmail.com> I'm speccing some code which monkey-patches initialize on ActiveResource::Base. The monkey-patch lives in a module. My spec looks like this: describe MyModule, "doing stuff" do it "adds methods to ARes subclasses" do class Thing < ARes::Base ; end (lambda {Thing.new.the_new_method}).should_not raise_error(NoMethodError) end end I did this thing backwards, all sloppy hack style, and I've got code which uses alias_method_chain to introduce the method-adding during initializiation. If I comment out that call to alias_method_chain, the spec fails. But if I comment it back in, the spec doesn't pass. Instead I get this: Pending: ActiveResourceFormHandlersInitializer initializing ARes all nifty-style NO NAME (Not Yet Implemented) It's very very likely this is due to some bug in my code - programming the sloppy way kind of has that effect - but I'm finding the output somewhere between weird and incomprehensible. What's going on? Is RSpec doing some initialization as well, so that my initialization monkey-patch screws with its head? -- Giles Bowkett Podcast: http://hollywoodgrit.blogspot.com Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com From lists at ruby-forum.com Fri Feb 1 18:33:59 2008 From: lists at ruby-forum.com (Paul Cameron) Date: Sat, 2 Feb 2008 00:33:59 +0100 Subject: [rspec-users] Autotest just sits there Message-ID: <177eef1b6b087052c74174b40724bce4@ruby-forum.com> I have had this problem for a while. autotest has never worked properly for me. I have tried different versions of rspec with different versions of ZenTest. I have tried it with .autotest files and without. When I run autotest from my rails app root, it says: loading autotest/rails_rspec and then it just sits there. If I look at the output from autotest -v, it is traversing the tree and it knows how to handle my source and specs, but it never seems to do anything. Thoughts? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Feb 1 18:42:19 2008 From: lists at ruby-forum.com (Paul Cameron) Date: Sat, 2 Feb 2008 00:42:19 +0100 Subject: [rspec-users] [ANN] RSpec-1.1.3 In-Reply-To: <200802010707.26860.qpadla@gmail.com> References: <57c63afe0801310442r7cbf7494we006ba5ef4571eec@mail.gmail.com> <200802010648.39065.qpadla@gmail.com> <57c63afe0801312100i4a3fc868rd1fa5186ed1a22a2@mail.gmail.com> <200802010707.26860.qpadla@gmail.com> Message-ID: Nikolay Pavlov wrote: >> http://blog.zenspider.com/archives/2008/01/zentest_version_391_has_been_ >>released.html >> > > WOW. Thanks for quick response. :) > Fixed. > > -- > ====================================================================== > - Best regards, Nikolay Pavlov. <<<----------------------------------- > ====================================================================== Agreed. Thanks David. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Feb 1 18:48:27 2008 From: lists at ruby-forum.com (Paul Cameron) Date: Sat, 2 Feb 2008 00:48:27 +0100 Subject: [rspec-users] Autotest just sits there In-Reply-To: <177eef1b6b087052c74174b40724bce4@ruby-forum.com> References: <177eef1b6b087052c74174b40724bce4@ruby-forum.com> Message-ID: <8ee780c07eacf91160969f0aae73d20e@ruby-forum.com> Paul Cameron wrote: > I have had this problem for a while. > > autotest has never worked properly for me. I have tried different > versions of rspec with different versions of ZenTest. I have tried it > with .autotest files and without. > > When I run autotest from my rails app root, it says: > > loading autotest/rails_rspec > > and then it just sits there. > > If I look at the output from autotest -v, it is traversing the tree and > it knows how to handle my source and specs, but it never seems to do > anything. > > Thoughts? Forgot to include my current versions (although this has been occurring since I first tried to get this working a few months back over various versions). ZenTest 3.9.1 rspec plugin 1.1.3 rspec_on_rails plugin 1.1.3 rspec gem 1.1.3 MacOsX Leopard (10.5.1) rake spec works just fine -- Posted via http://www.ruby-forum.com/. From coreyhaines at gmail.com Sat Feb 2 08:45:02 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Sat, 2 Feb 2008 08:45:02 -0500 Subject: [rspec-users] loading fixtures? In-Reply-To: <921ca2f80802010203rd357919lc93d34a03d33cf11@mail.gmail.com> References: <6bdacb70801311556l3967255fr2e3355d52ef6047f@mail.gmail.com> <6bdacb70801311603x26d65dd8h217349e9ff32b078@mail.gmail.com> <921ca2f80802010203rd357919lc93d34a03d33cf11@mail.gmail.com> Message-ID: <6bdacb70802020545y188071a0l8720fab28a4fc5a0@mail.gmail.com> I see, sorry. I misunderstood. This is good to know. -Corey On Feb 1, 2008 5:03 AM, Stefan Magnus Landr? wrote: > try this instead: rake spec:db:fixtures:load > > HTH > > 2008/2/1, Andrew WC Brown : > > > loads the test fixtures, instead of the spec fixtures directory.Does it > > work for you? > > > > On Jan 31, 2008 7:03 PM, Corey Haines wrote: > > > > > rake db:fixtures:load doesn't work? > > > > > > > > > On Jan 31, 2008 6:57 PM, Andrew WC Brown wrote: > > > > > > > no, just database > > > > > > > > > > > > On Jan 31, 2008 6:56 PM, Corey Haines wrote: > > > > > > > > > Do you want to load them in your controller? You can put > > > > > > > > > > class MyController > > > > > fixtures :fixturename > > > > > > > > > > end > > > > > > > > > > > > > > > -Corey > > > > > > > > > > On Jan 31, 2008 5:52 PM, Andrew WC Brown > > > > > wrote: > > > > > > > > > > > How do you load fixtures from specs as you would test? > > > > > > > > > > > > eg. rake db:fixtures:load RAILS_ENV=development > > > > > > > > > > > > _______________________________________________ > > > > > > 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 > > > > > _______________________________________________ > > > > > 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 > > > > > > _______________________________________________ > > > 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 > > > > > > -- > Bekk Open Source > http://boss.bekk.no > _______________________________________________ > 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/20080202/7b6937f9/attachment.html From matt at matt-darby.com Sat Feb 2 10:22:16 2008 From: matt at matt-darby.com (Matt Darby) Date: Sat, 2 Feb 2008 10:22:16 -0500 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> References: <57c63afe0801310325w3b44adfhf829b54c123a9b33@mail.gmail.com> <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> Message-ID: <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> David, I'm running ZenTest 3.9.1 / RSpec 1.1.3 and I'm suddenly getting this after the update on a Rails project: loading autotest/rails_rspec Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. I see that at least one other person is experiencing the same issue after an update: http://railsforum.com/viewtopic.php?pid=52699#p52699 Thoughts? Matt Darby, M.S. IT Manager / Lead Web Developer Dynamix Engineering Ltd. 1108 City Park Ave. Columbus, OH 43206 Cell: (614) 403-5289 www.dynamix-ltd.com On Jan 31, 2008, at 3:14 PM, David Chelimsky wrote: > On Jan 31, 2008 5:25 AM, David Chelimsky wrote: >> Hey all, >> >> Just a heads up that the ZenTest-3.9.0 release is not compatible with >> RSpec-1.1.2. I thought I had a release ready to go, but differences >> between a preview release of ZenTest that I received and the actual >> release seem to have broken compatibility. > > Hey spec'ers: it turns out that this was NOT a problem w/ ZenTest. I > had actually missed a step when checking RSpec against the preview > release. > > All should be working now as long as you're using either > ZenTest-3.8.0/RSpec-1.1.2 or ZenTest-3.9.0/RSpec-1.1.3. > > Cheers, > David > _______________________________________________ > 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/20080202/23c61ee0/attachment.html From matt at matt-darby.com Sat Feb 2 10:30:39 2008 From: matt at matt-darby.com (Matt Darby) Date: Sat, 2 Feb 2008 10:30:39 -0500 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> References: <57c63afe0801310325w3b44adfhf829b54c123a9b33@mail.gmail.com> <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> Message-ID: Just a quick follow up; I reinstalled both the rspec and rspec_for_rails plugins to CURRENT and all is up and running. (There is a 'hook' depreciation notice, FYI) On Feb 2, 2008, at 10:22 AM, Matt Darby wrote: > David, I'm running ZenTest 3.9.1 / RSpec 1.1.3 and I'm suddenly > getting this after the update on a Rails project: > > loading autotest/rails_rspec > Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. > > > I see that at least one other person is experiencing the same issue > after an update: http://railsforum.com/viewtopic.php?pid=52699#p52699 > > Thoughts? > > Matt Darby, M.S. > IT Manager / Lead Web Developer > > Dynamix Engineering Ltd. > 1108 City Park Ave. > Columbus, OH 43206 > Cell: (614) 403-5289 > www.dynamix-ltd.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080202/7d20b2f9/attachment.html From dchelimsky at gmail.com Sat Feb 2 11:18:05 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 2 Feb 2008 10:18:05 -0600 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> References: <57c63afe0801310325w3b44adfhf829b54c123a9b33@mail.gmail.com> <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> Message-ID: Did you install both the rspec and rspec_on_rails 1.1.3 plugins? On Feb 2, 2008, at 9:22 AM, Matt Darby wrote: > David, I'm running ZenTest 3.9.1 / RSpec 1.1.3 and I'm suddenly > getting this after the update on a Rails project: > > loading autotest/rails_rspec > Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. > > > I see that at least one other person is experiencing the same issue > after an update: http://railsforum.com/viewtopic.php?pid=52699#p52699 > > Thoughts? > > Matt Darby, M.S. > IT Manager / Lead Web Developer > > Dynamix Engineering Ltd. > 1108 City Park Ave. > Columbus, OH 43206 > Cell: (614) 403-5289 > www.dynamix-ltd.com > > > > On Jan 31, 2008, at 3:14 PM, David Chelimsky wrote: > >> On Jan 31, 2008 5:25 AM, David Chelimsky >> wrote: >>> Hey all, >>> >>> Just a heads up that the ZenTest-3.9.0 release is not compatible >>> with >>> RSpec-1.1.2. I thought I had a release ready to go, but differences >>> between a preview release of ZenTest that I received and the actual >>> release seem to have broken compatibility. >> >> Hey spec'ers: it turns out that this was NOT a problem w/ ZenTest. I >> had actually missed a step when checking RSpec against the preview >> release. >> >> All should be working now as long as you're using either >> ZenTest-3.8.0/RSpec-1.1.2 or ZenTest-3.9.0/RSpec-1.1.3. >> >> 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/20080202/3f6bb69a/attachment-0001.html From matt at matt-darby.com Sat Feb 2 11:42:56 2008 From: matt at matt-darby.com (Matt Darby) Date: Sat, 2 Feb 2008 11:42:56 -0500 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: References: <57c63afe0801310325w3b44adfhf829b54c123a9b33@mail.gmail.com> <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> Message-ID: <0DC08427-8AD4-42C5-9627-7435079647E8@matt-darby.com> That was the issue; I updated the RSpec and ZenTest gems, but not the plugins. On Feb 2, 2008, at 11:18 AM, David Chelimsky wrote: > Did you install both the rspec and rspec_on_rails 1.1.3 plugins? > > > > On Feb 2, 2008, at 9:22 AM, Matt Darby wrote: > >> David, I'm running ZenTest 3.9.1 / RSpec 1.1.3 and I'm suddenly >> getting this after the update on a Rails project: >> >> loading autotest/rails_rspec >> Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. >> >> >> I see that at least one other person is experiencing the same issue >> after an update: http://railsforum.com/viewtopic.php?pid=52699#p52699 >> >> Thoughts? >> >> Matt Darby, M.S. >> IT Manager / Lead Web Developer >> >> Dynamix Engineering Ltd. >> 1108 City Park Ave. >> Columbus, OH 43206 >> Cell: (614) 403-5289 >> www.dynamix-ltd.com >> >> >> >> On Jan 31, 2008, at 3:14 PM, David Chelimsky wrote: >> >>> On Jan 31, 2008 5:25 AM, David Chelimsky >>> wrote: >>>> Hey all, >>>> >>>> Just a heads up that the ZenTest-3.9.0 release is not compatible >>>> with >>>> RSpec-1.1.2. I thought I had a release ready to go, but differences >>>> between a preview release of ZenTest that I received and the actual >>>> release seem to have broken compatibility. >>> >>> Hey spec'ers: it turns out that this was NOT a problem w/ ZenTest. I >>> had actually missed a step when checking RSpec against the preview >>> release. >>> >>> All should be working now as long as you're using either >>> ZenTest-3.8.0/RSpec-1.1.2 or ZenTest-3.9.0/RSpec-1.1.3. >>> >>> 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 > _______________________________________________ > 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/20080202/5c7e6782/attachment.html From ben at benmabey.com Sat Feb 2 12:03:50 2008 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 Feb 2008 10:03:50 -0700 Subject: [rspec-users] deep test with rspec? Message-ID: <47A4A276.7010805@benmabey.com> All, Has anyone on this list tried to use DeepTest[1] with rspec? My initial attempts have failed so I would be really interested if someone has figured it out. Thanks. -Ben 1. http://www.somethingnimble.com/bliki/deep-test From ben at benmabey.com Sat Feb 2 12:09:03 2008 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 Feb 2008 10:09:03 -0700 Subject: [rspec-users] deep test with rspec? In-Reply-To: <47A4A276.7010805@benmabey.com> References: <47A4A276.7010805@benmabey.com> Message-ID: <47A4A3AF.5000708@benmabey.com> Ben Mabey wrote: > All, > Has anyone on this list tried to use DeepTest[1] with rspec? My initial > attempts have failed so I would be really interested if someone has > figured it out. Thanks. > > -Ben > > 1. http://www.somethingnimble.com/bliki/deep-test > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Or maybe someone has some experience with spec_distributed they could share? I'm just trying to see if I can get my specs to run faster on my multi-core machines.... -Ben From mailing_lists at railsnewbie.com Sat Feb 2 17:10:20 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 2 Feb 2008 17:10:20 -0500 Subject: [rspec-users] deep test with rspec? In-Reply-To: <47A4A3AF.5000708@benmabey.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> Message-ID: <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> On Feb 2, 2008, at 12:09 PM, Ben Mabey wrote: > Ben Mabey wrote: >> All, >> Has anyone on this list tried to use DeepTest[1] with rspec? My >> initial >> attempts have failed so I would be really interested if someone has >> figured it out. Thanks. >> >> -Ben >> >> 1. http://www.somethingnimble.com/bliki/deep-test >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > Or maybe someone has some experience with spec_distributed they could > share? I'm just trying to see if I can get my specs to run faster > on my > multi-core machines.... I haven't used deep test (this was by Dan Manges / Thoughtworks, correct?). If I recall correctly, it only worked on test/unit. I don't know if anyone else was working on a version for rspec... As for spec_distributed, I had gotten it working, and as I recall, it was pretty easy to do (at least, on a non-rails project). The documentation for that is pretty straight forward. It solves the speed problem by throwing hardware at the problem - If you have n number of machines, your test suite should take 1/n the amount of time it usually does on one machine (assuming the machines of equal processing power). Happy Hacking, Scott From ben at benmabey.com Sat Feb 2 21:17:35 2008 From: ben at benmabey.com (Ben Mabey) Date: Sat, 02 Feb 2008 19:17:35 -0700 Subject: [rspec-users] deep test with rspec? In-Reply-To: <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> Message-ID: <47A5243F.3030109@benmabey.com> Scott Taylor wrote: > On Feb 2, 2008, at 12:09 PM, Ben Mabey wrote: > > >> Ben Mabey wrote: >> >>> All, >>> Has anyone on this list tried to use DeepTest[1] with rspec? My >>> initial >>> attempts have failed so I would be really interested if someone has >>> figured it out. Thanks. >>> >>> -Ben >>> >>> 1. http://www.somethingnimble.com/bliki/deep-test >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> Or maybe someone has some experience with spec_distributed they could >> share? I'm just trying to see if I can get my specs to run faster >> on my >> multi-core machines.... >> > > I haven't used deep test (this was by Dan Manges / Thoughtworks, > correct?). If I recall correctly, it only worked on test/unit. I > don't know if anyone else was working on a version for rspec... > Right.. There were some comments in Dan's original post about someone working on rspec compatibility but as far as I can tell that never made it into the gem. > As for spec_distributed, I had gotten it working, and as I recall, it > was pretty easy to do (at least, on a non-rails project). The > documentation for that is pretty straight forward. It solves the > speed problem by throwing hardware at the problem - If you have n > number of machines, your test suite should take 1/n the amount of > time it usually does on one machine (assuming the machines of equal > processing power). > Does this really address the use of multicores on a single machine then? The only use I could see of this would be for running your CI faster over a number of machines... Thanks for you input, Ben From mailing_lists at railsnewbie.com Sat Feb 2 21:37:37 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 2 Feb 2008 21:37:37 -0500 Subject: [rspec-users] deep test with rspec? In-Reply-To: <47A5243F.3030109@benmabey.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> <47A5243F.3030109@benmabey.com> Message-ID: <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> On Feb 2, 2008, at 9:17 PM, Ben Mabey wrote: > Scott Taylor wrote: >> On Feb 2, 2008, at 12:09 PM, Ben Mabey wrote: >> >> >>> Ben Mabey wrote: >>> >>>> All, >>>> Has anyone on this list tried to use DeepTest[1] with rspec? My >>>> initial >>>> attempts have failed so I would be really interested if someone has >>>> figured it out. Thanks. >>>> >>>> -Ben >>>> >>>> 1. http://www.somethingnimble.com/bliki/deep-test >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> >>> Or maybe someone has some experience with spec_distributed they >>> could >>> share? I'm just trying to see if I can get my specs to run faster >>> on my >>> multi-core machines.... >>> >> >> I haven't used deep test (this was by Dan Manges / Thoughtworks, >> correct?). If I recall correctly, it only worked on test/unit. I >> don't know if anyone else was working on a version for rspec... >> > Right.. There were some comments in Dan's original post about someone > working on rspec compatibility but as far as I can tell that never > made > it into the gem. >> As for spec_distributed, I had gotten it working, and as I recall, it >> was pretty easy to do (at least, on a non-rails project). The >> documentation for that is pretty straight forward. It solves the >> speed problem by throwing hardware at the problem - If you have n >> number of machines, your test suite should take 1/n the amount of >> time it usually does on one machine (assuming the machines of equal >> processing power). >> > > Does this really address the use of multicores on a single machine > then? The only use I could see of this would be for running your CI > faster over a number of machines... > Thanks for you input, No - it doesn't, but it would cut your test suite in half, just as two processors would. I'm sure I'm not the only one who would like to know if you took up the job of getting deep test to run w/ rspec. Regards, Scott From coreyhaines at gmail.com Sun Feb 3 12:13:40 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Sun, 3 Feb 2008 12:13:40 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> Message-ID: <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> Thanks to everyone for their comments, as well as the lack of SCM fighting. :) Being on vista, it appears that my choices are a bit limited. -Corey On Jan 28, 2008 4:22 PM, Dan North wrote: > Yes, bazaar deserves extra props because it's the scm powering a lot of > the Ubuntu integration projects. It's open source (I think they pretty much > all are) but its development is sponsored by Canonical, which is the company > behind Ubuntu. > > I can't remember why I ditched bazaar - I think it was because it didn't > have an eclipse plugin, but I've since discovered that really doesn't matter > with a decent scm. > > > On 28/01/2008, Jeremy Burks wrote: > > > > although i primarily use mercurial, bazaar (http://bazaar-vcs.org/) is > > also worth a mention > > > > On Jan 27, 2008 4:42 PM, Chad Humphries wrote: > > > A good thing to note is that you can run many of the distributed scm > > tools > > > in a 'svn wrapper' mode to ease transition with existing > > repositories. That > > > made the switch much easier for me. > > > > > > > > > - Chad > > > > > > > > > On Jan 27, 2008 5:00 PM, Dan North wrote: > > > > > > > > > > I can see this descending into a mercurial vs git religious war :) > > > > > > > > Hi Corey. I'm using mercurial for both home and work use > > (supplementing > > > some of subversion's shortcomings, mainly around merging). I looked > > > (briefly) at git and - less briefly - at darcs. I settled on mercurial > > for > > > purely non-scientific reasons. People whose opinions I respect are > > using it, > > > the community seems both accommodating and active, and it's python > > which > > > means it runs anywhere python lives, which is all of my home and work > > > environments. > > > > > > > > Others on this list - including the lovely David - are using git and > > > having just as much fun and productivity, so I'm sure it comes down to > > a > > > matter of taste in the end. > > > > > > > > The big shift, though, is from centralised to distributed source > > control. > > > This means that any working copy is also a full repository in its own > > right, > > > so you can do everything you would usually need the server for: > > branching, > > > tagging, cloning, logging, checking in, rolling back, etc. This page > > > (http://tinyurl.com/ykcs25) from the Mercurial wiki gives a pretty > > good > > > overview. The basic model will be the same for any of the distributed > > SCMs. > > > > > > > > My experience so far is: > > > > > > > > git: insanely fast, made up of many shell scripts, big command set, > > does > > > /BIG/ repositories (currently used for the entire linux kernel), > > doesn't run > > > on windows. > > > > darcs: also fast, written in haskell so less "hackable". Has best > > > cherry-picking support (choosing out-of-sequence changesets). > > Apparently > > > doesn't do so well under biiig repositories. > > > > mercurial: also fast (seeing a pattern here?). Seems to scale well. > > Has > > > (deliberately) svn/cvs-like command set where it can, so easy to > > adopt. This > > > is where I've ended up. > > > > monotone: the first distributed scm I came across (Dave Astels was > > using > > > it before any of the rest of us had heard of distributed scm). Never > > really > > > used it much. > > > > > > > > At the end of the day it will be a personal preference. But > > whichever you > > > end up with, my prediction is that you'll enjoy it much more than > > > subversion. > > > > > > > > Cheers, > > > > Dan > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 27/01/2008, Corey Haines wrote: > > > > > > > > > > > > > > > > > > > > Hi, all, > > > > > > > > > > This isn't about rspec, but this list has people whose opinions I > > > respect. > > > > > > > > > > So, I'm looking for a new version control system for my local > > > development. I was going to install subversion, but I've heard rumors > > of > > > people using some newer ones. Thoughts? I'd like to be able to run it > > either > > > locally or on a home server. If I run it off a home server, then it > > needs to > > > support offline access, so that I can use a cached version when I'm > > not on > > > my home network. For simplicity's sake, running it locally is probably > > a > > > better solution. > > > > > > > > > > What do you all use? > > > > > > > > > > > > > > > -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 > > > > > > > > > > > > > _______________________________________________ > > > 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 > -- 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/20080203/b7ddcfab/attachment-0001.html From luislavena at gmail.com Sun Feb 3 12:23:28 2008 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 3 Feb 2008 15:23:28 -0200 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> Message-ID: <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> On Feb 3, 2008 3:13 PM, Corey Haines wrote: > Thanks to everyone for their comments, as well as the lack of SCM fighting. > :) Being on vista, it appears that my choices are a bit limited. > I don't know about Vista, but being using bzr (http://bazaar-vcs.org/) for 8 months and the shift from tradition centralized repositories (svn, cvs) to distributed was a joy. It also doesn't hide you under the same checkout all your branches (to avoid costly disk space?) Anyway, not starting the fight... not now, but I leave you with a link comparing Bzr to Git [1] and Bzr to Hg (Mercurial) [2] On a side note, I'll like to point that it allow you push branches to websites using just dumb protocols like ftp and http for retrieving, with is something sueful for someone with lack ssh or git server capability on their hosting providers. I'm using it to push new development of One-Click Ruby Installer [3] [1] http://bazaar-vcs.org/BzrVsGit [2] http://bazaar-vcs.org/BzrVsHg [3] http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1e2f1b9a3d611e3b -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From coreyhaines at gmail.com Sun Feb 3 12:45:31 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Sun, 3 Feb 2008 12:45:31 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> Message-ID: <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> I'll check that out, too, Luis. Thanks! I'm currently reading up on mercurial, and it is very enlightening. I'll admit that, being a .net developer by trade, I've not really been privy to some of the stuff going on in scm, mostly stuck at a company still using sourcesafe. Please no comments about how it isn't really scm. :) I'm definitely getting a mind-opener reading the mercurial site. My basic need right now is to be able to keep history of my project (Coupon Tracker: http://www.coreyhaines.com/coreysramblings/2008/02/03/TrackingEntertainmentBookSavingsInRailsPartIIIWhyArentYouUsingIt.aspx). While I'm learning RoR, I want to be able to roll back to a previous version if I mess things up too much. :) I'm starting to add some AJAX stuff to the site, and I want to make sure that I can revert when I misuse it. :) Thanks again to everyone for their input. -Corey On Feb 3, 2008 12:23 PM, Luis Lavena wrote: > On Feb 3, 2008 3:13 PM, Corey Haines wrote: > > Thanks to everyone for their comments, as well as the lack of SCM > fighting. > > :) Being on vista, it appears that my choices are a bit limited. > > > > I don't know about Vista, but being using bzr (http://bazaar-vcs.org/) > for 8 months and the shift from tradition centralized repositories > (svn, cvs) to distributed was a joy. > > It also doesn't hide you under the same checkout all your branches (to > avoid costly disk space?) > > Anyway, not starting the fight... not now, but I leave you with a link > comparing Bzr to Git [1] and Bzr to Hg (Mercurial) [2] > > On a side note, I'll like to point that it allow you push branches to > websites using just dumb protocols like ftp and http for retrieving, > with is something sueful for someone with lack ssh or git server > capability on their hosting providers. > > I'm using it to push new development of One-Click Ruby Installer [3] > > [1] http://bazaar-vcs.org/BzrVsGit > [2] http://bazaar-vcs.org/BzrVsHg > [3] > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1e2f1b9a3d611e3b > > -- > Luis Lavena > Multimedia systems > - > A common mistake that people make when trying to design > something completely foolproof is to underestimate > the ingenuity of complete fools. > Douglas Adams > _______________________________________________ > 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/20080203/1683f17d/attachment.html From omen.king at gmail.com Sun Feb 3 12:48:46 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Sun, 3 Feb 2008 12:48:46 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> Message-ID: sourcesafe! I'm suggestively working on getting the company I'm at onto Subversion instead.I feel your pain On Feb 3, 2008 12:45 PM, Corey Haines wrote: > I'll check that out, too, Luis. Thanks! > > I'm currently reading up on mercurial, and it is very enlightening. I'll > admit that, being a .net developer by trade, I've not really been privy to > some of the stuff going on in scm, mostly stuck at a company still using > sourcesafe. Please no comments about how it isn't really scm. :) I'm > definitely getting a mind-opener reading the mercurial site. > > My basic need right now is to be able to keep history of my project > (Coupon Tracker: > http://www.coreyhaines.com/coreysramblings/2008/02/03/TrackingEntertainmentBookSavingsInRailsPartIIIWhyArentYouUsingIt.aspx). > While I'm learning RoR, I want to be able to roll back to a previous version > if I mess things up too much. :) I'm starting to add some AJAX stuff to the > site, and I want to make sure that I can revert when I misuse it. :) > > Thanks again to everyone for their input. > > -Corey > > > On Feb 3, 2008 12:23 PM, Luis Lavena wrote: > > > On Feb 3, 2008 3:13 PM, Corey Haines wrote: > > > Thanks to everyone for their comments, as well as the lack of SCM > > fighting. > > > :) Being on vista, it appears that my choices are a bit limited. > > > > > > > I don't know about Vista, but being using bzr (http://bazaar-vcs.org/) > > for 8 months and the shift from tradition centralized repositories > > (svn, cvs) to distributed was a joy. > > > > It also doesn't hide you under the same checkout all your branches (to > > avoid costly disk space?) > > > > Anyway, not starting the fight... not now, but I leave you with a link > > comparing Bzr to Git [1] and Bzr to Hg (Mercurial) [2] > > > > On a side note, I'll like to point that it allow you push branches to > > websites using just dumb protocols like ftp and http for retrieving, > > with is something sueful for someone with lack ssh or git server > > capability on their hosting providers. > > > > I'm using it to push new development of One-Click Ruby Installer [3] > > > > [1] http://bazaar-vcs.org/BzrVsGit > > [2] http://bazaar-vcs.org/BzrVsHg > > [3] > > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1e2f1b9a3d611e3b > > > > -- > > Luis Lavena > > Multimedia systems > > - > > A common mistake that people make when trying to design > > something completely foolproof is to underestimate > > the ingenuity of complete fools. > > Douglas Adams > > _______________________________________________ > > 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 > > _______________________________________________ > 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/20080203/cf2ee7e7/attachment.html From coreyhaines at gmail.com Sun Feb 3 12:49:37 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Sun, 3 Feb 2008 12:49:37 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> Message-ID: <6bdacb70802030949g4d0f7321pf6f26a4719a32742@mail.gmail.com> :) We are moving to TFS soon, which will be nice. -Corey On Feb 3, 2008 12:48 PM, Andrew WC Brown wrote: > sourcesafe! I'm suggestively working on getting the company I'm at onto > Subversion instead.I feel your pain > > On Feb 3, 2008 12:45 PM, Corey Haines wrote: > > > I'll check that out, too, Luis. Thanks! > > > > I'm currently reading up on mercurial, and it is very enlightening. I'll > > admit that, being a .net developer by trade, I've not really been privy to > > some of the stuff going on in scm, mostly stuck at a company still using > > sourcesafe. Please no comments about how it isn't really scm. :) I'm > > definitely getting a mind-opener reading the mercurial site. > > > > My basic need right now is to be able to keep history of my project > > (Coupon Tracker: > > http://www.coreyhaines.com/coreysramblings/2008/02/03/TrackingEntertainmentBookSavingsInRailsPartIIIWhyArentYouUsingIt.aspx). > > While I'm learning RoR, I want to be able to roll back to a previous version > > if I mess things up too much. :) I'm starting to add some AJAX stuff to the > > site, and I want to make sure that I can revert when I misuse it. :) > > > > Thanks again to everyone for their input. > > > > -Corey > > > > > > On Feb 3, 2008 12:23 PM, Luis Lavena wrote: > > > > > On Feb 3, 2008 3:13 PM, Corey Haines wrote: > > > > Thanks to everyone for their comments, as well as the lack of SCM > > > fighting. > > > > :) Being on vista, it appears that my choices are a bit limited. > > > > > > > > > > I don't know about Vista, but being using bzr (http://bazaar-vcs.org/) > > > for 8 months and the shift from tradition centralized repositories > > > (svn, cvs) to distributed was a joy. > > > > > > It also doesn't hide you under the same checkout all your branches (to > > > avoid costly disk space?) > > > > > > Anyway, not starting the fight... not now, but I leave you with a link > > > comparing Bzr to Git [1] and Bzr to Hg (Mercurial) [2] > > > > > > On a side note, I'll like to point that it allow you push branches to > > > websites using just dumb protocols like ftp and http for retrieving, > > > with is something sueful for someone with lack ssh or git server > > > capability on their hosting providers. > > > > > > I'm using it to push new development of One-Click Ruby Installer [3] > > > > > > [1] http://bazaar-vcs.org/BzrVsGit > > > [2] http://bazaar-vcs.org/BzrVsHg > > > [3] > > > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1e2f1b9a3d611e3b > > > > > > -- > > > Luis Lavena > > > Multimedia systems > > > - > > > A common mistake that people make when trying to design > > > something completely foolproof is to underestimate > > > the ingenuity of complete fools. > > > Douglas Adams > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > > 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/20080203/89df9c79/attachment-0001.html From luislavena at gmail.com Sun Feb 3 13:00:12 2008 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 3 Feb 2008 16:00:12 -0200 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> Message-ID: <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> On Feb 3, 2008 3:45 PM, Corey Haines wrote: > I'll check that out, too, Luis. Thanks! > > I'm currently reading up on mercurial, and it is very enlightening. I'll > admit that, being a .net developer by trade, I've not really been privy to > some of the stuff going on in scm, mostly stuck at a company still using > sourcesafe. Please no comments about how it isn't really scm. :) I'm > definitely getting a mind-opener reading the mercurial site. Yes, Mercurial is nice, and have some functionalities similar to git (topic branches?) which make it more attractive. In any case, the use of python in both cases make Hg and Bzr a good alternative to git. Good luck and hope you then share your findings. Regards, -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From coreyhaines at gmail.com Sun Feb 3 13:28:22 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Sun, 3 Feb 2008 13:28:22 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> Message-ID: <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> Thanks, Luis! I'll do my best to post my findings on my blog. -Corey On Feb 3, 2008 1:00 PM, Luis Lavena wrote: > On Feb 3, 2008 3:45 PM, Corey Haines wrote: > > I'll check that out, too, Luis. Thanks! > > > > I'm currently reading up on mercurial, and it is very enlightening. I'll > > admit that, being a .net developer by trade, I've not really been privy > to > > some of the stuff going on in scm, mostly stuck at a company still using > > sourcesafe. Please no comments about how it isn't really scm. :) I'm > > definitely getting a mind-opener reading the mercurial site. > > Yes, Mercurial is nice, and have some functionalities similar to git > (topic branches?) which make it more attractive. > > In any case, the use of python in both cases make Hg and Bzr a good > alternative to git. > > Good luck and hope you then share your findings. > Regards, > > -- > Luis Lavena > Multimedia systems > - > A common mistake that people make when trying to design > something completely foolproof is to underestimate > the ingenuity of complete fools. > Douglas Adams > _______________________________________________ > 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/20080203/d7543aea/attachment.html From rspec-users at kero.tmfweb.nl Sun Feb 3 13:59:54 2008 From: rspec-users at kero.tmfweb.nl (rspec-users at kero.tmfweb.nl) Date: Sun, 3 Feb 2008 19:59:54 +0100 (CET) Subject: [rspec-users] "once" not honored? Message-ID: <20080203185954.074937B5C@mint.qinip.net> I'm trying this: firmware.should_receive(:execute).with("ATZ").once.ordered.and_return(AT_OK) firmware.should_receive(:execute).with("ATE0V1").once.ordered.and_return(AT_OK) firmware.should_receive(:execute).with("AT+CNUM").once.and_return(AT_OK) But rspec does not complain that "AT+CNUM" is never passed as argument. Bug? Or did I misinterpret the feature "once" ? NB: I'd love to be able to write firmware.should_receive("AT+CNUM") but that seems to fail on the way the method :"AT+CNUM" is being defined; which in turn seems something I can only change (quickly) for Ruby 1.9, namely blocks not accepting implicit blocks as parameter. Any chance of fixing that? Bye, Kero. From tyeshavik at gmail.com Sun Feb 3 16:12:35 2008 From: tyeshavik at gmail.com (Tye Shavik) Date: Sun, 3 Feb 2008 16:12:35 -0500 Subject: [rspec-users] specing dynamic routes Message-ID: Hi, I dynamically generating routes and I'm running into trouble specing due to isolation. I need to know if there is a way to mock routes, I tried but not sure how to approach it. Let me describe what I'm attempting to do: I have many nodes of different category types eg. polls, pictures, videos So whenever a new category is added there should be named routes for it. The code part works fine, the routes are being generated http://pastie.org/147021 But I don't know how to make rspec play pretend and say the routes are there. Routes and spec: http://pastie.org/147018 Error: 'NodesController#route_for should map { :controller => 'nodes', :action => 'index' } to /discussions' FAILED expected: "/discussions", got: "/nodes?node_category=discussions" (using ==) Thanks for any assistance From nathan.sutton at gmail.com Mon Feb 4 00:19:28 2008 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Sun, 3 Feb 2008 23:19:28 -0600 Subject: [rspec-users] Development Cycle Message-ID: <290242E1-2777-4359-9165-23B56CB68CC3@gmail.com> Hey guys, I'm trying to work out the order of development for features in an app. I'm struggling with using stories to drive development. So when looking at things, it seems to me to be the best idea to first write stories, then view specs, then controller specs, then model specs...but how to actually do it is what confuses me. Anyone know of any screencasts or tutorials working through the development of a feature in this way? Nathan Sutton fowlduck at gmail.com rspec 1.1.3 rspec_on_rails 1.1.3 rails 2.0.2 From ben at benmabey.com Mon Feb 4 01:41:25 2008 From: ben at benmabey.com (Ben Mabey) Date: Sun, 03 Feb 2008 23:41:25 -0700 Subject: [rspec-users] Development Cycle In-Reply-To: <290242E1-2777-4359-9165-23B56CB68CC3@gmail.com> References: <290242E1-2777-4359-9165-23B56CB68CC3@gmail.com> Message-ID: <47A6B395.70206@benmabey.com> Nathan Sutton wrote: > Hey guys, I'm trying to work out the order of development for features > in an app. I'm struggling with using stories to drive development. > > So when looking at things, it seems to me to be the best idea to first > write stories, then view specs, then controller specs, then model > specs...but how to actually do it is what confuses me. Anyone know of > any screencasts or tutorials working through the development of a > feature in this way? > > Nathan Sutton > fowlduck at gmail.com > rspec 1.1.3 > rspec_on_rails 1.1.3 > rails 2.0.2 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > There is a new peepcode on story runner... I have yet to watch it fully but if it is like the other peepcode rspec screencasts it will be an excellent source. Also, check out Pat Madox's screencast about the story runner. It is a little dated but it is still good: http://evang.eli.st/blog/2007/10/8/story-runner-top-to-bottom-screencast There are also some posts that cover the basics of plain text stories... Here is a more recent one with some other links at the bottom: http://www.tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app I also just posted one about using webrat to help write stories (webrat absolutely rocks!): http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ The screencasts go over the development process while the posts are more of how-tos for story runner. -Ben From rick.walsh at gmail.com Sun Feb 3 12:32:46 2008 From: rick.walsh at gmail.com (herding) Date: Sun, 3 Feb 2008 09:32:46 -0800 (PST) Subject: [rspec-users] Newbie question with rspec on rails Message-ID: <15255819.post@talk.nabble.com> Hi, I'm just startingwith Rspec with the rails framework. I have a question regarding contexts. If I use a generator for a model, for example, user, I get a user_spec which I can place rspec specs. Should I be only having one file per model? What is the convention for naming and creating specs when speccing out cross object behaviour? Really appreciate your thoughts. Also, can anybody recommend any good books or tutorials on Rspec? Many thanks! -- View this message in context: http://www.nabble.com/Newbie-question-with-rspec-on-rails-tp15255819p15255819.html Sent from the rspec-users mailing list archive at Nabble.com. From pergesu at gmail.com Mon Feb 4 02:14:25 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 3 Feb 2008 23:14:25 -0800 Subject: [rspec-users] Development Cycle In-Reply-To: <290242E1-2777-4359-9165-23B56CB68CC3@gmail.com> References: <290242E1-2777-4359-9165-23B56CB68CC3@gmail.com> Message-ID: <810a540e0802032314x7015d798s7af0fae3d577248b@mail.gmail.com> On Feb 3, 2008 9:19 PM, Nathan Sutton wrote: > Hey guys, I'm trying to work out the order of development for features > in an app. I'm struggling with using stories to drive development. > > So when looking at things, it seems to me to be the best idea to first > write stories, then view specs, then controller specs, then model > specs...but how to actually do it is what confuses me. Anyone know of > any screencasts or tutorials working through the development of a > feature in this way? hrm...yeah it's a little tough. I think we're all still figuring it out a bit and there's not a lot of solid info. I personally feel that my understanding has developed a bunch since I made my last Story Runner screencast, so maybe I'll try to put one out another one next weekend. Here's what I do, in a nutshell: Write out a story, without implementing any of the step runners Write the step runner implementations to get an idea of what stuff I'll need to make it run Delete those step implementations - that was just to get the blood flowing Write the first step implementation Drop out of the story and start writing specs for the behavior I need to pass the story step When that step is passing, I head back to the story and work on the next step Rinse, repeat ??? profit! Hope that's enough to get you started, in addition to the good links that Ben posted. And like I said, I'd like to do a new screencast this weekend. Pat From pergesu at gmail.com Mon Feb 4 02:20:48 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 3 Feb 2008 23:20:48 -0800 Subject: [rspec-users] Newbie question with rspec on rails In-Reply-To: <15255819.post@talk.nabble.com> References: <15255819.post@talk.nabble.com> Message-ID: <810a540e0802032320q23ac964eka38b9d2861cccf02@mail.gmail.com> On Feb 3, 2008 9:32 AM, herding wrote: > > Hi, > > I'm just startingwith Rspec with the rails framework. > > I have a question regarding contexts. > > If I use a generator for a model, for example, user, I get a user_spec which > I can place rspec specs. > > Should I be only having one file per model? What is the convention for > naming and creating specs when speccing out cross object behaviour? > > Really appreciate your thoughts. > > Also, can anybody recommend any good books or tutorials on Rspec? > > Many thanks! You don't necessarily have to have one spec file per model. It's a pretty convenient convention though (and I just noticed for the first time in my life that convenient and convention have the same root). You can do whatever you want to keep your specs organized, but I've found that I don't often need to use multiple files to spec the same class. As for tutorials, I'd recommend watching the peepcode vids. They do a great job of demonstrating the technical use of RSpec, though they're a bit light on the conceptual stuff. For some info on why BDD kicks TDD's butt, I would check out http://behaviour-driven.org/ http://video.google.com/videoplay?docid=8135690990081075324 http://dannorth.net/tags/agile/bdd http://blog.davidchelimsky.net/ Pat From pergesu at gmail.com Mon Feb 4 02:31:22 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 3 Feb 2008 23:31:22 -0800 Subject: [rspec-users] Newbie question with rspec on rails In-Reply-To: <15255819.post@talk.nabble.com> References: <15255819.post@talk.nabble.com> Message-ID: <810a540e0802032331r13214685nfab9aff2b6586cfa@mail.gmail.com> > What is the convention for naming and creating specs when speccing out cross object behaviour? I missed this. For stuff like mixins, I'll generally stick the module definition under lib/ and have a corresponding spec under spec/lib. Also I usually write the spec like module NameableSpec class Person include Nameable end describe Nameable do before(:each) do @person = Person.new @person.set_name "Pat Maddox" end it "should parse the first name" do @person.first_name.should == "Pat" end it "should parse the last name" do @person.last_name.should == "Maddox" end end end The reason that I do that is because in order to write a spec for this module, I have to actually mix it into a class. I wrap the whole spec in a module so that my test class name doesn't clash with any existing class names. Another way to do it is to define the class dynamically before each test: describe Nameable do before(:each) do klass = Class.new { include Nameable } @person = klass.new @person.set_name "Pat Maddox" end it "should parse the first name" do @person.first_name.should == "Pat" end it "should parse the last name" do @person.last_name.should == "Maddox" end end The upside to that is that you don't have the ugly wrapper module. The downside is that you can't easily reuse the class between describe blocks - you'd still want to have a wrapper module to avoid polluting the namespace. I tend to prefer this dynamic class creation, because it's usually less code. I also end up with a bunch of little, temporary helper classes that have only the behavior I want, rather than a bigger test helper class with behavior to support multiple specs. I'm curious how other people handle this type of thing. Pat From dave at 2young2die.com Mon Feb 4 06:24:46 2008 From: dave at 2young2die.com (David Currin) Date: Mon, 4 Feb 2008 12:24:46 +0100 Subject: [rspec-users] Trouble testing a method with loop Message-ID: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> I'm having trouble working out how to test a method that contains a loop. I'm new to rspec so not sure what the best way is to tackle this. class Company < ActiveRecord::Base def self.sync_with_basecamp companies = basecamp_fetch("companies") companies.each do |c| company = self.find_or_initialize_by_name_and_postcode(c.name, c.zip) company.county = c.state company.city = c.city company.save end end end I started by checking that the number of companies in my mock companies array was saved: it "should write all records from array to the database" do lambda { Company.sync_with_basecamp }.should change(Company, :count).by(37) end But I'm having trouble figuring out how to check individual records. I can pull the first record from the mock array: it "should populate name" do @company.first.name.should eql("The Media Collective") end But I can't check that this has been applied to the method because rspec doesn't know about the save loop. it "should populate name" do @company.name.should eql("The Media Collective") end Would appreciate some advice on how to tackle this please from someone more familiar with rspec than me. From voodoorai2000 at gmail.com Mon Feb 4 07:54:43 2008 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Mon, 4 Feb 2008 13:54:43 +0100 Subject: [rspec-users] RESTful Routes Message-ID: Hi, I'm trying to test the behavior of a route with a delete method. Something like this: When "the admin clicks on 'delete'" do delete admin_blog_path(@blog) end which raises the following exception: NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.env If I change the delete, for a get or a post it works like a charm. What am I missing here? Thanks in advance! Raimond Garcia From dchelimsky at gmail.com Mon Feb 4 08:10:42 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 07:10:42 -0600 Subject: [rspec-users] RESTful Routes In-Reply-To: References: Message-ID: <57c63afe0802040510t727e0481q1cb719459e22a4ed@mail.gmail.com> On Feb 4, 2008 6:54 AM, Raimond Garcia wrote: > Hi, > > I'm trying to test the behavior of a route with a delete method. > > Something like this: > When "the admin clicks on 'delete'" do > delete admin_blog_path(@blog) > end > > which raises the following exception: > NoMethodError: You have a nil object when you didn't expect it! > The error occurred while evaluating nil.env Can you show the rest of the backtrace? > > > If I change the delete, for a get or a post it works like a charm. > > What am I missing here? > > Thanks in advance! > > > Raimond Garcia > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Feb 4 08:12:29 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 07:12:29 -0600 Subject: [rspec-users] Trouble testing a method with loop In-Reply-To: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> References: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> Message-ID: <57c63afe0802040512i6637e89fk278a05b5542dd919@mail.gmail.com> On Feb 4, 2008 5:24 AM, David Currin wrote: > I'm having trouble working out how to test a method that contains a > loop. I'm new to rspec so not sure what the best way is to tackle > this. > > class Company < ActiveRecord::Base > > def self.sync_with_basecamp > companies = basecamp_fetch("companies") > > companies.each do |c| > company = self.find_or_initialize_by_name_and_postcode(c.name, c.zip) > company.county = c.state > company.city = c.city > company.save > end > > end > > end > > I started by checking that the number of companies in my mock > companies array was saved: > > it "should write all records from array to the database" do > lambda { > Company.sync_with_basecamp > }.should change(Company, :count).by(37) > end > > But I'm having trouble figuring out how to check individual records. I > can pull the first record from the mock array: > > it "should populate name" do > @company.first.name.should eql("The Media Collective") > end It depends on how clearly you want to isolate from the database. Your first example is going to hit the DB 37 times. I wouldn't do that personally. Even if I was hitting the database I'd reduce that dataset to one or two records. The way I'd approach this if I were trying to isolate from the DB would be like this: @company = mock_model(Company) Company.should_receive(:basecamp_fetch). with("companies"). and_return([@company]) # ... expectations about @company HTH, David > > But I can't check that this has been applied to the method because > rspec doesn't know about the save loop. > > it "should populate name" do > @company.name.should eql("The Media Collective") > end > > > Would appreciate some advice on how to tackle this please from someone > more familiar with rspec than me. > _______________________________________________ > 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/20080204/cafe800f/attachment.html From jarkko at jlaine.net Mon Feb 4 09:09:25 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Mon, 4 Feb 2008 16:09:25 +0200 Subject: [rspec-users] RESTful Routes In-Reply-To: References: Message-ID: <56496E32-27A2-47E8-BE82-ACE82C7CE42D@jlaine.net> On 4.2.2008, at 14.54, Raimond Garcia wrote: > Hi, > > I'm trying to test the behavior of a route with a delete method. > > Something like this: > When "the admin clicks on 'delete'" do > delete admin_blog_path(@blog) > end > > which raises the following exception: > NoMethodError: You have a nil object when you didn't expect it! > The error occurred while evaluating nil.env > > > If I change the delete, for a get or a post it works like a charm. > > What am I missing here? I would recommend against using the restful named routes in your stories. You want to test your full stack there, right, so just use the url. I also recommend using Webrat in conjunction with stories: http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ That way you are much more testing the behaviour of the application rather than its implementation. If you only want to test that the route is working, it would imho belong to the controller specs, not to the stories. Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From dave at 2young2die.com Mon Feb 4 09:35:35 2008 From: dave at 2young2die.com (David Currin) Date: Mon, 4 Feb 2008 15:35:35 +0100 Subject: [rspec-users] Trouble testing a method with loop In-Reply-To: <57c63afe0802040512i6637e89fk278a05b5542dd919@mail.gmail.com> References: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> <57c63afe0802040512i6637e89fk278a05b5542dd919@mail.gmail.com> Message-ID: <9d28ac860802040635y1d552ea1yf7104a87cb6e1063@mail.gmail.com> Thanks, Point taken about less interaction with the database. The 'companies' mock is an exact representation of the companies list returned by the basecamp api which is why there's 37 records in there. I need to learn to think more clearly about separation from the database I guess. The point is actually that none of these examples are touching the database at the moment because rspec doesn't know about the companies.each do loop in the model. I'm wanting to cycle through the list of companies in the fetched array and save these as rows in the database. I have done a basic implementation of this in the model, but I can't get this through to rspec. On 04/02/2008, David Chelimsky wrote: > On Feb 4, 2008 5:24 AM, David Currin wrote: > > I'm having trouble working out how to test a method that contains a > > loop. I'm new to rspec so not sure what the best way is to tackle > > this. > > > > class Company < ActiveRecord::Base > > > > def self.sync_with_basecamp > > companies = basecamp_fetch("companies") > > > > companies.each do |c| > > company = > self.find_or_initialize_by_name_and_postcode(c.name, c.zip) > > company.county = c.state > > company.city = c.city > > company.save > > end > > > > end > > > > end > > > > I started by checking that the number of companies in my mock > > companies array was saved: > > > > it "should write all records from array to the database" do > > lambda { > > Company.sync_with_basecamp > > }.should change(Company, :count).by(37) > > end > > > > But I'm having trouble figuring out how to check individual records. I > > can pull the first record from the mock array: > > > > it "should populate name" do > > @company.first.name.should eql("The Media Collective") > > end > > It depends on how clearly you want to isolate from the database. Your first > example is going to hit the DB 37 times. I wouldn't do that personally. Even > if I was hitting the database I'd reduce that dataset to one or two records. > > The way I'd approach this if I were trying to isolate from the DB would be > like this: > > @company = mock_model(Company) > Company.should_receive(:basecamp_fetch). > with("companies"). > and_return([@company]) > # ... expectations about @company > > HTH, > David > > > > > > But I can't check that this has been applied to the method because > > rspec doesn't know about the save loop. > > > > it "should populate name" do > > @company.name.should eql("The Media Collective") > > end > > > > > > Would appreciate some advice on how to tackle this please from someone > > more familiar with rspec than me. > > _______________________________________________ > > 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 pergesu at gmail.com Mon Feb 4 10:19:03 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 4 Feb 2008 07:19:03 -0800 Subject: [rspec-users] Trouble testing a method with loop In-Reply-To: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> References: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> Message-ID: <810a540e0802040719g5bd6c276x8ac0c69fd5847eb1@mail.gmail.com> Extract the company creation to a method, so that that method only builds one record at a time. Test that it works properly. Then you can keep the test that you have, verifying that it creates the right number of records. Pat From dchelimsky at gmail.com Mon Feb 4 10:51:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 09:51:33 -0600 Subject: [rspec-users] BDD and TDD (was "Newbie question with rspec on rails") Message-ID: <57c63afe0802040751k7122eb3fxb0c9ad72c8375106@mail.gmail.com> On Feb 4, 2008 1:20 AM, Pat Maddox wrote: > For some info on why BDD kicks TDD's butt ... Woah! I find this deeply disturbing. I believe your heart is in the right place here, so please don't take this as a personal attack, but this statement reflects a view that I see expressed quite often and I think we need to set the record straight on a few things. To be clear, what I'm about to express are my personal views and may not align with those of Dan, Dave, Aslak and others who are driving the BDD discussion. This is not a contest between approaches. BDD started off as a thought experiment: an attempt to find a better way to *talk* about TDD, because some of us who felt like we *got* TDD wanted to help those that we felt didn't. The process (at the object level) was (and remains) the same. We were just playing with words and constructs to better evoke what we believed to be the essence of TDD: driving out implementation with executable examples of the expected behaviour. Over time BDD has grown to include TDD (which is about the behaviour of objects) and an approach to Customer Acceptance Testing (which is about the behaviour of systems) called Acceptance Test Driven Planning. It's evolving into a full-stack agile process, so at this point trying to compare TDD with BDD doesn't make sense since the former is part of the latter. But even back when BDD was only about objects, it was still TDD at it's core. Not better than TDD. Not even different from TDD as practiced by those who really understood it. So while "TDD as intended" kicks "TDD the way many do"'s butt, and while BDD may help people to see the light, that light still belongs to TDD. FWIW, David From omen.king at gmail.com Mon Feb 4 11:07:08 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 4 Feb 2008 11:07:08 -0500 Subject: [rspec-users] BDD and TDD (was "Newbie question with rspec on rails") In-Reply-To: <57c63afe0802040751k7122eb3fxb0c9ad72c8375106@mail.gmail.com> References: <57c63afe0802040751k7122eb3fxb0c9ad72c8375106@mail.gmail.com> Message-ID: David, I'll be your cha'Dich Some people still sware using TDD over BDD. On Feb 4, 2008 10:51 AM, David Chelimsky wrote: > On Feb 4, 2008 1:20 AM, Pat Maddox wrote: > > For some info on why BDD kicks TDD's butt ... > > Woah! > > I find this deeply disturbing. I believe your heart is in the right > place here, so please don't take this as a personal attack, but this > statement reflects a view that I see expressed quite often and I think > we need to set the record straight on a few things. > > To be clear, what I'm about to express are my personal views and may > not align with those of Dan, Dave, Aslak and others who are driving > the BDD discussion. > > This is not a contest between approaches. > > BDD started off as a thought experiment: an attempt to find a better > way to *talk* about TDD, because some of us who felt like we *got* TDD > wanted to help those that we felt didn't. The process (at the object > level) was (and remains) the same. We were just playing with words and > constructs to better evoke what we believed to be the essence of TDD: > driving out implementation with executable examples of the expected > behaviour. > > Over time BDD has grown to include TDD (which is about the behaviour > of objects) and an approach to Customer Acceptance Testing (which is > about the behaviour of systems) called Acceptance Test Driven > Planning. It's evolving into a full-stack agile process, so at this > point trying to compare TDD with BDD doesn't make sense since the > former is part of the latter. > > But even back when BDD was only about objects, it was still TDD at > it's core. Not better than TDD. Not even different from TDD as > practiced by those who really understood it. > > So while "TDD as intended" kicks "TDD the way many do"'s butt, and > while BDD may help people to see the light, that light still belongs > to TDD. > > FWIW, > David > _______________________________________________ > 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/20080204/324c82b0/attachment-0001.html From nathan.sutton at gmail.com Mon Feb 4 11:09:45 2008 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Mon, 4 Feb 2008 10:09:45 -0600 Subject: [rspec-users] Development Cycle In-Reply-To: <810a540e0802032314x7015d798s7af0fae3d577248b@mail.gmail.com> References: <290242E1-2777-4359-9165-23B56CB68CC3@gmail.com> <810a540e0802032314x7015d798s7af0fae3d577248b@mail.gmail.com> Message-ID: sounds good guys, thanks :) Nathan Sutton fowlduck at gmail.com rspec 1.1.3 rspec_on_rails 1.1.3 rails 2.0.2 On Feb 4, 2008, at 1:14 AM, Pat Maddox wrote: > On Feb 3, 2008 9:19 PM, Nathan Sutton wrote: >> Hey guys, I'm trying to work out the order of development for >> features >> in an app. I'm struggling with using stories to drive development. >> >> So when looking at things, it seems to me to be the best idea to >> first >> write stories, then view specs, then controller specs, then model >> specs...but how to actually do it is what confuses me. Anyone know >> of >> any screencasts or tutorials working through the development of a >> feature in this way? > > hrm...yeah it's a little tough. I think we're all still figuring it > out a bit and there's not a lot of solid info. I personally feel that > my understanding has developed a bunch since I made my last Story > Runner screencast, so maybe I'll try to put one out another one next > weekend. > > Here's what I do, in a nutshell: > > Write out a story, without implementing any of the step runners > Write the step runner implementations to get an idea of what stuff > I'll need to make it run > Delete those step implementations - that was just to get the blood > flowing > Write the first step implementation > Drop out of the story and start writing specs for the behavior I need > to pass the story step > When that step is passing, I head back to the story and work on the > next step > Rinse, repeat > ??? > profit! > > Hope that's enough to get you started, in addition to the good links > that Ben posted. And like I said, I'd like to do a new screencast > this weekend. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From voodoorai2000 at gmail.com Mon Feb 4 11:49:39 2008 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Mon, 4 Feb 2008 17:49:39 +0100 Subject: [rspec-users] RESTful Routes Message-ID: <27A02E78-9A95-4990-9849-EEA873B18F42@gmail.com> On Feb 4, 2008 6:54 AM, Raimond Garcia wrote: > Hi, > > I'm trying to test the behavior of a route with a delete method. > > Something like this: > When "the admin clicks on 'delete'" do > delete admin_blog_path(@blog) > end > > which raises the following exception: > NoMethodError: You have a nil object when you didn't expect it! > The error occurred while evaluating nil.env Can you show the rest of the backtrace? Sure, I'm using rspec 1.1.2, the backtrace is nice and clean, to get the following, I commented out all the IGNORE_PATTERS, there is probably a better way of doing it, but it worked. NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.env /Users/raimondgarcia/Documents/workspace/breport.git/config/../ vendor/rails/actionpack/lib/action_controller/test_process.rb:352:in `delete' ./stories/steps/blog_steps.rb:10:in `the admin clicks on 'delete'' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ step.rb:16:in `__send__' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ step.rb:16:in `perform' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ world.rb:73:in `store_and_call' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ world.rb:110:in `When' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_mediator.rb:115:in `send' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_mediator.rb:115:in `to_proc' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_mediator.rb:95:in `instance_eval' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_mediator.rb:95:in `to_proc' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_mediator.rb:95:in `each' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_mediator.rb:95:in `to_proc' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/scenario_runner.rb:14:in `instance_eval' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/scenario_runner.rb:14:in `run' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_runner.rb:48:in `run_stories' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_runner.rb:44:in `each' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_runner.rb:44:in `run_stories' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_runner.rb:39:in `each' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner/story_runner.rb:39:in `run_stories' /Users/raimondgarcia/Documents/workspace/breport.git/config/../vendor/ plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/story/ runner.rb:46:in `register_exit_hook' stories/user_blogs.rb:4 Thanks, Raimond Garcia > > > If I change the delete, for a get or a post it works like a charm. > > What am I missing here? > > Thanks in advance! > > > Raimond Garcia -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080204/52717d1d/attachment.html From voodoorai2000 at gmail.com Mon Feb 4 12:00:50 2008 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Mon, 4 Feb 2008 18:00:50 +0100 Subject: [rspec-users] rspec-users Digest, Vol 20, Issue 6 In-Reply-To: References: Message-ID: <86009A2D-8C14-4BE7-B47A-E23F03F04313@gmail.com> On Feb 4, 2008, at 5:07 PM, rspec-users-request at rubyforge.org wrote: > On 4.2.2008, at 14.54, Raimond Garcia wrote: > >> Hi, >> >> I'm trying to test the behavior of a route with a delete method. >> >> Something like this: >> When "the admin clicks on 'delete'" do >> delete admin_blog_path(@blog) >> end >> >> which raises the following exception: >> NoMethodError: You have a nil object when you didn't expect it! >> The error occurred while evaluating nil.env >> >> >> If I change the delete, for a get or a post it works like a charm. >> >> What am I missing here? > > I would recommend against using the restful named routes in your > stories. You want to test your full stack there, right, so just use > the url. I also recommend using Webrat in conjunction with stories: http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ > > That way you are much more testing the behaviour of the application > rather than its implementation. > > If you only want to test that the route is working, it would imho > belong to the controller specs, not to the stories. > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > > ------------------------------ Interesting Jarkko... The restful routes, seem clearer than using urls, maybe not so much for this case, but for very long urls, that include for example the title of a blog, I would rather use blog_path(@blog). Yes, I want to test the full stack, for sure! However, I don't see how using named routes, stops you from doing this.... Webrat two thumbs up, I've been using selenium up to now, but would like to try other alternatives to see which one works better. Regards, Raimond Garcia -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080204/530be305/attachment.html From dchelimsky at gmail.com Mon Feb 4 12:12:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 11:12:18 -0600 Subject: [rspec-users] RESTful Routes In-Reply-To: <27A02E78-9A95-4990-9849-EEA873B18F42@gmail.com> References: <27A02E78-9A95-4990-9849-EEA873B18F42@gmail.com> Message-ID: <57c63afe0802040912j5b0f466bp5d4c7cdb2da548a5@mail.gmail.com> On Feb 4, 2008 10:49 AM, Raimond Garcia wrote: > > On Feb 4, 2008 6:54 AM, Raimond Garcia wrote: > Hi, > > I'm trying to test the behavior of a route with a delete method. > > Something like this: > When "the admin clicks on 'delete'" do > delete admin_blog_path(@blog) > end > > which raises the following exception: > NoMethodError: You have a nil object when you didn't expect it! > The error occurred while evaluating nil.env > > Can you show the rest of the backtrace? > > Sure, I'm using rspec 1.1.2, the backtrace is nice and clean, to get the > following, I commented out all the IGNORE_PATTERS, there is probably a > better way of doing it, but it worked. Sorry, but I can't really see anything related to rspec from the backtrace. I changed to a named route in one of my own steps and it worked fine. Can you try doing this in a rails integration test and see if you have a different result? From voodoorai2000 at gmail.com Mon Feb 4 12:16:16 2008 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Mon, 4 Feb 2008 18:16:16 +0100 Subject: [rspec-users] RESTful Routes In-Reply-To: References: Message-ID: <6A2E7837-E4F3-4DC8-9E3A-DE7B3E70D6D8@gmail.com> > > On 4.2.2008, at 14.54, Raimond Garcia wrote: > >> Hi, >> >> I'm trying to test the behavior of a route with a delete method. >> >> Something like this: >> When "the admin clicks on 'delete'" do >> delete admin_blog_path(@blog) >> end >> >> which raises the following exception: >> NoMethodError: You have a nil object when you didn't expect it! >> The error occurred while evaluating nil.env >> >> >> If I change the delete, for a get or a post it works like a charm. >> >> What am I missing here? > > I would recommend against using the restful named routes in your > stories. You want to test your full stack there, right, so just use > the url. I also recommend using Webrat in conjunction with stories: http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/ > > That way you are much more testing the behaviour of the application > rather than its implementation. > > If you only want to test that the route is working, it would imho > belong to the controller specs, not to the stories. > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi Interesting Jarkko... The restful routes, seem clearer than using urls, maybe not so much for this case, but for very long urls, that include for example the title of a blog, I would rather use blog_path(@blog). Yes, I want to test the full stack, for sure! However, I don't see how using named routes, stops you from doing this.... Webrat two thumbs up, I've been using selenium up to now, but would like to try other alternatives to see which one works better. Regards, Raimond Garcia P.S. This message is repeated with the wrong subject somewhere in the mailing list, sorry about that ;-| From pergesu at gmail.com Mon Feb 4 12:19:17 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 4 Feb 2008 09:19:17 -0800 Subject: [rspec-users] BDD and TDD (was "Newbie question with rspec on rails") In-Reply-To: <57c63afe0802040751k7122eb3fxb0c9ad72c8375106@mail.gmail.com> References: <57c63afe0802040751k7122eb3fxb0c9ad72c8375106@mail.gmail.com> Message-ID: <810a540e0802040919w74ef1a9dqa34e1574b283618@mail.gmail.com> On Feb 4, 2008 7:51 AM, David Chelimsky wrote: > On Feb 4, 2008 1:20 AM, Pat Maddox wrote: > > For some info on why BDD kicks TDD's butt ... > > Woah! > > I find this deeply disturbing. I believe your heart is in the right > place here, so please don't take this as a personal attack, but this > statement reflects a view that I see expressed quite often and I think > we need to set the record straight on a few things. > > To be clear, what I'm about to express are my personal views and may > not align with those of Dan, Dave, Aslak and others who are driving > the BDD discussion. > > This is not a contest between approaches. I'm pretty bad at the tongue-in-cheek thing. What I think newcomers to BDD will find - and that's because BDD advocates tend to explain this very well - is that BDD is strongly rooted in TDD, XP, and domain-driven design. My favorite way to explain BDD is: There's a quote that says "Seek not to follow in the footsteps of masters, seek what they sought." BDD presents the "seek what they sought" as first-level knowledge. I apologize for making a statement that might suggest there's a conflict where there isn't one. Pat From pergesu at gmail.com Mon Feb 4 12:22:50 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 4 Feb 2008 09:22:50 -0800 Subject: [rspec-users] BDD and TDD (was "Newbie question with rspec on rails") In-Reply-To: <810a540e0802040919w74ef1a9dqa34e1574b283618@mail.gmail.com> References: <57c63afe0802040751k7122eb3fxb0c9ad72c8375106@mail.gmail.com> <810a540e0802040919w74ef1a9dqa34e1574b283618@mail.gmail.com> Message-ID: <810a540e0802040922o7e3d2a1eu42cbd8eb72ad74eb@mail.gmail.com> On Feb 4, 2008 9:19 AM, Pat Maddox wrote: > My favorite way to explain BDD is: > > There's a quote that says "Seek not to follow in the footsteps of > masters, seek what they sought." BDD presents the "seek what they > sought" as first-level knowledge. That should read "...presents the 'what they sought' ..." From voodoorai2000 at gmail.com Mon Feb 4 14:16:11 2008 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Mon, 4 Feb 2008 20:16:11 +0100 Subject: [rspec-users] RESTful Routes In-Reply-To: References: Message-ID: >> Hi, >> >> I'm trying to test the behavior of a route with a delete method. >> >> Something like this: >> When "the admin clicks on 'delete'" do >> delete admin_blog_path(@blog) >> end >> >> which raises the following exception: >> NoMethodError: You have a nil object when you didn't expect it! >> The error occurred while evaluating nil.env >> >> Can you show the rest of the backtrace? >> >> Sure, I'm using rspec 1.1.2, the backtrace is nice and clean, to >> get the >> following, I commented out all the IGNORE_PATTERS, there is >> probably a >> better way of doing it, but it worked. > > Sorry, but I can't really see anything related to rspec from the > backtrace. I changed to a named route in one of my own steps and it > worked fine. Can you try doing this in a rails integration test and > see if you have a different result? > Will do. Thanks for the fast replies! > > ------------------------------ From lance at electricsheepcompany.com Mon Feb 4 13:57:10 2008 From: lance at electricsheepcompany.com (Lance Ball) Date: Mon, 4 Feb 2008 13:57:10 -0500 Subject: [rspec-users] Problems with plugins? Message-ID: <21666E3D-B611-410F-A750-2F9273D9AF91@electricsheepcompany.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there I've run into a bit of a problem that I can't seem to figure out. I have a model class User which includes our acts_as_role_context library. This lib acts like most other acts_as libs, evaluating class and instance methods at runtime. When I try to stub methods that are defined in acts_as_role_context, I get strange behavior. Perhaps it's just me. I am a bit under the weather, and the Nyquil could be clouding my thinking. :) Here is my spec. It's pretty simple, I just want to ensure that the correct redirect happens when it should. For the record, the controller works as expected outside of rspec. - --------- require File.dirname(__FILE__) + '/../spec_helper' describe MemberNetworkController do before(:each) do controller.should_receive(:beta_lockdown).and_return true login end after(:each) do logout end describe "on GET to add_as_friend" do it "should redirect to /network/friends" do logged_in_user.stub!(:add_user_to_role) controller.stub!(:make_friend_activity) get :add_as_friend, :key => logged_in_user.key response.should redirect_to("/members/#{logged_in_user.id}/ network/friends") end end end - -------- The line in question is logged_in_user.stub!(:add_user_to_role). User#add_user_to_role is defined in acts_as_role_context.rb. I'll not paste the entire file unless requested. It's fairly large. the instance method #add_user_to_role looks like this. - -------- def add_user_to_role(user, role_or_key) role = self.class.sanitize_role( role_or_key ) binding = role_bindings.find( :first, :conditions=> [ 'role_id=? AND user_id=?', role.id, user.id ] ) if ( binding.nil? ) role_bindings.create ( :context=>self, :user=>user, :role=>role ) end end - -------- When #add_user_to_role is called in the controller during my spec, the method is run, rather than being a stub as I would expect. Is this expected and/or known behavior? Any comments and direction are very much appreciated. Thanks Lance! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFHp2AG+EgDjU0WSaoRArYDAJ92Wpp1Nkybqk7lb8fY+of+tcIawACaAyRk y6Lo0iCvWS8/afBDTx42XiY= =dfEK -----END PGP SIGNATURE----- From dchelimsky at gmail.com Mon Feb 4 14:34:37 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 13:34:37 -0600 Subject: [rspec-users] Problems with plugins? In-Reply-To: <21666E3D-B611-410F-A750-2F9273D9AF91@electricsheepcompany.com> References: <21666E3D-B611-410F-A750-2F9273D9AF91@electricsheepcompany.com> Message-ID: <57c63afe0802041134s13ebc9f4s8a7a2093f20bbc9f@mail.gmail.com> On Feb 4, 2008 12:57 PM, Lance Ball wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi there > > I've run into a bit of a problem that I can't seem to figure out. I > have a model class User which includes our acts_as_role_context > library. This lib acts like most other acts_as libs, evaluating > class and instance methods at runtime. When I try to stub methods > that are defined in acts_as_role_context, I get strange behavior. > Perhaps it's just me. I am a bit under the weather, and the Nyquil > could be clouding my thinking. :) > > Here is my spec. It's pretty simple, I just want to ensure that the > correct redirect happens when it should. For the record, the > controller works as expected outside of rspec. > > - --------- > require File.dirname(__FILE__) + '/../spec_helper' > > describe MemberNetworkController do > before(:each) do > controller.should_receive(:beta_lockdown).and_return true > login > end > > after(:each) do > logout > end > > describe "on GET to add_as_friend" do > it "should redirect to /network/friends" do > logged_in_user.stub!(:add_user_to_role) > controller.stub!(:make_friend_activity) > get :add_as_friend, :key => logged_in_user.key > response.should redirect_to("/members/#{logged_in_user.id}/ > network/friends") > end > end > end > - -------- > > The line in question is logged_in_user.stub!(:add_user_to_role). > User#add_user_to_role is defined in acts_as_role_context.rb. I'll > not paste the entire file unless requested. It's fairly large. the > instance method #add_user_to_role looks like this. > > - -------- > def add_user_to_role(user, role_or_key) > role = self.class.sanitize_role( role_or_key ) > binding = role_bindings.find( :first, :conditions=> > [ 'role_id=? AND user_id=?', role.id, user.id ] ) > if ( binding.nil? ) > role_bindings.create > ( :context=>self, :user=>user, :role=>role ) > end > end > - -------- > > When #add_user_to_role is called in the controller during my spec, > the method is run, rather than being a stub as I would expect. Is > this expected and/or known behavior? Any comments and direction are > very much appreciated. My best guess is that the instance of logged_in_user is not the same one that the controller action is using. You're going through the controller and passing it a key, at which point it's probably using that key to access the logged in user from a source that is not the same as your logged_in_user method in the spec. HTH, David > > Thanks > Lance! > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (Darwin) > > iD8DBQFHp2AG+EgDjU0WSaoRArYDAJ92Wpp1Nkybqk7lb8fY+of+tcIawACaAyRk > y6Lo0iCvWS8/afBDTx42XiY= > =dfEK > -----END PGP SIGNATURE----- > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lance at electricsheepcompany.com Mon Feb 4 14:52:39 2008 From: lance at electricsheepcompany.com (Lance Ball) Date: Mon, 4 Feb 2008 14:52:39 -0500 Subject: [rspec-users] Problems with plugins? In-Reply-To: <57c63afe0802041134s13ebc9f4s8a7a2093f20bbc9f@mail.gmail.com> References: <21666E3D-B611-410F-A750-2F9273D9AF91@electricsheepcompany.com> <57c63afe0802041134s13ebc9f4s8a7a2093f20bbc9f@mail.gmail.com> Message-ID: <3D074898-0999-4220-99AF-AE360FF6E529@electricsheepcompany.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 4, 2008, at 2:34 PM, David Chelimsky wrote: > On Feb 4, 2008 12:57 PM, Lance Ball > wrote: >> >> When #add_user_to_role is called in the controller during my spec, >> the method is run, rather than being a stub as I would expect. Is >> this expected and/or known behavior? Any comments and direction are >> very much appreciated. > > My best guess is that the instance of logged_in_user is not the same > one that the controller action is using. You're going through the > controller and passing it a key, at which point it's probably using > that key to access the logged in user from a source that is not the > same as your logged_in_user method in the spec. Yes, that was my thought as well. So, I printed the ID of the logged in user in the spec and the ID in the controller. The IDs were the same. After that, I sent this note to the list. But, it turns out I should have been more thorough in my investigation. Instead of printing out the ID, this time I printed the object itself and found: # # So you are correct! Thanks. :) Lance -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFHp20H+EgDjU0WSaoRAnNkAJ9GpF2noGGfbfMyzXFJ3S8WxncnPACfdxHZ ukGJeaOcZ8vnesebC7hRgD0= =8cNF -----END PGP SIGNATURE----- From dchelimsky at gmail.com Mon Feb 4 15:00:47 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 14:00:47 -0600 Subject: [rspec-users] Problems with plugins? In-Reply-To: <3D074898-0999-4220-99AF-AE360FF6E529@electricsheepcompany.com> References: <21666E3D-B611-410F-A750-2F9273D9AF91@electricsheepcompany.com> <57c63afe0802041134s13ebc9f4s8a7a2093f20bbc9f@mail.gmail.com> <3D074898-0999-4220-99AF-AE360FF6E529@electricsheepcompany.com> Message-ID: <57c63afe0802041200v21110347i3c8fa9ef75ccb03b@mail.gmail.com> On Feb 4, 2008 1:52 PM, Lance Ball wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > On Feb 4, 2008, at 2:34 PM, David Chelimsky wrote: > > > On Feb 4, 2008 12:57 PM, Lance Ball > > wrote: > >> > >> When #add_user_to_role is called in the controller during my spec, > >> the method is run, rather than being a stub as I would expect. Is > >> this expected and/or known behavior? Any comments and direction are > >> very much appreciated. > > > > My best guess is that the instance of logged_in_user is not the same > > one that the controller action is using. You're going through the > > controller and passing it a key, at which point it's probably using > > that key to access the logged in user from a source that is not the > > same as your logged_in_user method in the spec. > > Yes, that was my thought as well. So, I printed the ID of the logged > in user in the spec and the ID in the controller. The IDs were the > same. After that, I sent this note to the list. > > But, it turns out I should have been more thorough in my > investigation. Instead of printing out the ID, this time I printed > the object itself and found: > > # > # > > So you are correct! Thanks. :) Sure. You good on how to solve it? > > Lance > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (Darwin) > > iD8DBQFHp20H+EgDjU0WSaoRAnNkAJ9GpF2noGGfbfMyzXFJ3S8WxncnPACfdxHZ > ukGJeaOcZ8vnesebC7hRgD0= > =8cNF > > -----END PGP SIGNATURE----- > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nate at nateclark.com Mon Feb 4 15:51:50 2008 From: nate at nateclark.com (Nate Clark) Date: Mon, 4 Feb 2008 12:51:50 -0800 Subject: [rspec-users] Mock objects not getting unloaded between specs Message-ID: I'm having a frustrating experience with a mock object in one example (a Rails controller test) interfering with an actual model test in a subsequent model example. More specifically, I have spec/controllers/section_controller_spec.rb with a mock call like this in one of the examples: Section.should_receive(:paginate_by_tag_set).with([], :page => nil).and_return([]) Ok, everything is fine so far. The mock does what it is supposed to and my example succeeds. Later on, I have a model spec in spec/models/section_spec.rb that actually tests the functionality of this "paginate_by_tag_set" class method, like this: Section.paginate_by_tag_set([], :page => nil).total_entries.should == 19 This model example fails, and I've determined that the code for my paginate_by_tag_set class method is never even getting called in this example. It seems to have something to do with the order in which my tests are run ... whenever I run the controller test before the model tests, this model example fails, presumably because the mocked call to paginate_by_tag_set is still living, and the actual code isn't getting called. If I run spec spec/models/section_spec.rb individually, everything passes just fine. Any ideas on how to isolate the mock to live only within the test in which it is defined? Am I understanding something wrong here? Thanks, Nate -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080204/a766a098/attachment.html From dchelimsky at gmail.com Mon Feb 4 16:07:05 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Feb 2008 15:07:05 -0600 Subject: [rspec-users] Mock objects not getting unloaded between specs In-Reply-To: References: Message-ID: <57c63afe0802041307l11ff8aafyaeb9a54aa602042d@mail.gmail.com> On Feb 4, 2008 2:51 PM, Nate Clark wrote: > I'm having a frustrating experience with a mock object in one example (a > Rails controller test) interfering with an actual model test in a subsequent > model example. More specifically, I have > spec/controllers/section_controller_spec.rb with a mock call like this in > one of the examples: > > Section.should_receive(:paginate_by_tag_set).with([], :page => > nil).and_return([]) > > Ok, everything is fine so far. The mock does what it is supposed to and my > example succeeds. > Later on, I have a model spec in spec/models/section_spec.rb that actually > tests the functionality of this "paginate_by_tag_set" class method, like > this: > > Section.paginate_by_tag_set([], :page => nil).total_entries.should == 19 > > This model example fails, and I've determined that the code for my > paginate_by_tag_set class method is never even getting called in this > example. It seems to have something to do with the order in which my tests > are run ... whenever I run the controller test before the model tests, this > model example fails, presumably because the mocked call to > paginate_by_tag_set is still living, and the actual code isn't getting > called. This was a bug a long time ago (probably a year), so unless you're on a very old version I doubt it's related. What version of rspec are you using? Also - can you pastie the spec and code for this controller? It would help to see what else is going on that might be leading to this. Thanks, David > > If I run spec spec/models/section_spec.rb individually, everything passes > just fine. > > Any ideas on how to isolate the mock to live only within the test in which > it is defined? Am I understanding something wrong here? > > Thanks, > Nate > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jarkko at jlaine.net Mon Feb 4 17:16:31 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 5 Feb 2008 00:16:31 +0200 Subject: [rspec-users] RESTful Routes In-Reply-To: <6A2E7837-E4F3-4DC8-9E3A-DE7B3E70D6D8@gmail.com> References: <6A2E7837-E4F3-4DC8-9E3A-DE7B3E70D6D8@gmail.com> Message-ID: On 4.2.2008, at 19.16, Raimond Garcia wrote: > Interesting Jarkko... > > The restful routes, seem clearer than using urls, maybe not so much > for this case, but for very long urls, that include for example the > title of a blog, I would rather use blog_path(@blog). > > Yes, I want to test the full stack, for sure! However, I don't see how > using named routes, stops you from doing this.... > > Webrat two thumbs up, I've been using selenium up to now, but would > like to try other alternatives to see which one works better. What I mean by testing the full stack is that you'd e.g. have this in your story: clicks_button "Delete" If you just use "delete some_url", there are two things that could be missed: 1) You have forgotten the DELETE method from your delete button. 2) The actual url in the form doesn't actually point to some_url. Neither of the two would be caught unless you used something like Webrat to drill through the whole stack. If you're using blog_path in the story, I feel like you're using the route to test itself. Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From lists at ruby-forum.com Mon Feb 4 17:24:38 2008 From: lists at ruby-forum.com (Chris Olsen) Date: Mon, 4 Feb 2008 23:24:38 +0100 Subject: [rspec-users] Error on nil.build Message-ID: I can't figure out why I am getting an error for one of the tests below: ======================== describe AccountsController, "POST" do before :each do @user = mock_model(User) @account = mock_model(Account, :id => 1, :valid => true, :save => true, :users => mock("users", :build => @user)) Account.should_receive(:new).and_return(@account) end def do_post post "create", {:account => {}, :user => {}} end it "should make the relation to the users" do @account.should_receive(:users).and_return do_post end #this test passes it "should receive the save method call" do @account.should_receive(:save).and_return(true) do_post end end ======================== #Controller code def create @account = Account.new(params[:account]) @user = @account.users.build(params[:user]) if @account.save #log the user in to allow them to be directed to their control panel self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) redirect_to admin_account_url(@account) else render :action => "new" end end ======================== It is this test that fails it "should make the relation to the users" do @account.should_receive(:users).and_return do_post end with the following error: ======================== NoMethodError in 'AccountsController POST should make the relation to the users' You have a nil object when you didn't expect it! The error occurred while evaluating nil.build I thought that: @account = mock_model(Account, ..., :users => mock("users", :build => @user)) would allow the call to users to stubbed out and pass the test. What is it that I am missing? Thanks for the help -- Posted via http://www.ruby-forum.com/. From tastapod at gmail.com Mon Feb 4 17:50:27 2008 From: tastapod at gmail.com (Dan North) Date: Mon, 4 Feb 2008 22:50:27 +0000 Subject: [rspec-users] outside-in BDD vs writing examples up front Message-ID: I thought I'd repost this because it had the not-very-obvious title of "Re: Textmate RSpec Bundle 'it' snippet". And it seems quite timely wrt the BDD vs TDD threads. Cheers, Dan ps. Not wishing to single out Edvard below - I just happened to reply to his message in the original thread. ---------- Forwarded message ---------- From: Dan North Date: 29 Jan 2008 23:35 Subject: Re: [rspec-users] Textmate RSpec Bundle 'it' snippet To: rspec-users Warning - bit of a ramble below! On 29/01/2008, Edvard Majakari wrote: > > > Not if you fill it out...and the BDD way is to write one example at a > > time, not a complete spec beforehand. > > I've done it this way too (being lazy), but is it really good thing? > Often I get more insight on how an interface should look like, > if I think even superficially what kinds of services an object should > offer. Thus I _think_ that writing a TODO-list in spec form > (marking all as pending) and starting to pick up those that you want > to do. Is this really considered non-BDDish by the authoritatives? > > If I remember correctly, Dave Astels wrote something along these lines > in his book Test Driven Development > (reminding that BDD is TDD done right): create a TODO list of small > tasks to do, related to roles of the object, and pick something > start writing tests. You make some good observations. The advice to "pick something and start writing tests" was one of the alarm bells early on that told me TDD was about more than testing. I write software to solve a problem - especially commercial software - and there is usually a stakeholder involved who wants to see tangible progress. With respect, BDD is more than TDD-done-right. "Full-scale" BDD (starting at the outside with stories and scenarios and working inwards to the code) grew out of trying to identify "the next most important thing" from the stakeholder's perspective, rather than whatever looked most interesting to me as a programmer. If you only have the close-up view of TDD - or example-level BDD (which unfortunately is what most people consider BDD to be) - it's difficult to see what the most valuable behaviour would be, and therefore the next most important thing to implement, so you end up choosing "somewhere interesting" (i.e. somewhere arbitrary in business terms). Without business-level acceptance criteria in the form of scenarios you don't know what "done" looks like, so it's very tempting to capture a whole bunch of things that occur to you in case one of them is the way forward. That's when you find yourself writing a bunch of "todo" or pending examples. If you start with a narrow, end-to-end piece of functionality and drill into it from the outside, right through until you have it working, you will find that at each layer of abstraction you will have a pretty focused subset of behaviour to implement to get the job done. IMO, if you don't think of the features at all and just start to spec > completely some single functionality, you risk rewriting that test > many times > when you add new tests for other methods on the same object, no? You certainly risk revisiting something many times - often assumptions you made in speccing out the object without any outside-in forces to identify its actual value. If I'm honest, I find myself doing this more often than I would like, especially when I'm reworking legacy code (which is a lot of my time recently). I usually take it as an indication that I haven't broadened my scope enough - I'm not "outside" enough to have a reasonable perspective. I stop, take a couple of steps back (usually reverting all my recent changes!) and reassess exactly who is the client of the code I've been tinkering with. I can relate to your point about writing a few examples to help you understand how an interface might work. Massaging code like that is a great way to explore an API. The important thing is to recognise it as just that - an exploratory exercise. Then you throw away any code you created in the process and start over, outside-in, armed with the knowledge that came out of the spike. Perhaps I ought to write this up - it's a theme that comes up quite often. Thanks for listening, Dan -- > "One day, when he was naughty, Mr Bunnsy looked over the hedge into > Farmer Fred's field and it was full of fresh green lettuces. Mr > Bunnsy, however, was not full of lettuces. This did not seem fair." > -- Terry Pratchett, Mr. Bunnsy Has An Adventure > _______________________________________________ > 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/20080204/751c4791/attachment.html From coreyhaines at gmail.com Mon Feb 4 18:28:46 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Mon, 4 Feb 2008 18:28:46 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> Message-ID: <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> Since it sounds like people don't mind talking about source control, and this group has people I trust, I thought, as I went through the learning/evaluating, I'd ask questions/make statements and get people's thoughts. If people on the list get annoyed, though, just let me know (offgroup is fine), and I'll stop the distractions, unoffended. Question/Discussion 1 Coming from an old school source control world, I'm used to the idea of "check out some files, work on them, check them back in." It seems like DVCS systems, at level 1, is "make a copy of your project, edit the files to make the change, then merge it back into your main branch." I see a lot discussion with pictures about it really more like a bunch of copies/branches of one project, moving through time independently, the merging back at some future date. I'm having a bit of trouble in my mind with this, so I'll leave that to the next level. -Corey On Feb 3, 2008 1:28 PM, Corey Haines wrote: > Thanks, Luis! > > I'll do my best to post my findings on my blog. > > -Corey > > > On Feb 3, 2008 1:00 PM, Luis Lavena wrote: > > > On Feb 3, 2008 3:45 PM, Corey Haines wrote: > > > I'll check that out, too, Luis. Thanks! > > > > > > I'm currently reading up on mercurial, and it is very enlightening. > > I'll > > > admit that, being a .net developer by trade, I've not really been > > privy to > > > some of the stuff going on in scm, mostly stuck at a company still > > using > > > sourcesafe. Please no comments about how it isn't really scm. :) I'm > > > definitely getting a mind-opener reading the mercurial site. > > > > Yes, Mercurial is nice, and have some functionalities similar to git > > (topic branches?) which make it more attractive. > > > > In any case, the use of python in both cases make Hg and Bzr a good > > alternative to git. > > > > Good luck and hope you then share your findings. > > Regards, > > > > -- > > Luis Lavena > > Multimedia systems > > - > > A common mistake that people make when trying to design > > something completely foolproof is to underestimate > > the ingenuity of complete fools. > > Douglas Adams > > _______________________________________________ > > 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 > -- 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/20080204/54eb1d4a/attachment.html From madcowley at gmail.com Mon Feb 4 18:48:28 2008 From: madcowley at gmail.com (Matt Cowley) Date: Mon, 4 Feb 2008 18:48:28 -0500 Subject: [rspec-users] odd versioning issue Message-ID: Hi folks, If I run rspec from textmate, or do a "spec " from the command-line, I get this message: ############################################################################ Your RSpec on Rails plugin is incompatible with your installed RSpec. RSpec : 20080114022430 RSpec on Rails : 20080131122909 I had rspec and rspec_on_rails installed as svn externals on the current tag; running 'rake spec' wasn't working, so I removed both completely and installed the 1.1.3 release, and now rake spec works but not individual files. Ideas? Thanks much matt From dave at 2young2die.com Mon Feb 4 18:51:21 2008 From: dave at 2young2die.com (David Currin) Date: Tue, 5 Feb 2008 00:51:21 +0100 Subject: [rspec-users] Trouble testing a method with loop In-Reply-To: <810a540e0802040719g5bd6c276x8ac0c69fd5847eb1@mail.gmail.com> References: <9d28ac860802040324o5cc19438hd1158f45914e7b11@mail.gmail.com> <810a540e0802040719g5bd6c276x8ac0c69fd5847eb1@mail.gmail.com> Message-ID: <9d28ac860802041551g60a83df9o5747aead0fdf28f@mail.gmail.com> Great, thanks for that, d. On 04/02/2008, Pat Maddox wrote: > Extract the company creation to a method, so that that method only > builds one record at a time. Test that it works properly. Then you > can keep the test that you have, verifying that it creates the right > number of records. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Mon Feb 4 19:09:41 2008 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 4 Feb 2008 22:09:41 -0200 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <124a48790801271442k350d7d5dp232e2600f2f3a878@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> Message-ID: <71166b3b0802041609k5f71461dpa1a0501f4506bec4@mail.gmail.com> On Feb 4, 2008 9:28 PM, Corey Haines wrote: > Since it sounds like people don't mind talking about source control, and > this group has people I trust, I thought, as I went through the > learning/evaluating, I'd ask questions/make statements and get people's > thoughts. If people on the list get annoyed, though, just let me know > (offgroup is fine), and I'll stop the distractions, unoffended. At least this group didn't react like others with "X is better than anything else..." I think David Chelimsky personally uses git for rspec, but being a nice guy, pushes svn mirrors for it. > Question/Discussion 1 > Coming from an old school source control world, I'm used to the idea of > "check out some files, work on them, check them back in." It seems like DVCS > systems, at level 1, is "make a copy of your project, edit the files to make > the change, then merge it back into your main branch." I see a lot > discussion with pictures about it really more like a bunch of > copies/branches of one project, moving through time independently, the > merging back at some future date. I'm having a bit of trouble in my mind > with this, so I'll leave that to the next level. Yeah, can be tricky sometimes, the learning curve can be steep, but is worth. When you checkout using a DVCS, you're not actually getting just a working copy, but the whole repository history. In that way, you can get differences, compare, list the log messages, everything without a single hit to the server (tried do a blame with svn?) The idea of branching is that you can implement new features "outside" trunk and don't affect the code stability. I've been using Bzr not just for personal projects, but also to track changes and submit patches to other open source projects, just to mention: ruby (1.8 and 1.9) mongrel hoe rubygems rubyinline parsetree rspec (even with the small contribution I did) Since for most of these projects I don't have commits rights, and some of them I don't even have access to the code (inline, hoe and parsetree). I create a "branch" for things, and do small commits based on the changes I've introduced, but that will depend on the workflow you're used. Later, when that feature is ready for integration, you then prepare and merge upstream with it. Takes some time to get used to it ;-) Anyway, at least with bzr, you can work in a similar way to subversion (running a smart server) and have bound checkout. In any case, read the documentation of all the dvcs to find the one that fits your current workflow but will allow improve it with time. HTH, -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From luislavena at gmail.com Mon Feb 4 19:11:22 2008 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 4 Feb 2008 22:11:22 -0200 Subject: [rspec-users] odd versioning issue In-Reply-To: References: Message-ID: <71166b3b0802041611y61df7e35w60bf69b4f7ca4e7a@mail.gmail.com> On Feb 4, 2008 9:48 PM, Matt Cowley wrote: > Hi folks, > > If I run rspec from textmate, or do a "spec " from the > command-line, I get this message: > ############################################################################ > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > RSpec : 20080114022430 > RSpec on Rails : 20080131122909 > > > > > I had rspec and rspec_on_rails installed as svn externals on the > current tag; running 'rake spec' wasn't working, so I removed both > completely and installed the 1.1.3 release, and now rake spec works > but not individual files. > > Ideas? > You need to also update your rspec gem, since TM is using "spec file" and not rake HTH, -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From coreyhaines at gmail.com Mon Feb 4 19:33:32 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Mon, 4 Feb 2008 19:33:32 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: <71166b3b0802041609k5f71461dpa1a0501f4506bec4@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> <71166b3b0802041609k5f71461dpa1a0501f4506bec4@mail.gmail.com> Message-ID: <6bdacb70802041633v63dfe9e5x1d4a4fa8b0548238@mail.gmail.com> Thanks for the response, Luis. I'm going through the user manual, and it looks like I can set up a main branch, make a clone, work on the clone with its own repository/revisions, then merge the changes back to the main branch when I'm ready. I like the idea of being able to work on several things at once. I'll let you guys know how it goes. -Corey On Feb 4, 2008 7:09 PM, Luis Lavena wrote: > On Feb 4, 2008 9:28 PM, Corey Haines wrote: > > Since it sounds like people don't mind talking about source control, and > > this group has people I trust, I thought, as I went through the > > learning/evaluating, I'd ask questions/make statements and get people's > > thoughts. If people on the list get annoyed, though, just let me know > > (offgroup is fine), and I'll stop the distractions, unoffended. > > At least this group didn't react like others with "X is better than > anything else..." > > I think David Chelimsky personally uses git for rspec, but being a > nice guy, pushes svn mirrors for it. > > > Question/Discussion 1 > > Coming from an old school source control world, I'm used to the idea of > > "check out some files, work on them, check them back in." It seems like > DVCS > > systems, at level 1, is "make a copy of your project, edit the files to > make > > the change, then merge it back into your main branch." I see a lot > > discussion with pictures about it really more like a bunch of > > copies/branches of one project, moving through time independently, the > > merging back at some future date. I'm having a bit of trouble in my mind > > with this, so I'll leave that to the next level. > > Yeah, can be tricky sometimes, the learning curve can be steep, but is > worth. > > When you checkout using a DVCS, you're not actually getting just a > working copy, but the whole repository history. > > In that way, you can get differences, compare, list the log messages, > everything without a single hit to the server (tried do a blame with > svn?) > > The idea of branching is that you can implement new features "outside" > trunk and don't affect the code stability. > > I've been using Bzr not just for personal projects, but also to track > changes and submit patches to other open source projects, just to > mention: > > ruby (1.8 and 1.9) > mongrel > hoe > rubygems > rubyinline > parsetree > rspec (even with the small contribution I did) > > Since for most of these projects I don't have commits rights, and some > of them I don't even have access to the code (inline, hoe and > parsetree). > > I create a "branch" for things, and do small commits based on the > changes I've introduced, but that will depend on the workflow you're > used. > > Later, when that feature is ready for integration, you then prepare > and merge upstream with it. > > Takes some time to get used to it ;-) > > Anyway, at least with bzr, you can work in a similar way to subversion > (running a smart server) and have bound checkout. > > In any case, read the documentation of all the dvcs to find the one > that fits your current workflow but will allow improve it with time. > > HTH, > -- > Luis Lavena > Multimedia systems > - > A common mistake that people make when trying to design > something completely foolproof is to underestimate > the ingenuity of complete fools. > Douglas Adams > _______________________________________________ > 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/20080204/c90679e4/attachment.html From voodoorai2000 at gmail.com Mon Feb 4 19:35:58 2008 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Tue, 5 Feb 2008 01:35:58 +0100 Subject: [rspec-users] RESTful Routes In-Reply-To: References: Message-ID: > > On 4.2.2008, at 19.16, Raimond Garcia wrote: >> Interesting Jarkko... >> >> The restful routes, seem clearer than using urls, maybe not so much >> for this case, but for very long urls, that include for example the >> title of a blog, I would rather use blog_path(@blog). >> >> Yes, I want to test the full stack, for sure! However, I don't see >> how >> using named routes, stops you from doing this.... >> >> Webrat two thumbs up, I've been using selenium up to now, but would >> like to try other alternatives to see which one works better. > > What I mean by testing the full stack is that you'd e.g. have this in > your story: > > clicks_button "Delete" > > If you just use "delete some_url", there are two things that could be > missed: > > 1) You have forgotten the DELETE method from your delete button. > 2) The actual url in the form doesn't actually point to some_url. > > Neither of the two would be caught unless you used something like > Webrat to drill through the whole stack. If you're using blog_path in > the story, I feel like you're using the route to test itself. > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > Excellent observations Jarkko! I'm still trying to get my head around the concept of "testing the full stack" and you just enlightened me a little more. Thanks! Rai From nate at nateclark.com Mon Feb 4 19:54:41 2008 From: nate at nateclark.com (Nate Clark) Date: Mon, 4 Feb 2008 16:54:41 -0800 Subject: [rspec-users] Mock objects not getting unloaded between specs In-Reply-To: <57c63afe0802041307l11ff8aafyaeb9a54aa602042d@mail.gmail.com> References: <57c63afe0802041307l11ff8aafyaeb9a54aa602042d@mail.gmail.com> Message-ID: David, thanks for getting back. Here is the pastie with (hopefully) all the relevant code: http://pastie.caboo.se/147536 We're using the latest and greatest Rspec 1.1.3, so I don't think it's old versions that is the problem. Through some debugging, I have determined that in fact my "paginate_by_tag_set" method is never getting called in the model spec example as long as the section_controller spec is run first. If I run the model spec alone, or before the controller spec where the mock is defined, it works fine. Nate On Feb 4, 2008 1:07 PM, David Chelimsky wrote: > On Feb 4, 2008 2:51 PM, Nate Clark wrote: > > I'm having a frustrating experience with a mock object in one example (a > > Rails controller test) interfering with an actual model test in a > subsequent > > model example. More specifically, I have > > spec/controllers/section_controller_spec.rb with a mock call like this > in > > one of the examples: > > > > Section.should_receive(:paginate_by_tag_set).with([], :page => > > nil).and_return([]) > > > > Ok, everything is fine so far. The mock does what it is supposed to and > my > > example succeeds. > > Later on, I have a model spec in spec/models/section_spec.rb that > actually > > tests the functionality of this "paginate_by_tag_set" class method, like > > this: > > > > Section.paginate_by_tag_set([], :page => nil).total_entries.should == 19 > > > > This model example fails, and I've determined that the code for my > > paginate_by_tag_set class method is never even getting called in this > > example. It seems to have something to do with the order in which my > tests > > are run ... whenever I run the controller test before the model tests, > this > > model example fails, presumably because the mocked call to > > paginate_by_tag_set is still living, and the actual code isn't getting > > called. > > This was a bug a long time ago (probably a year), so unless you're on > a very old version I doubt it's related. What version of rspec are you > using? > > Also - can you pastie the spec and code for this controller? It would > help to see what else is going on that might be leading to this. > > Thanks, > David > > > > > If I run spec spec/models/section_spec.rb individually, everything > passes > > just fine. > > > > Any ideas on how to isolate the mock to live only within the test in > which > > it is defined? Am I understanding something wrong here? > > > > Thanks, > > Nate > > > > _______________________________________________ > > 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://nateclark.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080204/d67ce3af/attachment-0001.html From madcowley at gmail.com Mon Feb 4 21:37:08 2008 From: madcowley at gmail.com (Matt Cowley) Date: Mon, 4 Feb 2008 21:37:08 -0500 Subject: [rspec-users] odd versioning issue In-Reply-To: <71166b3b0802041611y61df7e35w60bf69b4f7ca4e7a@mail.gmail.com> References: <71166b3b0802041611y61df7e35w60bf69b4f7ca4e7a@mail.gmail.com> Message-ID: <1A00BA87-96E1-4DCE-B18F-1FC90BF088B8@gmail.com> Yep, that was it. Thanks, knew it was something simple. On Feb 4, 2008, at 7:11 PM, Luis Lavena wrote: > On Feb 4, 2008 9:48 PM, Matt Cowley wrote: >> Hi folks, >> >> If I run rspec from textmate, or do a "spec " from the >> command-line, I get this message: >> ############################################################################ >> Your RSpec on Rails plugin is incompatible with your installed RSpec. >> >> RSpec : 20080114022430 >> RSpec on Rails : 20080131122909 >> >> >> >> >> I had rspec and rspec_on_rails installed as svn externals on the >> current tag; running 'rake spec' wasn't working, so I removed both >> completely and installed the 1.1.3 release, and now rake spec works >> but not individual files. >> >> Ideas? >> > > You need to also update your rspec gem, since TM is using "spec file" > and not rake > > HTH, > -- > Luis Lavena > Multimedia systems > - > A common mistake that people make when trying to design > something completely foolproof is to underestimate > the ingenuity of complete fools. > Douglas Adams > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Mon Feb 4 21:47:08 2008 From: lists at ruby-forum.com (Chris Olsen) Date: Tue, 5 Feb 2008 03:47:08 +0100 Subject: [rspec-users] Error on nil.build In-Reply-To: References: Message-ID: <64f142fbd278948a589ef7160f87c618@ruby-forum.com> Ooops there was a typo on the method causing the error. It should be: It is this test that fails it "should make the relation to the users" do @account.should_receive(:users) # removed the .and_return do_post end Is there a better way to test that the data is being loaded into the related models properly? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Feb 5 00:15:12 2008 From: lists at ruby-forum.com (Steve Hayes) Date: Tue, 5 Feb 2008 06:15:12 +0100 Subject: [rspec-users] Spec::Runner.register_at_exit_hook in RSpec 1.1.3 Message-ID: In RSpec 1.1.3 this method is invoked from Spec::Example::ExampleGroupMethods.inherited, but it no longer exists. I noticed this trying to run my specs inside Textmate. I looked for a new version of the Textmate bundle, but there doesn't seem to be one. Re-adding the method from an earlier version of RSpec gets me going, but seems a bit of a hack. Is there something else I should be doing, or is this a bug? Steve Hayes -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Feb 5 01:49:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Feb 2008 00:49:52 -0600 Subject: [rspec-users] Spec::Runner.register_at_exit_hook in RSpec 1.1.3 In-Reply-To: References: Message-ID: <57c63afe0802042249m394fc3f8v2087cd8fc1aac181@mail.gmail.com> On Feb 4, 2008 11:15 PM, Steve Hayes wrote: > In RSpec 1.1.3 this method is invoked from > Spec::Example::ExampleGroupMethods.inherited, but it no longer exists. It most certainly does. In fact, it's new in 1.1.3, so neither the method nor the call existed prior. Any chance you have mixed versions floating around? 1.1.3 gem but older plugins? > I > noticed this trying to run my specs inside Textmate. I looked for a new > version of the Textmate bundle, but there doesn't seem to be one. > > Re-adding the method from an earlier version of RSpec gets me going, but > seems a bit of a hack. Is there something else I should be doing, or is > this a bug? > > Steve Hayes > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From brianmrowe at 7effect.com Mon Feb 4 22:44:38 2008 From: brianmrowe at 7effect.com (Brian Rowe) Date: Mon, 4 Feb 2008 22:44:38 -0500 Subject: [rspec-users] rspec - rails put :update any examples Message-ID: I'm looking for a working example of a put :update on a controller. The documentation online avoids the update function. Any help pointing to this example would be great. Trying to get to 100% coverage...can't make it without update :) Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080204/71f37d1d/attachment.html From dchelimsky at gmail.com Tue Feb 5 02:02:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Feb 2008 01:02:02 -0600 Subject: [rspec-users] rspec - rails put :update any examples In-Reply-To: References: Message-ID: <57c63afe0802042302y5f3aafc4tb1464b2274fcee5f@mail.gmail.com> On Feb 4, 2008 9:44 PM, Brian Rowe wrote: > I'm looking for a working example of a put :update on a controller. The > documentation online avoids the update function. > > Any help pointing to this example would be great. Trying to get to 100% > coverage...can't make it without update :) This is what I do: it "should replace foo with bar partial" do page = mock("page") page.should_receive(:replace_html).with('foo', :partial => 'bar') controller.expect_render(:update).and_yield(page) do_post end HTH, David > > Brian > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tastapod at gmail.com Tue Feb 5 05:19:42 2008 From: tastapod at gmail.com (Dan North) Date: Tue, 5 Feb 2008 10:19:42 +0000 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802041633v63dfe9e5x1d4a4fa8b0548238@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> <71166b3b0802041609k5f71461dpa1a0501f4506bec4@mail.gmail.com> <6bdacb70802041633v63dfe9e5x1d4a4fa8b0548238@mail.gmail.com> Message-ID: Hi Corey. I recently discovered a rather excellent online book: http://hgbook.red-bean.com/ It's about mercurial but it's a) largely scm-agnostic and b) really well written, with some useful diagrams about how changesets work in the small and collaboration models in the large (i.e. exactly what you were asking about). I also discovered a "deal-breaker" feature of mercurial that I hadn't realised before, which is that it tracks changes across copies and renames of files. Or rather, what I hadn't realised is that other SCMs don't do this. This was what was crippling me with subversion - I had a branch where I had done some quite aggressive refactoring (which means files getting moved and/or renamed), and subversion wouldn't merge the changes from the branch onto trunk. On 05/02/2008, Corey Haines wrote: > > Thanks for the response, Luis. > > I'm going through the user manual, and it looks like I can set up a main > branch, make a clone, work on the clone with its own repository/revisions, > then merge the changes back to the main branch when I'm ready. I like the > idea of being able to work on several things at once. I'll let you guys know > how it goes. > > -Corey > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080205/0eb801b3/attachment.html From lists at ruby-forum.com Tue Feb 5 05:26:42 2008 From: lists at ruby-forum.com (Steve Hayes) Date: Tue, 5 Feb 2008 11:26:42 +0100 Subject: [rspec-users] Spec::Runner.register_at_exit_hook in RSpec 1.1.3 In-Reply-To: <57c63afe0802042249m394fc3f8v2087cd8fc1aac181@mail.gmail.com> References: <57c63afe0802042249m394fc3f8v2087cd8fc1aac181@mail.gmail.com> Message-ID: <3502954db793839cd088da762321d26f@ruby-forum.com> David Chelimsky wrote: > On Feb 4, 2008 11:15 PM, Steve Hayes wrote: >> In RSpec 1.1.3 this method is invoked from >> Spec::Example::ExampleGroupMethods.inherited, but it no longer exists. > > It most certainly does. In fact, it's new in 1.1.3, so neither the > method nor the call existed prior. Any chance you have mixed versions > floating around? 1.1.3 gem but older plugins? That was probably it - apologies. I'm should see what I need to do to run without the gem at all. Steve Hayes -- Posted via http://www.ruby-forum.com/. From coreyhaines at gmail.com Tue Feb 5 14:16:01 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 5 Feb 2008 14:16:01 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <6bdacb70802030913w7730e038s480f3153bbd84156@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> <71166b3b0802041609k5f71461dpa1a0501f4506bec4@mail.gmail.com> <6bdacb70802041633v63dfe9e5x1d4a4fa8b0548238@mail.gmail.com> Message-ID: <6bdacb70802051116r66200b0fk477667ae00162adc@mail.gmail.com> Thanks, Dan, I'll check that out. -Corey On Feb 5, 2008 5:19 AM, Dan North wrote: > Hi Corey. > > I recently discovered a rather excellent online book: > http://hgbook.red-bean.com/ > > It's about mercurial but it's a) largely scm-agnostic and b) really well > written, with some useful diagrams about how changesets work in the small > and collaboration models in the large (i.e. exactly what you were asking > about). > > I also discovered a "deal-breaker" feature of mercurial that I hadn't > realised before, which is that it tracks changes across copies and renames > of files. Or rather, what I hadn't realised is that other SCMs don't do > this. This was what was crippling me with subversion - I had a branch where > I had done some quite aggressive refactoring (which means files getting > moved and/or renamed), and subversion wouldn't merge the changes from the > branch onto trunk. > > > On 05/02/2008, Corey Haines wrote: > > > > Thanks for the response, Luis. > > > > I'm going through the user manual, and it looks like I can set up a main > > branch, make a clone, work on the clone with its own repository/revisions, > > then merge the changes back to the main branch when I'm ready. I like the > > idea of being able to work on several things at once. I'll let you guys know > > how it goes. > > > > -Corey > > > > > > _______________________________________________ > 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/20080205/aad4a4bf/attachment.html From edward.og at gmail.com Tue Feb 5 16:23:08 2008 From: edward.og at gmail.com (Edward Ocampo-gooding) Date: Tue, 5 Feb 2008 16:23:08 -0500 Subject: [rspec-users] DRb does not activate using options file In-Reply-To: <71166b3b0801301643n1e8f1624y7cc79c24b00e8eb0@mail.gmail.com> References: <71166b3b0801301643n1e8f1624y7cc79c24b00e8eb0@mail.gmail.com> Message-ID: On Jan 30, 2008 7:43 PM, Luis Lavena wrote: > Hello List, > > For a small project I've been using 'ruby script/spec -X spec' to > execute my specs. > > Now that I added ZenTest on it, found that the test takes longer to > run due the complete load of test environment. > > Since autotest uses 'script/spec -O spec/spec.opts' as the command, I > decided to add --drb to spec.opts > > Using --drb or -X, spec_server is just ignored and environment get > loaded locally. > > Trying to pinpoint the problem, it seems that using -O don't > handle/load set --drb, but when you put all the options in the command > line, works as expected. > > Couldn't find anything besides this (rspec/lib/spec/runner/option_parser.rb:111) > > on(*OPTIONS[:drb]) {} > > == > > Maybe I'm missing something, did anyone get it working? > > Thanks in advance, > -- > Luis Lavena > Multimedia systems > - > A common mistake that people make when trying to design > something completely foolproof is to underestimate > the ingenuity of complete fools. > Douglas Adams > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I'm also having this problem where --drb isn't being picked up. From wschenk at gmail.com Tue Feb 5 16:58:47 2008 From: wschenk at gmail.com (Will Schenk) Date: Tue, 5 Feb 2008 16:58:47 -0500 Subject: [rspec-users] rails rspec silently failing Message-ID: <313680E3-9C25-4A3F-9C42-C42923F73100@gmail.com> I've been beating my head against this for a couple of hours now, and I'm a bit frustrated, so I apologize in advance. I'm trying to use rspec to test an order processing system, which uses google checkout. The idea was to have a couple of orders in the database in various stages, and hit the notifier interface to make sure that everything transitioned to the right place. However, I can't get to this, because rspec seems to silently blow-up somewhere. This code "passes": require File.dirname(__FILE__) + '/../spec_helper' describe OrdersController do integrate_views fixtures :orders it "should set the right order amount" do prepare_order_mock post "subscribe", {:sub_type => "1"} fail "This should throw an error" end end It then returns: "0 examples, 0 failures". How is such a thing possible? This seems like a serious problem; I would expect an exception from somewhere inside of the post, or the fail message. Instead everything is green. My only hypothesis is that since I'm creating an order object and calling a bunch of methods on it and somehow that's verbotten. The docs mention suggests mocking domain objects -- which seems if not completely misguided at least seriously counter-intuitive -- and perhaps this has something to do with it. But silently imploding seems more like a bug. I should mention that the controller actually works in Real Life, but I was trying to get a little piece of mind and work out all the permutations in a test just to make sure. And failing silently is worse than no testing at all. Taking a few deep breaths, -w From coreyhaines at gmail.com Tue Feb 5 19:42:10 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 5 Feb 2008 19:42:10 -0500 Subject: [rspec-users] rspec - rails put :update any examples In-Reply-To: <57c63afe0802042302y5f3aafc4tb1464b2274fcee5f@mail.gmail.com> References: <57c63afe0802042302y5f3aafc4tb1464b2274fcee5f@mail.gmail.com> Message-ID: <6bdacb70802051642v194f5806iaf59bb7ebebd23e0@mail.gmail.com> David, I tried doing this, and I get an exception. Here's a pastie of the error, controller, controller_spec: http://pastie.caboo.se/148021 On Feb 5, 2008 2:02 AM, David Chelimsky wrote: > it "should replace foo with bar partial" do > page = mock("page") > page.should_receive(:replace_html).with('foo', :partial => 'bar') > controller.expect_render(:update).and_yield(page) > do_post > end > > HTH, > David > > > > > Brian > > > > > > _______________________________________________ > > 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/20080205/91031d1a/attachment.html From coreyhaines at gmail.com Tue Feb 5 19:44:12 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 5 Feb 2008 19:44:12 -0500 Subject: [rspec-users] rspec - rails put :update any examples In-Reply-To: <6bdacb70802051642v194f5806iaf59bb7ebebd23e0@mail.gmail.com> References: <57c63afe0802042302y5f3aafc4tb1464b2274fcee5f@mail.gmail.com> <6bdacb70802051642v194f5806iaf59bb7ebebd23e0@mail.gmail.com> Message-ID: <6bdacb70802051644n1c78db06r8a4e7a75edd20ef6@mail.gmail.com> And, of course, here are my versions: Ruby 1.8.6 Rails 2.0.2 Zentest 3.8 RSpec (I believe 1.1.2) On Feb 5, 2008 7:42 PM, Corey Haines wrote: > David, I tried doing this, and I get an exception. Here's a pastie of the > error, controller, controller_spec: http://pastie.caboo.se/148021 > > > On Feb 5, 2008 2:02 AM, David Chelimsky wrote: > > > it "should replace foo with bar partial" do > > page = mock("page") > > page.should_receive(:replace_html).with('foo', :partial => 'bar') > > controller.expect_render(:update).and_yield(page) > > do_post > > end > > > > HTH, > > David > > > > > > > > Brian > > > > > > > > > _______________________________________________ > > > 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 -- 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/20080205/f6bd8800/attachment.html From coreyhaines at gmail.com Tue Feb 5 19:54:35 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 5 Feb 2008 19:54:35 -0500 Subject: [rspec-users] rails rspec silently failing In-Reply-To: <313680E3-9C25-4A3F-9C42-C42923F73100@gmail.com> References: <313680E3-9C25-4A3F-9C42-C42923F73100@gmail.com> Message-ID: <6bdacb70802051654k61379373l71af176294e34ec@mail.gmail.com> That seems more like rspec isn't even finding it. What is the file name? Is it in a location that rspec is going to look for it? -Corey On Feb 5, 2008 4:58 PM, Will Schenk wrote: > I've been beating my head against this for a couple of hours now, and > I'm a bit frustrated, so I apologize in advance. > > I'm trying to use rspec to test an order processing system, which uses > google checkout. The idea was to have a couple of orders in the > database in various stages, and hit the notifier interface to make > sure that everything transitioned to the right place. However, I > can't get to this, because rspec seems to silently blow-up somewhere. > This code "passes": > > require File.dirname(__FILE__) + '/../spec_helper' > > describe OrdersController do > integrate_views > fixtures :orders > > it "should set the right order amount" do > prepare_order_mock > > post "subscribe", {:sub_type => "1"} > > fail "This should throw an error" > end > end > > It then returns: "0 examples, 0 failures". > > How is such a thing possible? This seems like a serious problem; I > would expect an exception from somewhere inside of the post, or the > fail message. Instead everything is green. > > My only hypothesis is that since I'm creating an order object and > calling a bunch of methods on it and somehow that's verbotten. The > docs mention suggests mocking domain objects -- which seems if not > completely misguided at least seriously counter-intuitive -- and > perhaps this has something to do with it. But silently imploding > seems more like a bug. > > I should mention that the controller actually works in Real Life, but > I was trying to get a little piece of mind and work out all the > permutations in a test just to make sure. And failing silently is > worse than no testing at all. > > Taking a few deep breaths, > -w > > > _______________________________________________ > 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/20080205/0ce9c770/attachment.html From dchelimsky at gmail.com Tue Feb 5 21:30:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Feb 2008 20:30:09 -0600 Subject: [rspec-users] rspec - rails put :update any examples In-Reply-To: <6bdacb70802051642v194f5806iaf59bb7ebebd23e0@mail.gmail.com> References: <57c63afe0802042302y5f3aafc4tb1464b2274fcee5f@mail.gmail.com> <6bdacb70802051642v194f5806iaf59bb7ebebd23e0@mail.gmail.com> Message-ID: <57c63afe0802051830p7b79c843s31b4d9658f7c34f7@mail.gmail.com> On Feb 5, 2008 6:42 PM, Corey Haines wrote: > David, I tried doing this, and I get an exception. Here's a pastie of the > error, controller, controller_spec: http://pastie.caboo.se/148021 You've got page[:coupon_list], not just page. So what you need to mock is this: page = mock("page") page.should_receive(:[]).with(:coupon_list).and_return(page) page.should_receive(:replace_html).with(:partial => "coupon_list") That's starting to get a bit brittle, but that's what you get for mixing all that view logic in your controllers. It's the Rails Way, but it comes with a price if you want this level of coverage and isolation. FWIW, David > > > > On Feb 5, 2008 2:02 AM, David Chelimsky wrote: > > > it "should replace foo with bar partial" do > > page = mock("page") > > page.should_receive(:replace_html).with('foo', :partial => 'bar') > > controller.expect_render(:update).and_yield(page) > > do_post > > end > > > > HTH, > > David > > > > > > > > Brian > > > > > > > > > _______________________________________________ > > > 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wschenk at gmail.com Tue Feb 5 23:50:27 2008 From: wschenk at gmail.com (Will Schenk) Date: Tue, 5 Feb 2008 23:50:27 -0500 Subject: [rspec-users] rails rspec silently failing In-Reply-To: <6bdacb70802051654k61379373l71af176294e34ec@mail.gmail.com> References: <313680E3-9C25-4A3F-9C42-C42923F73100@gmail.com> <6bdacb70802051654k61379373l71af176294e34ec@mail.gmail.com> Message-ID: This is both running the file directly or using script/spec. If I leave the spec file as is, and I comment out a line @order.send_order_to_google_checkout in the _controller_ then it runs fine, i.e. it gets to the fail statement. Either way the code runs all the way through the action method. But if I call a method on the Order, then it seems to just disappear after the controller returns. Something is swallowing exceptions or something like that. It runs to the end though, and I know it runs to the end because I put in puts statements. On Feb 5, 2008, at 7:54 PM, Corey Haines wrote: > That seems more like rspec isn't even finding it. What is the file > name? Is it in a location that rspec is going to look for it? > > -Corey > > On Feb 5, 2008 4:58 PM, Will Schenk wrote: > I've been beating my head against this for a couple of hours now, and > I'm a bit frustrated, so I apologize in advance. > > I'm trying to use rspec to test an order processing system, which uses > google checkout. The idea was to have a couple of orders in the > database in various stages, and hit the notifier interface to make > sure that everything transitioned to the right place. However, I > can't get to this, because rspec seems to silently blow-up somewhere. > This code "passes": > > require File.dirname(__FILE__) + '/../spec_helper' > > describe OrdersController do > integrate_views > fixtures :orders > > it "should set the right order amount" do > prepare_order_mock > > post "subscribe", {:sub_type => "1"} > > fail "This should throw an error" > end > end > > It then returns: "0 examples, 0 failures". > > How is such a thing possible? This seems like a serious problem; I > would expect an exception from somewhere inside of the post, or the > fail message. Instead everything is green. > > My only hypothesis is that since I'm creating an order object and > calling a bunch of methods on it and somehow that's verbotten. The > docs mention suggests mocking domain objects -- which seems if not > completely misguided at least seriously counter-intuitive -- and > perhaps this has something to do with it. But silently imploding > seems more like a bug. > > I should mention that the controller actually works in Real Life, but > I was trying to get a little piece of mind and work out all the > permutations in a test just to make sure. And failing silently is > worse than no testing at all. > > Taking a few deep breaths, > -w > > > _______________________________________________ > 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 Will Schenk wschenk at gmail.com http://benchcoach.com/ http://sublimeguile.com/ http://menumap.monkeythumb.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080205/ded47915/attachment-0001.html From hans at degraaff.org Wed Feb 6 00:58:42 2008 From: hans at degraaff.org (Hans de Graaff) Date: Wed, 06 Feb 2008 06:58:42 +0100 Subject: [rspec-users] rails rspec silently failing In-Reply-To: References: <313680E3-9C25-4A3F-9C42-C42923F73100@gmail.com> <6bdacb70802051654k61379373l71af176294e34ec@mail.gmail.com> Message-ID: <1202277522.23096.4.camel@ip6-localhost> On Tue, 2008-02-05 at 23:50 -0500, Will Schenk wrote: > This is both running the file directly or using script/spec. If I > leave the spec file as is, and I comment out a line > @order.send_order_to_google_checkout in the _controller_ then it runs > fine, i.e. it gets to the fail statement. Since you don't include the actual controller code it's a bit hard to help out here, but it's better form to just mock this code in your controller spec. You can then vary the different responses from the google checkout and see if your controller handles them correctly. The actual interaction with google checkout should be described with examples in the order_spec.rb file. Right now you are testing the whole stack and it becomes very hard to track down what is going wrong exactly. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080206/2bbe6c01/attachment.bin From dave at 2young2die.com Wed Feb 6 04:16:22 2008 From: dave at 2young2die.com (David Currin) Date: Wed, 6 Feb 2008 10:16:22 +0100 Subject: [rspec-users] Rspec accessing the wrong id? Message-ID: <9d28ac860802060116w5335e06epd5bb710fae976f8e@mail.gmail.com> Hi, This is probably straightforward to solve. I'm new to rspec so I hope you'll be patient with me. I've created a model method which works in practice, but which rspec is not passing. I'm obviously not going about things in the right way in rspec so I'd appreciate any advice offered. Here's the (releveant parts of the) method which sets up a one to many relationship between Company and Projects. def.self create_project(record) parent_company = Company.find_by_basecampid(record.company.id) project = self.find_or_initialize_by_basecampid(record.id) project.company_id = parent_company.id end In rspec I've got this: def parent_company_attributes { :id => 1, :basecampid => 448718, :name => "The Media Collective" } end before do mock_record Company.should_receive(:find_by_basecampid). with(parent_company_attributes[:basecampid]). and_return(parent_company_attributes) @project = Project.create_project(record) end it "should populate company_id" do @project.company_id.should eql(parent_company_attributes[:id]) end The problem is that it looks like rspec is using the object id rather than the id from parent_company_attributes. Here's the failure message: 1) 'Project.create project record should populate company_id' FAILED expected 1, got 8817400 (using .eql?) Thanks for any insights David Currin From address4spams at 21croissants.com Wed Feb 6 05:41:20 2008 From: address4spams at 21croissants.com (Jean-Michel Garnier) Date: Wed, 6 Feb 2008 11:41:20 +0100 Subject: [rspec-users] RSpec 1.1.3 + ZenTest 3.9.1 + Rails 1.2.6 do NOT ignore folders ^vendor/* Message-ID: Hi, I just updated to the latest RSpec 1.1.3 + ZenTest 3.9.1. I also have rspec 1.1.3 installed as a gem When starting autotest with -v option, there is a lot of noise because autotest does not ignore the vendor folder, the migrations, etc ...: Dunno! vendor/plugins/acts_as_solr/solr/lib/jetty-util-6.1.3.jar Dunno! vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb Dunno! vendor/rails/actionpack/lib/action_view.rb Dunno! vendor/plugins/active_scaffold/test/extensions/array.rb Dunno! vendor/plugins/active_scaffold/lib/extensions/nil_id_in_url_params.rb Dunno! config/amazon_s3.yml Dunno! vendor/rails/actionpack/lib/action_controller/base.rb Dunno! vendor/plugins/acts_as_solr/lib/solr/response/base.rb Dunno! vendor/plugins/rake_tasks/init.rb Dunno! public/images/linqia/icon_groupmember.gif Dunno! vendor/plugins/acts_as_solr/test/db/test.db Dunno! vendor/rails/actionpack/lib/action_controller/mime_type.rb Dunno! public/stylesheets/themes/default/close.gif Dunno! db/migrate/021_create_community_bookmarks.rb Dunno! vendor/plugins/cache_fu/test/local_cache_test.rb Dunno! public/images/icons/flags/bv.gif in the output. Am I the only one? After reading the code in rspec_on_rails/lib/autotest/rails_rspec.rb Autotest.add_hook :initialize do |at| %w{^config/ ^coverage/ ^db/ ^doc/ ^log/ ^public/ ^script ^vendor/rails ^vendor/plugins previous_failures.txt}.each do |exception| at.add_exception(exception) end I think the noise is not normal. Maybe I should write some specs to verify this code is working ;-) As David C. explained in his blog, I also have a .autotest in my HOME: Autotest.add_hook :initialize do |at| %w{.svn .hg .git .rhtml .png .txt .sh .project .rjs .rake .jpg .xml .xlst }.each {|exception|at.add_exception(exception)} end Jean-Michel From wschenk at gmail.com Wed Feb 6 11:27:26 2008 From: wschenk at gmail.com (Will Schenk) Date: Wed, 6 Feb 2008 11:27:26 -0500 Subject: [rspec-users] rails rspec silently failing In-Reply-To: <1202277522.23096.4.camel@ip6-localhost> References: <313680E3-9C25-4A3F-9C42-C42923F73100@gmail.com> <6bdacb70802051654k61379373l71af176294e34ec@mail.gmail.com> <1202277522.23096.4.camel@ip6-localhost> Message-ID: Ok I think I've figured out the command that makes rspec blow up. I'm creating the mock object like this: def prepare_order_mock $GCHECKOUT_FRONTEND = mock "gcheckout" @co_cmd_mock = mock "checkout_command" @shopping_cart = mock "shopping cart" @private_data = nil $ GCHECKOUT_FRONTEND.should_receive(:create_checkout_command).and_return { @co_cmd_mock } @co_cmd_mock.should_receive( "continue_shopping_url=" ) @co_cmd_mock.should_receive( "shopping_cart", 2 ).and_return { @shopping_cart } @shopping_cart.should_receive "create_item" @shopping_cart.should_receive( "private_data=" ).and_return do | data| @private_data = data end @co_cmd_mock.should_receive( "send_to_google_checkout" ).and_return do res = mock( "result" ) res.should_receive( "redirect_url" ).and_return{ "url string" } res end end Then when my code calls: command = $GCHECKOUT_FRONTEND.create_checkout_command command.continue_shopping_url = continue_url The second line makes rspec silently blow up. If I comment it out then it runs fine. On Feb 6, 2008, at 12:58 AM, Hans de Graaff wrote: > On Tue, 2008-02-05 at 23:50 -0500, Will Schenk wrote: >> This is both running the file directly or using script/spec. If I >> leave the spec file as is, and I comment out a line >> @order.send_order_to_google_checkout in the _controller_ then it runs >> fine, i.e. it gets to the fail statement. > > Since you don't include the actual controller code it's a bit hard to > help out here, but it's better form to just mock this code in your > controller spec. You can then vary the different responses from the > google checkout and see if your controller handles them correctly. > > The actual interaction with google checkout should be described with > examples in the order_spec.rb file. Right now you are testing the > whole > stack and it becomes very hard to track down what is going wrong > exactly. > > Kind regards, > > Hans From jaydonnell at yahoo.com Wed Feb 6 20:50:36 2008 From: jaydonnell at yahoo.com (Jay Donnell) Date: Wed, 6 Feb 2008 17:50:36 -0800 (PST) Subject: [rspec-users] trying to spec login requirement with a shared example Message-ID: <788143.34100.qm@web56002.mail.re3.yahoo.com> In all of my controller specs I have tests that look something like this. it "should require login" do get :edit, :id => '7' response.should redirect_to(new_session_path) end I'd like to move this to a shared example, but the request call (get() or post()) varies with each example. Is there a good way to tell the shared example how to request the page? I thought about doing something like this describe "whatever" do def request_page get :edit, :id => '7' end # use shared example end then in the shared example I would call request_page() instead. Although this is slightly more DRY it isn't saving me any lines of code and it feels like there could be a better way. Another idea I had was to make a helper function that returns a Proc (basically I'm faking currying) and I could bind that Proc to something like @request_proc and then run the proc in the shared example. Anyone have any better ideas? Jay ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From ben at benmabey.com Wed Feb 6 22:37:40 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 06 Feb 2008 20:37:40 -0700 Subject: [rspec-users] trying to spec login requirement with a shared example In-Reply-To: <788143.34100.qm@web56002.mail.re3.yahoo.com> References: <788143.34100.qm@web56002.mail.re3.yahoo.com> Message-ID: <47AA7D04.9000904@benmabey.com> I don't claim that my idea/way is a good way to go about it since it is kinda hackisk... but this is what I have been doing... In my spec_helper.rb I'll have the following: module Spec::Example::ExampleGroupMethods def it_should_require_a_user_to_be_logged_in it "should redirect to the signup page when no user is logged in" do stub_no_one_logged_in send("do_#{[:get, :post, :put, :delete].find{|verb| respond_to? :"do_#{verb}"}}") response.should redirect_to(signup_url(:service => "http://#{request.host}#{request.env["REQUEST_URI"]}")) end end end The implementation of it_should_require_a_user_to_be_logged_in are of course specific to my app but you get the picture with what I'm doing with the send command... Again, I know this is hackish but it was the best I could come up with. So it your example groups you can just say stuff like: describe UsersController, "handling PUT /users/1" do before do @user = stub_login(mock_user(:update_attributes => true)) User.stub!(:find).and_return(@user) end def do_put put :update, :id => @user.id end it_should_require_a_user_to_be_logged_in .... end Prior to this I would alias all of my do_put, do_get, etc.. as do_action, and then just call do_action. Hmm.. that actually just gave me an idea. You could use the method_added hook that ruby provides to alias the do_get, do_put, etc.. to do_action every time it is defined. How does that sound? I haven't tested it but that might be the best way to do things now that I think about it. Hope that helps... If you try out the method_added idea let me know since I would be interested. -Ben Jay Donnell wrote: > In all of my controller specs I have tests that look something like this. > > it "should require login" do > get :edit, :id => '7' > response.should redirect_to(new_session_path) > end > > I'd like to move this to a shared example, but the request call (get() or post()) varies with each example. Is there a good way to tell the shared example how to request the page? > > I thought about doing something like this > > describe "whatever" do > def request_page > get :edit, :id => '7' > end > > # use shared example > end > > then in the shared example I would call request_page() instead. Although this is slightly more DRY it isn't saving me any lines of code and it feels like there could be a better way. Another idea I had was to make a helper function that returns a Proc (basically I'm faking currying) and I could bind that Proc to something like @request_proc and then run the proc in the shared example. > > Anyone have any better ideas? > > Jay > > > > > ____________________________________________________________________________________ > Looking for last minute shopping deals? > Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From edvard at majakari.net Thu Feb 7 03:45:01 2008 From: edvard at majakari.net (Edvard Majakari) Date: Thu, 7 Feb 2008 10:45:01 +0200 Subject: [rspec-users] outside-in BDD vs writing examples up front In-Reply-To: References: Message-ID: This is a short reply, but thinking about it a bit deeper, I have to agree with Dan. What especially caught my attention was this piece: > If you start with a narrow, end-to-end piece of functionality and drill into > it from the outside, right through until you have it working, you will find > that at each layer of abstraction you will have a pretty focused subset of > behaviour to implement to get the job done. I think this comment is brilliant, as it is a more concrete viewpoint of what "BDD manifesto" mentions about business value (http://behaviour-driven.org/WheresTheBusinessValue). As it happens, one of my main concerns with TDD was that it didn't seem to have any strong opinions or rules about a) order of writing specifications regarding level of abstraction or architectural structure (eg. I prefer V, C, M spec order in Rails, as it starts from what the supposed client would see) b) how to pick the first test/spec you are going to implement. Dan, I think your post gave an excellent answer (well, at least one) to those questions -- and it also seems to be an opinion popular among those few BDD practitioners _I know_ of; outside-in practically clears out part a), as you are starting with high-level stuff like stories, going deeper driven by requirements of higher level entities. Part b) becomes much easier when you think about the clients priorities: what feature gives the most business value for the client at the moment? When starting an issue tracking system from the scratch, probably the ability to submit new tickets becomes first -- that is, even before being able to view them. Though quite obvious in retrospective, the emphasis on business value in BDD gives IMO extra structure and support for otherwise rather chaotic field of software engineering, especially when the idea is applied in concrete rules of the methodology. Thanks! -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From jarkko at jlaine.net Thu Feb 7 08:57:05 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 7 Feb 2008 15:57:05 +0200 Subject: [rspec-users] Rspec accessing the wrong id? In-Reply-To: <9d28ac860802060116w5335e06epd5bb710fae976f8e@mail.gmail.com> References: <9d28ac860802060116w5335e06epd5bb710fae976f8e@mail.gmail.com> Message-ID: On 6.2.2008, at 11.16, David Currin wrote: > Hi, > > This is probably straightforward to solve. I'm new to rspec so I hope > you'll be patient with me. I've created a model method which works in > practice, but which rspec is not passing. I'm obviously not going > about things in the right way in rspec so I'd appreciate any advice > offered. > > Here's the (releveant parts of the) method which sets up a one to many > relationship between Company and Projects. > > def.self create_project(record) > parent_company = Company.find_by_basecampid(record.company.id) > project = self.find_or_initialize_by_basecampid(record.id) > project.company_id = parent_company.id > end > > In rspec I've got this: > > def parent_company_attributes > { > :id => 1, > :basecampid => 448718, > :name => "The Media Collective" > } > end > > before do > > mock_record > Company.should_receive(:find_by_basecampid). > with(parent_company_attributes[:basecampid]). > and_return(parent_company_attributes) You're returning a hash here. If you call id for hash (like you do in this case), it will return the object id, not the element with key :id. I think what you want to do is to create a mock_model with that hash and then stub Company.find_by_basecampid to return that mock object. //jarkko > > > @project = Project.create_project(record) > > end > > it "should populate company_id" do > @project.company_id.should eql(parent_company_attributes[:id]) > end > > > The problem is that it looks like rspec is using the object id rather > than the id from parent_company_attributes. Here's the failure > message: > > 1) > 'Project.create project record should populate company_id' FAILED > expected 1, got 8817400 (using .eql?) > > Thanks for any insights > > David Currin > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From cgrindel at yahoo.com Thu Feb 7 10:39:15 2008 From: cgrindel at yahoo.com (Charles Grindel) Date: Thu, 7 Feb 2008 07:39:15 -0800 (PST) Subject: [rspec-users] Shared examples not reloading in spec_server Message-ID: <441680.34701.qm@web54108.mail.re2.yahoo.com> I am currently running RSpec 1.1.3 with ZenTest 3.9.1 on Windows XP. I have noticed that shared examples are not being reloaded by spec_server when they have been updated. Below is a simple example that reproduces the problem. The example code and output is at the location below. http://pastie.caboo.se/148688 I have confirmed that non-shared examples are being reloaded by spec_server. So, here are my questions. 1. Has anyone else noticed this behavior? 2. Does anyone know how I can force spec_server to reload the shared examples? 3. If this smells like a bug, can someone point me to instructions for filing a bug? Thanks, Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080207/b4f4e0b0/attachment-0001.html From dchelimsky at gmail.com Thu Feb 7 11:01:19 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Feb 2008 10:01:19 -0600 Subject: [rspec-users] Shared examples not reloading in spec_server In-Reply-To: <441680.34701.qm@web54108.mail.re2.yahoo.com> References: <441680.34701.qm@web54108.mail.re2.yahoo.com> Message-ID: <57c63afe0802070801o11939c48tf93172d8dec44043@mail.gmail.com> On Feb 7, 2008 9:39 AM, Charles Grindel wrote: > > I am currently running RSpec 1.1.3 with ZenTest 3.9.1 on Windows XP. I have > noticed that shared examples are not being reloaded by spec_server when they > have been updated. Below is a simple example that reproduces the problem. > The example code and output is at the location below. > > > http://pastie.caboo.se/148688 > > I have confirmed that non-shared examples are being reloaded by spec_server. > So, here are my questions. > > 1. Has anyone else noticed this behavior? > > 2. Does anyone know how I can force spec_server to reload the shared > examples? > > 3. If this smells like a bug, can someone point me to instructions for > filing a bug? Sounds like a problem with your autotest configuration, not with spec_server. Try it without spec server to verify that is correct. If it's that autotest isn't loading them, you just need to add a mapping in .autotest. Read the ZenTest docs for more info and/or check out my blog post on this: http://blog.davidchelimsky.net/articles/2008/01/15/rspec-1-1-2-and-zentest-3-8-0. If you try that and you still think it's an rspec bug, file a ticket at http://rspec.lighthouseapp.com. Cheers, David > > Thanks, > Chuck > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Thu Feb 7 15:27:53 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 7 Feb 2008 15:27:53 -0500 Subject: [rspec-users] Problems testing rss feed controller. Message-ID: I've got a controller which produces an RSS feed, pretty much based on Ryan Bates recent RailsCast. I'm having a heck of a time getting the spec to successfully fetch the feed though. I gave up got it working without a spec, and I'm now trying to back up and get the spec to work. The controller is simplicity itself: class PodcastRssFeedController < ApplicationController def index @podcasts = Podcast.latest(100) end end I have a route which gets to the index action and sets :format => :rss, as I said this produces a valid rss response in the real world, just not in the spec. Here's the basic spec: require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/../be_valid_feed' def mock_podcast(i) mock_model( Podcast, :artist_name_slug => "Artist#{i}" ) end describe PodcastRssFeedController do before(:all) do @podcasts = (1..5).map {|i| mock_podcast(i)} Podcast.stub!(:latest).and_return(@podcasts) end describe 'handling GET brightsidepodcasts/rss.xml' do def do_get @request.format = 'rss' get 'index', :format => :rss end it "should successfully get feed" do do_get response.should be_success end it "should validate" do do_get response.should be_valid_feed end end end The validation example is failing because the response body is being returned as podcast_rss_feed/index I've tried stepping through with rdebug and I can't figure out where it's going wrong. I eventually end up here: 1099 logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger => 1100 render_for_text(@template.render_file(template_path, use_full_path, locals), status) 1101 end 1102 1103 def render_for_text(text = nil, status = nil, append_response = false) #:nodoc: 1104 @performed_render = true /Users/rick/Documents/terralien/brightside/site/vendor/rails/actionpack/lib/action_controller/base.rb:1100 When I s(tep) into this I end up here: 173 @template.metaclass.class_eval do 174 define_method :file_exists? do 175 true 176 end 177 define_method :render_file do |*args| => 178 @first_render ||= args[0] 179 end 180 end 181 end 182 end /Users/rick/Documents/terralien/brightside/site/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb:178 It looks like the real ActionView::Base.render_file never gets called and that's where it looks like the realization that it's looking for rss rather than say html seems to happen. Can anyone shed any light on this? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From dchelimsky at gmail.com Thu Feb 7 15:32:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Feb 2008 14:32:25 -0600 Subject: [rspec-users] Problems testing rss feed controller. In-Reply-To: References: Message-ID: <57c63afe0802071232y4317a628taef28111d6ff9bd@mail.gmail.com> On Feb 7, 2008 2:27 PM, Rick DeNatale wrote: > I've got a controller which produces an RSS feed, pretty much based on > Ryan Bates recent RailsCast. > > I'm having a heck of a time getting the spec to successfully fetch the > feed though. I gave up got it working without a spec, and I'm now > trying to back up and get the spec to work. > > The controller is simplicity itself: > > class PodcastRssFeedController < ApplicationController > > def index > @podcasts = Podcast.latest(100) > end > > end > > I have a route which gets to the index action and sets :format => > :rss, as I said this produces a valid rss response in the real world, > just not in the spec. > > Here's the basic spec: > > require File.dirname(__FILE__) + '/../spec_helper' > require File.dirname(__FILE__) + '/../be_valid_feed' > > def mock_podcast(i) > mock_model( > Podcast, > :artist_name_slug => "Artist#{i}" > ) > end > > describe PodcastRssFeedController do > > before(:all) do > @podcasts = (1..5).map {|i| mock_podcast(i)} > Podcast.stub!(:latest).and_return(@podcasts) > end > > describe 'handling GET brightsidepodcasts/rss.xml' do > > def do_get > @request.format = 'rss' > get 'index', :format => :rss > end > > it "should successfully get feed" do > do_get > response.should be_success > end > > it "should validate" do > do_get > response.should be_valid_feed > end > end > > end > > The validation example is failing because the response body is being returned as > podcast_rss_feed/index > > I've tried stepping through with rdebug and I can't figure out where > it's going wrong. > > I eventually end up here: > > 1099 logger.info("Rendering #{template_path}" + (status ? > " (#{status})" : '')) if logger > => 1100 render_for_text(@template.render_file(template_path, > use_full_path, locals), status) > 1101 end > 1102 > 1103 def render_for_text(text = nil, status = nil, > append_response = false) #:nodoc: > 1104 @performed_render = true > /Users/rick/Documents/terralien/brightside/site/vendor/rails/actionpack/lib/action_controller/base.rb:1100 > > When I s(tep) into this I end up here: > > 173 @template.metaclass.class_eval do > 174 define_method :file_exists? do > 175 true > 176 end > 177 define_method :render_file do |*args| > => 178 @first_render ||= args[0] > 179 end > 180 end > 181 end > 182 end > /Users/rick/Documents/terralien/brightside/site/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb:178 > > It looks like the real ActionView::Base.render_file never gets called > and that's where it looks like the realization that it's looking for > rss rather than say html seems to happen. > > Can anyone shed any light on this? Try integrate_views: describe PodcastRssFeedController do integrate_views ... end Without that, render gets modified by rspec (to isolate your controllers from their views). HTH, David > > -- > 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 rick.denatale at gmail.com Thu Feb 7 15:39:26 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 7 Feb 2008 15:39:26 -0500 Subject: [rspec-users] Problems testing rss feed controller. In-Reply-To: <57c63afe0802071232y4317a628taef28111d6ff9bd@mail.gmail.com> References: <57c63afe0802071232y4317a628taef28111d6ff9bd@mail.gmail.com> Message-ID: On 2/7/08, David Chelimsky wrote: > On Feb 7, 2008 2:27 PM, Rick DeNatale wrote: > > I've got a controller which produces an RSS feed, pretty much based on > > Ryan Bates recent RailsCast. > > > > I'm having a heck of a time getting the spec to successfully fetch the > > feed though. I gave up got it working without a spec, and I'm now > > trying to back up and get the spec to work. > > Try integrate_views: > > describe PodcastRssFeedController do > integrate_views > ... > end > > Without that, render gets modified by rspec (to isolate your > controllers from their views). Thanks for the quick reply David, that was the problem, athough I found that it needs to go into the nested example group, not the outer one. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From rps at salas.com Thu Feb 7 18:26:33 2008 From: rps at salas.com (Pito Salas) Date: Thu, 7 Feb 2008 18:26:33 -0500 Subject: [rspec-users] Can you explain this code to me? Message-ID: I am experimenting with the restful-authentication plug in and I see that it has generated an rspec encantation which I had not seen before: it 'allows signup' do lambda do create_user response.should be_redirect end.should change(User, :count).by(1) end What does the combination of a lambda and a .should mean? Similarly but a little different: describe 'being created' do before do @user = nil @creating_user = lambda do @user = create_user violated "#{@user.errors.full_messages.to_sentence}" if @user.new_record? end end it 'increments User#count' do @creating_user.should change(User, :count).by(1) end end Thanks for any pointers or clarifications! From u.alberton at gmail.com Thu Feb 7 18:40:52 2008 From: u.alberton at gmail.com (Bira) Date: Thu, 7 Feb 2008 21:40:52 -0200 Subject: [rspec-users] Can you explain this code to me? In-Reply-To: References: Message-ID: On Feb 7, 2008 9:26 PM, Pito Salas wrote: > What does the combination of a lambda and a .should mean? I'm new to the list, but I think I can answer that :). >From what I know, it means that RSpec will run the lambda's code and check that it had the effect specified in the "should" call. And from that I can determine by looking at the two incantations you posted, the lambda is used because the code can throw an error, and the spec's author didn't want the first error to prevent the outer "should" from being checked. -- Bira http://compexplicita.wordpress.com http://compexplicita.tumblr.com From dchelimsky at gmail.com Thu Feb 7 18:37:15 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Feb 2008 17:37:15 -0600 Subject: [rspec-users] Can you explain this code to me? In-Reply-To: References: Message-ID: <57c63afe0802071537kc37b90bre41030551734a257@mail.gmail.com> On Feb 7, 2008 5:26 PM, Pito Salas wrote: > I am experimenting with the restful-authentication plug in and I see > that it has generated an rspec encantation which I had not seen > before: > > it 'allows signup' do > lambda do > create_user > response.should be_redirect > end.should change(User, :count).by(1) > end > > What does the combination of a lambda and a .should mean? This should answer your question: http://rspec.info/rdoc/classes/Spec/Matchers.html#M000386 HTH, David > > Similarly but a little different: > > describe 'being created' do > before do > @user = nil > @creating_user = lambda do > @user = create_user > violated "#{@user.errors.full_messages.to_sentence}" if > @user.new_record? > end > end > > it 'increments User#count' do > @creating_user.should change(User, :count).by(1) > end > end > > Thanks for any pointers or clarifications! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Thu Feb 7 19:31:13 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 7 Feb 2008 16:31:13 -0800 Subject: [rspec-users] Can you explain this code to me? In-Reply-To: References: Message-ID: <810a540e0802071631u420ff51co986feaac250e57f5@mail.gmail.com> On Feb 7, 2008 3:40 PM, Bira wrote: > On Feb 7, 2008 9:26 PM, Pito Salas wrote: > > > What does the combination of a lambda and a .should mean? > > I'm new to the list, but I think I can answer that :). > > >From what I know, it means that RSpec will run the lambda's code and > check that it had the effect specified in the "should" call. > > And from that I can determine by looking at the two incantations you > posted, the lambda is used because the code can throw an error, and > the spec's author didn't want the first error to prevent the outer > "should" from being checked. Sometimes, but in this case, what you are trying to do is before_count = User.send :count create_user response.should be_redirect User.send(:count).should == before_count + 1 that's some boilerplate that can be abstracted away... def change(target, method) before_count = target.send method yield target.send(method).should == before_count + 1 end (not exactly how it's implemented, but it should give you a rough idea of what's going on) Pat From gerrit+rspec-devel at gerritkaiser.de Fri Feb 8 00:41:07 2008 From: gerrit+rspec-devel at gerritkaiser.de (Gerrit Kaiser) Date: Fri, 8 Feb 2008 16:41:07 +1100 Subject: [rspec-users] =?windows-1252?q?Shared_Examples_+_=93initialized_c?= =?windows-1252?q?onstant=94_warnings?= Message-ID: <4B4CE463-78DB-4AD5-83BB-893BEA074807@gerritkaiser.de> Hi List, I'm using rspec's shared example groups in a rails project (rails 2.02, rspec(on_rails) 1.1.3) and I'm getting lots of errors of the following kind when(before) running the specs: (RAILS_ROOT)/vendor/plugins/rspec/lib/spec/extensions/main.rb:78: warning: already initialized constant ContentExamples (RAILS_ROOT)/vendor/plugins/rspec/lib/spec/extensions/main.rb:78: warning: already initialized constant EditViewExamples The shared example groups are defined in files like spec/shared/ foo_examples.rb and declared as share_as :FooExamples do?end (and then included in other example groups with "include FooExamples") They're loaded in spec_helper.rb with the following: Dir.glob(File.join(File.dirname(__FILE__), 'shared', '*.rb')).each do | shared_example| require shared_example end I'm guessing that's what needs to change. Has anyone else seen these warnings? I find them quite annoying and would like to get rid of them. Any pointers would be much appreciated. Thanks, Gerrit From jarkko at jlaine.net Fri Feb 8 02:21:36 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Fri, 8 Feb 2008 09:21:36 +0200 Subject: [rspec-users] Can you explain this code to me? In-Reply-To: References: Message-ID: On 8.2.2008, at 1.26, Pito Salas wrote: > I am experimenting with the restful-authentication plug in and I see > that it has generated an rspec encantation which I had not seen > before: > > it 'allows signup' do > lambda do > create_user > response.should be_redirect > end.should change(User, :count).by(1) > end > > What does the combination of a lambda and a .should mean? Lambda is an anonymous function, or pretty much the same as a block of code. So in the case above, running the code inside the lambda block should change the user count by one. This is the same as assert_difference does in test/unit. > > > Similarly but a little different: > > describe 'being created' do > before do > @user = nil > @creating_user = lambda do > @user = create_user > violated "#{@user.errors.full_messages.to_sentence}" if > @user.new_record? > end > end > > it 'increments User#count' do > @creating_user.should change(User, :count).by(1) > end > end > > Thanks for any pointers or clarifications! Same thing, just this time the function is first stored in an instance variable. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From lists at ruby-forum.com Fri Feb 8 10:23:13 2008 From: lists at ruby-forum.com (Kevin Barnes) Date: Fri, 8 Feb 2008 16:23:13 +0100 Subject: [rspec-users] template.expect_render 'failure' Message-ID: <378e70af43d2c02b18eb6c1b101948e1@ruby-forum.com> I keep having problems w/ expect_render, mainly that it doesn't work as advertised. I can put a template.expect_render(:partial => 'this should fail') in a view spec and I get no failure. I have read the docs, I have followed the threads (two, which never resolve the initial issue and dissolve into some other discussion) without much explanation for what I'm experiencing. This has manifested itself in both 1.1.3 and 1.1.2 releases. I do use mocha mocking. So as a last resort I turned that off and expect_render still 'fails silently'. (I've also seen the failure in Rails 2.0.2 and 1.2.5 if that helps. I'm at a loss at how to continue debugging the issue. Any suggestions? Thanks, Kevin -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Feb 8 11:34:26 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 8 Feb 2008 10:34:26 -0600 Subject: [rspec-users] template.expect_render 'failure' In-Reply-To: <378e70af43d2c02b18eb6c1b101948e1@ruby-forum.com> References: <378e70af43d2c02b18eb6c1b101948e1@ruby-forum.com> Message-ID: <57c63afe0802080834v337c33dapa7f2499e71cdda8@mail.gmail.com> On Feb 8, 2008 9:23 AM, Kevin Barnes wrote: > I keep having problems w/ expect_render, mainly that it doesn't work as > advertised. I can put a template.expect_render(:partial => 'this should > fail') in a view spec and I get no failure. I have read the docs, I have > followed the threads (two, which never resolve the initial issue and > dissolve into some other discussion) without much explanation for what > I'm experiencing. This has manifested itself in both 1.1.3 and 1.1.2 > releases. I do use mocha mocking. So as a last resort I turned that off > and expect_render still 'fails silently'. (I've also seen the failure in > Rails 2.0.2 and 1.2.5 if that helps. Code please. > > I'm at a loss at how to continue debugging the issue. Any suggestions? > > Thanks, > Kevin > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cdemyanovich at gmail.com Fri Feb 8 11:42:07 2008 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Fri, 8 Feb 2008 11:42:07 -0500 Subject: [rspec-users] template.expect_render 'failure' In-Reply-To: <378e70af43d2c02b18eb6c1b101948e1@ruby-forum.com> References: <378e70af43d2c02b18eb6c1b101948e1@ruby-forum.com> Message-ID: <61c885db0802080842u650e783aic27ca9e80cb7c673@mail.gmail.com> On Feb 8, 2008 10:23 AM, Kevin Barnes wrote: > I'm at a loss at how to continue debugging the issue. Any suggestions? I threw this line in one of my view specs template.expect_render(:partial => "fail") and it failed as it should. If you can, please share your view spec. Regards, Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080208/1bc05227/attachment.html From dchelimsky at gmail.com Fri Feb 8 11:43:06 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 8 Feb 2008 10:43:06 -0600 Subject: [rspec-users] =?windows-1252?q?Shared_Examples_+_=93initialized_c?= =?windows-1252?q?onstant=94_warnings?= In-Reply-To: <4B4CE463-78DB-4AD5-83BB-893BEA074807@gerritkaiser.de> References: <4B4CE463-78DB-4AD5-83BB-893BEA074807@gerritkaiser.de> Message-ID: <57c63afe0802080843k584703ebqaf7c95f68e1d8cf8@mail.gmail.com> On Feb 7, 2008 11:41 PM, Gerrit Kaiser wrote: > Hi List, > I'm using rspec's shared example groups in a rails project (rails > 2.02, rspec(on_rails) 1.1.3) and I'm getting lots of errors of the > following kind when(before) running the specs: > > (RAILS_ROOT)/vendor/plugins/rspec/lib/spec/extensions/main.rb:78: > warning: already initialized constant ContentExamples > (RAILS_ROOT)/vendor/plugins/rspec/lib/spec/extensions/main.rb:78: > warning: already initialized constant EditViewExamples > > The shared example groups are defined in files like spec/shared/ > foo_examples.rb > and declared as > share_as :FooExamples do?end > (and then included in other example groups with "include FooExamples") > They're loaded in spec_helper.rb with the following: > Dir.glob(File.join(File.dirname(__FILE__), 'shared', '*.rb')).each do | > shared_example| > require shared_example > end > > > I'm guessing that's what needs to change. Has anyone else seen these > warnings? I find them quite annoying and would like to get rid of > them. Any pointers would be much appreciated. Hey Gerritt. The likely culprit is in ExampleGroupRunner, which uses the load command (not require) and therefore reloads anything that might be in the spec path. That is necessary to support drb, and unlikely to change, so it is up to you to ensure that shared example groups don't get reloaded. How you do that depends on how you are running your specs and what other config changes you've made. So ... how are you running your specs? Have you made any additional config changes in terms of what files get loaded? David > Thanks, > Gerrit > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Feb 8 12:37:51 2008 From: lists at ruby-forum.com (Kevin Barnes) Date: Fri, 8 Feb 2008 18:37:51 +0100 Subject: [rspec-users] template.expect_render 'failure' In-Reply-To: <57c63afe0802080834v337c33dapa7f2499e71cdda8@mail.gmail.com> References: <378e70af43d2c02b18eb6c1b101948e1@ruby-forum.com> <57c63afe0802080834v337c33dapa7f2499e71cdda8@mail.gmail.com> Message-ID: David Chelimsky wrote: > > Code please. I stand corrected. It is only not working for me when mocha is enabled. I just stepped through four cases and detailed the view spec, view (that is sometimes empty) and results. This is running on OSX 10.4.11 with the following setup: moonbook:~ barnekr$ gem list --local | grep "mocha\|rspec\|rails" mocha (0.5.5, 0.5.3, 0.4.0, 0.3.2) rails (2.0.2, 1.2.5, 1.2.3, 1.2.2, 1.2.1, 1.1.6) rspec (1.1.3, 1.1.2, 1.0.8, 1.0.5) moonbook:~ barnekr$ ruby -v ruby 1.8.5 (2006-08-25) [i686-darwin8.8.1] http://pastie.caboo.se/149337 Thanks again, Kevin p.s. I updated the mocha gem to 0.5.6 and no change to the cases listed involving mocha. -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Fri Feb 8 13:34:33 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 8 Feb 2008 13:34:33 -0500 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails Message-ID: As I posted to rails-talk yesterday, I whipped up an Rspec matcher using the feedvalidator gem, which lets you write response.should be_valid_feed in view specs or controller specs which integrate_views I wrote about it this AM. http://talklikeaduck.denhaven2.com/articles/2008/02/08/validating-rss-feeds-with-rspec -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From gilesb at gmail.com Fri Feb 8 14:32:33 2008 From: gilesb at gmail.com (Giles Bowkett) Date: Fri, 8 Feb 2008 11:32:33 -0800 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails In-Reply-To: References: Message-ID: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> I hate to do this because it seems almost sadistic, but I encountered some borkage in the feed in my Safari (3). http://s3.amazonaws.com/giles/rss_feed_bork.png On 2/8/08, Rick DeNatale wrote: > As I posted to rails-talk yesterday, I whipped up an Rspec matcher > using the feedvalidator gem, which lets you write > > response.should be_valid_feed > > in view specs or controller specs which integrate_views > > I wrote about it this AM. > > http://talklikeaduck.denhaven2.com/articles/2008/02/08/validating-rss-feeds-with-rspec > > -- > 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 > -- Giles Bowkett Podcast: http://hollywoodgrit.blogspot.com Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com From ermok at tiscali.co.uk Fri Feb 8 15:50:28 2008 From: ermok at tiscali.co.uk (Neil M. Young) Date: Fri, 8 Feb 2008 12:50:28 -0800 (PST) Subject: [rspec-users] colored output for stories? Message-ID: <15363648.post@talk.nabble.com> sorry if this is documented somewhere, but do stories support colored output? neither -c nor --color are working for me. -- View this message in context: http://www.nabble.com/colored-output-for-stories--tp15363648p15363648.html Sent from the rspec-users mailing list archive at Nabble.com. From rps at salas.com Fri Feb 8 16:34:01 2008 From: rps at salas.com (Pito Salas) Date: Fri, 8 Feb 2008 16:34:01 -0500 Subject: [rspec-users] Can you explain this code to me? In-Reply-To: References: Message-ID: Thanks all for excellent pointers! On Feb 8, 2008 2:21 AM, Jarkko Laine wrote: > On 8.2.2008, at 1.26, Pito Salas wrote: > > > I am experimenting with the restful-authentication plug in and I see > > that it has generated an rspec encantation which I had not seen > > before: > > > > it 'allows signup' do > > lambda do > > create_user > > response.should be_redirect > > end.should change(User, :count).by(1) > > end > > > > What does the combination of a lambda and a .should mean? > > Lambda is an anonymous function, or pretty much the same as a block of > code. So in the case above, running the code inside the lambda block > should change the user count by one. This is the same as > assert_difference does in test/unit. > > > > > > > Similarly but a little different: > > > > describe 'being created' do > > before do > > @user = nil > > @creating_user = lambda do > > @user = create_user > > violated "#{@user.errors.full_messages.to_sentence}" if > > @user.new_record? > > end > > end > > > > it 'increments User#count' do > > @creating_user.should change(User, :count).by(1) > > end > > end > > > > Thanks for any pointers or clarifications! > > Same thing, just this time the function is first stored in an instance > variable. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Feb 8 17:46:59 2008 From: lists at ruby-forum.com (Terry Shuttleworth) Date: Fri, 8 Feb 2008 23:46:59 +0100 Subject: [rspec-users] Rspec 1.1.3 +ZenTest 3.9.1= rspec tests not found Message-ID: <527fd94446466712fc4136d0cfa1b8c8@ruby-forum.com> Hi there Have upgraded to Rspec 1.1.3 and ZenTest 3.9.1 and have --force re-installed rspec plugin in the relevant place, but am getting the following when I run rake spec:autotest spec --diff unified test/test_helper.rb and not spec --diff unified Have tried looking in the plugin codes and in the ZenTest gem code, but I can't find what I need to change to get it to look for my rspec tests rather than look at test/test_helper.rb Have spent the past couple of hours googling around to find an answer, but to no avail. Can anyone please point me in the right direction ? Thanks in advance ! Terry (I know about the "script/spec" edit that I have to make so that the "spec --diff unified" command works. Have reinstalled rspec this so many times tonight that I can't remember if I did it in the last incarnation!) -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Fri Feb 8 18:23:35 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 8 Feb 2008 18:23:35 -0500 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails In-Reply-To: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> References: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> Message-ID: Not sure what you're talking about. 1) My blog is just standard typo, so the code I'm talking about isn't involved. 2) The feed on my blog, does indeed validate. Now if Safari has a problem formating it, it's not a validation problem. On 2/8/08, Giles Bowkett wrote: > I hate to do this because it seems almost sadistic, but I encountered > some borkage in the feed in my Safari (3). > > http://s3.amazonaws.com/giles/rss_feed_bork.png > > On 2/8/08, Rick DeNatale wrote: > > As I posted to rails-talk yesterday, I whipped up an Rspec matcher > > using the feedvalidator gem, which lets you write > > > > response.should be_valid_feed > > > > in view specs or controller specs which integrate_views > > > > I wrote about it this AM. > > > > http://talklikeaduck.denhaven2.com/articles/2008/02/08/validating-rss-feeds-with-rspec > > > > -- > > 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 > > > > > -- > Giles Bowkett > > Podcast: http://hollywoodgrit.blogspot.com > Blog: http://gilesbowkett.blogspot.com > Portfolio: http://www.gilesgoatboy.org > Tumblelog: http://giles.tumblr.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From nathan.sutton at gmail.com Fri Feb 8 18:26:56 2008 From: nathan.sutton at gmail.com (Nathan Sutton) Date: Fri, 8 Feb 2008 17:26:56 -0600 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails In-Reply-To: References: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> Message-ID: <0FE890F5-F721-4F35-8BA8-F76A1959EBE8@gmail.com> Validation doesn't mean it's formatted to be readable though, does it? Nathan Sutton fowlduck at gmail.com rspec 1.1.3 rspec_on_rails 1.1.3 rails 2.0.2 On Feb 8, 2008, at 5:23 PM, Rick DeNatale wrote: > Not sure what you're talking about. > > 1) My blog is just standard typo, so the code I'm talking about > isn't involved. > > 2) The feed on my blog, does indeed validate. Now if Safari has a > problem formating it, it's not a validation problem. > > On 2/8/08, Giles Bowkett wrote: >> I hate to do this because it seems almost sadistic, but I encountered >> some borkage in the feed in my Safari (3). >> >> http://s3.amazonaws.com/giles/rss_feed_bork.png >> >> On 2/8/08, Rick DeNatale wrote: >>> As I posted to rails-talk yesterday, I whipped up an Rspec matcher >>> using the feedvalidator gem, which lets you write >>> >>> response.should be_valid_feed >>> >>> in view specs or controller specs which integrate_views >>> >>> I wrote about it this AM. >>> >>> http://talklikeaduck.denhaven2.com/articles/2008/02/08/validating-rss-feeds-with-rspec >>> >>> -- >>> 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 >>> >> >> >> -- >> Giles Bowkett >> >> Podcast: http://hollywoodgrit.blogspot.com >> Blog: http://gilesbowkett.blogspot.com >> Portfolio: http://www.gilesgoatboy.org >> Tumblelog: http://giles.tumblr.com >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > -- > 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 gilesb at gmail.com Fri Feb 8 18:39:24 2008 From: gilesb at gmail.com (Giles Bowkett) Date: Fri, 8 Feb 2008 15:39:24 -0800 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails In-Reply-To: References: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> Message-ID: <2d81dedb0802081539k3c7ea800o49db425ab54378e2@mail.gmail.com> Sorry, just kidding. Humorous irony, no serious intent. On 2/8/08, Rick DeNatale wrote: > Not sure what you're talking about. > > 1) My blog is just standard typo, so the code I'm talking about isn't involved. > > 2) The feed on my blog, does indeed validate. Now if Safari has a > problem formating it, it's not a validation problem. > > On 2/8/08, Giles Bowkett wrote: > > I hate to do this because it seems almost sadistic, but I encountered > > some borkage in the feed in my Safari (3). > > > > http://s3.amazonaws.com/giles/rss_feed_bork.png > > > > On 2/8/08, Rick DeNatale wrote: > > > As I posted to rails-talk yesterday, I whipped up an Rspec matcher > > > using the feedvalidator gem, which lets you write > > > > > > response.should be_valid_feed > > > > > > in view specs or controller specs which integrate_views > > > > > > I wrote about it this AM. > > > > > > http://talklikeaduck.denhaven2.com/articles/2008/02/08/validating-rss-feeds-with-rspec > > > > > > -- > > > 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 > > > > > > > > > -- > > Giles Bowkett > > > > Podcast: http://hollywoodgrit.blogspot.com > > Blog: http://gilesbowkett.blogspot.com > > Portfolio: http://www.gilesgoatboy.org > > Tumblelog: http://giles.tumblr.com > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > 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 > -- Giles Bowkett Podcast: http://hollywoodgrit.blogspot.com Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com From rick.denatale at gmail.com Fri Feb 8 18:40:10 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 8 Feb 2008 18:40:10 -0500 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails In-Reply-To: <0FE890F5-F721-4F35-8BA8-F76A1959EBE8@gmail.com> References: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> <0FE890F5-F721-4F35-8BA8-F76A1959EBE8@gmail.com> Message-ID: On 2/8/08, Nathan Sutton wrote: > Validation doesn't mean it's formatted to be readable though, does it? Correct. And by the way I just looked at my blog's feed on Safari (3.0.4 on OSX 10.4.11) on my system and it looks just fine. I suspect that the Giles' problem might actually lie in Safari/Leopard -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From gilesb at gmail.com Fri Feb 8 18:48:22 2008 From: gilesb at gmail.com (Giles Bowkett) Date: Fri, 8 Feb 2008 15:48:22 -0800 Subject: [rspec-users] RSS Validation matcher for RSpec/Rails In-Reply-To: References: <2d81dedb0802081132s3aac6ab7vbd310bb1a8db08e4@mail.gmail.com> <0FE890F5-F721-4F35-8BA8-F76A1959EBE8@gmail.com> Message-ID: <2d81dedb0802081548m321bbcfepebd2aaaf70a5834@mail.gmail.com> My Safari's 3.0.4 too, OS X 10.5. Weird that it would be the OS but I guess that's the case. On 2/8/08, Rick DeNatale wrote: > On 2/8/08, Nathan Sutton wrote: > > Validation doesn't mean it's formatted to be readable though, does it? > > Correct. > > And by the way I just looked at my blog's feed on Safari (3.0.4 on OSX > 10.4.11) on my system and it looks just fine. > > I suspect that the Giles' problem might actually lie in Safari/Leopard > > -- > 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 > -- Giles Bowkett Podcast: http://hollywoodgrit.blogspot.com Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com From gerrit+rspec-devel at gerritkaiser.de Fri Feb 8 22:14:29 2008 From: gerrit+rspec-devel at gerritkaiser.de (Gerrit Kaiser) Date: Sat, 9 Feb 2008 14:14:29 +1100 Subject: [rspec-users] =?windows-1252?q?Shared_Examples_+_=93initialized_c?= =?windows-1252?q?onstant=94_warnings?= In-Reply-To: <57c63afe0802080843k584703ebqaf7c95f68e1d8cf8@mail.gmail.com> References: <4B4CE463-78DB-4AD5-83BB-893BEA074807@gerritkaiser.de> <57c63afe0802080843k584703ebqaf7c95f68e1d8cf8@mail.gmail.com> Message-ID: <744475B8-52E0-41EC-8E47-9539859F7423@gerritkaiser.de> David, thanks for your prompt reply. On 09/02/2008, at 3:43 AM, David Chelimsky wrote: > so it is up to you to ensure that shared example groups don't > get reloaded. How you do that depends on how you are running your > specs and what other config changes you've made. > > So ... how are you running your specs? Have you made any additional > config changes in terms of what files get loaded? No changes in terms of loaded files. I'm normally running them via autotest, but invoking "script/spec spec/**/*_spec.rb" directly gives the same warnings (which is what I find weird, considering the shared example groups don't live in *_spec.rb files. Here's my spec.opts: --colour --format progress --format profile:doc/spec/slowest_examples --format html:doc/spec/report.html --loadby mtime --reverse Thanks for you help, Gerrit From win at wincent.com Sat Feb 9 08:17:48 2008 From: win at wincent.com (Wincent Colaiuta) Date: Sat, 9 Feb 2008 14:17:48 +0100 Subject: [rspec-users] diff output "back to front" Message-ID: <658B97A2-CB57-45C0-B008-019D8BBD2D6D@wincent.com> Is it just me, or is the output of "spec --diff" "back to front"? In other words given expected result: foo 1 foo 2 foo 3 And actual result: foo 1 foo 2 bar x foo 3 This is what "spec --diff u the_spec.rb" shows me: 2) 'Thing should blah' FAILED expected: "foo 1\nfoo 2\nfoo 3\n", got: "foo 1\nfoo 2\nbar x\nfoo 3\n" (using ==) Diff: @@ -1,5 +1,4 @@ foo 1 foo 2 -bar x foo 3 ./spec/the_spec.rb:208: In other words it's showing me "how is the expected result different from the actual?", but I think it would be more intuitive for it to show the opposite ("how is the actual result different from the expected?"); to me this latter question is much more interesting and is the answer I am interested in when I ask "what's the difference between the actual and the expected?". The output: 2) 'Thing should blah' FAILED expected: "foo 1\nfoo 2\nfoo 3\n", got: "foo 1\nfoo 2\nbar x\nfoo 3\n" (using ==) Diff: @@ -1,5 +1,4 @@ foo 1 foo 2 +bar x foo 3 ./spec/the_spec.rb:208: I understand that this kind of thing might be subjective, so wanted to know what other people think. I also have this spook sense of deja vu while writing this, so please forgive me if this has come up before. Cheers, Wincent From dchelimsky at gmail.com Sat Feb 9 08:54:48 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 9 Feb 2008 07:54:48 -0600 Subject: [rspec-users] diff output "back to front" In-Reply-To: <658B97A2-CB57-45C0-B008-019D8BBD2D6D@wincent.com> References: <658B97A2-CB57-45C0-B008-019D8BBD2D6D@wincent.com> Message-ID: <57c63afe0802090554v746bf360r25eddc0eb4774e97@mail.gmail.com> On Feb 9, 2008 7:17 AM, Wincent Colaiuta wrote: > Is it just me, or is the output of "spec --diff" "back to front"? > > In other words given expected result: > > foo 1 > foo 2 > foo 3 > > And actual result: > > foo 1 > foo 2 > bar x > foo 3 > > This is what "spec --diff u the_spec.rb" shows me: > > 2) > 'Thing should blah' FAILED > expected: "foo 1\nfoo 2\nfoo 3\n", > got: "foo 1\nfoo 2\nbar x\nfoo 3\n" (using ==) > Diff: > @@ -1,5 +1,4 @@ > foo 1 > foo 2 > -bar x > foo 3 > ./spec/the_spec.rb:208: > > In other words it's showing me "how is the expected result different > from the actual?", but I think it would be more intuitive for it to > show the opposite ("how is the actual result different from the > expected?"); to me this latter question is much more interesting and > is the answer I am interested in when I ask "what's the difference > between the actual and the expected?". The output: > > 2) > 'Thing should blah' FAILED > expected: "foo 1\nfoo 2\nfoo 3\n", > got: "foo 1\nfoo 2\nbar x\nfoo 3\n" (using ==) > Diff: > @@ -1,5 +1,4 @@ > foo 1 > foo 2 > +bar x > foo 3 > ./spec/the_spec.rb:208: > > I understand that this kind of thing might be subjective, so wanted to > know what other people think. +1 (That's not a diff. That's my opinion) Go ahead and patch it up if you want and I'll be glad to make this change. Cheers, David > > I also have this spook sense of deja vu while writing this, so please > forgive me if this has come up before. > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cgrindel at yahoo.com Sat Feb 9 13:55:28 2008 From: cgrindel at yahoo.com (Charles Grindel) Date: Sat, 9 Feb 2008 10:55:28 -0800 (PST) Subject: [rspec-users] Shared examples not reloading in spec_server Message-ID: <307904.40433.qm@web54107.mail.re2.yahoo.com> Hi, David, Thanks for the reply. I did try it with autotest only. The shared examples reloaded with each test run. I did some further investigation and sent an email to the dev mailing list with my findings and a possible solution. Depending upon what I hear, I will be glad to enter a bug. BTW, thanks for your work with RSpec. Chuck ----- Original Message ---- From: David Chelimsky To: rspec-users Sent: Thursday, February 7, 2008 11:01:19 AM Subject: Re: [rspec-users] Shared examples not reloading in spec_server On Feb 7, 2008 9:39 AM, Charles Grindel wrote: > > I am currently running RSpec 1.1.3 with ZenTest 3.9.1 on Windows XP. I have > noticed that shared examples are not being reloaded by spec_server when they > have been updated. Below is a simple example that reproduces the problem. > The example code and output is at the location below. > > > http://pastie.caboo.se/148688 > > I have confirmed that non-shared examples are being reloaded by spec_server. > So, here are my questions. > > 1. Has anyone else noticed this behavior? > > 2. Does anyone know how I can force spec_server to reload the shared > examples? > > 3. If this smells like a bug, can someone point me to instructions for > filing a bug? Sounds like a problem with your autotest configuration, not with spec_server. Try it without spec server to verify that is correct. If it's that autotest isn't loading them, you just need to add a mapping in .autotest. Read the ZenTest docs for more info and/or check out my blog post on this: http://blog.davidchelimsky.net/articles/2008/01/15/rspec-1-1-2-and-zentest-3-8-0. If you try that and you still think it's an rspec bug, file a ticket at http://rspec.lighthouseapp.com. Cheers, David > > Thanks, > Chuck > > _______________________________________________ > 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/20080209/cffdccfc/attachment.html From coreyhaines at gmail.com Sun Feb 10 08:03:09 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Sun, 10 Feb 2008 08:03:09 -0500 Subject: [rspec-users] rspec - rails put :update any examples In-Reply-To: <57c63afe0802051830p7b79c843s31b4d9658f7c34f7@mail.gmail.com> References: <57c63afe0802042302y5f3aafc4tb1464b2274fcee5f@mail.gmail.com> <6bdacb70802051642v194f5806iaf59bb7ebebd23e0@mail.gmail.com> <57c63afe0802051830p7b79c843s31b4d9658f7c34f7@mail.gmail.com> Message-ID: <6bdacb70802100503v289d96ccpda7267d78b910480@mail.gmail.com> Okay, I'll try that. Thanks. I don't really like all the view stuff in the controllers, and I intend to eventually move them into RJS, but, while I'm learning, I'm keeping it there. :) -Corey On Feb 5, 2008 9:30 PM, David Chelimsky wrote: > On Feb 5, 2008 6:42 PM, Corey Haines wrote: > > David, I tried doing this, and I get an exception. Here's a pastie of > the > > error, controller, controller_spec: http://pastie.caboo.se/148021 > > You've got page[:coupon_list], not just page. So what you need to mock is > this: > > page = mock("page") > page.should_receive(:[]).with(:coupon_list).and_return(page) > page.should_receive(:replace_html).with(:partial => "coupon_list") > > That's starting to get a bit brittle, but that's what you get for > mixing all that view logic in your controllers. It's the Rails Way, > but it comes with a price if you want this level of coverage and > isolation. > > FWIW, > David > > > > > > > > > On Feb 5, 2008 2:02 AM, David Chelimsky wrote: > > > > > it "should replace foo with bar partial" do > > > page = mock("page") > > > page.should_receive(:replace_html).with('foo', :partial => 'bar') > > > controller.expect_render(:update).and_yield(page) > > > do_post > > > end > > > > > > HTH, > > > David > > > > > > > > > > > Brian > > > > > > > > > > > > _______________________________________________ > > > > 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 > > _______________________________________________ > > 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/20080210/4768d218/attachment-0001.html From aslak.hellesoy at gmail.com Sun Feb 10 08:19:44 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 10 Feb 2008 14:19:44 +0100 Subject: [rspec-users] colored output for stories? In-Reply-To: <15363648.post@talk.nabble.com> References: <15363648.post@talk.nabble.com> Message-ID: <8d961d900802100519q5c7244f8k1a0fae8b6374525c@mail.gmail.com> On Feb 8, 2008 9:50 PM, Neil M. Young wrote: > > sorry if this is documented somewhere, but do stories support colored output? > neither -c nor --color are working for me. It works for me. What's your environment? > -- > View this message in context: http://www.nabble.com/colored-output-for-stories--tp15363648p15363648.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pritchie at videotron.ca Sun Feb 10 11:37:06 2008 From: pritchie at videotron.ca (Patrick Ritchie) Date: Sun, 10 Feb 2008 11:37:06 -0500 Subject: [rspec-users] Ticket #274 patch for --drb in spec.opts Message-ID: <47AF2832.6040203@videotron.ca> Hi All, I submitted a patch last week to fix a bug with --drb not working if it's specified in spec.opts, this causes autotest to run obscenely slowly out of the box on my machine. Please let me know if you need anything else from me on this. Cheers! Patrick From wshaddix at gmail.com Mon Feb 11 06:43:30 2008 From: wshaddix at gmail.com (Wes Shaddix) Date: Mon, 11 Feb 2008 06:43:30 -0500 Subject: [rspec-users] How to mock an association Message-ID: <47B034E2.2050401@gmail.com> I've got a "group" model that has a user_id attribute and a validates_existence_of :user and validates_presence_of :user_id validations. What method(s) do I need to stub on the User mock to intercept those validation calls? My goal is to isolate the Group model from the User model. Thanks Wes From ermok at tiscali.co.uk Mon Feb 11 07:41:19 2008 From: ermok at tiscali.co.uk (Neil M. Young) Date: Mon, 11 Feb 2008 04:41:19 -0800 (PST) Subject: [rspec-users] colored output for stories? In-Reply-To: <8d961d900802100519q5c7244f8k1a0fae8b6374525c@mail.gmail.com> References: <15363648.post@talk.nabble.com> <8d961d900802100519q5c7244f8k1a0fae8b6374525c@mail.gmail.com> Message-ID: <15410706.post@talk.nabble.com> aslak hellesoy wrote: > > On Feb 8, 2008 9:50 PM, Neil M. Young wrote: >> >> sorry if this is documented somewhere, but do stories support colored >> output? >> neither -c nor --color are working for me. > > It works for me. What's your environment? > ubuntu 7.10, rails 2.0.2, rspec 1.1.3 I get color output for specs but not for stories -- View this message in context: http://www.nabble.com/colored-output-for-stories--tp15363648p15410706.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Mon Feb 11 09:03:28 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 11 Feb 2008 08:03:28 -0600 Subject: [rspec-users] colored output for stories? In-Reply-To: <15410706.post@talk.nabble.com> References: <15363648.post@talk.nabble.com> <8d961d900802100519q5c7244f8k1a0fae8b6374525c@mail.gmail.com> <15410706.post@talk.nabble.com> Message-ID: <57c63afe0802110603j172930fej2c900531d568576e@mail.gmail.com> On Feb 11, 2008 6:41 AM, Neil M. Young wrote: > > > aslak hellesoy wrote: > > > > On Feb 8, 2008 9:50 PM, Neil M. Young wrote: > >> > >> sorry if this is documented somewhere, but do stories support colored > >> output? > >> neither -c nor --color are working for me. > > > > It works for me. What's your environment? > > > > ubuntu 7.10, rails 2.0.2, rspec 1.1.3 > I get color output for specs but not for stories Not working for me either. http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/286 Thanks, David > -- > View this message in context: http://www.nabble.com/colored-output-for-stories--tp15363648p15410706.html > > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From edvard at majakari.net Mon Feb 11 09:21:23 2008 From: edvard at majakari.net (Edvard Majakari) Date: Mon, 11 Feb 2008 16:21:23 +0200 Subject: [rspec-users] How to mock an association In-Reply-To: <47B034E2.2050401@gmail.com> References: <47B034E2.2050401@gmail.com> Message-ID: On Feb 11, 2008 1:43 PM, Wes Shaddix wrote: > I've got a "group" model that has a user_id attribute and a > validates_existence_of :user and validates_presence_of :user_id > validations. What method(s) do I need to stub on the User mock to > intercept those validation calls? My goal is to isolate the Group model > from the User model. See http://www.ruby-forum.com/topic/138342 and http://tersesystems.com/post/9700067.jhtml Obvious 'rails mocking associations' seemed to work for me, unless I misunderstood the question. Of course, you could just stub 'valid?' for any AR object as well. -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From edvard at majakari.net Mon Feb 11 09:26:13 2008 From: edvard at majakari.net (Edvard Majakari) Date: Mon, 11 Feb 2008 16:26:13 +0200 Subject: [rspec-users] How to mock an association In-Reply-To: References: <47B034E2.2050401@gmail.com> Message-ID: > Obvious 'rails mocking associations' seemed to work for me, unless I ...make that '...Googling for ...'. Duh. -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From rspec-users at kero.tmfweb.nl Mon Feb 11 22:07:18 2008 From: rspec-users at kero.tmfweb.nl (rspec-users at kero.tmfweb.nl) Date: Tue, 12 Feb 2008 04:07:18 +0100 (CET) Subject: [rspec-users] Generated rspec video Message-ID: <20080212030718.739A57BBC@mint.qinip.net> Hi all! A sneak preview of what I've been doing with my patch that made it into rspec 1.1.3: http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi (2MB video) Remarks: - this is a (not-too-comfortable) test of my program itself; that's what causes the double-lines in some places - I can not use "-f p -c" since it outputs a step later than you'd expect! (that's how it can get the color right, I assume) I'm going to wrestle this a bit tonight. Stuff for off-list: - created with mencoder, I can play with mplayer. Reports on success or failure of other players welcome. - I do not have the timings of espeak and mencoder right, yet. If you know tools that can concatenate (malformed espeak) wav-files and images besides mencoder, I'd like to know. If you know how to let mencoder stick to the 25fps I tell it to, I'd like to know. (my mencoder line is echo'ed in the video) Experience with festival, anyone? I'm on linux, but I suppose that's obvious from the tools I used. Bye, Kero. From omen.king at gmail.com Mon Feb 11 22:09:51 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 11 Feb 2008 22:09:51 -0500 Subject: [rspec-users] Generated rspec video In-Reply-To: <20080212030718.739A57BBC@mint.qinip.net> References: <20080212030718.739A57BBC@mint.qinip.net> Message-ID: Load Failed Reason : Operation could not be completed. (WebKitErrorDomain error 204.) On Feb 11, 2008 10:07 PM, wrote: > Hi all! > > A sneak preview of what I've been doing with my patch that made it > into rspec 1.1.3: > http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi > (2MB video) > > Remarks: > - this is a (not-too-comfortable) test of my program itself; > that's what causes the double-lines in some places > - I can not use "-f p -c" since it outputs a step later than you'd > expect! (that's how it can get the color right, I assume) > I'm going to wrestle this a bit tonight. > > Stuff for off-list: > - created with mencoder, I can play with mplayer. > Reports on success or failure of other players welcome. > - I do not have the timings of espeak and mencoder right, yet. > If you know tools that can concatenate (malformed espeak) wav-files > and images besides mencoder, I'd like to know. If you know how to > let mencoder stick to the 25fps I tell it to, I'd like to know. > (my mencoder line is echo'ed in the video) > Experience with festival, anyone? > I'm on linux, but I suppose that's obvious from the tools I used. > > Bye, > Kero. > > > _______________________________________________ > 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/20080211/4da12943/attachment.html From rspec-users at kero.tmfweb.nl Mon Feb 11 23:30:56 2008 From: rspec-users at kero.tmfweb.nl (rspec-users at kero.tmfweb.nl) Date: Tue, 12 Feb 2008 05:30:56 +0100 (CET) Subject: [rspec-users] Generated rspec video Message-ID: <20080212043056.299EB7BE6@mint.qinip.net> In reply to "Andrew WC Brown" on Tue Feb 12 05:18:49 2008: > Load Failed > > Reason : Operation could not be completed. (WebKitErrorDomain error 204.) > > http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi > > (2MB video) No idea what makes webkit (or connection, or ...) fail for you. md5sum is correct for me, too. (then again, I fear the proxy here cached this download. The upload of my server at home is nice, but not 600kB/s). $ wget http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi --23:19:26-- http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi => `R-Spec Demo.avi' Connecting to 130.140.55.5:80... connected. Proxy request sent, awaiting response... 200 OK Length: 2,100,752 (2.0M) [video/avi] 100%[============================================>] 2,100,752 672.52K/s ETA 00:00 23:19:29 (670.15 KB/s) - `R-Spec Demo.avi' saved [2100752/2100752] From luislavena at gmail.com Mon Feb 11 23:38:23 2008 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 12 Feb 2008 02:38:23 -0200 Subject: [rspec-users] Generated rspec video In-Reply-To: <20080212030718.739A57BBC@mint.qinip.net> References: <20080212030718.739A57BBC@mint.qinip.net> Message-ID: <71166b3b0802112038p76df0140kc3599f487927fb5b@mail.gmail.com> On Feb 12, 2008 1:07 AM, wrote: > Hi all! > > A sneak preview of what I've been doing with my patch that made it > into rspec 1.1.3: > http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi > (2MB video) > > Stuff for off-list: > - created with mencoder, I can play with mplayer. > Reports on success or failure of other players welcome. weird codec combo... you should have used thedora or xvid at least :-P (cannot play or even recognize the .avi codec signature). Anyway, will look at it when switch to linux. -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From grail at goldweb.com.au Mon Feb 11 23:42:31 2008 From: grail at goldweb.com.au (Alex Satrapa) Date: Tue, 12 Feb 2008 15:42:31 +1100 Subject: [rspec-users] Generated rspec video In-Reply-To: <20080212030718.739A57BBC@mint.qinip.net> References: <20080212030718.739A57BBC@mint.qinip.net> Message-ID: <241C9C4F-9110-4FD2-82DB-20AA8334E790@goldweb.com.au> On 12/02/2008, at 14:07 , rspec-users at kero.tmfweb.nl wrote: > A sneak preview of what I've been doing with my patch that made it > into rspec 1.1.3: > http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi What format is that video? I've got DivX and various others loaded, but none of them want to work on that video. Alex From omen.king at gmail.com Mon Feb 11 23:45:34 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 11 Feb 2008 23:45:34 -0500 Subject: [rspec-users] Generated rspec video In-Reply-To: <241C9C4F-9110-4FD2-82DB-20AA8334E790@goldweb.com.au> References: <20080212030718.739A57BBC@mint.qinip.net> <241C9C4F-9110-4FD2-82DB-20AA8334E790@goldweb.com.au> Message-ID: If this is a a video mostly in a text editor like TextMate I'd recommend converting it to Apple Animation. On Feb 11, 2008 11:42 PM, Alex Satrapa wrote: > On 12/02/2008, at 14:07 , rspec-users at kero.tmfweb.nl wrote: > > > A sneak preview of what I've been doing with my patch that made it > > into rspec 1.1.3: > > http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi > > What format is that video? I've got DivX and various others loaded, > but none of them want to work on that video. > > Alex > > > _______________________________________________ > 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/20080211/9530da8e/attachment.html From luislavena at gmail.com Mon Feb 11 23:49:14 2008 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 12 Feb 2008 02:49:14 -0200 Subject: [rspec-users] Generated rspec video In-Reply-To: References: <20080212030718.739A57BBC@mint.qinip.net> <241C9C4F-9110-4FD2-82DB-20AA8334E790@goldweb.com.au> Message-ID: <71166b3b0802112049t175176d9yc51d8a2a1c75c813@mail.gmail.com> On Feb 12, 2008 2:45 AM, Andrew WC Brown wrote: > If this is a a video mostly in a text editor like TextMate I'd recommend > converting it to Apple Animation. I've tried several times to get Quicktime output good (ala: highly compressed, small size) files with it and failed... It seems if the source isn't captured with it, the compression is the worse you could get (200MB files for 5 minutes). -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From rspec-users at kero.tmfweb.nl Tue Feb 12 00:32:08 2008 From: rspec-users at kero.tmfweb.nl (rspec-users at kero.tmfweb.nl) Date: Tue, 12 Feb 2008 06:32:08 +0100 (CET) Subject: [rspec-users] Generated rspec video Message-ID: <20080212053208.05BEE7D22@mint.qinip.net> > > Stuff for off-list: > > - created with mencoder, I can play with mplayer. > > Reports on success or failure of other players welcome. > > weird codec combo... you should have used thedora or xvid at least :-P > (cannot play or even recognize the .avi codec signature). > > Anyway, will look at it when switch to linux. Hmf, mencoder will not produce xvid or theora just like that. Will try more tomorrow. I installed xine to verify playback; it plays video on the url I posted but does not playback the audio :( Bye, Kero. PS: a slightly hacked rspec gives very nice results with "-f p -c" now :) Fails rspec tests themselves, of course. For now. From loop at superinfinite.com Tue Feb 12 04:04:01 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Tue, 12 Feb 2008 10:04:01 +0100 Subject: [rspec-users] Generated rspec video In-Reply-To: <20080212053208.05BEE7D22@mint.qinip.net> References: <20080212053208.05BEE7D22@mint.qinip.net> Message-ID: On 12-feb-2008, at 6:32, rspec-users at kero.tmfweb.nl wrote: >>> Stuff for off-list: >>> - created with mencoder, I can play with mplayer. >>> Reports on success or failure of other players welcome. >> >> weird codec combo... you should have used thedora or xvid at >> least :-P >> (cannot play or even recognize the .avi codec signature). >> >> Anyway, will look at it when switch to linux. > > Hmf, mencoder will not produce xvid or theora just like that. > Will try more tomorrow. > I installed xine to verify playback; it plays video on the url I > posted > but does not playback the audio :( Perian (http://perian.org/) does playback the video when using QuickTime. regards, bartz From robertdw at twasink.net Tue Feb 12 10:05:37 2008 From: robertdw at twasink.net (Robert Watkins) Date: Wed, 13 Feb 2008 01:05:37 +1000 Subject: [rspec-users] Using RSpec to Story Test Java code Message-ID: Hi, folks. I recently (ie on the weekend) came across RSpec, and knew it could be the answer to a problem I was looking into - story testing Java code. I've written up what I had to do to get it working at http://twasink.net/blog/archives/2008/02/rspec_jruby_and.html. Basically, I took the Accounts test from the RSpec home page and used it as the basis for testing a Java Accounts class. The resulting article is from the point of view of someone with virtually zero Ruby experience, and no RSpec experience at all. This isn't _just_ a blatant troll for hits to my blog. ;) I'm also seriously keen on feedback from anyone else who is trying to do this sort of thing, or even just from people trying to use the Story Test format _without_ testing Rails applications. 2 days isn't enough time for me to have come across all the good information out there (though I'm going to keep looking). I also hope to take part in this community some more - you guys have built a fantastic tool, and if you don't mind a Java guy hanging out here, I'd love to see how much I can get out of it. :) -- "Software is too expensive to build cheaply" Robert Watkins http://twasink.net/ robertdw at twasink.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080213/7c05adc7/attachment.html From ola.bini at gmail.com Tue Feb 12 10:16:12 2008 From: ola.bini at gmail.com (Ola Bini) Date: Tue, 12 Feb 2008 15:16:12 +0000 Subject: [rspec-users] Using RSpec to Story Test Java code In-Reply-To: References: Message-ID: <47B1B83C.3090606@gmail.com> Robert Watkins wrote: > Hi, folks. > > I recently (ie on the weekend) came across RSpec, and knew it could be > the answer to a problem I was looking into - story testing Java code. > I've written up what I had to do to get it working at > http://twasink.net/blog/archives/2008/02/rspec_jruby_and.html. > Basically, I took the Accounts test from the RSpec home page and used > it as the basis for testing a Java Accounts class. The resulting > article is from the point of view of someone with virtually zero Ruby > experience, and no RSpec experience at all. > > This isn't _just_ a blatant troll for hits to my blog. ;) I'm also > seriously keen on feedback from anyone else who is trying to do this > sort of thing, or even just from people trying to use the Story Test > format _without_ testing Rails applications. 2 days isn't enough time > for me to have come across all the good information out there (though > I'm going to keep looking). > > I also hope to take part in this community some more - you guys have > built a fantastic tool, and if you don't mind a Java guy hanging out > here, I'd love to see how much I can get out of it. :) > JtestR 0.2 will contain support for story testing of Java. Cheers -- Ola Bini (http://ola-bini.blogspot.com) JRuby Core Developer Developer, ThoughtWorks Studios (http://studios.thoughtworks.com) Practical JRuby on Rails (http://apress.com/book/view/9781590598818) "Yields falsehood when quined" yields falsehood when quined. From address4spams at 21croissants.com Tue Feb 12 12:11:57 2008 From: address4spams at 21croissants.com (21croissants) Date: Tue, 12 Feb 2008 09:11:57 -0800 (PST) Subject: [rspec-users] RSpec 1.1.3 + ZenTest 3.9.1 + Rails 1.2.6 do NOT ignore folders ^vendor/* In-Reply-To: References: Message-ID: <15436545.post@talk.nabble.com> I have found the solution to my problem: I had to patch rspec_on_rails. See patch attached http://www.nabble.com/file/p15436545/rspec_on_rails_autotest_hook_exceptions_so_autotest_ignore_rails_folders.diff rspec_on_rails_autotest_hook_exceptions_so_autotest_ignore_rails_folders.diff Any question, reply to this email or contact me at http://21croissants.com/contact JM 21croissants wrote: > > Hi, > > I just updated to the latest RSpec 1.1.3 + ZenTest 3.9.1. > I also have rspec 1.1.3 installed as a gem > > When starting autotest with -v option, there is a lot of noise because > autotest does not ignore the vendor folder, the migrations, etc ...: > > Dunno! vendor/plugins/acts_as_solr/solr/lib/jetty-util-6.1.3.jar > Dunno! > vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb > Dunno! vendor/rails/actionpack/lib/action_view.rb > Dunno! vendor/plugins/active_scaffold/test/extensions/array.rb > Dunno! > vendor/plugins/active_scaffold/lib/extensions/nil_id_in_url_params.rb > Dunno! config/amazon_s3.yml > Dunno! vendor/rails/actionpack/lib/action_controller/base.rb > Dunno! vendor/plugins/acts_as_solr/lib/solr/response/base.rb > Dunno! vendor/plugins/rake_tasks/init.rb > Dunno! public/images/linqia/icon_groupmember.gif > Dunno! vendor/plugins/acts_as_solr/test/db/test.db > Dunno! vendor/rails/actionpack/lib/action_controller/mime_type.rb > Dunno! public/stylesheets/themes/default/close.gif > Dunno! db/migrate/021_create_community_bookmarks.rb > Dunno! vendor/plugins/cache_fu/test/local_cache_test.rb > Dunno! public/images/icons/flags/bv.gif > > in the output. Am I the only one? > > After reading the code in rspec_on_rails/lib/autotest/rails_rspec.rb > > Autotest.add_hook :initialize do |at| > %w{^config/ ^coverage/ ^db/ ^doc/ ^log/ ^public/ ^script > ^vendor/rails ^vendor/plugins previous_failures.txt}.each do > |exception| > at.add_exception(exception) > end > > I think the noise is not normal. Maybe I should write some specs to > verify this code is working ;-) > > As David C. explained in his blog, I also have a .autotest in my HOME: > Autotest.add_hook :initialize do |at| > %w{.svn .hg .git .rhtml .png .txt .sh .project .rjs .rake .jpg .xml > .xlst }.each {|exception|at.add_exception(exception)} > end > > Jean-Michel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/RSpec-1.1.3-%2B-ZenTest-3.9.1-%2B-Rails-1.2.6-do-NOT-ignore-folders-%5Evendor-*-tp15309706p15436545.html Sent from the rspec-users mailing list archive at Nabble.com. From rick.denatale at gmail.com Tue Feb 12 15:17:39 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 12 Feb 2008 15:17:39 -0500 Subject: [rspec-users] attachment_fu and story runner, any updates In-Reply-To: References: <57c63afe0801212036j242a68ado6ea7f4f1fcb75ee1@mail.gmail.com> Message-ID: I've just submitted a rails patch http://dev.rubyonrails.org/ticket/11091 This patches actionpack/lib/action_controller/integration.rb so that post and put requests automatically get turned into multipart form submission requests if they have a parameter or parameters which are instances of TestUploadedFile. This allows file uploading to be tested in integration controllers or RSpec stories. Please have a look if interested and verify the patch, looking for +1s on the Rails Trac -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From ben at benmabey.com Tue Feb 12 15:25:22 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 12 Feb 2008 13:25:22 -0700 Subject: [rspec-users] attachment_fu and story runner, any updates In-Reply-To: References: <57c63afe0801212036j242a68ado6ea7f4f1fcb75ee1@mail.gmail.com> Message-ID: <47B200B2.8020509@benmabey.com> Rick DeNatale wrote: > I've just submitted a rails patch > http://dev.rubyonrails.org/ticket/11091 > > This patches actionpack/lib/action_controller/integration.rb so that > post and put requests automatically get turned into multipart form > submission requests if they have a parameter or parameters which are > instances of TestUploadedFile. > > This allows file uploading to be tested in integration controllers or > RSpec stories. > > Please have a look if interested and verify the patch, looking for +1s > on the Rails Trac > Thanks Rick! I'll check it out when I get a chance. BTW, would you mind posting some example code of how you are using the story runner in testing a multi-part form? Thanks, Ben From rick.denatale at gmail.com Tue Feb 12 16:11:56 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 12 Feb 2008 16:11:56 -0500 Subject: [rspec-users] attachment_fu and story runner, any updates In-Reply-To: <47B200B2.8020509@benmabey.com> References: <57c63afe0801212036j242a68ado6ea7f4f1fcb75ee1@mail.gmail.com> <47B200B2.8020509@benmabey.com> Message-ID: On 2/12/08, Ben Mabey wrote: > I'll check it out when I get a chance. BTW, would you mind posting some > example code of how you are using the story runner in testing a > multi-part form? > require File.expand_path(File.dirname(__FILE__) + "/helper.rb") Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/' def add_the_rebelz @image_filename = "therebelz.jpg" upload_data = fixture_file_upload(@image_filename, "image/jpg") post_via_redirect("/artists", {:artist => {:name => "The Rebelz"}, :image => {:uploaded_data => upload_data}}) @artist = Artist.find_by_name("The Rebelz") end Story "Sign up an Artist", %{ As an administrator I want to add the Artist to the system So that the Artist can be accessed }, :type => RailsStory do Scenario "New Artist" do Given "The Artist is not in the system" do pm = Artist.find_by_name("The Rebelz") pm.destroy if pm end When "I add the Artist" do add_the_rebelz end Then "The Artist page should show the Artist's name" do response.should have_text(/The Rebelz/) end And "The page should show the artist's picture or logo" do response.should have_tag("span.artist_logo") do with_tag("img[src*=?]", @image_filename) end end ... -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From wshaddix at gmail.com Tue Feb 12 22:12:50 2008 From: wshaddix at gmail.com (Wes Shaddix) Date: Tue, 12 Feb 2008 22:12:50 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? Message-ID: <47B26032.90800@gmail.com> I have a GroupController class that inherits from a SecuredController which have a before filter (before_filter :login_required). This is using the restul authentication system. I want to mock out the login_required method so that my GroupController actions don't get redirected to /sessions/new but I cant figure it out. Here is what I have so far that doesn't work. Any help would be most appreciated. require File.dirname(__FILE__) + '/../spec_helper' describe GroupsController do before(:each) do # mock and stub the Group model methods @group = mock_model(Group) Group.stub!(:search_with_paginate).and_return(@group) # since this is a secured controller, we have to mock the security system too @current_user = mock_model(User, :id => 1) self.stub!(:login_required).and_return(:false) self.stub!(:current_user).and_return(@current_user) end def do_get get :index end it "should be successful" do assigns[:page] = 1 assigns[:search] = "" do_get puts response.headers response.should be_success end end The error I get is NoMethodError in 'GroupsController should be successful' You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[]= From jarkko at jlaine.net Wed Feb 13 06:49:52 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 13 Feb 2008 13:49:52 +0200 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <47B26032.90800@gmail.com> References: <47B26032.90800@gmail.com> Message-ID: <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> On 13.2.2008, at 5.12, Wes Shaddix wrote: > I have a GroupController class that inherits from a SecuredController > which have a before filter (before_filter :login_required). This is > using the restul authentication system. I want to mock out the > login_required method so that my GroupController actions don't get > redirected to /sessions/new but I cant figure it out. Here is what I > have so far that doesn't work. Any help would be most appreciated. > > require File.dirname(__FILE__) + '/../spec_helper' > > describe GroupsController do > > before(:each) do > > # mock and stub the Group model methods > @group = mock_model(Group) > Group.stub!(:search_with_paginate).and_return(@group) > > > > # since this is a secured controller, we have to mock the > security system too > > @current_user = mock_model(User, :id => 1) > > self.stub!(:login_required).and_return(:false) > > self.stub!(:current_user).and_return(@current_user) > > end > > > > def do_get > > get :index > > end > > > > it "should be successful" do > > assigns[:page] = 1 > > assigns[:search] = "" > > do_get > > puts response.headers > > response.should be_success > > end > > end > > The error I get is > NoMethodError in 'GroupsController should be successful' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.[]= What do you expect the assigns[:... lines to do? If you mean to use them as url parameters, you have to pass them to the get method (through do_get in this case). assigns is a hash that contains all the instance variables set in the controllers. So if you say "@foo = "bar"" in your controller action, you can spec it in a controller view like this: assigns[:foo].should == "bar". However, afaik you're not supposed to write into that hash in your controller specs. On the other hand, in the view specs you *do* need a way to set instance variables available in the views, and there you can use the assigns for that. So in a view spec corresponding to my previous example, you would want the instance variable @foo to be there so you would say "assigns[:foo] = 'bar'" in your before block. That said, I'm not a fan of stubbing the login_required method. Instead, I have created a login_as method in my spec_helper that I use whenever I want to spec something to happen when a logged in user does something (note that I also use the acl_system2 plugin for roles): def login_as(role) @role = mock_model(Role, :title => role.to_s) @current_user = mock_user({:roles => [@role]}) [:admin, :organizer, :client, :teacher].each do |r| @current_user.stub!(:has_role?).with(r).and_return(role == r ? true : false) end if defined?(controller) controller.send :current_user=, @current_user else template.stub!(:logged_in?).and_return(true) template.stub!(:current_user).and_return(@current_user) end end end This is a bit simplified but it works for me pretty well with restful_authentication. Normally you would say something like "login_as(:admin)" in a before block in controller and view specs. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080213/8470c793/attachment.bin From cremes.devlist at mac.com Wed Feb 13 08:48:38 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Wed, 13 Feb 2008 07:48:38 -0600 Subject: [rspec-users] need to learn by example Message-ID: <3E0B5C74-20EC-4B63-831F-5BA4647B8AC5@mac.com> I'm starting a new project which I would like to use as a learning opportunity for BDD. I've searched through the archives of this list for past pointers on web sites and books to peruse but I haven't found very many suggestions on good projects "in the wild" which put BDD on display. I'm hoping this thread can change that minor oversight. Please post your suggestions for ruby projects (or projects in other languages) that are good examples of BDD in action. I learn best by example; this thread is for all the other lurkers who do too. cr From colin at logaan.net Wed Feb 13 09:17:14 2008 From: colin at logaan.net (Colin Campbell-McPherson) Date: Wed, 13 Feb 2008 23:17:14 +0900 Subject: [rspec-users] need to learn by example In-Reply-To: <3E0B5C74-20EC-4B63-831F-5BA4647B8AC5@mac.com> References: <3E0B5C74-20EC-4B63-831F-5BA4647B8AC5@mac.com> Message-ID: <9AE6AF5D-2F9F-4855-8DE9-FBA4FF09623A@logaan.net> I've just started a small rails project to test out BDD. It's a code golf application. Code golf is, for my money, the geekiest game out there. You set a challenge and users submit snippets of code. The winner is the person who submits the smallest piece of code that meets the requirements of the challenge. At the moment I've got it running with rspec and autotest, also using the haml plugin. Checkout http://svn.nightlite.org/applications/cody/trunk/ if you like. I'm open to including others in the development. On 13/02/2008, at 10:48 PM, Chuck Remes wrote: > I'm starting a new project which I would like to use as a learning > opportunity for BDD. I've searched through the archives of this list > for past pointers on web sites and books to peruse but I haven't found > very many suggestions on good projects "in the wild" which put BDD on > display. > > I'm hoping this thread can change that minor oversight. > > Please post your suggestions for ruby projects (or projects in other > languages) that are good examples of BDD in action. I learn best by > example; this thread is for all the other lurkers who do too. > > cr > _______________________________________________ > 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/20080213/829ee261/attachment.html From toastkid.williams at gmail.com Wed Feb 13 12:26:16 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 13 Feb 2008 09:26:16 -0800 (PST) Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? Message-ID: <15460582.post@talk.nabble.com> I'm testing a controller action that redirects to a different action/view, sending through some params. In my test, i'm only specifying the controller and action that it should redirect to, but the additional params are making it fail! Here's my test: it "should redirect to batch_saved after completing batch_save" do post 'batch_save', @params response.should redirect_to(:controller => 'admin/users', :action => 'batch_saved') end and here's the failure report: 'Admin::UserController When logged in as an admin level user should redirect to batch_saved after batch_save' FAILED expected redirect to {:controller=>"admin/users", :action=>"batch_saved"}, got redirect to "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup" Now, i would expect that since i'm just specifying a controller and action, and we redirect to them, that the test would pass. But the params are breaking it (I know this because i changed the controller action to not send params through at all and the test passed). How do i do the test so that it doesn't care about the params? -- View this message in context: http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html Sent from the rspec-users mailing list archive at Nabble.com. From lists at ruby-forum.com Wed Feb 13 12:46:18 2008 From: lists at ruby-forum.com (Brad Carson) Date: Wed, 13 Feb 2008 18:46:18 +0100 Subject: [rspec-users] Example controller spec no worky? Message-ID: I'm trying to spec a dead simple "show non-existent record should render 404" case, but it seems the RecordNotFound exception is making it impossible for some reason. #controller def show @event = Event.find(params[:id]) end #spec - pretty much straight from the rspec site before do Event.stub!(:find) get :show, :id => 'broken' end # passes it "should not assign an event" do assigns[:event].should == nil end # fails - expected 404 but got events/show it "should render 404" do response.should render_template("#{RAILS_ROOT}/public/404.html") response.response_code.should == 404 end #end spec Because I'm stubbing find does that mean the RecordNotFound exception doesn't happen and thus the 404 doesn't render? I tried stubbing and using should_raise, and_raise, whatever the heck it is, but I just don't get it, nothing seems to work. It behaves as expected when browser tested! :O I'm going to spontaneously combust! [RSpec 1.1.2, Rails 2.0.2, ZenTest 3.8.0] -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Feb 13 13:39:13 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Feb 2008 13:39:13 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: <15460582.post@talk.nabble.com> References: <15460582.post@talk.nabble.com> Message-ID: <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> On Feb 13, 2008 12:26 PM, Max Williams wrote: > > I'm testing a controller action that redirects to a different action/view, > sending through some params. In my test, i'm only specifying the controller > and action that it should redirect to, but the additional params are making > it fail! Here's my test: > > it "should redirect to batch_saved after completing batch_save" do > post 'batch_save', @params > response.should redirect_to(:controller => 'admin/users', :action => > 'batch_saved') > end > > and here's the failure report: > > 'Admin::UserController When logged in as an admin level user should redirect > to batch_saved after batch_save' FAILED > expected redirect to {:controller=>"admin/users", :action=>"batch_saved"}, > got redirect to > "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup" > > Now, i would expect that since i'm just specifying a controller and action, > and we redirect to them, that the test would pass. But the params are > breaking it (I know this because i changed the controller action to not send > params through at all and the test passed). How do i do the test so that it > doesn't care about the params? When you use a hash it checks the whole hash, so this is the expected behaviour. You can either used a named route (if you've got one available) or a String literal: response.should redirect_to(admin_users_batch_saved) response.should redirect_to('/admin/users/batch_saved') Based on Jay Field's latest advice (http://blog.jayfields.com/2008/02/testing-expect-literals.html) you may want to consider the literal. HTH, David > > > -- > View this message in context: http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Wed Feb 13 13:41:36 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 13 Feb 2008 10:41:36 -0800 Subject: [rspec-users] Example controller spec no worky? In-Reply-To: References: Message-ID: <810a540e0802131041n79893f0bw93b6c4a1d36364a6@mail.gmail.com> Try Event.stub!(:find).and_raise(RecordNotFound) On 2/13/08, Brad Carson wrote: > I'm trying to spec a dead simple "show non-existent record should render > 404" case, but it seems the RecordNotFound exception is making it > impossible for some reason. > > #controller > def show > @event = Event.find(params[:id]) > end > > #spec - pretty much straight from the rspec site > before do > Event.stub!(:find) > get :show, :id => 'broken' > end > > # passes > it "should not assign an event" do > assigns[:event].should == nil > end > > # fails - expected 404 but got events/show > it "should render 404" do > response.should render_template("#{RAILS_ROOT}/public/404.html") > response.response_code.should == 404 > end > #end spec > > Because I'm stubbing find does that mean the RecordNotFound exception > doesn't happen and thus the 404 doesn't render? I tried stubbing and > using should_raise, and_raise, whatever the heck it is, but I just don't > get it, nothing seems to work. It behaves as expected when browser > tested! :O > > I'm going to spontaneously combust! > > [RSpec 1.1.2, Rails 2.0.2, ZenTest 3.8.0] > -- > 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 Wed Feb 13 14:09:47 2008 From: lists at ruby-forum.com (Brad Carson) Date: Wed, 13 Feb 2008 20:09:47 +0100 Subject: [rspec-users] Example controller spec no worky? In-Reply-To: <810a540e0802131041n79893f0bw93b6c4a1d36364a6@mail.gmail.com> References: <810a540e0802131041n79893f0bw93b6c4a1d36364a6@mail.gmail.com> Message-ID: <4d11f43143df77e18318c9a8fbac8be1@ruby-forum.com> Pat Maddox wrote: > Try > > Event.stub!(:find).and_raise(RecordNotFound) To my credit, I did try that (though ActiveRecord::RecordNotFound, of course) but then I get: EventsController attempt to show non-existing event - should render 404 (ERROR - 2) - should not assign an event (ERROR - 3) ActiveRecord::RecordNotFound in 'EventsController attempt to show non-existing event should render 404' ActiveRecord::RecordNotFound Mind-boggling. -- Posted via http://www.ruby-forum.com/. From jarkko at jlaine.net Wed Feb 13 14:58:02 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 13 Feb 2008 21:58:02 +0200 Subject: [rspec-users] Example controller spec no worky? In-Reply-To: <4d11f43143df77e18318c9a8fbac8be1@ruby-forum.com> References: <810a540e0802131041n79893f0bw93b6c4a1d36364a6@mail.gmail.com> <4d11f43143df77e18318c9a8fbac8be1@ruby-forum.com> Message-ID: <3DCAD38F-7EF4-459F-A1D8-9E463B69BDC4@jlaine.net> On 13.2.2008, at 21.09, Brad Carson wrote: > Pat Maddox wrote: >> Try >> >> Event.stub!(:find).and_raise(RecordNotFound) > > To my credit, I did try that (though ActiveRecord::RecordNotFound, of > course) but then I get: > > EventsController attempt to show non-existing event > - should render 404 (ERROR - 2) > - should not assign an event (ERROR - 3) > > ActiveRecord::RecordNotFound in 'EventsController attempt to show > non-existing event should render 404' > ActiveRecord::RecordNotFound > > Mind-boggling. The exception is never rescued. You'd have to catch the exception yourself, I think, and render the 404 page. I might be talking through my ass but I think the built in rescue of AR::RNF only works in production. //jarkko > > -- > 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 Wed Feb 13 15:22:33 2008 From: lists at ruby-forum.com (Brad Carson) Date: Wed, 13 Feb 2008 21:22:33 +0100 Subject: [rspec-users] Example controller spec no worky? In-Reply-To: <3DCAD38F-7EF4-459F-A1D8-9E463B69BDC4@jlaine.net> References: <810a540e0802131041n79893f0bw93b6c4a1d36364a6@mail.gmail.com> <4d11f43143df77e18318c9a8fbac8be1@ruby-forum.com> <3DCAD38F-7EF4-459F-A1D8-9E463B69BDC4@jlaine.net> Message-ID: <6afa0cc3b7776c036f29e278a6299689@ruby-forum.com> Jarkko Laine wrote: > On 13.2.2008, at 21.09, Brad Carson wrote: > >> - should not assign an event (ERROR - 3) >> >> ActiveRecord::RecordNotFound in 'EventsController attempt to show >> non-existing event should render 404' >> ActiveRecord::RecordNotFound >> >> Mind-boggling. > > The exception is never rescued. You'd have to catch the exception > yourself, I think, and render the 404 page. I might be talking through > my ass but I think the built in rescue of AR::RNF only works in > production. > > //jarkko I was led to believe Rails automatically handled RecordNotFounds with a 404, meaning I didn't have to catch them myself. I made sure requests weren't considered local in the test environment to trigger the 404 page instead of the debug info. I tried putting a rescue_action_in_public in the application controller to handle the RecordNotFound and do the 404 render, just in case, but the spec won't pass unless I rescue the exception inside the show method, which doesn't seem right or necessary. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 13 15:53:08 2008 From: lists at ruby-forum.com (Brad Carson) Date: Wed, 13 Feb 2008 21:53:08 +0100 Subject: [rspec-users] Example controller spec no worky? In-Reply-To: <6afa0cc3b7776c036f29e278a6299689@ruby-forum.com> References: <810a540e0802131041n79893f0bw93b6c4a1d36364a6@mail.gmail.com> <4d11f43143df77e18318c9a8fbac8be1@ruby-forum.com> <3DCAD38F-7EF4-459F-A1D8-9E463B69BDC4@jlaine.net> <6afa0cc3b7776c036f29e278a6299689@ruby-forum.com> Message-ID: <7d9eb4754e6eb19ae01f86b73dbd6d9a@ruby-forum.com> > I was led to believe Rails automatically handled RecordNotFounds with a > 404, meaning I didn't have to catch them myself. > > I made sure requests weren't considered local in the test environment to > trigger the 404 page instead of the debug info. I tried putting a > rescue_action_in_public in the application controller to handle the > RecordNotFound and do the 404 render, just in case, but the spec won't > pass unless I rescue the exception inside the show method, which doesn't > seem right or necessary. Aha! Had to use: controller.use_rails_error_handling! Here's the complete spec: http://pastie.caboo.se/151743 As per the pasite, requests have to be non-local. Thank you to everyone who pitched in to help! -- Posted via http://www.ruby-forum.com/. From toastkid.williams at gmail.com Wed Feb 13 06:52:21 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 13 Feb 2008 03:52:21 -0800 (PST) Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <47B26032.90800@gmail.com> References: <47B26032.90800@gmail.com> Message-ID: <15456464.post@talk.nabble.com> I'm having a similar problem - my application controller has the UserSystem module included, and that's where the login_required method lives. In a spec for another controller, which has before_filter :login_required, i'm trying to stub the login_required method to just return true, but i think my problem is that i'm calling it on the class instead of an instance of ApplicationController: ApplicationController.stub!("login_required").and_return(true) Looking at my log file, the :login_required filter is still failing, so it looks like my stub has missed its target. How do i call it on the actually controller? I've seen in another thread that "I can get the controller from my specs" but i don't know exactly what's meant by that. -- View this message in context: http://www.nabble.com/How-do-I-mock-out-the-before-%3Alogin_required-method--tp15448454p15456464.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Feb 13 17:08:36 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Feb 2008 17:08:36 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <15456464.post@talk.nabble.com> References: <47B26032.90800@gmail.com> <15456464.post@talk.nabble.com> Message-ID: <57c63afe0802131408q5f5b2463w8eba64243b5863ab@mail.gmail.com> On Feb 13, 2008 6:52 AM, Max Williams wrote: > > I'm having a similar problem - my application controller has the UserSystem > module included, and that's where the login_required method lives. In a > spec for another controller, which has before_filter :login_required, i'm > trying to stub the login_required method to just return true, but i think my > problem is that i'm calling it on the class instead of an instance of > ApplicationController: > > ApplicationController.stub!("login_required").and_return(true) > > Looking at my log file, the :login_required filter is still failing, so it > looks like my stub has missed its target. How do i call it on the actually > controller? I've seen in another thread that "I can get the controller from > my specs" but i don't know exactly what's meant by that. There is a method named controller that you can call to access the controller from within the spec: controller.stub!(:whatever ....) HTH, David > -- > View this message in context: http://www.nabble.com/How-do-I-mock-out-the-before-%3Alogin_required-method--tp15448454p15456464.html > Sent from the rspec-users mailing list archive at Nabble.com. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wshaddix at gmail.com Wed Feb 13 18:03:51 2008 From: wshaddix at gmail.com (Wes Shaddix) Date: Wed, 13 Feb 2008 18:03:51 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> References: <47B26032.90800@gmail.com> <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> Message-ID: <47B37757.10607@gmail.com> Jarkko Laine wrote: > > On 13.2.2008, at 5.12, Wes Shaddix wrote: > >> I have a GroupController class that inherits from a SecuredController >> which have a before filter (before_filter :login_required). This is >> using the restul authentication system. I want to mock out the >> login_required method so that my GroupController actions don't get >> redirected to /sessions/new but I cant figure it out. Here is what I >> have so far that doesn't work. Any help would be most appreciated. >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe GroupsController do >> >> before(:each) do >> >> # mock and stub the Group model methods >> @group = mock_model(Group) >> Group.stub!(:search_with_paginate).and_return(@group) >> >> >> >> # since this is a secured controller, we have to mock the security >> system too >> >> @current_user = mock_model(User, :id => 1) >> >> self.stub!(:login_required).and_return(:false) >> >> self.stub!(:current_user).and_return(@current_user) >> >> end >> >> >> >> def do_get >> >> get :index >> >> end >> >> >> >> it "should be successful" do >> >> assigns[:page] = 1 >> >> assigns[:search] = "" >> >> do_get >> >> puts response.headers >> >> response.should be_success >> >> end >> >> end >> >> The error I get is >> NoMethodError in 'GroupsController should be successful' >> You have a nil object when you didn't expect it! >> You might have expected an instance of ActiveRecord::Base. >> The error occurred while evaluating nil.[]= > > What do you expect the assigns[:... lines to do? If you mean to use > them as url parameters, you have to pass them to the get method > (through do_get in this case). assigns is a hash that contains all the > instance variables set in the controllers. So if you say "@foo = > "bar"" in your controller action, you can spec it in a controller view > like this: assigns[:foo].should == "bar". However, afaik you're not > supposed to write into that hash in your controller specs. On the > other hand, in the view specs you *do* need a way to set instance > variables available in the views, and there you can use the assigns > for that. So in a view spec corresponding to my previous example, you > would want the instance variable @foo to be there so you would say > "assigns[:foo] = 'bar'" in your before block. > > That said, I'm not a fan of stubbing the login_required method. > Instead, I have created a login_as method in my spec_helper that I use > whenever I want to spec something to happen when a logged in user does > something (note that I also use the acl_system2 plugin for roles): > > def login_as(role) > @role = mock_model(Role, :title => role.to_s) > @current_user = mock_user({:roles => [@role]}) > > [:admin, :organizer, :client, :teacher].each do |r| > @current_user.stub!(:has_role?).with(r).and_return(role == r ? > true : false) > end > > if defined?(controller) > controller.send :current_user=, @current_user > else > template.stub!(:logged_in?).and_return(true) > template.stub!(:current_user).and_return(@current_user) > end > end > end > > This is a bit simplified but it works for me pretty well with > restful_authentication. Normally you would say something like > "login_as(:admin)" in a before block in controller and view specs. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users So, if I update my code to the following, I still get an exception, although it is a different one. I really wish I understood how to determine the actual call chain that is going on ... what object is nil in this case (see error message below the code)? require File.dirname(__FILE__) + '/../spec_helper' describe GroupsController do before(:each) do # mock and stub the Group model methods @group = mock_model(Group) Group.stub!(:search_with_paginate).and_return(@group) # since this is a secured controller, we have to mock the security system too @current_user = mock_model(User, :id => 1) controller.stub!(:login_required).and_return(:true) controller.stub!(:current_user).and_return(@current_user) end def do_get get :index end it "should be successful" do do_get puts response.headers response.should be_success end end Exception : RuntimeError in 'GroupsController should be successful' Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id From dchelimsky at gmail.com Wed Feb 13 18:02:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Feb 2008 18:02:52 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <47B37757.10607@gmail.com> References: <47B26032.90800@gmail.com> <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> <47B37757.10607@gmail.com> Message-ID: <57c63afe0802131502h2321198s9908e0c406772fac@mail.gmail.com> On Feb 13, 2008 6:03 PM, Wes Shaddix wrote: > > Jarkko Laine wrote: > > > > On 13.2.2008, at 5.12, Wes Shaddix wrote: > > > >> I have a GroupController class that inherits from a SecuredController > >> which have a before filter (before_filter :login_required). This is > >> using the restul authentication system. I want to mock out the > >> login_required method so that my GroupController actions don't get > >> redirected to /sessions/new but I cant figure it out. Here is what I > >> have so far that doesn't work. Any help would be most appreciated. > >> > >> require File.dirname(__FILE__) + '/../spec_helper' > >> > >> describe GroupsController do > >> > >> before(:each) do > >> > >> # mock and stub the Group model methods > >> @group = mock_model(Group) > >> Group.stub!(:search_with_paginate).and_return(@group) > >> > >> > >> > >> # since this is a secured controller, we have to mock the security > >> system too > >> > >> @current_user = mock_model(User, :id => 1) > >> > >> self.stub!(:login_required).and_return(:false) > >> > >> self.stub!(:current_user).and_return(@current_user) > >> > >> end > >> > >> > >> > >> def do_get > >> > >> get :index > >> > >> end > >> > >> > >> > >> it "should be successful" do > >> > >> assigns[:page] = 1 > >> > >> assigns[:search] = "" > >> > >> do_get > >> > >> puts response.headers > >> > >> response.should be_success > >> > >> end > >> > >> end > >> > >> The error I get is > >> NoMethodError in 'GroupsController should be successful' > >> You have a nil object when you didn't expect it! > >> You might have expected an instance of ActiveRecord::Base. > >> The error occurred while evaluating nil.[]= > > > > What do you expect the assigns[:... lines to do? If you mean to use > > them as url parameters, you have to pass them to the get method > > (through do_get in this case). assigns is a hash that contains all the > > instance variables set in the controllers. So if you say "@foo = > > "bar"" in your controller action, you can spec it in a controller view > > like this: assigns[:foo].should == "bar". However, afaik you're not > > supposed to write into that hash in your controller specs. On the > > other hand, in the view specs you *do* need a way to set instance > > variables available in the views, and there you can use the assigns > > for that. So in a view spec corresponding to my previous example, you > > would want the instance variable @foo to be there so you would say > > "assigns[:foo] = 'bar'" in your before block. > > > > That said, I'm not a fan of stubbing the login_required method. > > Instead, I have created a login_as method in my spec_helper that I use > > whenever I want to spec something to happen when a logged in user does > > something (note that I also use the acl_system2 plugin for roles): > > > > def login_as(role) > > @role = mock_model(Role, :title => role.to_s) > > @current_user = mock_user({:roles => [@role]}) > > > > [:admin, :organizer, :client, :teacher].each do |r| > > @current_user.stub!(:has_role?).with(r).and_return(role == r ? > > true : false) > > end > > > > if defined?(controller) > > controller.send :current_user=, @current_user > > else > > template.stub!(:logged_in?).and_return(true) > > template.stub!(:current_user).and_return(@current_user) > > end > > end > > end > > > > This is a bit simplified but it works for me pretty well with > > restful_authentication. Normally you would say something like > > "login_as(:admin)" in a before block in controller and view specs. > > > > //jarkko > > > > -- > > Jarkko Laine > > http://jlaine.net > > http://dotherightthing.com > > http://www.railsecommerce.com > > http://odesign.fi > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > So, if I update my code to the following, I still get an exception, > although it is a different one. I really wish I understood how to > determine the actual call chain that is going on ... what object is nil > in this case (see error message below the code)? It should give you a file/line number, which should point you to the offensive line. FWIW, this is the same message you'd get using any framework, as it comes from Rails, not RSpec. > > require File.dirname(__FILE__) + '/../spec_helper' > > describe GroupsController do > > before(:each) do > # mock and stub the Group model methods > @group = mock_model(Group) > Group.stub!(:search_with_paginate).and_return(@group) > > # since this is a secured controller, we have to mock the security > system too > @current_user = mock_model(User, :id => 1) > controller.stub!(:login_required).and_return(:true) > controller.stub!(:current_user).and_return(@current_user) > end > > def do_get > get :index > end > > it "should be successful" do > do_get > puts response.headers > response.should be_success > end > > end > > Exception : RuntimeError in 'GroupsController should be successful' > Called id for nil, which would mistakenly be 4 -- if you really wanted > the id of nil, use object_id > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wshaddix at gmail.com Wed Feb 13 18:24:32 2008 From: wshaddix at gmail.com (Wes Shaddix) Date: Wed, 13 Feb 2008 18:24:32 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <57c63afe0802131502h2321198s9908e0c406772fac@mail.gmail.com> References: <47B26032.90800@gmail.com> <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> <47B37757.10607@gmail.com> <57c63afe0802131502h2321198s9908e0c406772fac@mail.gmail.com> Message-ID: <47B37C30.3060206@gmail.com> David Chelimsky wrote: > On Feb 13, 2008 6:03 PM, Wes Shaddix wrote: > >> Jarkko Laine wrote: >> >>> On 13.2.2008, at 5.12, Wes Shaddix wrote: >>> >>> >>>> I have a GroupController class that inherits from a SecuredController >>>> which have a before filter (before_filter :login_required). This is >>>> using the restul authentication system. I want to mock out the >>>> login_required method so that my GroupController actions don't get >>>> redirected to /sessions/new but I cant figure it out. Here is what I >>>> have so far that doesn't work. Any help would be most appreciated. >>>> >>>> require File.dirname(__FILE__) + '/../spec_helper' >>>> >>>> describe GroupsController do >>>> >>>> before(:each) do >>>> >>>> # mock and stub the Group model methods >>>> @group = mock_model(Group) >>>> Group.stub!(:search_with_paginate).and_return(@group) >>>> >>>> >>>> >>>> # since this is a secured controller, we have to mock the security >>>> system too >>>> >>>> @current_user = mock_model(User, :id => 1) >>>> >>>> self.stub!(:login_required).and_return(:false) >>>> >>>> self.stub!(:current_user).and_return(@current_user) >>>> >>>> end >>>> >>>> >>>> >>>> def do_get >>>> >>>> get :index >>>> >>>> end >>>> >>>> >>>> >>>> it "should be successful" do >>>> >>>> assigns[:page] = 1 >>>> >>>> assigns[:search] = "" >>>> >>>> do_get >>>> >>>> puts response.headers >>>> >>>> response.should be_success >>>> >>>> end >>>> >>>> end >>>> >>>> The error I get is >>>> NoMethodError in 'GroupsController should be successful' >>>> You have a nil object when you didn't expect it! >>>> You might have expected an instance of ActiveRecord::Base. >>>> The error occurred while evaluating nil.[]= >>>> >>> What do you expect the assigns[:... lines to do? If you mean to use >>> them as url parameters, you have to pass them to the get method >>> (through do_get in this case). assigns is a hash that contains all the >>> instance variables set in the controllers. So if you say "@foo = >>> "bar"" in your controller action, you can spec it in a controller view >>> like this: assigns[:foo].should == "bar". However, afaik you're not >>> supposed to write into that hash in your controller specs. On the >>> other hand, in the view specs you *do* need a way to set instance >>> variables available in the views, and there you can use the assigns >>> for that. So in a view spec corresponding to my previous example, you >>> would want the instance variable @foo to be there so you would say >>> "assigns[:foo] = 'bar'" in your before block. >>> >>> That said, I'm not a fan of stubbing the login_required method. >>> Instead, I have created a login_as method in my spec_helper that I use >>> whenever I want to spec something to happen when a logged in user does >>> something (note that I also use the acl_system2 plugin for roles): >>> >>> def login_as(role) >>> @role = mock_model(Role, :title => role.to_s) >>> @current_user = mock_user({:roles => [@role]}) >>> >>> [:admin, :organizer, :client, :teacher].each do |r| >>> @current_user.stub!(:has_role?).with(r).and_return(role == r ? >>> true : false) >>> end >>> >>> if defined?(controller) >>> controller.send :current_user=, @current_user >>> else >>> template.stub!(:logged_in?).and_return(true) >>> template.stub!(:current_user).and_return(@current_user) >>> end >>> end >>> end >>> >>> This is a bit simplified but it works for me pretty well with >>> restful_authentication. Normally you would say something like >>> "login_as(:admin)" in a before block in controller and view specs. >>> >>> //jarkko >>> >>> -- >>> Jarkko Laine >>> http://jlaine.net >>> http://dotherightthing.com >>> http://www.railsecommerce.com >>> http://odesign.fi >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> So, if I update my code to the following, I still get an exception, >> although it is a different one. I really wish I understood how to >> determine the actual call chain that is going on ... what object is nil >> in this case (see error message below the code)? >> > > It should give you a file/line number, which should point you to the > offensive line. FWIW, this is the same message you'd get using any > framework, as it comes from Rails, not RSpec. > > >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe GroupsController do >> >> before(:each) do >> # mock and stub the Group model methods >> @group = mock_model(Group) >> Group.stub!(:search_with_paginate).and_return(@group) >> >> # since this is a secured controller, we have to mock the security >> system too >> @current_user = mock_model(User, :id => 1) >> controller.stub!(:login_required).and_return(:true) >> controller.stub!(:current_user).and_return(@current_user) >> end >> >> def do_get >> get :index >> end >> >> it "should be successful" do >> do_get >> puts response.headers >> response.should be_success >> end >> >> end >> >> Exception : RuntimeError in 'GroupsController should be successful' >> Called id for nil, which would mistakenly be 4 -- if you really wanted >> the id of nil, use object_id >> >> >> _______________________________________________ >> 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 > Gotcha ... this is the offending line in my GroupsController @groups = Group.search_with_paginate(params[:page], params[:search], @current_user.id) Which I'm sure is the @current_user.id. Where I'm confused is that I thought the following line in my GroupsController_spec would intercept this call and return the mock current_user instance: @current_user = mock_model(User, :id => 1) controller.stub!(:login_required).and_return(:true) controller.stub!(:current_user).and_return(@current_user) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080213/3c14965a/attachment.html From dchelimsky at gmail.com Wed Feb 13 18:22:34 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Feb 2008 18:22:34 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <47B37C30.3060206@gmail.com> References: <47B26032.90800@gmail.com> <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> <47B37757.10607@gmail.com> <57c63afe0802131502h2321198s9908e0c406772fac@mail.gmail.com> <47B37C30.3060206@gmail.com> Message-ID: <57c63afe0802131522w6232c37dyad50b8404d3dfef3@mail.gmail.com> On Feb 13, 2008 6:24 PM, Wes Shaddix wrote: > > David Chelimsky wrote: > > On Feb 13, 2008 6:03 PM, Wes Shaddix wrote: > > > Jarkko Laine wrote: > > > On 13.2.2008, at 5.12, Wes Shaddix wrote: > > > > I have a GroupController class that inherits from a SecuredController > which have a before filter (before_filter :login_required). This is > using the restul authentication system. I want to mock out the > login_required method so that my GroupController actions don't get > redirected to /sessions/new but I cant figure it out. Here is what I > have so far that doesn't work. Any help would be most appreciated. > > require File.dirname(__FILE__) + '/../spec_helper' > > describe GroupsController do > > before(:each) do > > # mock and stub the Group model methods > @group = mock_model(Group) > Group.stub!(:search_with_paginate).and_return(@group) > > > > # since this is a secured controller, we have to mock the security > system too > > @current_user = mock_model(User, :id => 1) > > self.stub!(:login_required).and_return(:false) > > self.stub!(:current_user).and_return(@current_user) > > end > > > > def do_get > > get :index > > end > > > > it "should be successful" do > > assigns[:page] = 1 > > assigns[:search] = "" > > do_get > > puts response.headers > > response.should be_success > > end > > end > > The error I get is > NoMethodError in 'GroupsController should be successful' > You have a nil object when you didn't expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.[]= > > What do you expect the assigns[:... lines to do? If you mean to use > them as url parameters, you have to pass them to the get method > (through do_get in this case). assigns is a hash that contains all the > instance variables set in the controllers. So if you say "@foo = > "bar"" in your controller action, you can spec it in a controller view > like this: assigns[:foo].should == "bar". However, afaik you're not > supposed to write into that hash in your controller specs. On the > other hand, in the view specs you *do* need a way to set instance > variables available in the views, and there you can use the assigns > for that. So in a view spec corresponding to my previous example, you > would want the instance variable @foo to be there so you would say > "assigns[:foo] = 'bar'" in your before block. > > That said, I'm not a fan of stubbing the login_required method. > Instead, I have created a login_as method in my spec_helper that I use > whenever I want to spec something to happen when a logged in user does > something (note that I also use the acl_system2 plugin for roles): > > def login_as(role) > @role = mock_model(Role, :title => role.to_s) > @current_user = mock_user({:roles => [@role]}) > > [:admin, :organizer, :client, :teacher].each do |r| > @current_user.stub!(:has_role?).with(r).and_return(role == r ? > true : false) > end > > if defined?(controller) > controller.send :current_user=, @current_user > else > template.stub!(:logged_in?).and_return(true) > template.stub!(:current_user).and_return(@current_user) > end > end > end > > This is a bit simplified but it works for me pretty well with > restful_authentication. Normally you would say something like > "login_as(:admin)" in a before block in controller and view specs. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > So, if I update my code to the following, I still get an exception, > although it is a different one. I really wish I understood how to > determine the actual call chain that is going on ... what object is nil > in this case (see error message below the code)? > > It should give you a file/line number, which should point you to the > offensive line. FWIW, this is the same message you'd get using any > framework, as it comes from Rails, not RSpec. > > > > require File.dirname(__FILE__) + '/../spec_helper' > > describe GroupsController do > > before(:each) do > # mock and stub the Group model methods > @group = mock_model(Group) > Group.stub!(:search_with_paginate).and_return(@group) > > # since this is a secured controller, we have to mock the security > system too > @current_user = mock_model(User, :id => 1) > controller.stub!(:login_required).and_return(:true) > controller.stub!(:current_user).and_return(@current_user) > end > > def do_get > get :index > end > > it "should be successful" do > do_get > puts response.headers > response.should be_success > end > > end > > Exception : RuntimeError in 'GroupsController should be successful' > Called id for nil, which would mistakenly be 4 -- if you really wanted > the id of nil, use object_id > > > _______________________________________________ > 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 > > Gotcha ... this is the offending line in my GroupsController > > @groups = Group.search_with_paginate(params[:page], params[:search], > @current_user.id) This is referencing the @current_user instance variable here, not the current_user method. > > Which I'm sure is the @current_user.id. Where I'm confused is that I > thought the following line in my GroupsController_spec would intercept this > call and return the mock current_user instance: > > @current_user = mock_model(User, :id => 1) > controller.stub!(:login_required).and_return(:true) > controller.stub!(:current_user).and_return(@current_user) And this is stubbing the current_user method. So you want to change the line in the controller to: @groups = Group.search_with_paginate(params[:page], params[:search], current_user.id) Cheers, David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wshaddix at gmail.com Wed Feb 13 18:32:16 2008 From: wshaddix at gmail.com (Wes Shaddix) Date: Wed, 13 Feb 2008 18:32:16 -0500 Subject: [rspec-users] How do I mock out the before :login_required method? In-Reply-To: <57c63afe0802131522w6232c37dyad50b8404d3dfef3@mail.gmail.com> References: <47B26032.90800@gmail.com> <4E384C3D-E4C8-440A-B3E2-8DCEB0D7EFE9@jlaine.net> <47B37757.10607@gmail.com> <57c63afe0802131502h2321198s9908e0c406772fac@mail.gmail.com> <47B37C30.3060206@gmail.com> <57c63afe0802131522w6232c37dyad50b8404d3dfef3@mail.gmail.com> Message-ID: <47B37E00.4050901@gmail.com> David Chelimsky wrote: > On Feb 13, 2008 6:24 PM, Wes Shaddix wrote: > >> David Chelimsky wrote: >> >> On Feb 13, 2008 6:03 PM, Wes Shaddix wrote: >> >> >> Jarkko Laine wrote: >> >> >> On 13.2.2008, at 5.12, Wes Shaddix wrote: >> >> >> >> I have a GroupController class that inherits from a SecuredController >> which have a before filter (before_filter :login_required). This is >> using the restul authentication system. I want to mock out the >> login_required method so that my GroupController actions don't get >> redirected to /sessions/new but I cant figure it out. Here is what I >> have so far that doesn't work. Any help would be most appreciated. >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe GroupsController do >> >> before(:each) do >> >> # mock and stub the Group model methods >> @group = mock_model(Group) >> Group.stub!(:search_with_paginate).and_return(@group) >> >> >> >> # since this is a secured controller, we have to mock the security >> system too >> >> @current_user = mock_model(User, :id => 1) >> >> self.stub!(:login_required).and_return(:false) >> >> self.stub!(:current_user).and_return(@current_user) >> >> end >> >> >> >> def do_get >> >> get :index >> >> end >> >> >> >> it "should be successful" do >> >> assigns[:page] = 1 >> >> assigns[:search] = "" >> >> do_get >> >> puts response.headers >> >> response.should be_success >> >> end >> >> end >> >> The error I get is >> NoMethodError in 'GroupsController should be successful' >> You have a nil object when you didn't expect it! >> You might have expected an instance of ActiveRecord::Base. >> The error occurred while evaluating nil.[]= >> >> What do you expect the assigns[:... lines to do? If you mean to use >> them as url parameters, you have to pass them to the get method >> (through do_get in this case). assigns is a hash that contains all the >> instance variables set in the controllers. So if you say "@foo = >> "bar"" in your controller action, you can spec it in a controller view >> like this: assigns[:foo].should == "bar". However, afaik you're not >> supposed to write into that hash in your controller specs. On the >> other hand, in the view specs you *do* need a way to set instance >> variables available in the views, and there you can use the assigns >> for that. So in a view spec corresponding to my previous example, you >> would want the instance variable @foo to be there so you would say >> "assigns[:foo] = 'bar'" in your before block. >> >> That said, I'm not a fan of stubbing the login_required method. >> Instead, I have created a login_as method in my spec_helper that I use >> whenever I want to spec something to happen when a logged in user does >> something (note that I also use the acl_system2 plugin for roles): >> >> def login_as(role) >> @role = mock_model(Role, :title => role.to_s) >> @current_user = mock_user({:roles => [@role]}) >> >> [:admin, :organizer, :client, :teacher].each do |r| >> @current_user.stub!(:has_role?).with(r).and_return(role == r ? >> true : false) >> end >> >> if defined?(controller) >> controller.send :current_user=, @current_user >> else >> template.stub!(:logged_in?).and_return(true) >> template.stub!(:current_user).and_return(@current_user) >> end >> end >> end >> >> This is a bit simplified but it works for me pretty well with >> restful_authentication. Normally you would say something like >> "login_as(:admin)" in a before block in controller and view specs. >> >> //jarkko >> >> -- >> Jarkko Laine >> http://jlaine.net >> http://dotherightthing.com >> http://www.railsecommerce.com >> http://odesign.fi >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> So, if I update my code to the following, I still get an exception, >> although it is a different one. I really wish I understood how to >> determine the actual call chain that is going on ... what object is nil >> in this case (see error message below the code)? >> >> It should give you a file/line number, which should point you to the >> offensive line. FWIW, this is the same message you'd get using any >> framework, as it comes from Rails, not RSpec. >> >> >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> describe GroupsController do >> >> before(:each) do >> # mock and stub the Group model methods >> @group = mock_model(Group) >> Group.stub!(:search_with_paginate).and_return(@group) >> >> # since this is a secured controller, we have to mock the security >> system too >> @current_user = mock_model(User, :id => 1) >> controller.stub!(:login_required).and_return(:true) >> controller.stub!(:current_user).and_return(@current_user) >> end >> >> def do_get >> get :index >> end >> >> it "should be successful" do >> do_get >> puts response.headers >> response.should be_success >> end >> >> end >> >> Exception : RuntimeError in 'GroupsController should be successful' >> Called id for nil, which would mistakenly be 4 -- if you really wanted >> the id of nil, use object_id >> >> >> _______________________________________________ >> 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 >> >> Gotcha ... this is the offending line in my GroupsController >> >> @groups = Group.search_with_paginate(params[:page], params[:search], >> @current_user.id) >> > > > This is referencing the @current_user instance variable here, not the > current_user method. > > >> Which I'm sure is the @current_user.id. Where I'm confused is that I >> thought the following line in my GroupsController_spec would intercept this >> call and return the mock current_user instance: >> >> @current_user = mock_model(User, :id => 1) >> controller.stub!(:login_required).and_return(:true) >> controller.stub!(:current_user).and_return(@current_user) >> > > > And this is stubbing the current_user method. > > So you want to change the line in the controller to: > > @groups = Group.search_with_paginate(params[:page], params[:search], > current_user.id) > > 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 > Well, it seems so clear when you write the code for me :) Thank you for your time and help. Wes From lfeistel at lnstar.com Wed Feb 13 18:27:31 2008 From: lfeistel at lnstar.com (lfeistel) Date: Wed, 13 Feb 2008 15:27:31 -0800 (PST) Subject: [rspec-users] How to load fixtures for plugins with rspec tests Message-ID: <15470591.post@talk.nabble.com> Hello all, I had no trouble loading fixtures from the application's base spec/fixtures directory, but I am working on a plugin which has its own rspec tests and fixtures. I am getting the rspec tests to run, but they cannot seem to load the fixtures that go with each plugin, so of course they fail. If I run rake spec:plugins it does run the specs in my plugins, but inside the plugin specs, the fixtures are not being loaded even through I have a 'fixtures' line in all my specs. What is the correct way to get fixtures loaded for plugins with rspec tests? Lee -- View this message in context: http://www.nabble.com/How-to-load-fixtures-for-plugins-with-rspec-tests-tp15470591p15470591.html Sent from the rspec-users mailing list archive at Nabble.com. From rspec-users at kero.tmfweb.nl Thu Feb 14 00:48:23 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Thu, 14 Feb 2008 06:48:23 +0100 Subject: [rspec-users] Generated rspec video In-Reply-To: <71166b3b0802112038p76df0140kc3599f487927fb5b@mail.gmail.com> References: <20080212030718.739A57BBC@mint.qinip.net> <71166b3b0802112038p76df0140kc3599f487927fb5b@mail.gmail.com> Message-ID: <20080214054822.GA21973@chello.nl> > > A sneak preview of what I've been doing with my patch that made it > > into rspec 1.1.3: > > > > Stuff for off-list: > > - created with mencoder, I can play with mplayer. > > Reports on success or failure of other players welcome. > > weird codec combo... you should have used thedora or xvid at least :-P > (cannot play or even recognize the .avi codec signature). mencoder manages neither libxvid or libtheora as video encoder. No clue why, it should support them. I put up six combinations which google helped me find on http://chmeee.dyndns.org/ruby/ but xine and vlc only do audio as well as video on the wmv8+wmav2 video. Showed the stuff yesterday on NYC.rb, got one comment to hook this up to selenium (instead of the -f p -c). and that the nice thing: these formatters (listeners) allow you to execute about anything you'd want :) Bye, Kero. From toastkid.williams at gmail.com Thu Feb 14 05:15:01 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Thu, 14 Feb 2008 10:15:01 +0000 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> Message-ID: Hi David - thanks for replying. The literal doesn't work either, because of all the params at the end, and i don't have named routes in this old, non-restful app. I see your point about the hash...is there any way to get the redirected-to url from 'response' and test against that? Then i could split it at "?" to ignore the params. (I'd rather not include the specific params in this test since i really just want to know about where it's redirected to). So, ideally i could do something like this - response.url.split("?").first.should eql(" http://test.host/admin/users/batch_saved") I've been looking for documentation for methods for the response object, to get the url, but i can't find any in the api docs (i'm probably just looking in the wrong place). I can see the url data in the object but it's private. thanks max On 13/02/2008, David Chelimsky wrote: > > On Feb 13, 2008 12:26 PM, Max Williams > wrote: > > > > I'm testing a controller action that redirects to a different > action/view, > > sending through some params. In my test, i'm only specifying the > controller > > and action that it should redirect to, but the additional params are > making > > it fail! Here's my test: > > > > it "should redirect to batch_saved after completing batch_save" do > > post 'batch_save', @params > > response.should redirect_to(:controller => 'admin/users', :action => > > 'batch_saved') > > end > > > > and here's the failure report: > > > > 'Admin::UserController When logged in as an admin level user should > redirect > > to batch_saved after batch_save' FAILED > > expected redirect to {:controller=>"admin/users", > :action=>"batch_saved"}, > > got redirect to > > " > http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup > " > > > > Now, i would expect that since i'm just specifying a controller and > action, > > and we redirect to them, that the test would pass. But the params are > > breaking it (I know this because i changed the controller action to not > send > > params through at all and the test passed). How do i do the test so > that it > > doesn't care about the params? > > > When you use a hash it checks the whole hash, so this is the expected > behaviour. > > You can either used a named route (if you've got one available) or a > String literal: > > response.should redirect_to(admin_users_batch_saved) > response.should redirect_to('/admin/users/batch_saved') > > Based on Jay Field's latest advice > (http://blog.jayfields.com/2008/02/testing-expect-literals.html) you > may want to consider the literal. > > HTH, > David > > > > > > > > -- > > > View this message in context: > http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html > > Sent from the rspec-users mailing list archive at Nabble.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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080214/e7c74d8e/attachment.html From dchelimsky at gmail.com Thu Feb 14 08:06:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Feb 2008 08:06:02 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> Message-ID: <57c63afe0802140506u4ad0febco9ea6111667aeac7e@mail.gmail.com> On Thu, Feb 14, 2008 at 5:15 AM, Max Williams wrote: > Hi David - thanks for replying. The literal doesn't work either, because of > all the params at the end, and i don't have named routes in this old, > non-restful app. I see your point about the hash...is there any way to get > the redirected-to url from 'response' and test against that? Then i could > split it at "?" to ignore the params. (I'd rather not include the specific > params in this test since i really just want to know about where it's > redirected to). > > So, ideally i could do something like this - > > response.url.split("?").first.should > eql("http://test.host/admin/users/batch_saved") Try response.redirect_url. > > I've been looking for documentation for methods for the response object, to > get the url, but i can't find any in the api docs (i'm probably just looking > in the wrong place). I can see the url data in the object but it's private. > > thanks > max > > > > On 13/02/2008, David Chelimsky wrote: > > On Feb 13, 2008 12:26 PM, Max Williams > wrote: > > > > > > I'm testing a controller action that redirects to a different > action/view, > > > sending through some params. In my test, i'm only specifying the > controller > > > and action that it should redirect to, but the additional params are > making > > > it fail! Here's my test: > > > > > > it "should redirect to batch_saved after completing batch_save" do > > > post 'batch_save', @params > > > response.should redirect_to(:controller => 'admin/users', :action => > > > 'batch_saved') > > > end > > > > > > and here's the failure report: > > > > > > 'Admin::UserController When logged in as an admin level user should > redirect > > > to batch_saved after batch_save' FAILED > > > expected redirect to {:controller=>"admin/users", > :action=>"batch_saved"}, > > > got redirect to > > > > "http://test.host/admin/users/batch_saved?music_service_id=1&new_users%5B%5D%5Bemail%5D=mark%40zadeup.com&new_users%5B%5D%5Bfirstname%5D=Mark&new_users%5B%5D%5Bmusic_service_id%5D=1&new_users%5B%5D%5Bschool%5D=&new_users%5B%5D%5Bsurname%5D=Madeup" > > > > > > Now, i would expect that since i'm just specifying a controller and > action, > > > and we redirect to them, that the test would pass. But the params are > > > breaking it (I know this because i changed the controller action to not > send > > > params through at all and the test passed). How do i do the test so > that it > > > doesn't care about the params? > > > > > > When you use a hash it checks the whole hash, so this is the expected > behaviour. > > > > You can either used a named route (if you've got one available) or a > > String literal: > > > > response.should redirect_to(admin_users_batch_saved) > > response.should redirect_to('/admin/users/batch_saved') > > > > Based on Jay Field's latest advice > > (http://blog.jayfields.com/2008/02/testing-expect-literals.html) you > > may want to consider the literal. > > > > HTH, > > David > > > > > > > > > > > > > -- > > > > > View this message in context: > http://www.nabble.com/params-are-making-my-%22should-redirect_to%22-test-fail---why---tp15460582p15460582.html > > > Sent from the rspec-users mailing list archive at Nabble.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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Thu Feb 14 08:22:55 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 14 Feb 2008 08:22:55 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> Message-ID: On 2/14/08, Max Williams wrote: > Hi David - thanks for replying. The literal doesn't work either, because of > all the params at the end, and i don't have named routes in this old, > non-restful app. I see your point about the hash...is there any way to get > the redirected-to url from 'response' and test against that? Then i could > split it at "?" to ignore the params. (I'd rather not include the specific > params in this test since i really just want to know about where it's > redirected to). > > So, ideally i could do something like this - > > response.url.split("?").first.should > eql("http://test.host/admin/users/batch_saved") > > I've been looking for documentation for methods for the response object, to > get the url, but i can't find any in the api docs (i'm probably just looking > in the wrong place). I can see the url data in the object but it's private. Well the RedirectTo matcher gets it using response.redirect_url I'd probably write the check as response.should be_redirect response.redirect_url.should match(%r{^http://test.host/admin/users/batch_saved(\?|$)}) -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From toastkid.williams at gmail.com Thu Feb 14 09:15:32 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Thu, 14 Feb 2008 14:15:32 +0000 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> Message-ID: perfect - that's the method i was looking for. Thanks! On 14/02/2008, Rick DeNatale wrote: > > On 2/14/08, Max Williams wrote: > > Hi David - thanks for replying. The literal doesn't work either, > because of > > all the params at the end, and i don't have named routes in this old, > > non-restful app. I see your point about the hash...is there any way to > get > > the redirected-to url from 'response' and test against that? Then i > could > > split it at "?" to ignore the params. (I'd rather not include the > specific > > params in this test since i really just want to know about where it's > > redirected to). > > > > So, ideally i could do something like this - > > > > response.url.split("?").first.should > > eql("http://test.host/admin/users/batch_saved") > > > > I've been looking for documentation for methods for the response > object, to > > get the url, but i can't find any in the api docs (i'm probably just > looking > > in the wrong place). I can see the url data in the object but it's > private. > > > Well the RedirectTo matcher gets it using > > response.redirect_url > > I'd probably write the check as > > response.should be_redirect > response.redirect_url.should > match(%r{^http://test.host/admin/users/batch_saved(\?|$)}) > > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080214/01f70526/attachment-0001.html From dchelimsky at gmail.com Thu Feb 14 09:21:16 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Feb 2008 09:21:16 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> Message-ID: <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale wrote: > On 2/14/08, Max Williams wrote: > > Hi David - thanks for replying. The literal doesn't work either, because of > > all the params at the end, and i don't have named routes in this old, > > non-restful app. I see your point about the hash...is there any way to get > > the redirected-to url from 'response' and test against that? Then i could > > split it at "?" to ignore the params. (I'd rather not include the specific > > params in this test since i really just want to know about where it's > > redirected to). > > > > So, ideally i could do something like this - > > > > response.url.split("?").first.should > > eql("http://test.host/admin/users/batch_saved") > > > > I've been looking for documentation for methods for the response object, to > > get the url, but i can't find any in the api docs (i'm probably just looking > > in the wrong place). I can see the url data in the object but it's private. > > Well the RedirectTo matcher gets it using > > response.redirect_url > > I'd probably write the check as > > response.should be_redirect > response.redirect_url.should > match(%r{^http://test.host/admin/users/batch_saved(\?|$)}) That seems reasonable given what is offered. What do you guys think of a new matcher named redirect_with: response.should redirect_with(:controller => 'admin/users', :action => 'batch_saved') This would let you express exactly what you want and only accept a Hash and only match those present in the expectation, ignoring anything else in the Hash. I don't have the cycles to add this anytime soon, so if you like the idea, feel free to submit a patch to the tracker. Cheers, David > > -- > 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 rick.denatale at gmail.com Thu Feb 14 09:48:09 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 14 Feb 2008 09:48:09 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> Message-ID: On 2/14/08, David Chelimsky wrote: > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale wrote: > > On 2/14/08, Max Williams wrote: > > > I've been looking for documentation for methods for the response object, to > > > get the url, but i can't find any in the api docs (i'm probably just looking > > > in the wrong place). I can see the url data in the object but it's private. > > > > Well the RedirectTo matcher gets it using > > > > response.redirect_url > > > > I'd probably write the check as > > > > response.should be_redirect > > response.redirect_url.should > > match(%r{^http://test.host/admin/users/batch_saved(\?|$)}) > > > That seems reasonable given what is offered. > > What do you guys think of a new matcher named redirect_with: > > response.should redirect_with(:controller => 'admin/users', :action => > 'batch_saved') > > This would let you express exactly what you want and only accept a > Hash and only match those present in the expectation, ignoring > anything else in the Hash. > > I don't have the cycles to add this anytime soon, so if you like the > idea, feel free to submit a patch to the tracker. I'd be happy to do that, although I'm not entirely convinced that redirect_with is the right name, not that I've got a better alternative. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From joseph at josephholsten.com Thu Feb 14 09:44:39 2008 From: joseph at josephholsten.com (Joseph Anthony Pasquale Holsten) Date: Thu, 14 Feb 2008 08:44:39 -0600 Subject: [rspec-users] specdoc and taskpaper Message-ID: Hello there, I was wondering if anyone had looked at taskpaper? [1] They've got a vaguely yaml inspired format for todo lists. It reminded me of specdocs. I wonder how much work it would be to convert or build it in? Anyone else interested in seeing this? http:// Joseph Holsten .com [1] http://hogbaysoftware.com/products/taskpaper -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080214/39f25b6d/attachment.html From dchelimsky at gmail.com Thu Feb 14 10:03:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Feb 2008 10:03:18 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> Message-ID: <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale wrote: > On 2/14/08, David Chelimsky wrote: > > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale wrote: > > > On 2/14/08, Max Williams wrote: > > > > > > I've been looking for documentation for methods for the response object, to > > > > get the url, but i can't find any in the api docs (i'm probably just looking > > > > in the wrong place). I can see the url data in the object but it's private. > > > > > > Well the RedirectTo matcher gets it using > > > > > > response.redirect_url > > > > > > I'd probably write the check as > > > > > > response.should be_redirect > > > response.redirect_url.should > > > match(%r{^http://test.host/admin/users/batch_saved(\?|$)}) > > > > > > That seems reasonable given what is offered. > > > > What do you guys think of a new matcher named redirect_with: > > > > response.should redirect_with(:controller => 'admin/users', :action => > > 'batch_saved') > > > > This would let you express exactly what you want and only accept a > > Hash and only match those present in the expectation, ignoring > > anything else in the Hash. > > > > I don't have the cycles to add this anytime soon, so if you like the > > idea, feel free to submit a patch to the tracker. > > I'd be happy to do that, although I'm not entirely convinced that > redirect_with is the right name, not that I've got a better > alternative. redirect_with_options? How about something added to the existing call? response.should redirect_to(:controller => 'foo', :action => 'bar').ignoring_other_options Or something like that? > > -- > > > 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 rick.denatale at gmail.com Thu Feb 14 10:07:38 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 14 Feb 2008 10:07:38 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> Message-ID: On 2/14/08, David Chelimsky wrote: > On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale wrote: > > On 2/14/08, David Chelimsky wrote: > > > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale wrote: > > > I don't have the cycles to add this anytime soon, so if you like the > > > idea, feel free to submit a patch to the tracker. > > > > I'd be happy to do that, although I'm not entirely convinced that > > redirect_with is the right name, not that I've got a better > > alternative. > > > redirect_with_options? I think I like that. > How about something added to the existing call? > > response.should redirect_to(:controller => 'foo', :action => > 'bar').ignoring_other_options This seems too wordy. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From toastkid.williams at gmail.com Thu Feb 14 10:16:09 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Thu, 14 Feb 2008 15:16:09 +0000 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> Message-ID: I'm new to rspec (and coding in general) but would it break a lot of people's tests if redirect_to was changed to do this by default? It's what i expected it to do, personally, that is to pass if the given :action and :controller match up. If i pass a url string, and it's missing the params, then it seems fair that it should fail, but if for example i just specify a controller, and that controller is called (with any action) i'd expect it to pass as well. Like i say i'm a newb with no idea of the impact of this to existing tests :) On 14/02/2008, Rick DeNatale wrote: > > On 2/14/08, David Chelimsky wrote: > > On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale > wrote: > > > On 2/14/08, David Chelimsky wrote: > > > > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale < > rick.denatale at gmail.com> wrote: > > > > > I don't have the cycles to add this anytime soon, so if you like > the > > > > idea, feel free to submit a patch to the tracker. > > > > > > I'd be happy to do that, although I'm not entirely convinced that > > > redirect_with is the right name, not that I've got a better > > > alternative. > > > > > > redirect_with_options? > > > I think I like that. > > > > > How about something added to the existing call? > > > > response.should redirect_to(:controller => 'foo', :action => > > 'bar').ignoring_other_options > > > This seems too wordy. > > > > -- > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080214/8ea4c5f4/attachment.html From dchelimsky at gmail.com Thu Feb 14 10:32:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Feb 2008 10:32:33 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> Message-ID: <57c63afe0802140732j3c5d156em13f28291984dfd4d@mail.gmail.com> On Thu, Feb 14, 2008 at 10:16 AM, Max Williams wrote: > I'm new to rspec (and coding in general) but would it break a lot of > people's tests if redirect_to was changed to do this by default? It's what > i expected it to do, personally, that is to pass if the given :action and > :controller match up. If i pass a url string, and it's missing the params, > then it seems fair that it should fail, but if for example i just specify a > controller, and that controller is called (with any action) i'd expect it to > pass as well. > > Like i say i'm a newb with no idea of the impact of this to existing tests > :) It is conceivable that existing examples could break, but the docs do set out the same expectation that you have. Can you file a bug at http://rspec.lighthouseapp.com so we can get it in the queue? > On 14/02/2008, Rick DeNatale wrote: > > On 2/14/08, David Chelimsky wrote: > > > On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale > wrote: > > > > On 2/14/08, David Chelimsky wrote: > > > > > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale > wrote: > > > > > > > I don't have the cycles to add this anytime soon, so if you like > the > > > > > idea, feel free to submit a patch to the tracker. > > > > > > > > I'd be happy to do that, although I'm not entirely convinced that > > > > redirect_with is the right name, not that I've got a better > > > > alternative. > > > > > > > > > redirect_with_options? > > > > > > I think I like that. > > > > > > > > > How about something added to the existing call? > > > > > > response.should redirect_to(:controller => 'foo', :action => > > > 'bar').ignoring_other_options > > > > > > This seems too wordy. > > > > > > > > -- > > > > 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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Thu Feb 14 10:55:18 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 14 Feb 2008 10:55:18 -0500 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: <57c63afe0802140732j3c5d156em13f28291984dfd4d@mail.gmail.com> References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> <57c63afe0802140732j3c5d156em13f28291984dfd4d@mail.gmail.com> Message-ID: On Thu, Feb 14, 2008 at 10:32 AM, David Chelimsky wrote: > On Thu, Feb 14, 2008 at 10:16 AM, Max Williams > > wrote: > > > I'm new to rspec (and coding in general) but would it break a lot of > > people's tests if redirect_to was changed to do this by default? It's what > > i expected it to do, personally, that is to pass if the given :action and > > :controller match up. If i pass a url string, and it's missing the params, > > then it seems fair that it should fail, but if for example i just specify a > > controller, and that controller is called (with any action) i'd expect it to > > pass as well. > > > > Like i say i'm a newb with no idea of the impact of this to existing tests > > :) > > It is conceivable that existing examples could break, but the docs do > set out the same expectation that you have. > > Can you file a bug at http://rspec.lighthouseapp.com so we can get it > in the queue? I guess I'll hold off on the patch then. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From toastkid.williams at gmail.com Thu Feb 14 11:22:24 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Thu, 14 Feb 2008 16:22:24 +0000 Subject: [rspec-users] params are making my "should redirect_to" test fail - why?? In-Reply-To: <57c63afe0802140732j3c5d156em13f28291984dfd4d@mail.gmail.com> References: <15460582.post@talk.nabble.com> <57c63afe0802131039o54bf32b4lc61b73cbda7f4cae@mail.gmail.com> <57c63afe0802140621y4e9029fbhe052bfe53663da94@mail.gmail.com> <57c63afe0802140703k4c40cc6qaf442f3fea2f41d9@mail.gmail.com> <57c63afe0802140732j3c5d156em13f28291984dfd4d@mail.gmail.com> Message-ID: Done, thanks everyone. On 14/02/2008, David Chelimsky wrote: > > On Thu, Feb 14, 2008 at 10:16 AM, Max Williams > > wrote: > > > I'm new to rspec (and coding in general) but would it break a lot of > > people's tests if redirect_to was changed to do this by default? It's > what > > i expected it to do, personally, that is to pass if the given :action > and > > :controller match up. If i pass a url string, and it's missing the > params, > > then it seems fair that it should fail, but if for example i just > specify a > > controller, and that controller is called (with any action) i'd expect > it to > > pass as well. > > > > Like i say i'm a newb with no idea of the impact of this to existing > tests > > :) > > > It is conceivable that existing examples could break, but the docs do > set out the same expectation that you have. > > Can you file a bug at http://rspec.lighthouseapp.com so we can get it > in the queue? > > > > > On 14/02/2008, Rick DeNatale wrote: > > > On 2/14/08, David Chelimsky wrote: > > > > On Thu, Feb 14, 2008 at 9:48 AM, Rick DeNatale < > rick.denatale at gmail.com> > > wrote: > > > > > On 2/14/08, David Chelimsky wrote: > > > > > > On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale > > wrote: > > > > > > > > > I don't have the cycles to add this anytime soon, so if you > like > > the > > > > > > idea, feel free to submit a patch to the tracker. > > > > > > > > > > I'd be happy to do that, although I'm not entirely convinced > that > > > > > redirect_with is the right name, not that I've got a better > > > > > alternative. > > > > > > > > > > > > redirect_with_options? > > > > > > > > > I think I like that. > > > > > > > > > > > > > How about something added to the existing call? > > > > > > > > response.should redirect_to(:controller => 'foo', :action => > > > > 'bar').ignoring_other_options > > > > > > > > > This seems too wordy. > > > > > > > > > > > > -- > > > > > > 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 > > > > > > > > > _______________________________________________ > > 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/20080214/3979d301/attachment.html From bryansray at gmail.com Thu Feb 14 12:11:53 2008 From: bryansray at gmail.com (Bryan Ray) Date: Thu, 14 Feb 2008 11:11:53 -0600 Subject: [rspec-users] How to mock an association In-Reply-To: References: <47B034E2.2050401@gmail.com> Message-ID: <29a0119e0802140911m5b63cce6m4785e8a51d990a0e@mail.gmail.com> I don't know exactly how you're using the code, but validates_presence_of :user_id seems redundant. If you've setup a relationship from Group to User then Active Record will be enforcing that validation for you. Just a thought ... Other than that you would probably do (without seeing any of your code): group = mock_model(Group, :to_param => 1) user = mock_model(User, :to_param => 1) group.stub!(:user).and_return(user) On Mon, Feb 11, 2008 at 8:21 AM, Edvard Majakari wrote: > On Feb 11, 2008 1:43 PM, Wes Shaddix wrote: > > I've got a "group" model that has a user_id attribute and a > > validates_existence_of :user and validates_presence_of :user_id > > validations. What method(s) do I need to stub on the User mock to > > intercept those validation calls? My goal is to isolate the Group model > > from the User model. > > See http://www.ruby-forum.com/topic/138342 > > and http://tersesystems.com/post/9700067.jhtml > > Obvious 'rails mocking associations' seemed to work for me, unless I > misunderstood the question. > > Of course, you could just stub 'valid?' for any AR object as well. > -- > "One day, when he was naughty, Mr Bunnsy looked over the hedge into > Farmer Fred's field and it was full of fresh green lettuces. Mr > Bunnsy, however, was not full of lettuces. This did not seem fair." > -- Terry Pratchett, Mr. Bunnsy Has An Adventure > _______________________________________________ > 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/20080214/76f15584/attachment.html From vertebrate at gmail.com Thu Feb 14 12:53:42 2008 From: vertebrate at gmail.com (Steve) Date: Thu, 14 Feb 2008 17:53:42 +0000 (UTC) Subject: [rspec-users] Wrong ZenTest being used? Message-ID: When I try to run autotest I get the following error: loading autotest/rails_rspec /usr/local/lib/site_ruby/1.8/rubygems.rb:319:in `activate': can't activate ZenTest (= 3.7.1), already activated ZenTest-3.9.1] (Gem::Exception) This is after just upgrading to the latest of everything from a previously working much earlier rev of rspec/rails, and zentest. I'm guessing something old is lingering around. Where would I be best off looking? Thanks, Steve From vertebrate at gmail.com Thu Feb 14 16:37:30 2008 From: vertebrate at gmail.com (Steve) Date: Thu, 14 Feb 2008 21:37:30 +0000 (UTC) Subject: [rspec-users] Failed specs spike autotest Message-ID: I'm getting some weird behavior. I'm currently running on trunk rspec/ rails, with 3.9.1 autotest. If a all tests succeed or are pending, autotest just sits there dutifully with the blinking cursor. If an example fails, it will take a few seconds, and pop up this line: /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts script/spec Once that comes up, the cpu spikes. Autotest no longer acknowledges file changes. The only thing that can be done is to kill autotest. Here's my script/spec file if it's of any use: http://pastebin.com/m4c1d212a Please let me know if there's any more information I can provide. Thanks, Steve From colin at logaan.net Thu Feb 14 17:09:16 2008 From: colin at logaan.net (Colin Campbell-McPherson) Date: Fri, 15 Feb 2008 07:09:16 +0900 Subject: [rspec-users] specdoc and taskpaper In-Reply-To: References: Message-ID: I use task paper and love it. Definitely the fastest way to throw in todo items. I wouldn't call the format yaml-ish though. Here's an example: This is a project: - This is a task @done - Another Task @context Another Project: - Task again Plain text Words followed by a colon are a project. Words following a hyphen are a task. The @context following a task sets it's context. @done means it's done. Any other words are plain text. I've been thinking of writing a todo app that had an export to taskpaper function. On 14/02/2008, at 11:44 PM, Joseph Anthony Pasquale Holsten wrote: > Hello there, > I was wondering if anyone had looked at taskpaper? [1] They've got a > vaguely yaml inspired format for todo lists. > > It reminded me of specdocs. I wonder how much work it would be to > convert or build it in? > > Anyone else interested in seeing this? > > http:// Joseph Holsten .com > > [1] http://hogbaysoftware.com/products/taskpaper > > > > _______________________________________________ > 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/20080215/ecb3e471/attachment-0001.html From philodespotos at gmail.com Thu Feb 14 19:32:57 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 14 Feb 2008 18:32:57 -0600 Subject: [rspec-users] Failed specs spike autotest In-Reply-To: References: Message-ID: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> On Thu, Feb 14, 2008 at 3:37 PM, Steve wrote: > I'm getting some weird behavior. I'm currently running on trunk rspec/ > rails, with 3.9.1 autotest. If a all tests succeed or are pending, > autotest just sits there dutifully with the blinking cursor. If an > example fails, it will take a few seconds, and pop up this line: > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts script/spec > > Once that comes up, the cpu spikes. Autotest no longer acknowledges file > changes. The only thing that can be done is to kill autotest. Here's my > script/spec file if it's of any use: > > http://pastebin.com/m4c1d212a > > Please let me know if there's any more information I can provide. > > Thanks, > Steve Same thing happening here, though I didn't recognize that it's only after failures. The problem continues whether I use .autotest files or not. This is on a Rails 2.0.2 project, with rspec+rspec_on_rails r3306 in vendor/plugins, and ZenTest 3.9.1 installed as a gem. Kyle From baccigalupi at gmail.com Thu Feb 14 19:14:38 2008 From: baccigalupi at gmail.com (Kane Baccigalupi) Date: Thu, 14 Feb 2008 16:14:38 -0800 Subject: [rspec-users] Loosing params and request info in 'if' statements Message-ID: <7bdd6b770802141614o140738bcx20216a01af5cb789@mail.gmail.com> Hi, I have been a bad TDD developer and developed before testing. My code is working fine, but I have been writing tests because it is the right thing to do. I am running into trouble with some controller methods that are saved in a separate lib module and included in the application.rb file. I started out specing the methods from one of the controller specs and then when all went well I moved them into a separate file and made the description shared. This seemed to be working until I started testing a completely separate set of method. Here is the code: The specs: # shared_member_restriction_spec.rb describe "MemberRestriction", :shared => true do before(:each) do params[:username] = "some_user" params[:password] = "password" request.request_uri = "members/" + controller.controller_name end describe "authenticate_if_in_members" do it "should call authenticate_if_in_members" do controller.should_receive(:authenticate_if_in_members) get :index end it "should call authenticate_member" do controller.should_receive(:authenticate_member) get :index end end end # episode_controller_spec.rb require File.dirname(__FILE__) + '/shared_member_restriction_spec' describe EpisodesController do it_should_behave_like "MemberRestriction" # ... end And the lib module: module MemberRestriction def authenticate_if_in_members if request.request_uri.include? "members/" authenticate_member bounce_if_membership_not_in_collection end end # ... end Finally the episode controller code: class EpisodesController < ApplicationController before_filter :authenticate_if_in_members # ... end The spec "should call authenticate_member" is failing like so: Spec::Mocks::MockExpectationError in 'EpisodesController authenticate_if_in_members should call authenticate_member' Mock 'EpisodesController' expected :authenticate_member with (any args) once, but received it 0 times I thought maybe the problem was that really I hadn't gotten these specs setup correctly for sharing, so I tried moving them back into the episode controller spec. No luck. Then I thought that maybe this was a bug with the version of rspec/autotest. I upgraded them both yesterday to the most recent version. I ran into a similar problem testing a different module. I had some params and a ruby statement that said something like User.authenticate(params[:user], params[:password]) if params[:user] and params[:password] The error that I got said that params was nil and therefore nil.[] wasn't a kosher ruby request. The if statement was redundant and so I took it out, at which point the params were not nil and everything worked according to plan. This was another situation where the code ran fine, but the tests were coughing on an if statement. I am honestly fuzzy about at what point rspec is setting the http head variables, and how everything works, so please let me know if I am doing something terribly or subtly wrong. I think it is my confusion about the controller setup process that makes me avoid BDD when it comes to my controllers, and delight in it when it comes to my models. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080214/21f1b507/attachment.html From kamal.fariz at gmail.com Thu Feb 14 19:57:32 2008 From: kamal.fariz at gmail.com (Kamal Fariz) Date: Fri, 15 Feb 2008 08:57:32 +0800 Subject: [rspec-users] Failed specs spike autotest In-Reply-To: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> Message-ID: <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> > Same thing happening here, though I didn't recognize that it's only > after failures. The problem continues whether I use .autotest files or > not. > > This is on a Rails 2.0.2 project, with rspec+rspec_on_rails r3306 in > vendor/plugins, and ZenTest 3.9.1 installed as a gem. I got this too, but didn't bother to find out where and how script/ spec would sneak into the list of files to test. I got this even if i explicitly exclude the file in my .autotest. The quick and dirty thing I did was: def make_test_cmd(files_to_test) return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.select { |i| i != 'script/spec' }.join(' ')}" end in vendor/plugins/rspec/lib/autotest/rspec.rb Regards, Kamal From dchelimsky at gmail.com Thu Feb 14 20:15:24 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 14 Feb 2008 20:15:24 -0500 Subject: [rspec-users] Failed specs spike autotest In-Reply-To: <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> Message-ID: <57c63afe0802141715rd561240xb2f793c808c1cb80@mail.gmail.com> On Thu, Feb 14, 2008 at 7:57 PM, Kamal Fariz wrote: > > Same thing happening here, though I didn't recognize that it's only > > after failures. The problem continues whether I use .autotest files or > > not. > > > > This is on a Rails 2.0.2 project, with rspec+rspec_on_rails r3306 in > > vendor/plugins, and ZenTest 3.9.1 installed as a gem. > > > I got this too, but didn't bother to find out where and how script/ > spec would sneak into the list of files to test. I got this even if i > explicitly exclude the file in my .autotest. > > The quick and dirty thing I did was: > > def make_test_cmd(files_to_test) > return "#{ruby} -S #{spec_command} #{add_options_if_present} > #{files_to_test.keys.flatten.select { |i| i != 'script/spec' }.join(' > ')}" > end > > in vendor/plugins/rspec/lib/autotest/rspec.rb Thanks for the workaround. Looking into fixing this for real. > > Regards, > Kamal > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From raasdnil at gmail.com Thu Feb 14 21:45:31 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Fri, 15 Feb 2008 13:45:31 +1100 Subject: [rspec-users] Spec'ing Rails request.env params Message-ID: <57a815bf0802141845w582a6ee1o71b325ba60a06968@mail.gmail.com> I have an internal system that has a rails controller action that needs to behave differently based on browser type reported by request.env['HTTP_USER_AGENT'] But I can't find a way to stub! mock or set this setting from within a spec. Looked through Test::Unit and can't find a straight forward way in there either. Anyone had any luck with this? Mikel From pergesu at gmail.com Thu Feb 14 22:52:11 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 14 Feb 2008 19:52:11 -0800 Subject: [rspec-users] Spec'ing Rails request.env params In-Reply-To: <57a815bf0802141845w582a6ee1o71b325ba60a06968@mail.gmail.com> References: <57a815bf0802141845w582a6ee1o71b325ba60a06968@mail.gmail.com> Message-ID: <810a540e0802141952w1d7ecb58nd6c67cfdb7863c64@mail.gmail.com> On Thu, Feb 14, 2008 at 6:45 PM, Mikel Lindsaar wrote: > I have an internal system that has a rails controller action that > needs to behave differently based on browser type reported by > request.env['HTTP_USER_AGENT'] > > But I can't find a way to stub! mock or set this setting from within a spec. > > Looked through Test::Unit and can't find a straight forward way in there either. > > Anyone had any luck with this? > > Mikel > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I think you can just set it before making a request... request.env['HTTP_USER_AGENT'] = 'mozilla blah blah' get :new I've never had to do it before, but I just tried it and it seems to work. Pat From raasdnil at gmail.com Thu Feb 14 22:55:50 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Fri, 15 Feb 2008 14:55:50 +1100 Subject: [rspec-users] Spec'ing Rails request.env params In-Reply-To: <810a540e0802141952w1d7ecb58nd6c67cfdb7863c64@mail.gmail.com> References: <57a815bf0802141845w582a6ee1o71b325ba60a06968@mail.gmail.com> <810a540e0802141952w1d7ecb58nd6c67cfdb7863c64@mail.gmail.com> Message-ID: <57a815bf0802141955u6773948bq34f70843b706a872@mail.gmail.com> On Fri, Feb 15, 2008 at 2:52 PM, Pat Maddox wrote: > On Thu, Feb 14, 2008 at 6:45 PM, Mikel Lindsaar wrote: > > I have an internal system that has a rails controller action that > > needs to behave differently based on browser type reported by > > request.env['HTTP_USER_AGENT'] > > > > But I can't find a way to stub! mock or set this setting from within a spec. > I think you can just set it before making a request... > request.env['HTTP_USER_AGENT'] = 'mozilla blah blah' > get :new > I've never had to do it before, but I just tried it and it seems to work. Thanks Pat, it can't be that easy... I am _SURE_ I tried that... In fact, I think it was the first thing I tried... maybe I had a typo and thought "OK, that doesn't work, must be something else..." - don't you _hate_ that ? :D I'll try it out :) Thanks Mikel From vertebrate at gmail.com Thu Feb 14 23:16:05 2008 From: vertebrate at gmail.com (Steve) Date: Fri, 15 Feb 2008 04:16:05 +0000 (UTC) Subject: [rspec-users] Failed specs spike autotest References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> Message-ID: On Fri, 15 Feb 2008 08:57:32 +0800, Kamal Fariz wrote: > > I got this too, but didn't bother to find out where and how script/ spec > would sneak into the list of files to test. I got this even if i > explicitly exclude the file in my .autotest. > > The quick and dirty thing I did was: > > def make_test_cmd(files_to_test) > return "#{ruby} -S #{spec_command} #{add_options_if_present} > #{files_to_test.keys.flatten.select { |i| i != 'script/spec' }.join(' > ')}" > end > > in vendor/plugins/rspec/lib/autotest/rspec.rb Is perhaps something else required? If I put this in autotest just keeps running all of my specs repeatedly. It doesn't wait for a file change to signal it to try running some explicit spec again. It does put out the first line minus the script/spec at the end before launching into all of that. I think it then thinks that perhaps the broken specs are fixed, so that's why it then tries to run all of the specs again. Finished in 15.703733 seconds 398 examples, 1 failure, 1 pending /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts spec/views/users/ index.html.haml_spec.rb etc... Thanks, Steve From vertebrate at gmail.com Thu Feb 14 23:50:39 2008 From: vertebrate at gmail.com (Steve) Date: Fri, 15 Feb 2008 04:50:39 +0000 (UTC) Subject: [rspec-users] Wrong ZenTest being used? References: Message-ID: On Thu, 14 Feb 2008 17:53:42 +0000, Steve wrote: > When I try to run autotest I get the following error: > > loading autotest/rails_rspec > /usr/local/lib/site_ruby/1.8/rubygems.rb:319:in `activate': can't > activate ZenTest (= 3.7.1), already activated ZenTest-3.9.1] > (Gem::Exception) > > This is after just upgrading to the latest of everything from a > previously working much earlier rev of rspec/rails, and zentest. I'm > guessing something old is lingering around. Where would I be best off > looking? This was a false alarm caused by something in my ~/.autotest file that just needed updating for 3.9.1. Sorry for the interruption. From dchelimsky at gmail.com Fri Feb 15 00:31:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Feb 2008 00:31:23 -0500 Subject: [rspec-users] Failed specs spike autotest In-Reply-To: References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> Message-ID: <57c63afe0802142131t7993047cvd198809c9bb37e3b@mail.gmail.com> I found the source of the problem and I'm working on a fix. On Thu, Feb 14, 2008 at 11:16 PM, Steve wrote: > On Fri, 15 Feb 2008 08:57:32 +0800, Kamal Fariz wrote: > > > > I got this too, but didn't bother to find out where and how script/ spec > > would sneak into the list of files to test. I got this even if i > > explicitly exclude the file in my .autotest. > > > > The quick and dirty thing I did was: > > > > def make_test_cmd(files_to_test) > > return "#{ruby} -S #{spec_command} #{add_options_if_present} > > #{files_to_test.keys.flatten.select { |i| i != 'script/spec' }.join(' > > ')}" > > end > > > > in vendor/plugins/rspec/lib/autotest/rspec.rb > > Is perhaps something else required? If I put this in autotest just keeps > running all of my specs repeatedly. It doesn't wait for a file change to > signal it to try running some explicit spec again. It does put out the > first line minus the script/spec at the end before launching into all of > that. I think it then thinks that perhaps the broken specs are fixed, so > that's why it then tries to run all of the specs again. > > Finished in 15.703733 seconds > > 398 examples, 1 failure, 1 pending > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts spec/views/users/ > index.html.haml_spec.rb etc... > > Thanks, > Steve > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From will.sargent at gmail.com Fri Feb 15 00:35:58 2008 From: will.sargent at gmail.com (Will Sargent) Date: Thu, 14 Feb 2008 21:35:58 -0800 Subject: [rspec-users] specdoc and taskpaper In-Reply-To: References: Message-ID: On Thu, Feb 14, 2008 at 2:09 PM, Colin Campbell-McPherson wrote: > I use task paper and love it. Definitely the fastest way to throw in todo > items. I wouldn't call the format yaml-ish though. Here's an example: > I use Toodledo myself. Works from anywhere, including iPhone, and there's even a command line client in Ruby for it. (I wrote it myself, but it's still pretty cool.) Will. From dchelimsky at gmail.com Fri Feb 15 01:07:27 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Feb 2008 01:07:27 -0500 Subject: [rspec-users] Failed specs spike autotest In-Reply-To: <57c63afe0802142131t7993047cvd198809c9bb37e3b@mail.gmail.com> References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> <57c63afe0802142131t7993047cvd198809c9bb37e3b@mail.gmail.com> Message-ID: <57c63afe0802142207jeb84960xbb1a46553fe53f71@mail.gmail.com> The source of the bug was a patch that we applied a while back. This was after the 1.1.3 release, so if you're using 1.1.3 you're fine. If you're using trunk, go ahead and update and you should be fine now. On Fri, Feb 15, 2008 at 12:31 AM, David Chelimsky wrote: > I found the source of the problem and I'm working on a fix. > > > > On Thu, Feb 14, 2008 at 11:16 PM, Steve wrote: > > On Fri, 15 Feb 2008 08:57:32 +0800, Kamal Fariz wrote: > > > > > > I got this too, but didn't bother to find out where and how script/ spec > > > would sneak into the list of files to test. I got this even if i > > > explicitly exclude the file in my .autotest. > > > > > > The quick and dirty thing I did was: > > > > > > def make_test_cmd(files_to_test) > > > return "#{ruby} -S #{spec_command} #{add_options_if_present} > > > #{files_to_test.keys.flatten.select { |i| i != 'script/spec' }.join(' > > > ')}" > > > end > > > > > > in vendor/plugins/rspec/lib/autotest/rspec.rb > > > > Is perhaps something else required? If I put this in autotest just keeps > > running all of my specs repeatedly. It doesn't wait for a file change to > > signal it to try running some explicit spec again. It does put out the > > first line minus the script/spec at the end before launching into all of > > that. I think it then thinks that perhaps the broken specs are fixed, so > > that's why it then tries to run all of the specs again. > > > > Finished in 15.703733 seconds > > > > 398 examples, 1 failure, 1 pending > > > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts spec/views/users/ > > index.html.haml_spec.rb etc... > > > > Thanks, > > Steve > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From kamal.fariz at gmail.com Fri Feb 15 02:09:04 2008 From: kamal.fariz at gmail.com (Kamal Fariz) Date: Fri, 15 Feb 2008 15:09:04 +0800 Subject: [rspec-users] Autotest setup to run Story Runner? Message-ID: <54EB15AE-9C47-4D02-A765-C311F08FECBE@gmail.com> Has anyone looked at hooking up the Story Runner to Autotest? Currently, the autotest hooks that rspec uses explicitly runs ./script/ spec, which when pointed to a story runner file doesn't do anything. (In fact, the generated spec.opts has an incompatible --format option - changing progress to just p works as it maps to plain in story runner) Here's how I think it can be mapped. I have a fairly simple convention: 1. Match stories/stories/(.*), rerun stories/stories/basename($1).rb (i name my story files with .story extension) 2. Match stories/(helper|all).rb, rerun stories/all.rb 3. Match stories/steps/(.*)_step.rb, rerun stories/stories/ basename($1).rb You can be fancier for steps if you like to break them up, like looking into which Story Runner uses those steps. Can Story Runner run a specific scenario in a story? Like how Spec Runner can just execute a particular example. Regards, Kamal p/s: I'm using rstakeout currently to run my stories and autotest to run my specs. It'll be great if they can context-switch in the same autotest instance. From address4spams at 21croissants.com Fri Feb 15 08:03:56 2008 From: address4spams at 21croissants.com (21croissants) Date: Fri, 15 Feb 2008 05:03:56 -0800 (PST) Subject: [rspec-users] Re ducing frequency of autotest file checks Message-ID: <15500400.post@talk.nabble.com> I am using RSpec 1.1.3 with ZenTest-3.9.1 and I wanted to share my set up. If your cpu is at 100% when autotest is running and the fan noise is getting too much, don't worry there's something you can do. You can reduce the frequency at which autotest checks for changes on your file system by adding an initialize hook in your ~/.autotest configuration: gedit ~/.autotest Autotest.add_hook :initialize do |at| # Reducing frequency of autotest file checks too 30 seconds. Default is 1s which makes my laptop very hoooot at.sleep = 30 # Ignore files with suffix %w{.svn .hg .git .rhtml .png .txt .sh .project .rjs .rake .jpg .xml .xlst}.each { |exception| at.add_exception(exception) } end More information about autotest hooks in David Chelimsky blog. I also posted this trick to my blog (with some links) at http://21croissants.blogspot.com/2008/02/reducing-frequency-of-autotest-file.html -- View this message in context: http://www.nabble.com/Reducing-frequency-of-autotest-file-checks-tp15500400p15500400.html Sent from the rspec-users mailing list archive at Nabble.com. From philodespotos at gmail.com Fri Feb 15 08:12:03 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Fri, 15 Feb 2008 07:12:03 -0600 Subject: [rspec-users] Failed specs spike autotest In-Reply-To: <57c63afe0802142207jeb84960xbb1a46553fe53f71@mail.gmail.com> References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> <57c63afe0802142131t7993047cvd198809c9bb37e3b@mail.gmail.com> <57c63afe0802142207jeb84960xbb1a46553fe53f71@mail.gmail.com> Message-ID: <60f3810c0802150512t7563404dq75ed520cd1c2121b@mail.gmail.com> Thank you much. On Fri, Feb 15, 2008 at 12:07 AM, David Chelimsky wrote: > The source of the bug was a patch that we applied a while back. This > was after the 1.1.3 release, so if you're using 1.1.3 you're fine. If > you're using trunk, go ahead and update and you should be fine now. > > > > On Fri, Feb 15, 2008 at 12:31 AM, David Chelimsky wrote: > > I found the source of the problem and I'm working on a fix. > > > > > > > > On Thu, Feb 14, 2008 at 11:16 PM, Steve wrote: > > > On Fri, 15 Feb 2008 08:57:32 +0800, Kamal Fariz wrote: > > > > > > > > I got this too, but didn't bother to find out where and how script/ spec > > > > would sneak into the list of files to test. I got this even if i > > > > explicitly exclude the file in my .autotest. > > > > > > > > The quick and dirty thing I did was: > > > > > > > > def make_test_cmd(files_to_test) > > > > return "#{ruby} -S #{spec_command} #{add_options_if_present} > > > > #{files_to_test.keys.flatten.select { |i| i != 'script/spec' }.join(' > > > > ')}" > > > > end > > > > > > > > in vendor/plugins/rspec/lib/autotest/rspec.rb > > > > > > Is perhaps something else required? If I put this in autotest just keeps > > > running all of my specs repeatedly. It doesn't wait for a file change to > > > signal it to try running some explicit spec again. It does put out the > > > first line minus the script/spec at the end before launching into all of > > > that. I think it then thinks that perhaps the broken specs are fixed, so > > > that's why it then tries to run all of the specs again. > > > > > > Finished in 15.703733 seconds > > > > > > 398 examples, 1 failure, 1 pending > > > > > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts > > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts spec/views/users/ > > > index.html.haml_spec.rb etc... > > > > > > Thanks, > > > Steve > > > > > > > > > > > > _______________________________________________ > > > 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 kiran.soumya at gmail.com Fri Feb 15 07:49:35 2008 From: kiran.soumya at gmail.com (Kiran1009) Date: Fri, 15 Feb 2008 04:49:35 -0800 (PST) Subject: [rspec-users] need to learn by example In-Reply-To: <3E0B5C74-20EC-4B63-831F-5BA4647B8AC5@mac.com> References: <3E0B5C74-20EC-4B63-831F-5BA4647B8AC5@mac.com> Message-ID: <15500392.post@talk.nabble.com> Hi, This is most USEFUL... http://www.oreillynet.com/pub/a/ruby/2007/08/09/behavior-driven-development-using-ruby-part-1.html Check this out... Thanks&Regards. Kiran. Chuck Remes-3 wrote: > > I'm starting a new project which I would like to use as a learning > opportunity for BDD. I've searched through the archives of this list > for past pointers on web sites and books to peruse but I haven't found > very many suggestions on good projects "in the wild" which put BDD on > display. > > I'm hoping this thread can change that minor oversight. > > Please post your suggestions for ruby projects (or projects in other > languages) that are good examples of BDD in action. I learn best by > example; this thread is for all the other lurkers who do too. > > cr > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/need-to-learn-by-example-tp15458745p15500392.html Sent from the rspec-users mailing list archive at Nabble.com. From kiran.soumya at gmail.com Fri Feb 15 08:31:52 2008 From: kiran.soumya at gmail.com (Kiran1009) Date: Fri, 15 Feb 2008 05:31:52 -0800 (PST) Subject: [rspec-users] need to learn by example Message-ID: <15500392.post@talk.nabble.com> Hi, This is most USEFUL... http://www.oreillynet.com/pub/a/ruby/2007/08/09/behavior-driven-development-using-ruby-part-1.html Check this out... Thanks&Regards. Kiran. Chuck Remes-3 wrote: > > I'm starting a new project which I would like to use as a learning > opportunity for BDD. I've searched through the archives of this list > for past pointers on web sites and books to peruse but I haven't found > very many suggestions on good projects "in the wild" which put BDD on > display. > > I'm hoping this thread can change that minor oversight. > > Please post your suggestions for ruby projects (or projects in other > languages) that are good examples of BDD in action. I learn best by > example; this thread is for all the other lurkers who do too. > > cr > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/need-to-learn-by-example-tp15458745p15500392.html Sent from the rspec-users mailing list archive at Nabble.com. From kiran.soumya at gmail.com Fri Feb 15 09:14:35 2008 From: kiran.soumya at gmail.com (Kiran1009) Date: Fri, 15 Feb 2008 06:14:35 -0800 (PST) Subject: [rspec-users] need to learn by example Message-ID: <15500392.post@talk.nabble.com> Hi, This is most USEFUL... http://www.oreillynet.com/pub/a/ruby/2007/08/09/behavior-driven-development-using-ruby-part-1.html Check this out... Thanks&Regards. Kiran. Chuck Remes-3 wrote: > > I'm starting a new project which I would like to use as a learning > opportunity for BDD. I've searched through the archives of this list > for past pointers on web sites and books to peruse but I haven't found > very many suggestions on good projects "in the wild" which put BDD on > display. > > I'm hoping this thread can change that minor oversight. > > Please post your suggestions for ruby projects (or projects in other > languages) that are good examples of BDD in action. I learn best by > example; this thread is for all the other lurkers who do too. > > cr > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/need-to-learn-by-example-tp15458745p15500392.html Sent from the rspec-users mailing list archive at Nabble.com. From vertebrate at gmail.com Fri Feb 15 09:24:22 2008 From: vertebrate at gmail.com (Steve) Date: Fri, 15 Feb 2008 14:24:22 +0000 (UTC) Subject: [rspec-users] Failed specs spike autotest References: <60f3810c0802141632r624c7e70uaf7a3f82ee7ca500@mail.gmail.com> <31E26938-879B-43B9-99C2-C50A410669DE@gmail.com> <57c63afe0802142131t7993047cvd198809c9bb37e3b@mail.gmail.com> <57c63afe0802142207jeb84960xbb1a46553fe53f71@mail.gmail.com> Message-ID: On Fri, 15 Feb 2008 01:07:27 -0500, David Chelimsky wrote: > The source of the bug was a patch that we applied a while back. This was > after the 1.1.3 release, so if you're using 1.1.3 you're fine. If you're > using trunk, go ahead and update and you should be fine now. > Thanks, I appreciate it. It works great now. From kamal.fariz at gmail.com Fri Feb 15 09:44:45 2008 From: kamal.fariz at gmail.com (Kamal Fariz) Date: Fri, 15 Feb 2008 22:44:45 +0800 Subject: [rspec-users] Re ducing frequency of autotest file checks In-Reply-To: <15500400.post@talk.nabble.com> References: <15500400.post@talk.nabble.com> Message-ID: <65F8F219-4610-4E4D-BBD9-0176C4B9895B@gmail.com> > You can reduce the frequency at which autotest checks for changes on > your > file system by adding an initialize hook in your ~/.autotest > configuration: If you are running Leopard, you might be interested in a hack a co- worker of mine used to tame autotest. He replaced autotest's polling with listening to filesystem events instead with a bit of RubyCocoa glue. Check it out at http://rails.aizatto.com/2007/11/28/taming-the-autotest-beast-with-fsevents Regards, Kamal From dchelimsky at gmail.com Fri Feb 15 10:11:15 2008 From: dchelimsky at gmail.com (dchelimsky at gmail.com) Date: Fri, 15 Feb 2008 07:11:15 -0800 (PST) Subject: [rspec-users] test Message-ID: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> test From colin at logaan.net Fri Feb 15 10:16:37 2008 From: colin at logaan.net (Colin Campbell-McPherson) Date: Sat, 16 Feb 2008 00:16:37 +0900 Subject: [rspec-users] test In-Reply-To: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> References: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> Message-ID: Now implement and refractor and you're correctly doing BDD. On 16/02/2008, at 12:11 AM, dchelimsky at gmail.com wrote: > test > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mike at vincent.ws Fri Feb 15 10:25:53 2008 From: mike at vincent.ws (Mike Vincent) Date: Fri, 15 Feb 2008 09:25:53 -0600 Subject: [rspec-users] test In-Reply-To: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> References: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> Message-ID: <2386bfa00802150725r1af06c5ajbf04d069c8809b32@mail.gmail.com> On Fri, Feb 15, 2008 at 9:11 AM, dchelimsky at gmail.com wrote: > test 1 tests, 0 assertions, 0 failures, 0 errors From dchelimsky at gmail.com Fri Feb 15 10:27:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 15 Feb 2008 10:27:40 -0500 Subject: [rspec-users] test In-Reply-To: <2386bfa00802150725r1af06c5ajbf04d069c8809b32@mail.gmail.com> References: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> <2386bfa00802150725r1af06c5ajbf04d069c8809b32@mail.gmail.com> Message-ID: <57c63afe0802150727q785bd4b1u1a40608690d44c42@mail.gmail.com> D'oh! Let's try that again. behave On Fri, Feb 15, 2008 at 10:25 AM, Mike Vincent wrote: > On Fri, Feb 15, 2008 at 9:11 AM, dchelimsky at gmail.com > wrote: > > test > > 1 tests, 0 assertions, 0 failures, 0 errors > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pritchie at videotron.ca Fri Feb 15 11:28:32 2008 From: pritchie at videotron.ca (Patrick Ritchie) Date: Fri, 15 Feb 2008 11:28:32 -0500 Subject: [rspec-users] Ticket #274 patch for --drb in spec.opts In-Reply-To: <47AF2832.6040203@videotron.ca> References: <47AF2832.6040203@videotron.ca> Message-ID: <47B5BDB0.6080701@videotron.ca> Bug report from Scott Taylor on this: http://rspec.lighthouseapp.com/projects/5645/tickets/274 > Hi All, > > I submitted a patch last week to fix a bug with --drb not working if > it's specified in spec.opts, this causes autotest to run obscenely > slowly out of the box on my machine. > > Please let me know if you need anything else from me on this. > > Cheers! > Patrick > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From rick.denatale at gmail.com Fri Feb 15 11:59:45 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 15 Feb 2008 11:59:45 -0500 Subject: [rspec-users] test In-Reply-To: <57c63afe0802150727q785bd4b1u1a40608690d44c42@mail.gmail.com> References: <5d094176-0ab0-48df-af1d-552f4dfd5678@d4g2000prg.googlegroups.com> <2386bfa00802150725r1af06c5ajbf04d069c8809b32@mail.gmail.com> <57c63afe0802150727q785bd4b1u1a40608690d44c42@mail.gmail.com> Message-ID: On Fri, Feb 15, 2008 at 10:27 AM, David Chelimsky wrote: > D'oh! Let's try that again. > > behave Austin "Chelimsky" Powers ?! -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From cremes.devlist at mac.com Fri Feb 15 12:15:41 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Fri, 15 Feb 2008 11:15:41 -0600 Subject: [rspec-users] need to learn by example In-Reply-To: <15500392.post@talk.nabble.com> References: <15500392.post@talk.nabble.com> Message-ID: On Feb 15, 2008, at 8:14 AM, Kiran1009 wrote: > > Hi, > > This is most USEFUL... > > http://www.oreillynet.com/pub/a/ruby/2007/08/09/behavior-driven-development-using-ruby-part-1.html > > Check this out... Excellent pointer!! Thank you. I'll see if this series of articles can be added to an rspec wiki (if there is one). cr From vertebrate at gmail.com Fri Feb 15 18:06:55 2008 From: vertebrate at gmail.com (Steve) Date: Fri, 15 Feb 2008 23:06:55 +0000 (UTC) Subject: [rspec-users] Run all tests after success Message-ID: I seem to remember when I was running a previous version of rspec and autotest that when a set of specs passed for some changed files, that all of the specs would then be run automatically. Particularly when tests had previously failed. It's not doing it now on trunk. Was I imagining this, or is something wrong? Thanks, Steve From ivo.dancet at gmail.com Sat Feb 16 08:51:06 2008 From: ivo.dancet at gmail.com (Ivo Dancet) Date: Sat, 16 Feb 2008 14:51:06 +0100 Subject: [rspec-users] can't get (r)spec to work in non-rails project Message-ID: Hi I can't seem to get rspec and autotest to work in a small test project. The spec command doesn't load the implementation file. I found some info about non-rails projects with rspec, but these did not solve my problem. I have the following files: project_map/ lib/todoist.rb spec/todoist_spec.rb in todoist.rb I have a Todoist class, in the spec I have a describe Todoist with one example Autotest runs and does reload files in /lib and /spec, it's the spec (spec spec/todoist_spec.rb) that crashes with 'uninitialized constant Todoist'. Backtrace: ./spec/todoist_spec.rb:3: uninitialized constant Todoist (NameError) from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ example_group_runner.rb:14:in `load' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ example_group_runner.rb:14:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ example_group_runner.rb:13:in `each' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ example_group_runner.rb:13:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ options.rb:84:in `run_examples' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ command_line.rb:19:in `run' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec:4 from /usr/bin/spec:16:in `load' from /usr/bin/spec:16 rspec 1.1.3 (run as gem) standard Mac OS X Leopard ruby (1.8.6) Any solutions? Regards From dchelimsky at gmail.com Sat Feb 16 08:59:04 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 08:59:04 -0500 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: References: Message-ID: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> On Feb 16, 2008 8:51 AM, Ivo Dancet wrote: > Hi > > I can't seem to get rspec and autotest to work in a small test > project. The spec command doesn't load the implementation file. I > found some info about non-rails projects with rspec, but these did not > solve my problem. > > I have the following files: > > project_map/ > lib/todoist.rb > spec/todoist_spec.rb > > in todoist.rb I have a Todoist class, in the spec I have a describe > Todoist with one example > > Autotest runs and does reload files in /lib and /spec, it's the spec > (spec spec/todoist_spec.rb) that crashes with 'uninitialized constant > Todoist'. Are you requiring the implementation file from the spec file? > > Backtrace: > ./spec/todoist_spec.rb:3: uninitialized constant Todoist (NameError) > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > example_group_runner.rb:14:in `load' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > example_group_runner.rb:14:in `load_files' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > example_group_runner.rb:13:in `each' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > example_group_runner.rb:13:in `load_files' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > options.rb:84:in `run_examples' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > command_line.rb:19:in `run' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec:4 > from /usr/bin/spec:16:in `load' > from /usr/bin/spec:16 > > rspec 1.1.3 (run as gem) > standard Mac OS X Leopard ruby (1.8.6) > > Any solutions? > Regards > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ivo.dancet at gmail.com Sat Feb 16 09:10:05 2008 From: ivo.dancet at gmail.com (Ivo Dancet) Date: Sat, 16 Feb 2008 15:10:05 +0100 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> Message-ID: <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> That was very quick, thanks! No, I was not (and it works when I require the file), I thought rspec would have some method to load the implementation file (as I followed the naming convention) like it does in rails. Op 16-feb-08, om 14:59 heeft David Chelimsky het volgende geschreven: > On Feb 16, 2008 8:51 AM, Ivo Dancet wrote: >> Hi >> >> I can't seem to get rspec and autotest to work in a small test >> project. The spec command doesn't load the implementation file. I >> found some info about non-rails projects with rspec, but these did >> not >> solve my problem. >> >> I have the following files: >> >> project_map/ >> lib/todoist.rb >> spec/todoist_spec.rb >> >> in todoist.rb I have a Todoist class, in the spec I have a describe >> Todoist with one example >> >> Autotest runs and does reload files in /lib and /spec, it's the spec >> (spec spec/todoist_spec.rb) that crashes with 'uninitialized constant >> Todoist'. > > Are you requiring the implementation file from the spec file? > >> >> Backtrace: >> ./spec/todoist_spec.rb:3: uninitialized constant Todoist >> (NameError) >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >> example_group_runner.rb:14:in `load' >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >> example_group_runner.rb:14:in `load_files' >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >> example_group_runner.rb:13:in `each' >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >> example_group_runner.rb:13:in `load_files' >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >> options.rb:84:in `run_examples' >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >> command_line.rb:19:in `run' >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec:4 >> from /usr/bin/spec:16:in `load' >> from /usr/bin/spec:16 >> >> rspec 1.1.3 (run as gem) >> standard Mac OS X Leopard ruby (1.8.6) >> >> Any solutions? >> Regards >> >> _______________________________________________ >> 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 dchelimsky at gmail.com Sat Feb 16 09:13:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 09:13:18 -0500 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> Message-ID: <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> On Feb 16, 2008 9:10 AM, Ivo Dancet wrote: > That was very quick, thanks! > > No, I was not (and it works when I require the file), I thought rspec > would have some method to load the implementation file (as I followed > the naming convention) like it does in rails. What mislead you to believe such a thing? > > Op 16-feb-08, om 14:59 heeft David Chelimsky het volgende geschreven: > > > > On Feb 16, 2008 8:51 AM, Ivo Dancet wrote: > >> Hi > >> > >> I can't seem to get rspec and autotest to work in a small test > >> project. The spec command doesn't load the implementation file. I > >> found some info about non-rails projects with rspec, but these did > >> not > >> solve my problem. > >> > >> I have the following files: > >> > >> project_map/ > >> lib/todoist.rb > >> spec/todoist_spec.rb > >> > >> in todoist.rb I have a Todoist class, in the spec I have a describe > >> Todoist with one example > >> > >> Autotest runs and does reload files in /lib and /spec, it's the spec > >> (spec spec/todoist_spec.rb) that crashes with 'uninitialized constant > >> Todoist'. > > > > Are you requiring the implementation file from the spec file? > > > >> > >> Backtrace: > >> ./spec/todoist_spec.rb:3: uninitialized constant Todoist > >> (NameError) > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >> example_group_runner.rb:14:in `load' > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >> example_group_runner.rb:14:in `load_files' > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >> example_group_runner.rb:13:in `each' > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >> example_group_runner.rb:13:in `load_files' > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >> options.rb:84:in `run_examples' > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >> command_line.rb:19:in `run' > >> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec:4 > >> from /usr/bin/spec:16:in `load' > >> from /usr/bin/spec:16 > >> > >> rspec 1.1.3 (run as gem) > >> standard Mac OS X Leopard ruby (1.8.6) > >> > >> Any solutions? > >> Regards > >> > >> _______________________________________________ > >> 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 dchelimsky at gmail.com Sat Feb 16 10:23:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 10:23:53 -0500 Subject: [rspec-users] Run all tests after success In-Reply-To: References: Message-ID: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> On Feb 15, 2008 6:06 PM, Steve wrote: > I seem to remember when I was running a previous version of rspec and > autotest that when a set of specs passed for some changed files, that all > of the specs would then be run automatically. Particularly when tests had > previously failed. It's not doing it now on trunk. Was I imagining this, > or is something wrong? Something was wrong, but it's fixed now in trunk. > > Thanks, > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ivo.dancet at gmail.com Sat Feb 16 11:07:48 2008 From: ivo.dancet at gmail.com (Ivo Dancet) Date: Sat, 16 Feb 2008 17:07:48 +0100 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> Message-ID: <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> Op 16-feb-08, om 15:13 heeft David Chelimsky het volgende geschreven: > On Feb 16, 2008 9:10 AM, Ivo Dancet wrote: >> That was very quick, thanks! >> >> No, I was not (and it works when I require the file), I thought rspec >> would have some method to load the implementation file (as I followed >> the naming convention) like it does in rails. > > What mislead you to believe such a thing? such a thing as in: rspec in rails doesn't work the way I thought, or as in: why would it work the same way or as in: 'naming convention? there is no such thing'! I guess the answer on all three possibilities is: I don't really know much about the internals of rspec... I'm working with it for about two months now and I really love it. With rails it just works, but now that I want to use rspec outside of rails, I couldn't find what I really need to do easily and I may have jumped to conclusions... > > >> >> Op 16-feb-08, om 14:59 heeft David Chelimsky het volgende geschreven: >> >> >>> On Feb 16, 2008 8:51 AM, Ivo Dancet wrote: >>>> Hi >>>> >>>> I can't seem to get rspec and autotest to work in a small test >>>> project. The spec command doesn't load the implementation file. I >>>> found some info about non-rails projects with rspec, but these did >>>> not >>>> solve my problem. >>>> >>>> I have the following files: >>>> >>>> project_map/ >>>> lib/todoist.rb >>>> spec/todoist_spec.rb >>>> >>>> in todoist.rb I have a Todoist class, in the spec I have a describe >>>> Todoist with one example >>>> >>>> Autotest runs and does reload files in /lib and /spec, it's the >>>> spec >>>> (spec spec/todoist_spec.rb) that crashes with 'uninitialized >>>> constant >>>> Todoist'. >>> >>> Are you requiring the implementation file from the spec file? >>> >>>> >>>> Backtrace: >>>> ./spec/todoist_spec.rb:3: uninitialized constant Todoist >>>> (NameError) >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >>>> example_group_runner.rb:14:in `load' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >>>> example_group_runner.rb:14:in `load_files' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >>>> example_group_runner.rb:13:in `each' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >>>> example_group_runner.rb:13:in `load_files' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >>>> options.rb:84:in `run_examples' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ >>>> command_line.rb:19:in `run' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec:4 >>>> from /usr/bin/spec:16:in `load' >>>> from /usr/bin/spec:16 >>>> >>>> rspec 1.1.3 (run as gem) >>>> standard Mac OS X Leopard ruby (1.8.6) >>>> >>>> Any solutions? >>>> Regards >>>> >>>> _______________________________________________ >>>> 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 From dchelimsky at gmail.com Sat Feb 16 13:06:00 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 13:06:00 -0500 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> Message-ID: <57c63afe0802161006w79a296f4w6078150bad5bd198@mail.gmail.com> On Feb 16, 2008 11:07 AM, Ivo Dancet wrote: > > Op 16-feb-08, om 15:13 heeft David Chelimsky het volgende geschreven: > > > On Feb 16, 2008 9:10 AM, Ivo Dancet wrote: > >> That was very quick, thanks! > >> > >> No, I was not (and it works when I require the file), I thought rspec > >> would have some method to load the implementation file (as I followed > >> the naming convention) like it does in rails. > > > > What mislead you to believe such a thing? > > such a thing as in: rspec in rails doesn't work the way I thought, or > as in: why would it work the same way or as in: 'naming convention? > there is no such thing'! > > I guess the answer on all three possibilities is: I don't really know > much about the internals of rspec... I'm working with it for about two > months now and I really love it. With rails it just works, but now > that I want to use rspec outside of rails, I couldn't find what I > really need to do easily and I may have jumped to conclusions... The rspec/rails plugin works because there are generators which create the files for you, not because of any auto-loading facility. The generated files have require statements that get you the right stuff. We could conceivably add generators for other-than-rails apps. The reason we have them in rails apps is because there is already a generation facility that is easy to hook into. If we were to add generators, how do you think they should work? Where should they live? Part of the spec command? A new shell command? A separate plugin? > > > >> > >> Op 16-feb-08, om 14:59 heeft David Chelimsky het volgende geschreven: > >> > >> > >>> On Feb 16, 2008 8:51 AM, Ivo Dancet wrote: > >>>> Hi > >>>> > >>>> I can't seem to get rspec and autotest to work in a small test > >>>> project. The spec command doesn't load the implementation file. I > >>>> found some info about non-rails projects with rspec, but these did > >>>> not > >>>> solve my problem. > >>>> > >>>> I have the following files: > >>>> > >>>> project_map/ > >>>> lib/todoist.rb > >>>> spec/todoist_spec.rb > >>>> > >>>> in todoist.rb I have a Todoist class, in the spec I have a describe > >>>> Todoist with one example > >>>> > >>>> Autotest runs and does reload files in /lib and /spec, it's the > >>>> spec > >>>> (spec spec/todoist_spec.rb) that crashes with 'uninitialized > >>>> constant > >>>> Todoist'. > >>> > >>> Are you requiring the implementation file from the spec file? > >>> > >>>> > >>>> Backtrace: > >>>> ./spec/todoist_spec.rb:3: uninitialized constant Todoist > >>>> (NameError) > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >>>> example_group_runner.rb:14:in `load' > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >>>> example_group_runner.rb:14:in `load_files' > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >>>> example_group_runner.rb:13:in `each' > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >>>> example_group_runner.rb:13:in `load_files' > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >>>> options.rb:84:in `run_examples' > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/lib/spec/runner/ > >>>> command_line.rb:19:in `run' > >>>> from /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec:4 > >>>> from /usr/bin/spec:16:in `load' > >>>> from /usr/bin/spec:16 > >>>> > >>>> rspec 1.1.3 (run as gem) > >>>> standard Mac OS X Leopard ruby (1.8.6) > >>>> > >>>> Any solutions? > >>>> Regards > >>>> > >>>> _______________________________________________ > >>>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From vertebrate at gmail.com Sat Feb 16 13:13:51 2008 From: vertebrate at gmail.com (Steve) Date: Sat, 16 Feb 2008 18:13:51 +0000 (UTC) Subject: [rspec-users] Run all tests after success References: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> Message-ID: On Sat, 16 Feb 2008 10:23:53 -0500, David Chelimsky wrote: > On Feb 15, 2008 6:06 PM, Steve > wrote: >> I seem to remember when I was running a previous version of rspec and >> autotest that when a set of specs passed for some changed files, that >> all of the specs would then be run automatically. Particularly when >> tests had previously failed. It's not doing it now on trunk. Was I >> imagining this, or is something wrong? > > Something was wrong, but it's fixed now in trunk. > What was the nature of the changes. I just updated to r3312, and when I run autotest I get: loading autotest/rails_rspec /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts No server is running I've never seen the "No server is running" message before. Steve From vertebrate at gmail.com Sat Feb 16 13:21:39 2008 From: vertebrate at gmail.com (Steve) Date: Sat, 16 Feb 2008 18:21:39 +0000 (UTC) Subject: [rspec-users] Run all tests after success References: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> Message-ID: On Sat, 16 Feb 2008 18:13:51 +0000, Steve wrote: > What was the nature of the changes. I just updated to r3312, and when I > run autotest I get: > > loading autotest/rails_rspec > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts No > server is running > > I've never seen the "No server is running" message before. Cancel that. I had --drb in spec.opts, and it looks like there was a commit to make that work. Funny I never noticed that before. From vertebrate at gmail.com Sat Feb 16 13:26:49 2008 From: vertebrate at gmail.com (Steve) Date: Sat, 16 Feb 2008 18:26:49 +0000 (UTC) Subject: [rspec-users] can't get (r)spec to work in non-rails project References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> <57c63afe0802161006w79a296f4w6078150bad5bd198@mail.gmail.com> Message-ID: On Sat, 16 Feb 2008 13:06:00 -0500, David Chelimsky wrote: > > The rspec/rails plugin works because there are generators which create > the files for you, not because of any auto-loading facility. The > generated files have require statements that get you the right stuff. > > We could conceivably add generators for other-than-rails apps. The > reason we have them in rails apps is because there is already a > generation facility that is easy to hook into. > > If we were to add generators, how do you think they should work? Where > should they live? Part of the spec command? A new shell command? A > separate plugin? > I would think just have the spec_helper.rb file for the specs try to load config/rspec.rb or something along those lines. Similar to how rspec for rails just loads the rails env. It would then be up to the user to do the necessary loading in that file. There's really no way to know what crazy way someone might layout their projects. Steve From dchelimsky at gmail.com Sat Feb 16 13:39:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 13:39:03 -0500 Subject: [rspec-users] Run all tests after success In-Reply-To: References: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> Message-ID: <57c63afe0802161039k579d4974q628e0430f7ee84d@mail.gmail.com> On Feb 16, 2008 1:21 PM, Steve wrote: > On Sat, 16 Feb 2008 18:13:51 +0000, Steve wrote: > > What was the nature of the changes. I just updated to r3312, and when I > > run autotest I get: > > > > loading autotest/rails_rspec > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts No > > server is running > > > > I've never seen the "No server is running" message before. > > Cancel that. I had --drb in spec.opts, and it looks like there was a > commit to make that work. Funny I never noticed that before. It was broken until a recent changeset :) > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ivo.dancet at gmail.com Sat Feb 16 13:56:43 2008 From: ivo.dancet at gmail.com (Ivo Dancet) Date: Sat, 16 Feb 2008 19:56:43 +0100 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> <57c63afe0802161006w79a296f4w6078150bad5bd198@mail.gmail.com> Message-ID: <3EDA8E0F-2879-44B9-A070-B9039E0E6DE9@gmail.com> Op 16-feb-08, om 19:26 heeft Steve het volgende geschreven: > On Sat, 16 Feb 2008 13:06:00 -0500, David Chelimsky wrote: >> >> The rspec/rails plugin works because there are generators which >> create >> the files for you, not because of any auto-loading facility. The >> generated files have require statements that get you the right stuff. >> >> We could conceivably add generators for other-than-rails apps. The >> reason we have them in rails apps is because there is already a >> generation facility that is easy to hook into. >> >> If we were to add generators, how do you think they should work? >> Where >> should they live? Part of the spec command? A new shell command? A >> separate plugin? >> > > I would think just have the spec_helper.rb file for the specs try to > load > config/rspec.rb or something along those lines. Similar to how rspec > for > rails just loads the rails env. It would then be up to the user to > do the > necessary loading in that file. There's really no way to know what > crazy > way someone might layout their projects. > > Steve I second that. On the other side, autotest makes some assumptions about the layout of a project (that's how things got mixed up for me), why shouldn't rspec use the same conventions (and still keep the possibility to override conventions in config/rspec). Or it doesn't use conventions but it has a generator that makes a config/rspec file with some standard config in it. From dchelimsky at gmail.com Sat Feb 16 14:26:50 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 14:26:50 -0500 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: <3EDA8E0F-2879-44B9-A070-B9039E0E6DE9@gmail.com> References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> <57c63afe0802161006w79a296f4w6078150bad5bd198@mail.gmail.com> <3EDA8E0F-2879-44B9-A070-B9039E0E6DE9@gmail.com> Message-ID: <57c63afe0802161126x530c71bemfdb68d90fdab4f30@mail.gmail.com> On Feb 16, 2008 1:56 PM, Ivo Dancet wrote: > > Op 16-feb-08, om 19:26 heeft Steve het volgende geschreven: > > > On Sat, 16 Feb 2008 13:06:00 -0500, David Chelimsky wrote: > >> > >> The rspec/rails plugin works because there are generators which > >> create > >> the files for you, not because of any auto-loading facility. The > >> generated files have require statements that get you the right stuff. > >> > >> We could conceivably add generators for other-than-rails apps. The > >> reason we have them in rails apps is because there is already a > >> generation facility that is easy to hook into. > >> > >> If we were to add generators, how do you think they should work? > >> Where > >> should they live? Part of the spec command? A new shell command? A > >> separate plugin? > >> > > > > I would think just have the spec_helper.rb file for the specs try to > > load > > config/rspec.rb or something along those lines. Similar to how rspec > > for > > rails just loads the rails env. It would then be up to the user to > > do the > > necessary loading in that file. There's really no way to know what > > crazy > > way someone might layout their projects. > > > > Steve > > I second that. On the other side, autotest makes some assumptions > about the layout of a project (that's how things got mixed up for me), > why shouldn't rspec use the same conventions (and still keep the > possibility to override conventions in config/rspec). Or it doesn't > use conventions but it has a generator that makes a config/rspec file > with some standard config in it. > I'd be more open to generators than convention-enforcement. The 1-1 mapping promoted by autotest is a very good convention, but is often abused. This is something we discussed a lot in RSpec's early days. As for generators, there are several project-bootstrapping gems out there these days like newgem, mr bones, hoe that will set up a project w/ the basic directories and all the files including the right stuff. Hoe doesn't support rspec out of the box, but newgem and mr bones do. So maybe we don't need one built into RSpec? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.lists at gmail.com Sat Feb 16 16:07:12 2008 From: zach.lists at gmail.com (Zach Moazeni) Date: Sat, 16 Feb 2008 16:07:12 -0500 Subject: [rspec-users] A case study on view specs Message-ID: <4AA70A34-FB67-42BA-9F3E-92F10BE01958@gmail.com> I wanted to thank all the developers working a great testing framework. We switched to rspec on our last project, and haven't looked back. I know testing views is a touchy subject for some. After having a surprisingly great time using them on one of our projects, we decided to adopt it for all of our development work. I wrote a post about our expectations and favorable experiences using them. http://www.simplechatter.com/2008/2/16/ascribe-a-case-study-on-view-specs -Zach From gwtmp01 at mac.com Sat Feb 16 17:19:00 2008 From: gwtmp01 at mac.com (Gary Wright) Date: Sat, 16 Feb 2008 17:19:00 -0500 Subject: [rspec-users] #describe behavior with a module Message-ID: Consider: module X def initialize(a) super() end end describe X do it "is a module" do X.should be_instance_of(Module) end end This generates an error because #describe tries to include X into the test harness and the test harness doesn't know about the extra argument to #initialize. The work around is to just use 'describe "X" do' but I spent a bit of time just trying to figure out what was going on. Why is #describe trying to include the module? Gary Wright From dchelimsky at gmail.com Sat Feb 16 18:10:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Feb 2008 18:10:25 -0500 Subject: [rspec-users] #describe behavior with a module In-Reply-To: References: Message-ID: <57c63afe0802161510k3a543990tde858577cb476dee@mail.gmail.com> On Feb 16, 2008 5:19 PM, Gary Wright wrote: > Consider: > > module X > def initialize(a) > super() > end > end > > describe X do > > it "is a module" do > X.should be_instance_of(Module) > end > end > > This generates an error because #describe tries to include X into the > test harness and the test harness doesn't know about the extra > argument to #initialize. > > The work around is to just use 'describe "X" do' but I spent a bit of > time just trying to figure out what was going on. > > Why is #describe trying to include the module? That was done initially to support Rails helper specs. As it turns out, I usually wrap add a #helper method that returns self in those cases to make it explicit. So I'm not sure of it's value, but removing it (unfortunately) would probably break myriad specs out there. We should definitely improve the docs though. HTH, David > > Gary Wright > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From gwtmp01 at mac.com Sun Feb 17 00:59:17 2008 From: gwtmp01 at mac.com (Gary Wright) Date: Sun, 17 Feb 2008 00:59:17 -0500 Subject: [rspec-users] #describe behavior with a module In-Reply-To: <57c63afe0802161510k3a543990tde858577cb476dee@mail.gmail.com> References: <57c63afe0802161510k3a543990tde858577cb476dee@mail.gmail.com> Message-ID: <8285A9DB-A983-4EEA-BE77-8BB46E885563@mac.com> On Feb 16, 2008, at 6:10 PM, David Chelimsky wrote: > That was done initially to support Rails helper specs. As it turns > out, I usually wrap add a #helper method that returns self in those > cases to make it explicit. So I'm not sure of it's value, but removing > it (unfortunately) would probably break myriad specs out there. > > We should definitely improve the docs though. It is quite odd. Perhaps a flag and/or alternate method name to turn off that behavior? In my case my module also extends the including module with class methods so it seems like a great way to get some pretty obscure name clashes. Gary Wright From vertebrate at gmail.com Sun Feb 17 01:08:36 2008 From: vertebrate at gmail.com (Steve) Date: Sun, 17 Feb 2008 06:08:36 +0000 (UTC) Subject: [rspec-users] Helpers in view specs Message-ID: I'm not sure of what the community stance is on this, but is there a builtin way to include helpers in view specs? Is this practice shunned? My thoughts on the matter are that I expect my views to have a specific output, and sometimes it would be much easier to call the helper function in the view spec, so that that output could be expected. My helper functions all have their own specs, so it would seem that I'm not doing anything magical, just making the specs a little simpler. Steve From dchelimsky at gmail.com Sun Feb 17 08:06:10 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Feb 2008 08:06:10 -0500 Subject: [rspec-users] Helpers in view specs In-Reply-To: References: Message-ID: <57c63afe0802170506n3fe485c0m6501fb50bef286f4@mail.gmail.com> On Feb 17, 2008 1:08 AM, Steve wrote: > I'm not sure of what the community stance is on this, but is there a > builtin way to include helpers in view specs? Is this practice shunned? > My thoughts on the matter are that I expect my views to have a specific > output, and sometimes it would be much easier to call the helper function > in the view spec, so that that output could be expected. My helper > functions all have their own specs, so it would seem that I'm not doing > anything magical, just making the specs a little simpler. http://rspec.info/rdoc-rails/classes/Spec/Rails/Example/ViewExampleGroup.html#M000037 > > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Feb 17 08:09:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Feb 2008 08:09:33 -0500 Subject: [rspec-users] #describe behavior with a module In-Reply-To: <8285A9DB-A983-4EEA-BE77-8BB46E885563@mac.com> References: <57c63afe0802161510k3a543990tde858577cb476dee@mail.gmail.com> <8285A9DB-A983-4EEA-BE77-8BB46E885563@mac.com> Message-ID: <57c63afe0802170509v59f747a7y293f1ef076dec500@mail.gmail.com> On Feb 17, 2008 12:59 AM, Gary Wright wrote: > > On Feb 16, 2008, at 6:10 PM, David Chelimsky wrote: > > That was done initially to support Rails helper specs. As it turns > > out, I usually wrap add a #helper method that returns self in those > > cases to make it explicit. So I'm not sure of it's value, but removing > > it (unfortunately) would probably break myriad specs out there. > > > > We should definitely improve the docs though. > > It is quite odd. Perhaps a flag and/or alternate method name to turn > off that behavior? In my case my module also extends the including > module with class methods so it seems like a great way to get some > pretty obscure name clashes. Personally I'd just as soon deprecate it rather than add a flag. Let me write up a separate email to get feedback on this. > > > Gary Wright > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From vertebrate at gmail.com Sun Feb 17 11:17:02 2008 From: vertebrate at gmail.com (Steve) Date: Sun, 17 Feb 2008 16:17:02 +0000 (UTC) Subject: [rspec-users] Helpers in view specs References: <57c63afe0802170506n3fe485c0m6501fb50bef286f4@mail.gmail.com> Message-ID: On Sun, 17 Feb 2008 08:06:10 -0500, David Chelimsky wrote: > On Feb 17, 2008 1:08 AM, Steve > wrote: >> I'm not sure of what the community stance is on this, but is there a >> builtin way to include helpers in view specs? Is this practice shunned? >> My thoughts on the matter are that I expect my views to have a specific >> output, and sometimes it would be much easier to call the helper >> function in the view spec, so that that output could be expected. My >> helper functions all have their own specs, so it would seem that I'm >> not doing anything magical, just making the specs a little simpler. > > http://rspec.info/rdoc-rails/classes/Spec/Rails/Example/ ViewExampleGroup.html#M000037 > I think that's showing a way of maybe overriding existing helpers in the view? What I'm asking is more like this: http://pastie.caboo.se/153392 In the example I actually have "include ApplicationHelper" in there, and am using a method "row_class_for_idx" in the spec. It works. I'm just wondering if that's bad form or not. From dchelimsky at gmail.com Sun Feb 17 12:40:31 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Feb 2008 12:40:31 -0500 Subject: [rspec-users] Helpers in view specs In-Reply-To: References: <57c63afe0802170506n3fe485c0m6501fb50bef286f4@mail.gmail.com> Message-ID: <57c63afe0802170940k5a443944t3cf851833bf9b312@mail.gmail.com> On Feb 17, 2008 11:17 AM, Steve wrote: > On Sun, 17 Feb 2008 08:06:10 -0500, David Chelimsky wrote: > > > On Feb 17, 2008 1:08 AM, Steve > > wrote: > >> I'm not sure of what the community stance is on this, but is there a > >> builtin way to include helpers in view specs? Is this practice shunned? > >> My thoughts on the matter are that I expect my views to have a specific > >> output, and sometimes it would be much easier to call the helper > >> function in the view spec, so that that output could be expected. My > >> helper functions all have their own specs, so it would seem that I'm > >> not doing anything magical, just making the specs a little simpler. > > > > http://rspec.info/rdoc-rails/classes/Spec/Rails/Example/ > ViewExampleGroup.html#M000037 > > > > I think that's showing a way of maybe overriding existing helpers in the > view? What I'm asking is more like this: > > http://pastie.caboo.se/153392 > > In the example I actually have "include ApplicationHelper" in there, and > am using a method "row_class_for_idx" in the spec. It works. I'm just > wondering if that's bad form or not. You may want to give this a read: http://blog.jayfields.com/2008/02/testing-expect-literals.html. Please do write back here if you do and let us know what you think. Cheers, David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From vertebrate at gmail.com Sun Feb 17 14:27:08 2008 From: vertebrate at gmail.com (Steve) Date: Sun, 17 Feb 2008 19:27:08 +0000 (UTC) Subject: [rspec-users] Helpers in view specs References: <57c63afe0802170506n3fe485c0m6501fb50bef286f4@mail.gmail.com> <57c63afe0802170940k5a443944t3cf851833bf9b312@mail.gmail.com> Message-ID: On Sun, 17 Feb 2008 12:40:31 -0500, David Chelimsky wrote: > On Feb 17, 2008 11:17 AM, Steve > wrote: >> >> In the example I actually have "include ApplicationHelper" in there, >> and am using a method "row_class_for_idx" in the spec. It works. I'm >> just wondering if that's bad form or not. > > You may want to give this a read: > http://blog.jayfields.com/2008/02/testing-expect-literals.html. > > Please do write back here if you do and let us know what you think. By and large I agree with what Jay is saying, and I try to use literals as much as possible already. I don't try to make my specs DRY by any means, and do in fact have much that is redundant because it improves readability. I do have some arguments for constants and variable values though. For constants if you have the constant spec'd to ensure that it itself is the correct value, then why not use the constant in your specs? You're not saying that the code being tested has to use the constant, just that the algorithm comes out correct. If the spec for the constant fails, you know that it's not what it's supposed to be. If you don't layer your specs like this, then I could see how it would be a problem, but I personally spec my constants. For variable values, such as using a method. Sometimes I just don't care. The method being called is trivial. The example I presented above is good. Right now row_class_for_idx returns "" for even, and "alt" for odds. Let's say in the future I wanted it to be "even", and "odd" for the class names respectively. It's a very simple requirement, used commonly to make sure the lists are going to display properly. It seems like something that's just tedious to go back and change. Also since row_class_for_idx has it's own specs, I know that it will be putting out what I want. From dchelimsky at gmail.com Sun Feb 17 14:48:35 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Feb 2008 14:48:35 -0500 Subject: [rspec-users] Proposed deprecation Message-ID: <57c63afe0802171148k6a5acab9n2f061d9a0d210db2@mail.gmail.com> >From http://rspec.lighthouseapp.com/projects/5645/tickets/295 (please comment there, not here). Cheers, David ==================================================================================== Proposed Deprecation: do not include modules implicitly As those of you using RSpec for Rails likely know, Rails Helper Specs implicitly include the helper module right in the HelperExampleGroup, so you can do this: describe DogHelper do it "should bark" do bark.should == "woof" end end module DogHelper def bark woof end end Personally, I find this to be a bit too magical and confusing. Not to mention inconsistent with controller and view examples, each of which provide a convenience object (controller, response) but require that you interact with this object explicitly. Because I find this confusing, I've been in the habit of wrapping self in a #helper method, so the above example would look like this: describe DogHelper do it "should bark" do helper.bark.should == "woof" end end That is a lot easier for anyone familiar with rspec to look at and grok away. This feature is implemented in rspec core such that any time you describe a module, that module is included in the ExampleGroup. It turns out that it causes trouble if you have an initialize method that accepts one or more arguments. You can get around that by using a string: describe "SomeModule" do ... end But I don't think that really honors the principal of least surprise. I'd like to deprecate this feature, but I'd like feedback from the community before I do. Please post your comments to the original ticket, which can be found at http://rspec.lighthouseapp.com/projects/5645/tickets/295. Thank you, David From phlip2005 at gmail.com Sun Feb 17 21:49:11 2008 From: phlip2005 at gmail.com (Phlip) Date: Sun, 17 Feb 2008 18:49:11 -0800 Subject: [rspec-users] uh... fixtures? Message-ID: RSpec-ers: I'm aware this is quite the FAQ. I have probably asked it myself, but I just can't Google up anything but others asking it. I grabbed the source to Beast, to use as a Rails project uninfluenced by me, or RSpec. Then I installed the CURRENT version of RSpec and rspec_on_rails, and set up a model spec on Post. Here's the spec_helper.rb lines: config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/test/fixtures/' # borrow existing ones ^ config.global_fixtures = :posts, :topics, :users And here's a Beast test translated into a spec: describe Post do fixtures :forums, :moderatorships, :monitorships, :posts, :topics, :users it 'should require body for post' do @post = topics(:pdi).posts.build @post.valid? assert @post.errors.on(:body) end end And the whiny nil error message hits topics(:pid). Any ideas? -- Phlip From dchelimsky at gmail.com Sun Feb 17 22:21:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Feb 2008 22:21:53 -0500 Subject: [rspec-users] uh... fixtures? In-Reply-To: References: Message-ID: <57c63afe0802171921r45fcfc07m8581ede09b246743@mail.gmail.com> On Feb 17, 2008 9:49 PM, Phlip wrote: > RSpec-ers: > > I'm aware this is quite the FAQ. I have probably asked it myself, but I just > can't Google up anything but others asking it. > > I grabbed the source to Beast, to use as a Rails project uninfluenced by me, or > RSpec. Then I installed the CURRENT version of RSpec and rspec_on_rails, and set > up a model spec on Post. > > Here's the spec_helper.rb lines: > > config.use_transactional_fixtures = true > config.use_instantiated_fixtures = false > config.fixture_path = RAILS_ROOT + '/test/fixtures/' > # borrow existing ones ^ > config.global_fixtures = :posts, :topics, :users > > And here's a Beast test translated into a spec: > > describe Post do > fixtures :forums, :moderatorships, :monitorships, :posts, :topics, :users > > it 'should require body for post' do > @post = topics(:pdi).posts.build s/pdi/pid Funny that the typo should lead you to PDI :) > @post.valid? > assert @post.errors.on(:body) > end > end > > And the whiny nil error message hits topics(:pid). > > Any ideas? > > -- > Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Sun Feb 17 22:30:13 2008 From: phlip2005 at gmail.com (Phlip) Date: Sun, 17 Feb 2008 19:30:13 -0800 Subject: [rspec-users] uh... fixtures? In-Reply-To: <57c63afe0802171921r45fcfc07m8581ede09b246743@mail.gmail.com> References: <57c63afe0802171921r45fcfc07m8581ede09b246743@mail.gmail.com> Message-ID: > s/pdi/pid > > Funny that the typo should lead you to PDI :) Oh kewt, but that's copied live out of a passing Beast test. (You know - always clone a working test when branching in a new direction..): /beast/stable-1.0/test/fixtures$ grep pdi * monitorships.yml:aaron_pdi: monitorships.yml:sam_pdi: posts.yml:pdi: posts.yml: body: P D I pdi posts.yml:pdi_reply: posts.yml: body: what? pdi posts.yml:pdi_rebuttal: posts.yml: body: you heard me pdi topics.yml:pdi: Go ask the Beastmasters why they want an unpronounceable acronym there... (And their conversation suspiciously resembles ours!;) -- Phlip From dchelimsky at gmail.com Sun Feb 17 22:34:43 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Feb 2008 22:34:43 -0500 Subject: [rspec-users] uh... fixtures? In-Reply-To: References: <57c63afe0802171921r45fcfc07m8581ede09b246743@mail.gmail.com> Message-ID: <57c63afe0802171934h4cd99d4di540685b0e3af4599@mail.gmail.com> On Feb 17, 2008 10:30 PM, Phlip wrote: > > s/pdi/pid > > > > Funny that the typo should lead you to PDI :) > > Oh kewt, but that's copied live out of a passing Beast test. (You know - always > clone a working test when branching in a new direction..): > > /beast/stable-1.0/test/fixtures$ grep pdi * > monitorships.yml:aaron_pdi: > monitorships.yml:sam_pdi: > posts.yml:pdi: > posts.yml: body: P D I pdi > posts.yml:pdi_reply: > posts.yml: body: what? pdi > posts.yml:pdi_rebuttal: > posts.yml: body: you heard me pdi > topics.yml:pdi: > > Go ask the Beastmasters why they want an unpronounceable acronym there... > > (And their conversation suspiciously resembles ours!;) Sorry - that's all I got. Anybody else? > > -- > > Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Sun Feb 17 22:46:17 2008 From: phlip2005 at gmail.com (Phlip) Date: Sun, 17 Feb 2008 19:46:17 -0800 Subject: [rspec-users] uh... fixtures? In-Reply-To: <57c63afe0802171934h4cd99d4di540685b0e3af4599@mail.gmail.com> References: <57c63afe0802171921r45fcfc07m8581ede09b246743@mail.gmail.com> <57c63afe0802171934h4cd99d4di540685b0e3af4599@mail.gmail.com> Message-ID: > Sorry - that's all I got. Anybody else? In general, all Rails tests have friction, of various types, because someone had the bright idea to make 'fixtures' like a directive, instead of just a method you can call from setup(). So if anyone knew the function we could call there... -- Venkman From phlip2005 at gmail.com Sun Feb 17 22:52:53 2008 From: phlip2005 at gmail.com (Phlip) Date: Sun, 17 Feb 2008 19:52:53 -0800 Subject: [rspec-users] uh... fixtures? In-Reply-To: <57c63afe0802171934h4cd99d4di540685b0e3af4599@mail.gmail.com> References: <57c63afe0802171921r45fcfc07m8581ede09b246743@mail.gmail.com> <57c63afe0802171934h4cd99d4di540685b0e3af4599@mail.gmail.com> Message-ID: BTW it got better! I guess my hard drive just had to cool off... (-; From edvard at majakari.net Mon Feb 18 06:58:18 2008 From: edvard at majakari.net (Edvard Majakari) Date: Mon, 18 Feb 2008 13:58:18 +0200 Subject: [rspec-users] can't get (r)spec to work in non-rails project In-Reply-To: References: <57c63afe0802160559t100ab1b3m505dcae17c2f8a8a@mail.gmail.com> <9832EC77-014B-4683-B0C3-1FFCF2BB3909@gmail.com> <57c63afe0802160613n30869f34n1e1e98f9275f51bf@mail.gmail.com> <8B9E6451-2B1F-47FC-9917-6A5DAB57DA0D@gmail.com> <57c63afe0802161006w79a296f4w6078150bad5bd198@mail.gmail.com> Message-ID: > I would think just have the spec_helper.rb file for the specs try to load > config/rspec.rb or something along those lines. Similar to how rspec for > rails just loads the rails env. It would then be up to the user to do the > necessary loading in that file. There's really no way to know what crazy > way someone might layout their projects. +1. Something along the lines require File.join(File.dirname(__FILE__), 'config.rb') if File.exist?('config.rb') would be sufficient, no? -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From vic at civrot.org Mon Feb 18 02:57:55 2008 From: vic at civrot.org (Victor Asteinza) Date: Sun, 17 Feb 2008 23:57:55 -0800 Subject: [rspec-users] Specs versus Stories Message-ID: <40957B40-7226-433E-873E-7D657F6DCB89@civrot.org> I am new to BDD and have been doing some reading and playing with rSpec. I am a little confused. I am not sure what the best practice for using stories and specs. Should I be writing stories first, then specs that would fulfill those stories, and then write the implementation code to have everything pass? At first that seems a little redundant. I understand that the stories let you write the behavior in plane English, which I can see it being useful when dealing with non technical users. But if I am developing an internal app I am struggling with whether I should develop the stories first and then move on to the specs. Opinions? Experiences? Thanks, Victor From toastkid.williams at gmail.com Mon Feb 18 08:29:09 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Mon, 18 Feb 2008 13:29:09 +0000 Subject: [rspec-users] Problem with testing for an exception from a controller method Message-ID: I have a User controller where users aren't added with the usual new/create actions. I'm trying to set it so that it raises when 'new' is called but it doesn't seem to be working - here's the method, test and test result. Can anyone see why it's not working? #in controller def new raise "Users should be added with 'batch_add' rather than 'new" end #test describe "/new" do it "should raise an error when called" do lambda{get('new')}.should raise_error(RuntimeError) end end #test report 'Admin::UserController /new should raise an error when called' FAILED expected RuntimeError but nothing was raised -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080218/73f1aad3/attachment-0001.html From coreyhaines at gmail.com Mon Feb 18 08:30:32 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Mon, 18 Feb 2008 08:30:32 -0500 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: References: Message-ID: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> Won't the exception get turned into a http return code from the get? On Feb 18, 2008 8:29 AM, Max Williams wrote: > I have a User controller where users aren't added with the usual > new/create actions. I'm trying to set it so that it raises when 'new' is > called but it doesn't seem to be working - here's the method, test and test > result. Can anyone see why it's not working? > > #in controller > def new > raise "Users should be added with 'batch_add' rather than 'new" > end > > #test > describe "/new" do > it "should raise an error when called" do > lambda{get('new')}.should raise_error(RuntimeError) > end > end > > #test report > 'Admin::UserController /new should raise an error when called' FAILED > expected RuntimeError but nothing was raised > > > _______________________________________________ > 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/20080218/1a4b495e/attachment.html From dchelimsky at gmail.com Mon Feb 18 08:41:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Feb 2008 08:41:09 -0500 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> Message-ID: <57c63afe0802180541n18855ea1j3d7c413120859f07@mail.gmail.com> On Feb 18, 2008 8:30 AM, Corey Haines wrote: > Won't the exception get turned into a http return code from the get? It depends on a few things. Max - what versions of rspec and rails are you using? > > > > On Feb 18, 2008 8:29 AM, Max Williams wrote: > > > > > > > > > I have a User controller where users aren't added with the usual > new/create actions. I'm trying to set it so that it raises when 'new' is > called but it doesn't seem to be working - here's the method, test and test > result. Can anyone see why it's not working? > > > > #in controller > > def new > > raise "Users should be added with 'batch_add' rather than 'new" > > end > > > > #test > > describe "/new" do > > it "should raise an error when called" do > > lambda{get('new')}.should raise_error(RuntimeError) > > end > > end > > > > #test report > > 'Admin::UserController /new should raise an error when called' FAILED > > expected RuntimeError but nothing was raised > > > > > > _______________________________________________ > > 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Mon Feb 18 08:43:07 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Mon, 18 Feb 2008 13:43:07 +0000 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> Message-ID: ah yes of course :) So, now, "should_not be_success" passes ok, but should i be more specific and require a particular error code? If so, which would i get from a get call that's failed because of a RuntimeError exception? thanks! On 18/02/2008, Corey Haines wrote: > > Won't the exception get turned into a http return code from the get? > > On Feb 18, 2008 8:29 AM, Max Williams wrote: > > > I have a User controller where users aren't added with the usual > > new/create actions. I'm trying to set it so that it raises when 'new' is > > called but it doesn't seem to be working - here's the method, test and test > > result. Can anyone see why it's not working? > > > > #in controller > > def new > > raise "Users should be added with 'batch_add' rather than 'new" > > end > > > > #test > > describe "/new" do > > it "should raise an error when called" do > > lambda{get('new')}.should raise_error(RuntimeError) > > end > > end > > > > #test report > > 'Admin::UserController /new should raise an error when called' FAILED > > expected RuntimeError but nothing was raised > > > > > > _______________________________________________ > > 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 > _______________________________________________ > 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/20080218/dbd3a4a2/attachment.html From dchelimsky at gmail.com Mon Feb 18 08:46:42 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Feb 2008 08:46:42 -0500 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> Message-ID: <57c63afe0802180546v7c2b7975i7ab4261c19e05bd2@mail.gmail.com> On Feb 18, 2008 8:43 AM, Max Williams wrote: > ah yes of course :) > > So, now, "should_not be_success" passes ok, but should i be more specific > and require a particular error code? If so, which would i get from a get > call that's failed because of a RuntimeError exception? You should be able to discover that by specifying one (like 200) and seeing what you get. response.error_code.should == 200 Cheers, David > > thanks! > > > > On 18/02/2008, Corey Haines wrote: > > Won't the exception get turned into a http return code from the get? > > > > > > > > On Feb 18, 2008 8:29 AM, Max Williams wrote: > > > > > > > > I have a User controller where users aren't added with the usual > new/create actions. I'm trying to set it so that it raises when 'new' is > called but it doesn't seem to be working - here's the method, test and test > result. Can anyone see why it's not working? > > > > > > #in controller > > > def new > > > raise "Users should be added with 'batch_add' rather than 'new" > > > end > > > > > > #test > > > describe "/new" do > > > it "should raise an error when called" do > > > lambda{get('new')}.should raise_error(RuntimeError) > > > end > > > end > > > > > > #test report > > > 'Admin::UserController /new should raise an error when called' FAILED > > > expected RuntimeError but nothing was raised > > > > > > > > > _______________________________________________ > > > 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 > > _______________________________________________ > > 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 coreyhaines at gmail.com Mon Feb 18 08:46:56 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Mon, 18 Feb 2008 08:46:56 -0500 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> Message-ID: <6bdacb70802180546p1e88490an2c4703f9615f8df2@mail.gmail.com> 500? That's internal server error. You could set up an expectation for the return, using a code you know isn't right (200?), then see what the actual value is after you get the failing test. On Feb 18, 2008 8:43 AM, Max Williams wrote: > ah yes of course :) > > So, now, "should_not be_success" passes ok, but should i be more specific > and require a particular error code? If so, which would i get from a get > call that's failed because of a RuntimeError exception? > > thanks! > > > On 18/02/2008, Corey Haines wrote: > > > > Won't the exception get turned into a http return code from the get? > > > > On Feb 18, 2008 8:29 AM, Max Williams > > wrote: > > > > > I have a User controller where users aren't added with the usual > > > new/create actions. I'm trying to set it so that it raises when 'new' is > > > called but it doesn't seem to be working - here's the method, test and test > > > result. Can anyone see why it's not working? > > > > > > #in controller > > > def new > > > raise "Users should be added with 'batch_add' rather than 'new" > > > end > > > > > > #test > > > describe "/new" do > > > it "should raise an error when called" do > > > lambda{get('new')}.should raise_error(RuntimeError) > > > end > > > end > > > > > > #test report > > > 'Admin::UserController /new should raise an error when called' FAILED > > > expected RuntimeError but nothing was raised > > > > > > > > > _______________________________________________ > > > 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 > > _______________________________________________ > > 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/20080218/23eea1ae/attachment.html From dchelimsky at gmail.com Mon Feb 18 08:48:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Feb 2008 08:48:02 -0500 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: <6bdacb70802180546p1e88490an2c4703f9615f8df2@mail.gmail.com> References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> <6bdacb70802180546p1e88490an2c4703f9615f8df2@mail.gmail.com> Message-ID: <57c63afe0802180548t5884186od0db9eb900ff1b0@mail.gmail.com> On Feb 18, 2008 8:46 AM, Corey Haines wrote: > 500? That's internal server error. You could set up an expectation for the > return, using a code you know isn't right (200?), then see what the actual > value is after you get the failing test. What he said :) > > > > On Feb 18, 2008 8:43 AM, Max Williams wrote: > > ah yes of course :) > > > > So, now, "should_not be_success" passes ok, but should i be more specific > and require a particular error code? If so, which would i get from a get > call that's failed because of a RuntimeError exception? > > > > thanks! > > > > > > > > > > > > On 18/02/2008, Corey Haines wrote: > > > Won't the exception get turned into a http return code from the get? > > > > > > > > > > > > On Feb 18, 2008 8:29 AM, Max Williams > wrote: > > > > > > > > > > > I have a User controller where users aren't added with the usual > new/create actions. I'm trying to set it so that it raises when 'new' is > called but it doesn't seem to be working - here's the method, test and test > result. Can anyone see why it's not working? > > > > > > > > #in controller > > > > def new > > > > raise "Users should be added with 'batch_add' rather than 'new" > > > > end > > > > > > > > #test > > > > describe "/new" do > > > > it "should raise an error when called" do > > > > lambda{get('new')}.should raise_error(RuntimeError) > > > > end > > > > end > > > > > > > > #test report > > > > 'Admin::UserController /new should raise an error when called' FAILED > > > > expected RuntimeError but nothing was raised > > > > > > > > > > > > _______________________________________________ > > > > 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 > > > _______________________________________________ > > > 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Mon Feb 18 08:48:24 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Mon, 18 Feb 2008 13:48:24 +0000 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: <57c63afe0802180541n18855ea1j3d7c413120859f07@mail.gmail.com> References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> <57c63afe0802180541n18855ea1j3d7c413120859f07@mail.gmail.com> Message-ID: RAILS_GEM_VERSION = '1.1.6' rspec - Version 1.1.3 On 18/02/2008, David Chelimsky wrote: > > On Feb 18, 2008 8:30 AM, Corey Haines wrote: > > Won't the exception get turned into a http return code from the get? > > It depends on a few things. > > Max - what versions of rspec and rails are you using? > > > > > > > > On Feb 18, 2008 8:29 AM, Max Williams > wrote: > > > > > > > > > > > > > > I have a User controller where users aren't added with the usual > > new/create actions. I'm trying to set it so that it raises when 'new' > is > > called but it doesn't seem to be working - here's the method, test and > test > > result. Can anyone see why it's not working? > > > > > > #in controller > > > def new > > > raise "Users should be added with 'batch_add' rather than 'new" > > > end > > > > > > #test > > > describe "/new" do > > > it "should raise an error when called" do > > > lambda{get('new')}.should raise_error(RuntimeError) > > > end > > > end > > > > > > #test report > > > 'Admin::UserController /new should raise an error when called' FAILED > > > expected RuntimeError but nothing was raised > > > > > > > > > _______________________________________________ > > > 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 > > _______________________________________________ > > 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/20080218/f97e3981/attachment.html From toastkid.williams at gmail.com Mon Feb 18 08:52:29 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Mon, 18 Feb 2008 13:52:29 +0000 Subject: [rspec-users] Problem with testing for an exception from a controller method In-Reply-To: <57c63afe0802180546v7c2b7975i7ab4261c19e05bd2@mail.gmail.com> References: <6bdacb70802180530q5195f265y9b9f73e13bb2720@mail.gmail.com> <57c63afe0802180546v7c2b7975i7ab4261c19e05bd2@mail.gmail.com> Message-ID: great minds :) thanks guys! On 18/02/2008, David Chelimsky wrote: > > On Feb 18, 2008 8:43 AM, Max Williams wrote: > > ah yes of course :) > > > > So, now, "should_not be_success" passes ok, but should i be more > specific > > and require a particular error code? If so, which would i get from a > get > > call that's failed because of a RuntimeError exception? > > You should be able to discover that by specifying one (like 200) and > seeing what you get. > > response.error_code.should == 200 > > Cheers, > David > > > > > thanks! > > > > > > > > On 18/02/2008, Corey Haines wrote: > > > Won't the exception get turned into a http return code from the get? > > > > > > > > > > > > On Feb 18, 2008 8:29 AM, Max Williams > wrote: > > > > > > > > > > > I have a User controller where users aren't added with the usual > > new/create actions. I'm trying to set it so that it raises when 'new' > is > > called but it doesn't seem to be working - here's the method, test and > test > > result. Can anyone see why it's not working? > > > > > > > > #in controller > > > > def new > > > > raise "Users should be added with 'batch_add' rather than 'new" > > > > end > > > > > > > > #test > > > > describe "/new" do > > > > it "should raise an error when called" do > > > > lambda{get('new')}.should raise_error(RuntimeError) > > > > end > > > > end > > > > > > > > #test report > > > > 'Admin::UserController /new should raise an error when called' > FAILED > > > > expected RuntimeError but nothing was raised > > > > > > > > > > > > _______________________________________________ > > > > 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 > > > _______________________________________________ > > > 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/20080218/caa2cb27/attachment.html From omen.king at gmail.com Mon Feb 18 11:21:47 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 18 Feb 2008 11:21:47 -0500 Subject: [rspec-users] Specs versus Stories In-Reply-To: <40957B40-7226-433E-873E-7D657F6DCB89@civrot.org> References: <40957B40-7226-433E-873E-7D657F6DCB89@civrot.org> Message-ID: My workflow is the following: Stories->Spec Views->Spec Controllers-Spec Models I'll write a few stories of what I think should it happen. Then I'll write my specs of what should show (and also do some static html page mockups) Then I'll spec my controllers and models I'll go back to my stories to see if they need adjusting because my perceptive of how the app changed Then I run my stories and make them pass. Then I write a few stories and repeat. I constantly step move back and forth. I think Stories and BDD greatly assists you to shape your idea. Write stories for what you can think of and then move on to specing. You don't need complete stories you can also go back and fill them in later. On Feb 18, 2008 2:57 AM, Victor Asteinza wrote: > I am new to BDD and have been doing some reading and playing with > rSpec. I am a little confused. I am not sure what the best practice > for using stories and specs. Should I be writing stories first, then > specs that would fulfill those stories, and then write the > implementation code to have everything pass? At first that seems a > little redundant. > > I understand that the stories let you write the behavior in plane > English, which I can see it being useful when dealing with non > technical users. But if I am developing an internal app I am > struggling with whether I should develop the stories first and then > move on to the specs. > > Opinions? Experiences? > > Thanks, > Victor > _______________________________________________ > 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/20080218/2fd08018/attachment.html From vertebrate at gmail.com Mon Feb 18 12:09:50 2008 From: vertebrate at gmail.com (Steve) Date: Mon, 18 Feb 2008 17:09:50 +0000 (UTC) Subject: [rspec-users] rspec_controller generator for HAML? Message-ID: Is there currently an option to have the rspec_controller generator generate haml instead of erb view files, and the corresponding spec? Thanks, Steve From vertebrate at gmail.com Mon Feb 18 16:59:50 2008 From: vertebrate at gmail.com (Steve) Date: Mon, 18 Feb 2008 21:59:50 +0000 (UTC) Subject: [rspec-users] File loading bug Message-ID: Not sure if this is rspec or autotest. When autotest is running, and I add new files in my rails project, it doesn't notice. I have to restart autotest for it to start seeing them. Not the end of the world, just a small inconvenience. Steve From dchelimsky at gmail.com Mon Feb 18 17:06:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Feb 2008 17:06:03 -0500 Subject: [rspec-users] File loading bug In-Reply-To: References: Message-ID: <57c63afe0802181406v56aef4e0h917062f71568de2a@mail.gmail.com> On Feb 18, 2008 4:59 PM, Steve wrote: > Not sure if this is rspec or autotest. When autotest is running, and I > add new files in my rails project, it doesn't notice. I have to restart > autotest for it to start seeing them. Not the end of the world, just a > small inconvenience. That's autotest. You can prove it to yourself by starting up a new non-rails project w/ test/unit and you'll see the same behaviour. HTH, David > > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From vertebrate at gmail.com Mon Feb 18 18:07:08 2008 From: vertebrate at gmail.com (Steve) Date: Mon, 18 Feb 2008 23:07:08 +0000 (UTC) Subject: [rspec-users] File loading bug References: <57c63afe0802181406v56aef4e0h917062f71568de2a@mail.gmail.com> Message-ID: On Mon, 18 Feb 2008 17:06:03 -0500, David Chelimsky wrote: > On Feb 18, 2008 4:59 PM, Steve > wrote: >> Not sure if this is rspec or autotest. When autotest is running, and I >> add new files in my rails project, it doesn't notice. I have to restart >> autotest for it to start seeing them. Not the end of the world, just a >> small inconvenience. > > That's autotest. You can prove it to yourself by starting up a new > non-rails project w/ test/unit and you'll see the same behaviour. Do you know if it's a bug? I thought it used to work the way I was expecting. From vic at civrot.org Mon Feb 18 18:38:43 2008 From: vic at civrot.org (Victor Asteinza) Date: Mon, 18 Feb 2008 15:38:43 -0800 Subject: [rspec-users] Specs versus Stories In-Reply-To: References: Message-ID: <3B87748D-51A3-483D-9A89-9754BAFE9466@civrot.org> Isn't there redundancy between what is in your stories and your specs? Or are your stories at a higher level and the specs are at a lower level? That would make more sense to me. There would be some cross over. but the specs expand on what is in the stories.... > Message: 3 > Date: Mon, 18 Feb 2008 11:21:47 -0500 > From: "Andrew WC Brown" > Subject: Re: [rspec-users] Specs versus Stories > To: rspec-users > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > My workflow is the following: > Stories->Spec Views->Spec Controllers-Spec Models > > I'll write a few stories of what I think should it happen. > Then I'll write my specs of what should show (and also do some > static html > page mockups) > Then I'll spec my controllers and models > I'll go back to my stories to see if they need adjusting because my > perceptive of how the app changed > Then I run my stories and make them pass. > > Then I write a few stories and repeat. > > I constantly step move back and forth. > I think Stories and BDD greatly assists you to shape your idea. > Write stories for what you can think of and then move on to specing. > You don't need complete stories you can also go back and fill them > in later. > > On Feb 18, 2008 2:57 AM, Victor Asteinza wrote: > >> I am new to BDD and have been doing some reading and playing with >> rSpec. I am a little confused. I am not sure what the best practice >> for using stories and specs. Should I be writing stories first, then >> specs that would fulfill those stories, and then write the >> implementation code to have everything pass? At first that seems a >> little redundant. >> >> I understand that the stories let you write the behavior in plane >> English, which I can see it being useful when dealing with non >> technical users. But if I am developing an internal app I am >> struggling with whether I should develop the stories first and then >> move on to the specs. >> >> Opinions? Experiences? >> >> Thanks, >> Victor >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> From dchelimsky at gmail.com Mon Feb 18 18:44:59 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Feb 2008 18:44:59 -0500 Subject: [rspec-users] Specs versus Stories In-Reply-To: <3B87748D-51A3-483D-9A89-9754BAFE9466@civrot.org> References: <3B87748D-51A3-483D-9A89-9754BAFE9466@civrot.org> Message-ID: <57c63afe0802181544g4615eeb1w92409a0aecb04f92@mail.gmail.com> On Feb 18, 2008 6:38 PM, Victor Asteinza wrote: > Isn't there redundancy between what is in your stories and your specs? > Or are your stories at a higher level and the specs are at a lower > level? That would make more sense to me. There would be some cross > over. but the specs expand on what is in the stories.... While either tool can technically support either mode of thinking: Stories are aimed at describing the behaviour of your applications. Specs are aimed at describing the behaviour of the objects in your applications. You are correct that there will likely be some cross over, but keep in mind that there are different audiences and different processes. The steps in stories (the descriptive text, not the implementation of the steps) are typically written in entirety before setting out to develop a body of work. Stories should be run before a commit, or as part of a CI build, but are not always run between every step. The examples in specs, on the other hand, typically come into existence in a very granular red-green-refactor cycle, and should be run between every step. HTH, David > > > Message: 3 > > Date: Mon, 18 Feb 2008 11:21:47 -0500 > > From: "Andrew WC Brown" > > Subject: Re: [rspec-users] Specs versus Stories > > To: rspec-users > > Message-ID: > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > > My workflow is the following: > > Stories->Spec Views->Spec Controllers-Spec Models > > > > I'll write a few stories of what I think should it happen. > > Then I'll write my specs of what should show (and also do some > > static html > > page mockups) > > Then I'll spec my controllers and models > > I'll go back to my stories to see if they need adjusting because my > > perceptive of how the app changed > > Then I run my stories and make them pass. > > > > Then I write a few stories and repeat. > > > > I constantly step move back and forth. > > I think Stories and BDD greatly assists you to shape your idea. > > Write stories for what you can think of and then move on to specing. > > You don't need complete stories you can also go back and fill them > > in later. > > > > On Feb 18, 2008 2:57 AM, Victor Asteinza wrote: > > > >> I am new to BDD and have been doing some reading and playing with > >> rSpec. I am a little confused. I am not sure what the best practice > >> for using stories and specs. Should I be writing stories first, then > >> specs that would fulfill those stories, and then write the > >> implementation code to have everything pass? At first that seems a > >> little redundant. > >> > >> I understand that the stories let you write the behavior in plane > >> English, which I can see it being useful when dealing with non > >> technical users. But if I am developing an internal app I am > >> struggling with whether I should develop the stories first and then > >> move on to the specs. > >> > >> Opinions? Experiences? > >> > >> Thanks, > >> Victor > >> _______________________________________________ > >> 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 dchelimsky at gmail.com Mon Feb 18 18:46:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Feb 2008 18:46:52 -0500 Subject: [rspec-users] File loading bug In-Reply-To: References: <57c63afe0802181406v56aef4e0h917062f71568de2a@mail.gmail.com> Message-ID: <57c63afe0802181546k6a9c1581lf4bedb9b34e2d802@mail.gmail.com> On Feb 18, 2008 6:07 PM, Steve wrote: > On Mon, 18 Feb 2008 17:06:03 -0500, David Chelimsky wrote: > > > On Feb 18, 2008 4:59 PM, Steve > > wrote: > >> Not sure if this is rspec or autotest. When autotest is running, and I > >> add new files in my rails project, it doesn't notice. I have to restart > >> autotest for it to start seeing them. Not the end of the world, just a > >> small inconvenience. > > > > That's autotest. You can prove it to yourself by starting up a new > > non-rails project w/ test/unit and you'll see the same behaviour. > > Do you know if it's a bug? I thought it used to work the way I was > expecting. You just answered your own question. You may want to file a bug report in the ZenTest tracker: http://rubyforge.org/tracker/?group_id=419 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ericw at xmtp.net Mon Feb 18 20:10:48 2008 From: ericw at xmtp.net (EAW) Date: Mon, 18 Feb 2008 18:10:48 -0700 Subject: [rspec-users] render_to_string in a controller test? Message-ID: Hi all, I know that in general, view and controller tests should be isolated, such that controller specs don't test views etc. However, I think I've run into a situation that might be an exception. My controller uses render_to_string to produce a chunk of HTML that it passes to a model to be processed. The controller then redirects the user to a different page. The results of the render_to_string are not seen by the user. Since the controller is calling render_to_string, I've been trying to test that it is rendered correctly in my controller spec. Because a controller spec normally doesn't render views, render_to_string just returns the path of the view, rather than the rendered output. This prevents me from testing the output of render_to_string in the controller spec. I can work around the issue by using integrate_views, and I guess that's fine, but shouldn't render_to_string really work in controllers? Thanks for your input, e. -- ericw at xmtp.net "If the answer isn't violence, neither is your silence!" -- Pop Will Eat Itself, "Ich Bin Ein Auslander" From daniel.manges at gmail.com Mon Feb 18 22:06:02 2008 From: daniel.manges at gmail.com (Dan Manges) Date: Mon, 18 Feb 2008 22:06:02 -0500 Subject: [rspec-users] deep test with rspec? In-Reply-To: <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> <47A5243F.3030109@benmabey.com> <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> Message-ID: David Vollbracht spiked an rspec implementation for DeepTest: svn diff -r 20:21 http://deep-test.rubyforge.org/svn/trunk Unfortunately nobody has had time to finish it. If anybody is interested in working on it, that would be awesome. I can give you repo access. Dan On Feb 2, 2008 9:37 PM, Scott Taylor wrote: > > On Feb 2, 2008, at 9:17 PM, Ben Mabey wrote: > > > Scott Taylor wrote: > >> On Feb 2, 2008, at 12:09 PM, Ben Mabey wrote: > >> > >> > >>> Ben Mabey wrote: > >>> > >>>> All, > >>>> Has anyone on this list tried to use DeepTest[1] with rspec? My > >>>> initial > >>>> attempts have failed so I would be really interested if someone has > >>>> figured it out. Thanks. > >>>> > >>>> -Ben > >>>> > >>>> 1. http://www.somethingnimble.com/bliki/deep-test > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-users at rubyforge.org > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > >>>> > >>>> > >>> Or maybe someone has some experience with spec_distributed they > >>> could > >>> share? I'm just trying to see if I can get my specs to run faster > >>> on my > >>> multi-core machines.... > >>> > >> > >> I haven't used deep test (this was by Dan Manges / Thoughtworks, > >> correct?). If I recall correctly, it only worked on test/unit. I > >> don't know if anyone else was working on a version for rspec... > >> > > Right.. There were some comments in Dan's original post about someone > > working on rspec compatibility but as far as I can tell that never > > made > > it into the gem. > >> As for spec_distributed, I had gotten it working, and as I recall, it > >> was pretty easy to do (at least, on a non-rails project). The > >> documentation for that is pretty straight forward. It solves the > >> speed problem by throwing hardware at the problem - If you have n > >> number of machines, your test suite should take 1/n the amount of > >> time it usually does on one machine (assuming the machines of equal > >> processing power). > >> > > > > Does this really address the use of multicores on a single machine > > then? The only use I could see of this would be for running your CI > > faster over a number of machines... > > Thanks for you input, > > No - it doesn't, but it would cut your test suite in half, just as > two processors would. > > I'm sure I'm not the only one who would like to know if you took up > the job of getting deep test to run w/ rspec. > > Regards, > > Scott > _______________________________________________ > 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/20080218/85fa3114/attachment.html From lists at ruby-forum.com Tue Feb 19 05:32:09 2008 From: lists at ruby-forum.com (Fernando Perez) Date: Tue, 19 Feb 2008 11:32:09 +0100 Subject: [rspec-users] Specs versus Stories In-Reply-To: References: <40957B40-7226-433E-873E-7D657F6DCB89@civrot.org> Message-ID: <022dfce9e8d4e66c68c08eefb6eb1fc6@ruby-forum.com> Andrew, By testing your views before the controllers and models, aren't you wasting time on adjusting tests as you make changes to the views? I see many people postpone the testing of views to the very late stage of development, so that they don't get distracted. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Feb 19 06:26:36 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Feb 2008 06:26:36 -0500 Subject: [rspec-users] rspec_controller generator for HAML? In-Reply-To: References: Message-ID: <57c63afe0802190326ia7c0c3xbafc2367040c6052@mail.gmail.com> On Feb 18, 2008 12:09 PM, Steve wrote: > Is there currently an option to have the rspec_controller generator > generate haml instead of erb view files, and the corresponding spec? Nope. > > Thanks, > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Feb 19 06:42:13 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Feb 2008 06:42:13 -0500 Subject: [rspec-users] render_to_string in a controller test? In-Reply-To: References: Message-ID: <57c63afe0802190342u4f22f9a9ue360418e3c935a9c@mail.gmail.com> On Feb 18, 2008 8:10 PM, EAW wrote: > Hi all, > > I know that in general, view and controller tests should be isolated, > such that controller specs don't test views etc. However, I think > I've run into a situation that might be an exception. > > My controller uses render_to_string to produce a chunk of HTML that it > passes to a model to be processed. > > The controller then redirects the user to a different page. The > results of the render_to_string are not seen by the user. > > Since the controller is calling render_to_string, I've been trying to > test that it is rendered correctly in my controller spec. Because a > controller spec normally doesn't render views, render_to_string just > returns the path of the view, rather than the rendered output. This > prevents me from testing the output of render_to_string in the > controller spec. > > I can work around the issue by using integrate_views, and I guess > that's fine, but shouldn't render_to_string really work in controllers? The whole point of isolation is to isolate the code in the controller from the code in the view. The two primary reasons for this are that it allows you to write controller code before the view exists and it keeps failures in views isolated to the view specs (why should a controller spec fail because of a typo in a view?). The fact that the result of rendering is being passed to a model instead of a (theoretical) browser should not make a difference, should it? I can see your argument for wanting to be able to treat this example differently, and you can, as you pointed out, accomplish that with integrate_views. FWIW, David > > Thanks for your input, > > e. > -- > ericw at xmtp.net > > "If the answer isn't violence, neither is your silence!" > -- Pop Will Eat Itself, "Ich Bin Ein Auslander" > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jarkko at jlaine.net Tue Feb 19 07:52:52 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 19 Feb 2008 14:52:52 +0200 Subject: [rspec-users] Specs versus Stories In-Reply-To: <022dfce9e8d4e66c68c08eefb6eb1fc6@ruby-forum.com> References: <40957B40-7226-433E-873E-7D657F6DCB89@civrot.org> <022dfce9e8d4e66c68c08eefb6eb1fc6@ruby-forum.com> Message-ID: On 19.2.2008, at 12.32, Fernando Perez wrote: > Andrew, > > By testing your views before the controllers and models, aren't you > wasting time on adjusting tests as you make changes to the views? > > I see many people postpone the testing of views to the very late stage > of development, so that they don't get distracted. One of the founding principles of BDD is the concept of "outside in". In Rails that naturally means the process Andrew described. By starting from what your views need, you have a better understanding of what you need from the controller action and related models, so you have a good foundation from where you start speccing them when you drill down towards the core. That also follows one of the 37signals' mantras that is worth repeating: "the interface is the application". If changing some small things (like a

to

) in the views breaks your specs, you're probably speccing wrong things. I always try to spec for logical things, not the actual tags, for example. That is not always an option, of course. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080219/774ab30e/attachment.bin From lists at ruby-forum.com Tue Feb 19 10:32:19 2008 From: lists at ruby-forum.com (Jennifer Lindner) Date: Tue, 19 Feb 2008 16:32:19 +0100 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: References: <57c63afe0801310325w3b44adfhf829b54c123a9b33@mail.gmail.com> <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> Message-ID: <420bf25b6300ef5926938b3db695b7ee@ruby-forum.com> David Chelimsky wrote: > Did you install both the rspec and rspec_on_rails 1.1.3 plugins? hey i've updated the plugins and still get the error: loading autotest/rails_rspec Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. i'm running ruby 1.8.5 and rails 1.2.3, ZenTest 3.9.1 and rspec 1.1.3. i reinstalled the plugins and then updated the gem too. any other ideas? maybe i should just try going back down to ZenTest 3.8.0 and rspec 1.1.2 and restarting machine. -- Posted via http://www.ruby-forum.com/. From jarkko at jlaine.net Tue Feb 19 10:42:22 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 19 Feb 2008 17:42:22 +0200 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) Message-ID: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> rspec and rspec_on_rails rev 3316, ZenTest 3.9.1 When run through spec_server, running spec fails if the spec file is not specified with an absolute path: Probutanol:koulutusweb jarkko$ script/spec --options spec/spec.opts `pwd`/spec/models/address_spec.rb ...... Finished in 0.166251 seconds 6 examples, 0 failures Probutanol:koulutusweb jarkko$ script/spec --options spec/spec.opts spec/models/address_spec.rb (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/runner/ options.rb:197:in `files_to_load': File or directory not found: spec/ models/address_spec.rb (RuntimeError) from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ runner/options.rb:189:in `each' from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ runner/options.rb:189:in `files_to_load' In the same way, autotest fails with spec_server: Probutanol:koulutusweb jarkko$ autotest loading autotest/rails_rspec /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S script/spec -O spec/spec.opts spec/controllers/ activations_controller_spec.rb spec/helpers/clients_helper_spec.rb [a bunch of files omitted] spec/models/enrollment_notifier_spec.rb spec/views/clients/ email_form.html.erb_spec.rb (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/runner/ options.rb:5:in `mtime': Not a directory - spec/models/address_spec.rb (Errno::ENOTDIR) from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ runner/options.rb:5 from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ runner/options.rb:251:in `sort' from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ runner/options.rb:251:in `sorted_files' Any ideas why spec_server has lost its marbles? Without the --drb option autotest runs fine. Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080219/14d880fc/attachment.bin From dchelimsky at gmail.com Tue Feb 19 10:57:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Feb 2008 10:57:25 -0500 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> Message-ID: <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> On Feb 19, 2008 10:42 AM, Jarkko Laine wrote: > rspec and rspec_on_rails rev 3316, ZenTest 3.9.1 > > When run through spec_server, running spec fails if the spec file is > not specified with an absolute path: > > Probutanol:koulutusweb jarkko$ script/spec --options spec/spec.opts > `pwd`/spec/models/address_spec.rb > ...... > > Finished in 0.166251 seconds > > 6 examples, 0 failures > Probutanol:koulutusweb jarkko$ script/spec --options spec/spec.opts > spec/models/address_spec.rb > (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/runner/ > options.rb:197:in `files_to_load': File or directory not found: spec/ > models/address_spec.rb (RuntimeError) > from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ > runner/options.rb:189:in `each' > from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ > runner/options.rb:189:in `files_to_load' > > > In the same way, autotest fails with spec_server: > > Probutanol:koulutusweb jarkko$ autotest > loading autotest/rails_rspec > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S > script/spec -O spec/spec.opts spec/controllers/ > activations_controller_spec.rb spec/helpers/clients_helper_spec.rb > [a bunch of files omitted] > spec/models/enrollment_notifier_spec.rb spec/views/clients/ > email_form.html.erb_spec.rb > (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/runner/ > options.rb:5:in `mtime': Not a directory - spec/models/address_spec.rb > (Errno::ENOTDIR) > from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ > runner/options.rb:5 > from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ > runner/options.rb:251:in `sort' > from (druby://localhost:8989) ./../vendor/plugins/rspec/lib/spec/ > runner/options.rb:251:in `sorted_files' > > > Any ideas why spec_server has lost its marbles? Without the --drb > option autotest runs fine. Did this just start happening for you? If so, it could be the patch I applied in r3310. Would you mind checking out 3309 and seeing if you still have this problem? > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jarkko at jlaine.net Tue Feb 19 11:27:06 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 19 Feb 2008 18:27:06 +0200 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> Message-ID: <87102E9E-638A-4359-9DFC-AF61874BDA72@jlaine.net> On 19.2.2008, at 17.57, David Chelimsky wrote: > Did this just start happening for you? If so, it could be the patch I > applied in r3310. Would you mind checking out 3309 and seeing if you > still have this problem? That's it. However, with 3309 it seems that autotest doesn't really run through drb at all since it runs the same whether or not the spec_server is running. Yeah, I know that was the reason for the patch. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080219/881f102a/attachment.bin From jarkko at jlaine.net Tue Feb 19 12:08:01 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 19 Feb 2008 19:08:01 +0200 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> Message-ID: <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> On 19.2.2008, at 17.57, David Chelimsky wrote: > Did this just start happening for you? If so, it could be the patch I > applied in r3310. Would you mind checking out 3309 and seeing if you > still have this problem? Ok, found out the reason. I started spec_server from within the script directory and it only works correctly if you start it from the root of your Rails app. Gotcha. That said, now that autotest runs via drb, it's vastly (like 50%) slower than without it, doesn't respect the --colour option in spec.opts and causes failures that don't happen when running just plain autotest. All of them seem to be related to methods being run more times than they are supposed to. Examples: Mock 'Location_18994' expected :valid? with (any args) once, but received it twice expected: "Barney Hops doesn't have the required competency (MBA) to teach this class", got: ["Barney Hops doesn't have the required competency (MBA) to teach this class", "Barney Hops doesn't have the required competency (MBA) to teach this class"] Mock 'Enrollment' expected :on_waiting_list? with (any args) twice, but received it 3 times //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080219/d0305d7a/attachment-0001.bin From andy at r210.com Tue Feb 19 12:12:50 2008 From: andy at r210.com (Andy Leak) Date: Tue, 19 Feb 2008 12:12:50 -0500 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: <420bf25b6300ef5926938b3db695b7ee@ruby-forum.com> Message-ID: I got it working - using: - Cygwin on XP - Cygwin Ruby 1.8.6 - ZenTest 3.9.1 and RSpec 1.1.3 -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Jennifer Lindner Sent: Tuesday, February 19, 2008 7:32 AM To: rspec-users at rubyforge.org Subject: Re: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 David Chelimsky wrote: > Did you install both the rspec and rspec_on_rails 1.1.3 plugins? hey i've updated the plugins and still get the error: loading autotest/rails_rspec Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. i'm running ruby 1.8.5 and rails 1.2.3, ZenTest 3.9.1 and rspec 1.1.3. i reinstalled the plugins and then updated the gem too. any other ideas? maybe i should just try going back down to ZenTest 3.8.0 and rspec 1.1.2 and restarting machine. -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From andy at r210.com Tue Feb 19 12:22:45 2008 From: andy at r210.com (Andy Leak) Date: Tue, 19 Feb 2008 12:22:45 -0500 Subject: [rspec-users] Playing Sounds with Autotest/RSpec on Cygwin Message-ID: I've read about integrating Growl with Autotest/RSpec to display test results. For cygwin users - here is a snippet that will play a sound after autotest runs. Add the code below to your ~/.autotest file. Modify the path of the .wav file to the sounds you want to play on your system. Cheers, Andy vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Module AddSoundtoAutoTestforCygwin Autotest.add_hook :ran_command do |at| results = [at.results].flatten.join("\n") output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?/) if output if $~[2].to_i > 0 `cat /cygdrive/c/i386/ringout.wav > /dev/dsp` # failure else `cat /cygdrive/c/i386/chimes.wav > /dev/dsp` # success end end end end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080219/d05d06f2/attachment.html From lists at ruby-forum.com Tue Feb 19 12:29:46 2008 From: lists at ruby-forum.com (Jennifer Lindner) Date: Tue, 19 Feb 2008 18:29:46 +0100 Subject: [rspec-users] ZenTest-3.9.0 incompatible with RSpec-1.1.2 In-Reply-To: References: <57c63afe0801310325w3b44adfhf829b54c123a9b33@mail.gmail.com> <57c63afe0801311214o2ea1903ao1163bbd95ec3a7ea@mail.gmail.com> <709E5FF1-93AF-4632-BF29-39591731B5A0@matt-darby.com> <420bf25b6300ef5926938b3db695b7ee@ruby-forum.com> Message-ID: <073b9bc4f7e24b552249bf5f05754edd@ruby-forum.com> Andy Leak wrote: > I got it working - using: > - Cygwin on XP > - Cygwin Ruby 1.8.6 > - ZenTest 3.9.1 and RSpec 1.1.3 thanks..i did go from ruby 1.8.4 to 1.8.5 recently.. going to go for 1.8.6 etc. -- Posted via http://www.ruby-forum.com/. From andy at r210.com Tue Feb 19 12:35:10 2008 From: andy at r210.com (Andy Leak) Date: Tue, 19 Feb 2008 12:35:10 -0500 Subject: [rspec-users] RSpec and script/console?? Message-ID: I am a rSpec newbie. When learning ruby and rails, I found the console to be a really helpful tool. But I haven't been able to figure out how to drive RSpec from the console. Is using rSpec with the Console even a valid approach? Does anyone else use rSpec from the console?? - Andy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080219/10859606/attachment.html From omen.king at gmail.com Tue Feb 19 13:00:28 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Tue, 19 Feb 2008 13:00:28 -0500 Subject: [rspec-users] RSpec and script/console?? In-Reply-To: References: Message-ID: I don't know how or what the advantage would be to run it from console.I think the approach is just to run the specs file as normal. On Feb 19, 2008 12:35 PM, Andy Leak wrote: > I am a rSpec newbie. When learning ruby and rails, I found the console > to be a really helpful tool. But I haven't been able to figure out how to > drive RSpec from the console. > > > > Is using rSpec with the Console even a valid approach? > > > > Does anyone else use rSpec from the console?? > > > > - Andy > > > > _______________________________________________ > 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/20080219/cfae56e2/attachment.html From dchelimsky at gmail.com Tue Feb 19 13:09:19 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Feb 2008 13:09:19 -0500 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> Message-ID: <57c63afe0802191009p2a670f6axdf0a43a59dc3477e@mail.gmail.com> On Feb 19, 2008 12:08 PM, Jarkko Laine wrote: > On 19.2.2008, at 17.57, David Chelimsky wrote: > > Did this just start happening for you? If so, it could be the patch I > > applied in r3310. Would you mind checking out 3309 and seeing if you > > still have this problem? > > > Ok, found out the reason. I started spec_server from within the script > directory and it only works correctly if you start it from the root of > your Rails app. Gotcha. > > That said, now that autotest runs via drb, it's vastly (like 50%) > slower than without it, doesn't respect the --colour option in > spec.opts and causes failures that don't happen when running just > plain autotest. All of them seem to be related to methods being run > more times than they are supposed to. Examples: > > Mock 'Location_18994' expected :valid? with (any args) once, but > received it twice > > expected: "Barney Hops doesn't have the required competency (MBA) to > teach this class", > got: ["Barney Hops doesn't have the required competency (MBA) to > teach this class", "Barney Hops doesn't have the required competency > (MBA) to teach this class"] > > Mock 'Enrollment' expected :on_waiting_list? with (any args) twice, > but received it 3 times There are a few drb related tickets in lighthouse. Please add this if information if/where appropriate or add a new ticket. Thanks, David > > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From james.deville at gmail.com Tue Feb 19 13:18:54 2008 From: james.deville at gmail.com (James Deville) Date: Tue, 19 Feb 2008 10:18:54 -0800 Subject: [rspec-users] render_to_string in a controller test? In-Reply-To: <57c63afe0802190342u4f22f9a9ue360418e3c935a9c@mail.gmail.com> References: <57c63afe0802190342u4f22f9a9ue360418e3c935a9c@mail.gmail.com> Message-ID: <4757C873-69BD-41AA-95AB-7FC699E06C84@gmail.com> On Feb 19, 2008, at 3:42 AM, David Chelimsky wrote: > On Feb 18, 2008 8:10 PM, EAW wrote: >> Hi all, >> >> I know that in general, view and controller tests should be isolated, >> such that controller specs don't test views etc. However, I think >> I've run into a situation that might be an exception. >> >> My controller uses render_to_string to produce a chunk of HTML that >> it >> passes to a model to be processed. >> >> The controller then redirects the user to a different page. The >> results of the render_to_string are not seen by the user. >> >> Since the controller is calling render_to_string, I've been trying to >> test that it is rendered correctly in my controller spec. Because a >> controller spec normally doesn't render views, render_to_string just >> returns the path of the view, rather than the rendered output. This >> prevents me from testing the output of render_to_string in the >> controller spec. >> >> I can work around the issue by using integrate_views, and I guess >> that's fine, but shouldn't render_to_string really work in >> controllers? > > The whole point of isolation is to isolate the code in the controller > from the code in the view. The two primary reasons for this are that > it allows you to write controller code before the view exists and it > keeps failures in views isolated to the view specs (why should a > controller spec fail because of a typo in a view?). > > The fact that the result of rendering is being passed to a model > instead of a (theoretical) browser should not make a difference, > should it? > I am of two minds on this. On one, I can see testing that the controller assigns a template to a variable, and then test that the view is as expected in a view spec. On the other hand, if I am doing a render to string, then from a testing perspective, I'm assigning a variable. Whether that variable goes to the browser or a model shouldn't matter, we should enable testing of it as a variable. > I can see your argument for wanting to be able to treat this example > differently, and you can, as you pointed out, accomplish that with > integrate_views. Perhaps there should be a way to allow render_to_string to render a without making all views render. WDYT? James Deville http://devillecompanies.org james.deville at gmail.com rspec r3172 rspec_on_rails r3172 rails r8331 > > > FWIW, > David > >> >> Thanks for your input, >> >> e. >> -- >> ericw at xmtp.net >> >> "If the answer isn't violence, neither is your silence!" >> -- Pop Will Eat Itself, "Ich Bin Ein >> Auslander" >> >> >> _______________________________________________ >> 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 ed.howland at gmail.com Tue Feb 19 13:32:06 2008 From: ed.howland at gmail.com (Ed Howland) Date: Tue, 19 Feb 2008 12:32:06 -0600 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks Message-ID: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> Hi, I am trying to get Webrat integrated with RSpec. I've followed the steps in the various blog posts about this, but have one sniggling little issue. It might be a Webrat issue, but I am hoping the RSpec folks might have already solved it. I have the stories run from a Rake task (am hoping for one of these in the main rspec rake task soon,) ut to run webrat stuff in the steps, you need to: rake spec:stories RAILS_ENV=test. The reason is due to the boot order of rake and plugins (of which webrat and rspec are ones), webrat/init.rb doesn't attach itself to ActionController::Integration::Session unless it is on the test environment. Only setting the RAILS_ENV ahead of the boot sequence fixes this. But I am wondering if there is another alternative. Also, has anyone gotten it to run with autotest? Thanks in advance. Ed -- 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 dchelimsky at gmail.com Tue Feb 19 13:34:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Feb 2008 13:34:33 -0500 Subject: [rspec-users] render_to_string in a controller test? In-Reply-To: <4757C873-69BD-41AA-95AB-7FC699E06C84@gmail.com> References: <57c63afe0802190342u4f22f9a9ue360418e3c935a9c@mail.gmail.com> <4757C873-69BD-41AA-95AB-7FC699E06C84@gmail.com> Message-ID: <57c63afe0802191034s3a9f5299ma72423c84fb2e06d@mail.gmail.com> On Feb 19, 2008 1:18 PM, James Deville wrote: > > > On Feb 19, 2008, at 3:42 AM, David Chelimsky wrote: > > > On Feb 18, 2008 8:10 PM, EAW wrote: > >> Hi all, > >> > >> I know that in general, view and controller tests should be isolated, > >> such that controller specs don't test views etc. However, I think > >> I've run into a situation that might be an exception. > >> > >> My controller uses render_to_string to produce a chunk of HTML that > >> it > >> passes to a model to be processed. > >> > >> The controller then redirects the user to a different page. The > >> results of the render_to_string are not seen by the user. > >> > >> Since the controller is calling render_to_string, I've been trying to > >> test that it is rendered correctly in my controller spec. Because a > >> controller spec normally doesn't render views, render_to_string just > >> returns the path of the view, rather than the rendered output. This > >> prevents me from testing the output of render_to_string in the > >> controller spec. > >> > >> I can work around the issue by using integrate_views, and I guess > >> that's fine, but shouldn't render_to_string really work in > >> controllers? > > > > The whole point of isolation is to isolate the code in the controller > > from the code in the view. The two primary reasons for this are that > > it allows you to write controller code before the view exists and it > > keeps failures in views isolated to the view specs (why should a > > controller spec fail because of a typo in a view?). > > > > The fact that the result of rendering is being passed to a model > > instead of a (theoretical) browser should not make a difference, > > should it? > > > > I am of two minds on this. On one, I can see testing that the > controller assigns a template to a variable, and then test that the > view is as expected in a view spec. On the other hand, if I am doing a > render to string, then from a testing perspective, I'm assigning a > variable. Whether that variable goes to the browser or a model > shouldn't matter, we should enable testing of it as a variable. > > > I can see your argument for wanting to be able to treat this example > > differently, and you can, as you pointed out, accomplish that with > > integrate_views. > > Perhaps there should be a way to allow render_to_string to render a > without making all views render. There already is. You can already integrate_views in a single example group. describe FooController, " ... exception case ..." do integrate_views ... end > > WDYT? > > James Deville > http://devillecompanies.org > james.deville at gmail.com > rspec r3172 > rspec_on_rails r3172 > rails r8331 > > > > > > > > FWIW, > > David > > > >> > >> Thanks for your input, > >> > >> e. > >> -- > >> ericw at xmtp.net > >> > >> "If the answer isn't violence, neither is your silence!" > >> -- Pop Will Eat Itself, "Ich Bin Ein > >> Auslander" > >> > >> > >> _______________________________________________ > >> 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 james.deville at gmail.com Tue Feb 19 13:45:14 2008 From: james.deville at gmail.com (James Deville) Date: Tue, 19 Feb 2008 10:45:14 -0800 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> Message-ID: <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> I set RAILS_ENV in my stories/helper.rb file. That might be a good solution. On Feb 19, 2008, at 10:32 AM, Ed Howland wrote: > Hi, > > I am trying to get Webrat integrated with RSpec. I've followed the > steps in the various blog posts about this, but have one sniggling > little issue. It might be a Webrat issue, but I am hoping the RSpec > folks might have already solved it. > > I have the stories run from a Rake task (am hoping for one of these > in the main rspec rake task soon,) ut to run webrat stuff in the > steps, you need to: > > rake spec:stories RAILS_ENV=test. > > The reason is due to the boot order of rake and plugins (of which > webrat and rspec are ones), webrat/init.rb doesn't attach itself to > ActionController::Integration::Session unless it is on the test > environment. Only setting the RAILS_ENV ahead of the boot sequence > fixes this. But I am wondering if there is another alternative. > > Also, has anyone gotten it to run with autotest? > > Thanks in advance. > > Ed > > > > > -- > 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 James Deville http://devillecompanies.org james.deville at gmail.com rspec r3172 rspec_on_rails r3172 rails r8331 From lists at ruby-forum.com Tue Feb 19 16:41:18 2008 From: lists at ruby-forum.com (=?utf-8?Q?Art=c5=abras_=c5=a0lajus?=) Date: Tue, 19 Feb 2008 22:41:18 +0100 Subject: [rspec-users] Mocking kills usefullness of controller tests? Message-ID: <0e706e66d811c2d1800ac3262ac0d208@ruby-forum.com> Hello, Let's say we mock our User objects in controllers. Then we change attr_accessible in user.rb. Model tests break, controller do not. You fix the model ones and go on thinking everything is ok when it's not (the controllers are broken). Even with technique in http://www.ruby-forum.com/topic/128149 you would only be testing if attr_accessible gets called. It wouldn't show you places in your controllers where you need to change that mass assignment to attribute assignment. Any ideas how to prevent it? -- Posted via http://www.ruby-forum.com/. From brian.takita at gmail.com Tue Feb 19 16:44:36 2008 From: brian.takita at gmail.com (Brian Takita) Date: Tue, 19 Feb 2008 13:44:36 -0800 Subject: [rspec-users] deep test with rspec? In-Reply-To: References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> <47A5243F.3030109@benmabey.com> <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> Message-ID: <1d7ddd110802191344v4e076d5fuf62c32f74e551cad@mail.gmail.com> On Feb 18, 2008 7:06 PM, Dan Manges wrote: > David Vollbracht spiked an rspec implementation for DeepTest: > svn diff -r 20:21 http://deep-test.rubyforge.org/svn/trunk > > Unfortunately nobody has had time to finish it. If anybody is interested in > working on it, that would be awesome. I can give you repo access. I would be interested in trying to get it to work. > > Dan > > > > On Feb 2, 2008 9:37 PM, Scott Taylor wrote: > > > > > > > > > > On Feb 2, 2008, at 9:17 PM, Ben Mabey wrote: > > > > > Scott Taylor wrote: > > >> On Feb 2, 2008, at 12:09 PM, Ben Mabey wrote: > > >> > > >> > > >>> Ben Mabey wrote: > > >>> > > >>>> All, > > >>>> Has anyone on this list tried to use DeepTest[1] with rspec? My > > >>>> initial > > >>>> attempts have failed so I would be really interested if someone has > > >>>> figured it out. Thanks. > > >>>> > > >>>> -Ben > > >>>> > > >>>> 1. http://www.somethingnimble.com/bliki/deep-test > > >>>> _______________________________________________ > > >>>> rspec-users mailing list > > >>>> rspec-users at rubyforge.org > > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > > >>>> > > >>>> > > >>> Or maybe someone has some experience with spec_distributed they > > >>> could > > >>> share? I'm just trying to see if I can get my specs to run faster > > >>> on my > > >>> multi-core machines.... > > >>> > > >> > > >> I haven't used deep test (this was by Dan Manges / Thoughtworks, > > >> correct?). If I recall correctly, it only worked on test/unit. I > > >> don't know if anyone else was working on a version for rspec... > > >> > > > Right.. There were some comments in Dan's original post about someone > > > working on rspec compatibility but as far as I can tell that never > > > made > > > it into the gem. > > >> As for spec_distributed, I had gotten it working, and as I recall, it > > >> was pretty easy to do (at least, on a non-rails project). The > > >> documentation for that is pretty straight forward. It solves the > > >> speed problem by throwing hardware at the problem - If you have n > > >> number of machines, your test suite should take 1/n the amount of > > >> time it usually does on one machine (assuming the machines of equal > > >> processing power). > > >> > > > > > > Does this really address the use of multicores on a single machine > > > then? The only use I could see of this would be for running your CI > > > faster over a number of machines... > > > Thanks for you input, > > > > No - it doesn't, but it would cut your test suite in half, just as > > two processors would. > > > > I'm sure I'm not the only one who would like to know if you took up > > the job of getting deep test to run w/ rspec. > > > > Regards, > > > > Scott > > > > > > > > _______________________________________________ > > 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 brian.takita at gmail.com Tue Feb 19 16:55:45 2008 From: brian.takita at gmail.com (Brian Takita) Date: Tue, 19 Feb 2008 13:55:45 -0800 Subject: [rspec-users] Mocking kills usefullness of controller tests? In-Reply-To: <0e706e66d811c2d1800ac3262ac0d208@ruby-forum.com> References: <0e706e66d811c2d1800ac3262ac0d208@ruby-forum.com> Message-ID: <1d7ddd110802191355t770a9f80g46ae7184569b7c99@mail.gmail.com> On Feb 19, 2008 1:41 PM, Art?ras ?lajus wrote: > Hello, > > Let's say we mock our User objects in controllers. Then we change > attr_accessible in user.rb. Model tests break, controller do not. > > You fix the model ones and go on thinking everything is ok when it's not > (the controllers are broken). > > Even with technique in http://www.ruby-forum.com/topic/128149 you would > only be testing if attr_accessible gets called. It wouldn't show you > places in your controllers where you need to change that mass assignment > to attribute assignment. > > Any ideas how to prevent it? This is a common tradeoff when using mocks. You lose the integration aspects and arguably incur more maintenance overhead but gain speed and isolation. It looks like you want to have integration coverage over that code. You can either use controller specs without mocks, rails integration specs, and/or selenium (or watir) test that covers that piece of code. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mailing_lists at railsnewbie.com Tue Feb 19 23:55:12 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 19 Feb 2008 23:55:12 -0500 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> Message-ID: <5FA7A5CA-66AA-4B98-929D-79FFA6BB92D7@railsnewbie.com> On Feb 19, 2008, at 12:08 PM, Jarkko Laine wrote: > On 19.2.2008, at 17.57, David Chelimsky wrote: >> Did this just start happening for you? If so, it could be the patch I >> applied in r3310. Would you mind checking out 3309 and seeing if you >> still have this problem? > > > Ok, found out the reason. I started spec_server from within the > script directory and it only works correctly if you start it from > the root of your Rails app. Gotcha. > > That said, now that autotest runs via drb, it's vastly (like 50%) > slower than without it, That's the idea. > doesn't respect the --colour option in spec.opts That's been a bug since 0.6 or 0.7 when I started with rspec. I guess not enough people have used the spec server for it to be already patched. I'll take a look at fixing it this weekend. > and causes failures that don't happen when running just plain > autotest. > All of them seem to be related to methods being run more times than > they are supposed to. Examples: > > Mock 'Location_18994' expected :valid? with (any args) once, but > received it twice I saw this happen recently when the spec server was started twice: once with the rake task (rake spec:server:start), the other with a straight script/spec_sever. My hunch is that both servers are loading the files at the same time. > > expected: "Barney Hops doesn't have the required competency (MBA) > to teach this class", > got: ["Barney Hops doesn't have the required competency (MBA) > to teach this class", "Barney Hops doesn't have the required > competency (MBA) to teach this class"] > Yeah - this is because rails load's instead of requires. You'll also see this sort of thing if you just call load directly in your specs. I've never dug deeper into how all of the rails magic happens regarding loading and constants (and the method generation with the association macros (has_* belongs_to), so if you have any insight, I'd be happy to hear it. Scott From mailing_lists at railsnewbie.com Tue Feb 19 23:59:05 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 19 Feb 2008 23:59:05 -0500 Subject: [rspec-users] deep test with rspec? In-Reply-To: <1d7ddd110802191344v4e076d5fuf62c32f74e551cad@mail.gmail.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> <47A5243F.3030109@benmabey.com> <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> <1d7ddd110802191344v4e076d5fuf62c32f74e551cad@mail.gmail.com> Message-ID: <2127C586-BFFE-43DC-9BC8-EE4844577C4A@railsnewbie.com> On Feb 19, 2008, at 4:44 PM, Brian Takita wrote: > On Feb 18, 2008 7:06 PM, Dan Manges wrote: >> David Vollbracht spiked an rspec implementation for DeepTest: >> svn diff -r 20:21 http://deep-test.rubyforge.org/svn/trunk >> >> Unfortunately nobody has had time to finish it. If anybody is >> interested in >> working on it, that would be awesome. I can give you repo access. > I would be interested in trying to get it to work. Cool. Glad to hear it's out there. I'd be interesting in helping out, too. Scott From zach.dennis at gmail.com Wed Feb 20 00:06:22 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 20 Feb 2008 00:06:22 -0500 Subject: [rspec-users] Old Style Stories Message-ID: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> I was working on a past project tonight to trunk which is using the old story format. IE: Given "desc" do / end When "someting "do /end etc.. Is this officially supported, or is this just something that hasn't been ripped out yet? If it is officially supported how attached are people to the re-using of do/end blocks which match the same description. Every now and then it bites me and I end up having to change one of the descriptions to differ textually then another. IMO it is kind of annoying. A story part description may have the same description as another in the same scenario. Sometimes the sequence of steps provide the context, -- Zach Dennis http://www.continuousthinking.com From ben at benmabey.com Wed Feb 20 00:12:41 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 19 Feb 2008 22:12:41 -0700 Subject: [rspec-users] deep test with rspec? In-Reply-To: <2127C586-BFFE-43DC-9BC8-EE4844577C4A@railsnewbie.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> <47A5243F.3030109@benmabey.com> <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> <1d7ddd110802191344v4e076d5fuf62c32f74e551cad@mail.gmail.com> <2127C586-BFFE-43DC-9BC8-EE4844577C4A@railsnewbie.com> Message-ID: <47BBB6C9.9020001@benmabey.com> Scott Taylor wrote: > On Feb 19, 2008, at 4:44 PM, Brian Takita wrote: > > >> On Feb 18, 2008 7:06 PM, Dan Manges wrote: >> >>> David Vollbracht spiked an rspec implementation for DeepTest: >>> svn diff -r 20:21 http://deep-test.rubyforge.org/svn/trunk >>> >>> Unfortunately nobody has had time to finish it. If anybody is >>> interested in >>> working on it, that would be awesome. I can give you repo access. >>> >> I would be interested in trying to get it to work. >> > > Cool. Glad to hear it's out there. I'd be interesting in helping > out, too. > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I'd like to see this working as well. I have never used rinda so I'll check it out so see what I can do to help. -Ben From lists at ruby-forum.com Wed Feb 20 00:35:19 2008 From: lists at ruby-forum.com (Peter Recore) Date: Wed, 20 Feb 2008 06:35:19 +0100 Subject: [rspec-users] does the rspec_scaffold generator know about :references ? Message-ID: I checked out the CURRENT release of rspec and rails_spec as outlined on the rubyforge page. I am having trouble with models that use the :references column type. I get tests with syntax errors after generating a new class from scratch using ruby script/generate rspec_scaffold. The problem seems to be that no default values are generated for these types in the templates used by the generator. I feel that there is a 2/3 chance I am wrong here, and 1/3 that rspec just doesn't handle this part of rails 2 yet. 1. I am supposed to edit the spec scaffolding for all models with associations. 2. I am doing something else wrong. 3. Rspec just doesn't support :references yet, and I should maybe figure out how and write a patch, assuming I continue to use rspec and fall in love with it like everyone seems to have. Can anyone tell me which of the above is correct, if any? Thanks! (PS: spec_server is going to save my sanity on my ever so cute but ever so slow ultraportable) Here is the line i use to generate the class: ruby script/generate rspec_scaffold MyBar foo:references Here is the specific syntax error. You can see where the value should be is blank. C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load': C:/instantrails/rails_apps/silver/spec/vi ews/my_bars/index.html.erb_spec.rb:17: syntax error, unexpected ',' (SyntaxError) response.should have_tag("tr>td", , 2) ^ from C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489 :in `load' from C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in' from C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load' from C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load_files' from C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in `each' from C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in `load_files' from C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/options.rb:85:in `run_examples' from C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' from script/spec:4 -- Posted via http://www.ruby-forum.com/. From jarkko at jlaine.net Wed Feb 20 01:52:45 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 20 Feb 2008 08:52:45 +0200 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <5FA7A5CA-66AA-4B98-929D-79FFA6BB92D7@railsnewbie.com> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> <5FA7A5CA-66AA-4B98-929D-79FFA6BB92D7@railsnewbie.com> Message-ID: <412AF32D-58D7-416C-8994-94481F142583@jlaine.net> On 20.2.2008, at 6.55, Scott Taylor wrote: >> That said, now that autotest runs via drb, it's vastly (like 50%) >> slower than without it, > > That's the idea. Isn't the idea that specs run faster through drb, rather than slower? However, in general my specs seem to take a lot longer when run through autotest in the first place (compared to running just rake spec:models, e.g.). I haven't so far been able to track down what causes this. >> Mock 'Location_18994' expected :valid? with (any args) once, but >> received it twice > > I saw this happen recently when the spec server was started twice: > once with the rake task (rake spec:server:start), the other with a > straight script/spec_sever. My hunch is that both servers are > loading the files at the same time. That would seem logical. However, I just checked that I only have one spec_server process running and am still able to reproduce the problem. >> expected: "Barney Hops doesn't have the required competency (MBA) >> to teach this class", >> got: ["Barney Hops doesn't have the required competency (MBA) >> to teach this class", "Barney Hops doesn't have the required >> competency (MBA) to teach this class"] >> > > Yeah - this is because rails load's instead of requires. You'll also > see this sort of thing if you just call load directly in your specs. > I've never dug deeper into how all of the rails magic happens > regarding loading and constants (and the method generation with the > association macros (has_* belongs_to), so if you have any insight, > I'd be happy to hear it. Yeah, all these failures are certainly related and probably caused by something like what you describe. Got to try to figure out what spec_server does differently than normal spec. Or maybe we should just bite the bullet and make the deeptest spec fork work :-) Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080220/6c07b70e/attachment.bin From jarkko at jlaine.net Wed Feb 20 01:58:35 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 20 Feb 2008 08:58:35 +0200 Subject: [rspec-users] deep test with rspec? In-Reply-To: <47BBB6C9.9020001@benmabey.com> References: <47A4A276.7010805@benmabey.com> <47A4A3AF.5000708@benmabey.com> <6F782576-3A1C-4F44-8557-C8DFC3BF5E96@railsnewbie.com> <47A5243F.3030109@benmabey.com> <79F67841-B8AF-4597-A097-331736FD2C49@railsnewbie.com> <1d7ddd110802191344v4e076d5fuf62c32f74e551cad@mail.gmail.com> <2127C586-BFFE-43DC-9BC8-EE4844577C4A@railsnewbie.com> <47BBB6C9.9020001@benmabey.com> Message-ID: On 20.2.2008, at 7.12, Ben Mabey wrote: > Scott Taylor wrote: >> On Feb 19, 2008, at 4:44 PM, Brian Takita wrote: >> >> >>> On Feb 18, 2008 7:06 PM, Dan Manges wrote: >>> >>>> David Vollbracht spiked an rspec implementation for DeepTest: >>>> svn diff -r 20:21 http://deep-test.rubyforge.org/svn/trunk >>>> >>>> Unfortunately nobody has had time to finish it. If anybody is >>>> interested in >>>> working on it, that would be awesome. I can give you repo access. >>>> >>> I would be interested in trying to get it to work. >>> >> >> Cool. Glad to hear it's out there. I'd be interesting in helping >> out, too. >> >> Scott >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > I'd like to see this working as well. I have never used rinda so I'll > check it out so see what I can do to help. +1 > > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080220/58b6e7ee/attachment.bin From jarkko at jlaine.net Wed Feb 20 02:02:45 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 20 Feb 2008 09:02:45 +0200 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> Message-ID: On 19.2.2008, at 20.45, James Deville wrote: > I set RAILS_ENV in my stories/helper.rb file. That might be a good > solution. > > > On Feb 19, 2008, at 10:32 AM, Ed Howland wrote: > >> Hi, >> >> I am trying to get Webrat integrated with RSpec. I've followed the >> steps in the various blog posts about this, but have one sniggling >> little issue. It might be a Webrat issue, but I am hoping the RSpec >> folks might have already solved it. >> >> I have the stories run from a Rake task (am hoping for one of these >> in the main rspec rake task soon,) ut to run webrat stuff in the >> steps, you need to: >> >> rake spec:stories RAILS_ENV=test. >> >> The reason is due to the boot order of rake and plugins (of which >> webrat and rspec are ones), webrat/init.rb doesn't attach itself to >> ActionController::Integration::Session unless it is on the test >> environment. Only setting the RAILS_ENV ahead of the boot sequence >> fixes this. But I am wondering if there is another alternative. >> >> Also, has anyone gotten it to run with autotest? Using Webrat for 100% of my stories (and running autotest) and loving it. I also have the env set in stories/helper.rb, but I'm not sure whether it was there from the beginning (I just copied it from some of the early posts about stories). //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080220/1de36c08/attachment.bin From dchelimsky at gmail.com Wed Feb 20 07:26:59 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Feb 2008 07:26:59 -0500 Subject: [rspec-users] Old Style Stories In-Reply-To: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> Message-ID: <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> On Feb 20, 2008 12:06 AM, Zach Dennis wrote: > I was working on a past project tonight to trunk which is using the > old story format. IE: > Given "desc" do / end > When "someting "do /end > etc.. > > Is this officially supported, or is this just something that hasn't > been ripped out yet? It's funny to me that this is "Old Style" in your view. It's really just another approach. Plain text is great for some situations, but so is writing in Ruby :) Depends on the team, really, and how involved the customer is in actually doing the typing. > If it is officially supported how attached are people to the re-using > of do/end blocks which match the same description. Every now and then > it bites me and I end up having to change one of the descriptions to > differ textually then another. Why would this be specific to scenarios written in Ruby? > IMO it is kind of annoying. A story > part description may have the same description as another in the same > scenario. Sometimes the sequence of steps provide the context, This seems unfinished - was there more to this sentence? I think this is just a matter of documentation. If we got rid of block-sharing we'd be promoting much more verbose scenarios with a lot of redundancy. I think it's here to stay. FWIW, David > > -- > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 20 07:28:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Feb 2008 07:28:23 -0500 Subject: [rspec-users] does the rspec_scaffold generator know about :references ? In-Reply-To: References: Message-ID: <57c63afe0802200428r140d7736h887b05435efb5651@mail.gmail.com> On Feb 20, 2008 12:35 AM, Peter Recore wrote: > I checked out the CURRENT release of rspec and rails_spec as outlined on > the rubyforge page. I am having trouble with models that use the > :references column type. I get tests with syntax errors after > generating a new class from scratch using ruby script/generate > rspec_scaffold. The problem seems to be that no default values are > generated for these types in the templates used by the generator. I > feel that there is a 2/3 chance I am wrong here, and 1/3 that rspec just > doesn't handle this part of rails 2 yet. > > 1. I am supposed to edit the spec scaffolding for all models with > associations. > 2. I am doing something else wrong. > 3. Rspec just doesn't support :references yet, and I should maybe > figure out how and write a patch, assuming I continue to use rspec and > fall in love with it like everyone seems to have. #3 - patch away: http://rspec.lighthouseapp.com. Cheers, David > > Can anyone tell me which of the above is correct, if any? > > Thanks! (PS: spec_server is going to save my sanity on my ever so cute > but ever so slow ultraportable) > > > > Here is the line i use to generate the class: > > ruby script/generate rspec_scaffold MyBar foo:references > > Here is the specific syntax error. You can see where the value should be > is blank. > > C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in > `load': C:/instantrails/rails_apps/silver/spec/vi > ews/my_bars/index.html.erb_spec.rb:17: syntax error, unexpected ',' > (SyntaxError) > response.should have_tag("tr>td", , 2) > ^ from > C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489 > :in `load' > from > C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in > `new_constants_in' > from > C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in > `load' > from > C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > from > C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in > `each' > from > C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in > `load_files' > from > C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/options.rb:85:in > `run_examples' > from > C:/instantrails/rails_apps/silver/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in > `run' > from script/spec:4 > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 20 07:32:34 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Feb 2008 07:32:34 -0500 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> Message-ID: <57c63afe0802200432p20f64c03pc71de50f6aa93e07@mail.gmail.com> On Feb 20, 2008 2:02 AM, Jarkko Laine wrote: > > On 19.2.2008, at 20.45, James Deville wrote: > > > I set RAILS_ENV in my stories/helper.rb file. That might be a good > > solution. > > > > > > On Feb 19, 2008, at 10:32 AM, Ed Howland wrote: > > > >> Hi, > >> > >> I am trying to get Webrat integrated with RSpec. I've followed the > >> steps in the various blog posts about this, but have one sniggling > >> little issue. It might be a Webrat issue, but I am hoping the RSpec > >> folks might have already solved it. > >> > >> I have the stories run from a Rake task (am hoping for one of these > >> in the main rspec rake task soon,) ut to run webrat stuff in the > >> steps, you need to: > >> > >> rake spec:stories RAILS_ENV=test. > >> > >> The reason is due to the boot order of rake and plugins (of which > >> webrat and rspec are ones), webrat/init.rb doesn't attach itself to > >> ActionController::Integration::Session unless it is on the test > >> environment. Only setting the RAILS_ENV ahead of the boot sequence > >> fixes this. But I am wondering if there is another alternative. > >> > >> Also, has anyone gotten it to run with autotest? > > Using Webrat for 100% of my stories (and running autotest) and loving > it. I also have the env set in stories/helper.rb, but I'm not sure > whether it was there from the beginning (I just copied it from some of > the early posts about stories). This is set in the generated stories/helper.rb (when you run 'script/generate rspec'). Cheers, David > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lattam at mac.com Wed Feb 20 13:30:49 2008 From: lattam at mac.com (Michael Latta) Date: Wed, 20 Feb 2008 10:30:49 -0800 Subject: [rspec-users] Shared scenarios? Message-ID: <29703BDB-0509-41AF-B58E-535D9C691891@mac.com> In the story framework I would like to have tests that mix and match scenarios using GivenScenario so for example a scenario that does scenarios A, B, C in various orders. Right now all scenarios need to be self-standing since all the scenarios in the story get run. I would like scenarios that are only run from GivenScenario so they can be modular. Is this possible? Alternatively could I use GivenScenario to invoke scenarios from another story that is never itself directly run? Michael From dchelimsky at gmail.com Wed Feb 20 13:50:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Feb 2008 13:50:23 -0500 Subject: [rspec-users] Shared scenarios? In-Reply-To: <29703BDB-0509-41AF-B58E-535D9C691891@mac.com> References: <29703BDB-0509-41AF-B58E-535D9C691891@mac.com> Message-ID: <57c63afe0802201050ied2b138obb067c6372eafbb7@mail.gmail.com> On Feb 20, 2008 1:30 PM, Michael Latta wrote: > In the story framework I would like to have tests that mix and match > scenarios using GivenScenario so for example a scenario that does > scenarios A, B, C in various orders. Right now all scenarios need to > be self-standing since all the scenarios in the story get run. I > would like scenarios that are only run from GivenScenario so they can > be modular. Is this possible? Alternatively could I use > GivenScenario to invoke scenarios from another story that is never > itself directly run? Neither of these are currently supported. Feel free to enter feature request tickets at http://rspec.lighthouseapp.com. Cheers, David > > Michael > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lattam at mac.com Wed Feb 20 14:36:48 2008 From: lattam at mac.com (Michael Latta) Date: Wed, 20 Feb 2008 11:36:48 -0800 Subject: [rspec-users] Shared scenarios? In-Reply-To: <57c63afe0802201050ied2b138obb067c6372eafbb7@mail.gmail.com> References: <29703BDB-0509-41AF-B58E-535D9C691891@mac.com> <57c63afe0802201050ied2b138obb067c6372eafbb7@mail.gmail.com> Message-ID: <0CF3FD12-D83B-49B2-9CCE-FAD02F8C5992@mac.com> David, I am new to rspec. What is the process for getting changes done? If I implement this is it hard to get into the release version? What is the recommended approach for submitting such a change? Michael On Feb 20, 2008, at 10:50 AM, David Chelimsky wrote: > On Feb 20, 2008 1:30 PM, Michael Latta wrote: >> In the story framework I would like to have tests that mix and match >> scenarios using GivenScenario so for example a scenario that does >> scenarios A, B, C in various orders. Right now all scenarios need to >> be self-standing since all the scenarios in the story get run. I >> would like scenarios that are only run from GivenScenario so they can >> be modular. Is this possible? Alternatively could I use >> GivenScenario to invoke scenarios from another story that is never >> itself directly run? > > Neither of these are currently supported. Feel free to enter feature > request tickets at http://rspec.lighthouseapp.com. > > Cheers, > David > >> >> Michael >> >> _______________________________________________ >> 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 cremes.devlist at mac.com Wed Feb 20 16:33:54 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Wed, 20 Feb 2008 15:33:54 -0600 Subject: [rspec-users] newbie - am I on the right track? Message-ID: A few days ago I posted a message asking for help in pointing out examples of rspec in the wild. I took the input from that thread, looked through specs from random projects on rubyforge, and pored over the docs. I decided to make my first project a rewrite of a Protocol for EventMachine [1] that I had created a few weeks ago. I want to tap into the hive brain here and make sure I'm doing things right because I feel kind of nervous. For example, the original version I wrote used a little fsm (finite state machine) for reading the header and body from incoming packets and extracting messages from it. In retrospect this factor probably made this project a bad choice for my first BDD. The whole "tell, don't ask" style doesn't come into play very much when verifying the specific states of a fsm. :-) Anyway, here is a printout of what I have spec'ed so far. I sort of know which way to go with this design, but even with that foreknowledge I am surprised how the design is *already different.* I am keeping all specs (except one) to a single assertion/check. I am refactoring my class code when any method exceeds 5 real lines. I'd like experienced BDD'ers to take a peek here and let me know if I'm going in the right direction. These specs are for a buffer utility class used by the EM::Protocol. Any hints or observations would be appreciated. If you want to see the actual specs or class code, let me know and I'll post that in a follow-up. cremes$ spec buf_spec.rb -f s Buf (creation) - should exist - should default to a header length of 1 like a pascal string - should take an integer in its initializer specifying header length - should allow a multi-byte integer in its initializer specifying header length - should default to the state :read_header given correct input - should raise an exception given an incorrect argument type in #new Buf (reading headers, :read_header state) - should remain in state :read_header when it doesn't receive the entire header in one chunk - should transition to the state :read_header_done when it receives the entire header in one chunk - should transition to the state :read_header_done when it receives the entire header in 2 chunks - should transition to the state :read_header_done when it receives the header in multiple chunks Buf ( interpreting header data, default behavior like pascal string) - should interpret the header as a packed byte - should be able to interpret multi-byte headers when the default header_length is overridden (PENDING: Not Yet Implemented) Buf (read header and read body, single message) - should read header and then consume that many bytes as the body (PENDING: Not Yet Implemented) - should read a whole message and end in the :read_body_done state (PENDING: Not Yet Implemented) - should transition to :read_header from :read_body_done when given more data (PENDING: Not Yet Implemented) - should return an array containing a string corresponding to the input (PENDING: Not Yet Implemented) Buf (read header and read body, multiple messages) - should behave like a single message (PENDING: Not Yet Implemented) - should return an array containing a string element corresponding to each message from the input (PENDING: Not Yet Implemented) Pending: Buf ( interpreting header data, default behavior like pascal string) should be able to interpret multi-byte headers when the default header_length is overridden (Not Yet Implemented) Buf (read header and read body, single message) should read header and then consume that many bytes as the body (Not Yet Implemented) Buf (read header and read body, single message) should read a whole message and end in the :read_body_done state (Not Yet Implemented) Buf (read header and read body, single message) should transition to :read_header from :read_body_done when given more data (Not Yet Implemented) Buf (read header and read body, single message) should return an array containing a string corresponding to the input (Not Yet Implemented) Buf (read header and read body, multiple messages) should behave like a single message (Not Yet Implemented) Buf (read header and read body, multiple messages) should return an array containing a string element corresponding to each message from the input (Not Yet Implemented) Finished in 0.011039 seconds 18 examples, 0 failures, 7 pending [1] http://rubyeventmachine.com/ From dchelimsky at gmail.com Wed Feb 20 19:14:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Feb 2008 19:14:18 -0500 Subject: [rspec-users] Shared scenarios? In-Reply-To: <0CF3FD12-D83B-49B2-9CCE-FAD02F8C5992@mac.com> References: <29703BDB-0509-41AF-B58E-535D9C691891@mac.com> <57c63afe0802201050ied2b138obb067c6372eafbb7@mail.gmail.com> <0CF3FD12-D83B-49B2-9CCE-FAD02F8C5992@mac.com> Message-ID: <57c63afe0802201614p4550a4fai97216cd99dcdd7ef@mail.gmail.com> On Wed, Feb 20, 2008 at 2:36 PM, Michael Latta wrote: > David, > > I am new to rspec. What is the process for getting changes done? If > I implement this is it hard to get into the release version? What is > the recommended approach for submitting such a change? First read this: http://rspec.lighthouseapp.com/projects/5645/how-to-file-a-ticket. Then post back here if you have any questions. Cheers, David > > Michael > > > > > > On Feb 20, 2008, at 10:50 AM, David Chelimsky wrote: > > > On Feb 20, 2008 1:30 PM, Michael Latta wrote: > >> In the story framework I would like to have tests that mix and match > >> scenarios using GivenScenario so for example a scenario that does > >> scenarios A, B, C in various orders. Right now all scenarios need to > >> be self-standing since all the scenarios in the story get run. I > >> would like scenarios that are only run from GivenScenario so they can > >> be modular. Is this possible? Alternatively could I use > >> GivenScenario to invoke scenarios from another story that is never > >> itself directly run? > > > > Neither of these are currently supported. Feel free to enter feature > > request tickets at http://rspec.lighthouseapp.com. > > > > Cheers, > > David > > > >> > >> Michael > >> > >> _______________________________________________ > >> 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 mailing_lists at railsnewbie.com Wed Feb 20 21:14:56 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 20 Feb 2008 21:14:56 -0500 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <412AF32D-58D7-416C-8994-94481F142583@jlaine.net> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> <5FA7A5CA-66AA-4B98-929D-79FFA6BB92D7@railsnewbie.com> <412AF32D-58D7-416C-8994-94481F142583@jlaine.net> Message-ID: <769B3D7F-A046-4C70-BAC7-81955674C562@railsnewbie.com> On Feb 20, 2008, at 1:52 AM, Jarkko Laine wrote: > On 20.2.2008, at 6.55, Scott Taylor wrote: >>> That said, now that autotest runs via drb, it's vastly (like 50%) >>> slower than without it, >> >> That's the idea. > > Isn't the idea that specs run faster through drb, rather than > slower? However, in general my specs seem to take a lot longer when > run through autotest in the first place (compared to running just > rake spec:models, e.g.). I haven't so far been able to track down > what causes this. Oops. Misread your post. Is this true running a single spec (or a single file)? I've noticed that a test suite which takes about 5 seconds normally takes about 7 seconds under drb (according to the numbers reported by rspec). Then again, running a single file is blazingly fast, as their is no wait (as though I'm testing against a non-rails project). > >>> Mock 'Location_18994' expected :valid? with (any args) once, but >>> received it twice >> >> I saw this happen recently when the spec server was started twice: >> once with the rake task (rake spec:server:start), the other with a >> straight script/spec_sever. My hunch is that both servers are >> loading the files at the same time. > > That would seem logical. However, I just checked that I only have > one spec_server process running and am still able to reproduce the > problem. Hmm. Are you reloading classes or using anonymous classes derived from AR::Base, or anything crazy like that? Are all your models in app/models? Do you have pending migrations? Are your running with rake, or with autotest? How about running the file alone? > >>> expected: "Barney Hops doesn't have the required competency (MBA) >>> to teach this class", >>> got: ["Barney Hops doesn't have the required competency (MBA) >>> to teach this class", "Barney Hops doesn't have the required >>> competency (MBA) to teach this class"] >>> >> >> Yeah - this is because rails load's instead of requires. You'll also >> see this sort of thing if you just call load directly in your specs. >> I've never dug deeper into how all of the rails magic happens >> regarding loading and constants (and the method generation with the >> association macros (has_* belongs_to), so if you have any insight, >> I'd be happy to hear it. > > Yeah, all these failures are certainly related and probably caused > by something like what you describe. Got to try to figure out what > spec_server does differently than normal spec. Or maybe we should > just bite the bullet and make the deeptest spec fork work :-) > Yeah - deeptest is great for slow suites, but now that I have a fast suite (take 5-7 seconds), deeptest probably wouldn't be much of a performance gain for me. Scott From mailing_lists at railsnewbie.com Wed Feb 20 21:27:23 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 20 Feb 2008 21:27:23 -0500 Subject: [rspec-users] Shared scenarios? In-Reply-To: <0CF3FD12-D83B-49B2-9CCE-FAD02F8C5992@mac.com> References: <29703BDB-0509-41AF-B58E-535D9C691891@mac.com> <57c63afe0802201050ied2b138obb067c6372eafbb7@mail.gmail.com> <0CF3FD12-D83B-49B2-9CCE-FAD02F8C5992@mac.com> Message-ID: <2E1D5197-7B89-4FDA-A749-68537D689457@railsnewbie.com> On Feb 20, 2008, at 2:36 PM, Michael Latta wrote: > David, > > I am new to rspec. What is the process for getting changes done? If > I implement this is it hard to get into the release version? What is > the recommended approach for submitting such a change? > > Michael > 1. Download a copy of trunk 2. make a test driven change (obviously) 3. When done, rake install_dependencies, and rake pre_commit 4. svn diff > your_patch.diff 5. Create a ticket on lighthouse, give some explanation, and attach the patch. That's the basic process. Scott > > > On Feb 20, 2008, at 10:50 AM, David Chelimsky wrote: > >> On Feb 20, 2008 1:30 PM, Michael Latta wrote: >>> In the story framework I would like to have tests that mix and match >>> scenarios using GivenScenario so for example a scenario that does >>> scenarios A, B, C in various orders. Right now all scenarios >>> need to >>> be self-standing since all the scenarios in the story get run. I >>> would like scenarios that are only run from GivenScenario so they >>> can >>> be modular. Is this possible? Alternatively could I use >>> GivenScenario to invoke scenarios from another story that is never >>> itself directly run? >> >> Neither of these are currently supported. Feel free to enter feature >> request tickets at http://rspec.lighthouseapp.com. >> >> Cheers, >> David >> >>> >>> Michael >>> >>> _______________________________________________ >>> 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 joe at pinkpucker.net Wed Feb 20 22:41:15 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Wed, 20 Feb 2008 19:41:15 -0800 Subject: [rspec-users] Run all tests after success In-Reply-To: <57c63afe0802161039k579d4974q628e0430f7ee84d@mail.gmail.com> References: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> <57c63afe0802161039k579d4974q628e0430f7ee84d@mail.gmail.com> Message-ID: On Sat, Feb 16, 2008 at 10:39 AM, David Chelimsky wrote: > On Feb 16, 2008 1:21 PM, Steve wrote: > > On Sat, 16 Feb 2008 18:13:51 +0000, Steve wrote: > > > What was the nature of the changes. I just updated to r3312, and when I > > > run autotest I get: > > > > > > loading autotest/rails_rspec > > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts No > > > server is running > > > > > > I've never seen the "No server is running" message before. > > > > Cancel that. I had --drb in spec.opts, and it looks like there was a > > commit to make that work. Funny I never noticed that before. > > It was broken until a recent changeset :) I don't think it's working quite right. 1) 'A puzzle if rejected, when resaved, should be re-submitted' FAILED expected rejected? to return true, got false /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations.rb:52:in `fail_with' /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations/handler.rb:21:in `handle_matcher' /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:34:in `should' ./spec/models/puzzle_spec.rb:187: Then this is the next executation: ruby -S script/spec -O spec/spec.opts spec/models/puzzle_spec.rb /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations.rb So it thiks that some rspec file was the cause of the crash. If the exception was raised from inside the Rails framework, then it tries to re-run the Rails file, and that sometimes really messes things up. Joe From rspec-users at kero.tmfweb.nl Wed Feb 20 23:21:07 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Thu, 21 Feb 2008 05:21:07 +0100 Subject: [rspec-users] Old Style Stories In-Reply-To: <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> Message-ID: <20080221042106.GA562@chello.nl> > > I was working on a past project tonight to trunk which is using the > > old story format. IE: > > Given "desc" do / end > > When "someting "do /end > > etc.. > > > > Is this officially supported, or is this just something that hasn't > > been ripped out yet? > > It's funny to me that this is "Old Style" in your view. It's really > just another approach. Plain text is great for some situations, but so > is writing in Ruby :) Depends on the team, really, and how involved > the customer is in actually doing the typing. > > > If it is officially supported how attached are people to the re-using > > of do/end blocks which match the same description. Every now and then > > it bites me and I end up having to change one of the descriptions to > > differ textually then another. > > Why would this be specific to scenarios written in Ruby? > > > IMO it is kind of annoying. A story > > part description may have the same description as another in the same > > scenario. Sometimes the sequence of steps provide the context, If I understand you correctly, then we had a discussion on this: http://rspec.lighthouseapp.com/projects/5645/tickets/167-blocks-provided-to-when-then-clauses-should-always-be-used and concluded that same-description means exactly-same-step, then continued http://rspec.lighthouseapp.com/projects/5645/tickets/172-warn-or-fail-on-re-specified-when-then-clause which is still open. > This seems unfinished - was there more to this sentence? > > I think this is just a matter of documentation. If we got rid of > block-sharing we'd be promoting much more verbose scenarios with a lot > of redundancy. I think it's here to stay. From jed.hurt at gmail.com Thu Feb 21 00:52:19 2008 From: jed.hurt at gmail.com (Jed Hurt) Date: Wed, 20 Feb 2008 22:52:19 -0700 Subject: [rspec-users] Quiet Backtrace in RSpec In-Reply-To: <8d961d900801190039x7c973fb3xad1052df557c2e45@mail.gmail.com> References: <8d961d900801190039x7c973fb3xad1052df557c2e45@mail.gmail.com> Message-ID: Ahh, I see. Is Spec::Runner::QuietBacktraceTweaker configurable for more quietness? On Sat, Jan 19, 2008 at 1:39 AM, aslak hellesoy wrote: > On Jan 19, 2008 4:16 AM, Jed Hurt wrote: > > I'm using RSpec on Rails and would like to clean up the backtraces, so I > > went looking for an RSpec equivalent to ThoughtBot's Quiet Backtrace > gem. I > > found Spec::Runner::QuietBacktraceTweaker in the RDOCS, but I can't > figure > > out how to use it. Can I add something to spec_helper.rb that will > utilize > > Spec::Runner::QuietBacktraceTweaker to quiet the backtraces? > > It's on by default, and you can turn it off with -b on the command line > > Thanks for telling me about the Quiet Backtrace gem, I've added a > ticket for that: > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/243-add-support-for-quietbacktrace-gem > > Aslak > > > _______________________________________________ > > 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/20080220/3c5c06a3/attachment.html From jarkko at jlaine.net Thu Feb 21 01:20:58 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Thu, 21 Feb 2008 08:20:58 +0200 Subject: [rspec-users] spec_server requiring absolute paths (and autotest breaking) In-Reply-To: <769B3D7F-A046-4C70-BAC7-81955674C562@railsnewbie.com> References: <75AEFAFF-6CAD-4A04-8270-85C8F51EF928@jlaine.net> <57c63afe0802190757m40197549n1b2e8570fab2df66@mail.gmail.com> <049954B4-A032-40D9-9D6C-3640135D2506@jlaine.net> <5FA7A5CA-66AA-4B98-929D-79FFA6BB92D7@railsnewbie.com> <412AF32D-58D7-416C-8994-94481F142583@jlaine.net> <769B3D7F-A046-4C70-BAC7-81955674C562@railsnewbie.com> Message-ID: <5602D2DF-3E3B-4650-9F89-68D888819A3F@jlaine.net> On 21.2.2008, at 4.14, Scott Taylor wrote: > > On Feb 20, 2008, at 1:52 AM, Jarkko Laine wrote: > >> On 20.2.2008, at 6.55, Scott Taylor wrote: >>>> That said, now that autotest runs via drb, it's vastly (like 50%) >>>> slower than without it, >>> >>> That's the idea. >> >> Isn't the idea that specs run faster through drb, rather than >> slower? However, in general my specs seem to take a lot longer when >> run through autotest in the first place (compared to running just >> rake spec:models, e.g.). I haven't so far been able to track down >> what causes this. > > Oops. Misread your post. > > Is this true running a single spec (or a single file)? I've noticed > that a test suite which takes about 5 seconds normally takes about 7 > seconds under drb (according to the numbers reported by rspec). Then > again, running a single file is blazingly fast, as their is no wait > (as though I'm testing against a non-rails project). If I run a single, small file (like a helper spec), it's faster in an absolute sense (using time): Probutanol:koulutusweb jarkko$ time script/spec -O spec/spec.opts spec/ helpers/date_extension_spec.rb .... Finished in 2.061605 seconds 4 examples, 0 failures real 0m2.212s user 0m0.060s sys 0m0.024s Probutanol:koulutusweb jarkko$ time script/spec spec/helpers/ date_extension_spec.rb .... Finished in 0.102506 seconds 4 examples, 0 failures real 0m4.682s user 0m3.738s sys 0m0.688s However, as you can see even there the actual running of the specs is painfully slow (2 vs 0.1 secs) and the only reason drb is faster is because there is no startup time. This is on 3316. Also, there really seems to be something wonky going on with the loading. When I run a model spec right after starting the spec server, it works, but running it the second time already gives some weird stuff back: Probutanol:koulutusweb jarkko$ time script/spec -O spec/spec.opts spec/ models/account_spec.rb .......... Finished in 0.371612 seconds 10 examples, 0 failures real 0m1.647s user 0m0.068s sys 0m0.024s Probutanol:koulutusweb jarkko$ time script/spec -O spec/spec.opts spec/ models/account_spec.rb .FFF.FFFFF 1) ActiveRecord::AssociationTypeMismatch in 'Account users should return user' Address expected, got Address > >> >>>> Mock 'Location_18994' expected :valid? with (any args) once, but >>>> received it twice >>> >>> I saw this happen recently when the spec server was started twice: >>> once with the rake task (rake spec:server:start), the other with a >>> straight script/spec_sever. My hunch is that both servers are >>> loading the files at the same time. >> >> That would seem logical. However, I just checked that I only have >> one spec_server process running and am still able to reproduce the >> problem. > > Hmm. Are you reloading classes or using anonymous classes derived > from AR::Base, or anything crazy like that? Are all your models in > app/models? Do you have pending migrations? Are your running with > rake, or with autotest? How about running the file alone? Doesn't matter. Shouldn't be doing anything super special with models but got to think about it. >>>> expected: "Barney Hops doesn't have the required competency (MBA) >>>> to teach this class", >>>> got: ["Barney Hops doesn't have the required competency (MBA) >>>> to teach this class", "Barney Hops doesn't have the required >>>> competency (MBA) to teach this class"] >>>> >>> >>> Yeah - this is because rails load's instead of requires. You'll >>> also >>> see this sort of thing if you just call load directly in your specs. >>> I've never dug deeper into how all of the rails magic happens >>> regarding loading and constants (and the method generation with the >>> association macros (has_* belongs_to), so if you have any insight, >>> I'd be happy to hear it. >> >> Yeah, all these failures are certainly related and probably caused >> by something like what you describe. Got to try to figure out what >> spec_server does differently than normal spec. Or maybe we should >> just bite the bullet and make the deeptest spec fork work :-) >> > Yeah - deeptest is great for slow suites, but now that I have a fast > suite (take 5-7 seconds), deeptest probably wouldn't be much of a > performance gain for me. Yeah, the funny thing is, model specs that sometimes need to go to the db are pretty fast but controller specs where most of the db traffic is stubbed out seem to become a drag, and I would think deeptest would help there. -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080221/5338a226/attachment.bin From rubyphunk at googlemail.com Thu Feb 21 05:12:11 2008 From: rubyphunk at googlemail.com (rubyphunk) Date: Thu, 21 Feb 2008 02:12:11 -0800 (PST) Subject: [rspec-users] [ANN] RSpec mailing list Google Group mirror Message-ID: <208d0010-1007-4d1d-be63-9964cbd4d0b6@i29g2000prf.googlegroups.com> Hi. I've created a Google Group 'rspec' that acts as a mirror to the RSpec- users mailing list. You can find the group at http://groups.google.com/group/rspec. lg -- andreas From toastkid.williams at gmail.com Thu Feb 21 06:17:46 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Thu, 21 Feb 2008 11:17:46 +0000 Subject: [rspec-users] Unwanted fixture data messing up my other tests Message-ID: I have a fixture for one of my tables that i use in some model tests. The data in it is messing up some other tests for a different model, that doesn't ask for the fixture - isn't the fixture data supposed to be cleared out of the test db in between tests, and only be present if specifically asked for? or am i using them wrong? thanks max -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080221/efa88355/attachment-0001.html From dchelimsky at gmail.com Thu Feb 21 08:21:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Feb 2008 08:21:02 -0500 Subject: [rspec-users] Run all tests after success In-Reply-To: References: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> <57c63afe0802161039k579d4974q628e0430f7ee84d@mail.gmail.com> Message-ID: <57c63afe0802210521u646e6c1bj3a6d3985868a06b3@mail.gmail.com> On Wed, Feb 20, 2008 at 10:41 PM, Joe Van Dyk wrote: > On Sat, Feb 16, 2008 at 10:39 AM, David Chelimsky wrote: > > On Feb 16, 2008 1:21 PM, Steve wrote: > > > On Sat, 16 Feb 2008 18:13:51 +0000, Steve wrote: > > > > What was the nature of the changes. I just updated to r3312, and when I > > > > run autotest I get: > > > > > > > > loading autotest/rails_rspec > > > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts No > > > > server is running > > > > > > > > I've never seen the "No server is running" message before. > > > > > > Cancel that. I had --drb in spec.opts, and it looks like there was a > > > commit to make that work. Funny I never noticed that before. > > > > It was broken until a recent changeset :) > > I don't think it's working quite right. > > 1) > 'A puzzle if rejected, when resaved, should be re-submitted' FAILED > expected rejected? to return true, got false > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations.rb:52:in > `fail_with' > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations/handler.rb:21:in > `handle_matcher' > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:34:in > `should' > ./spec/models/puzzle_spec.rb:187: > > Then this is the next executation: > ruby -S script/spec -O spec/spec.opts spec/models/puzzle_spec.rb > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations.rb > > So it thiks that some rspec file was the cause of the crash. If the > exception was raised from inside the Rails framework, then it tries to > re-run the Rails file, and that sometimes really messes things up. What rspec revision? > > Joe > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Feb 21 08:21:19 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Feb 2008 08:21:19 -0500 Subject: [rspec-users] Quiet Backtrace in RSpec In-Reply-To: References: <8d961d900801190039x7c973fb3xad1052df557c2e45@mail.gmail.com> Message-ID: <57c63afe0802210521x625ad9efg1c87a37f2c113cf8@mail.gmail.com> On Thu, Feb 21, 2008 at 12:52 AM, Jed Hurt wrote: > Ahh, I see. Is Spec::Runner::QuietBacktraceTweaker configurable for more > quietness? Nope. > > > > On Sat, Jan 19, 2008 at 1:39 AM, aslak hellesoy > wrote: > > > > > > > > > On Jan 19, 2008 4:16 AM, Jed Hurt wrote: > > > I'm using RSpec on Rails and would like to clean up the backtraces, so I > > > went looking for an RSpec equivalent to ThoughtBot's Quiet Backtrace > gem. I > > > found Spec::Runner::QuietBacktraceTweaker in the RDOCS, but I can't > figure > > > out how to use it. Can I add something to spec_helper.rb that will > utilize > > > Spec::Runner::QuietBacktraceTweaker to quiet the backtraces? > > > > It's on by default, and you can turn it off with -b on the command line > > > > Thanks for telling me about the Quiet Backtrace gem, I've added a > > ticket for that: > > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/243-add-support-for-quietbacktrace-gem > > > > Aslak > > > > > _______________________________________________ > > > 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 dchelimsky at gmail.com Thu Feb 21 08:24:27 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Feb 2008 08:24:27 -0500 Subject: [rspec-users] Unwanted fixture data messing up my other tests In-Reply-To: References: Message-ID: <57c63afe0802210524w2b8a36a7je765f7c11aaddda1@mail.gmail.com> On Thu, Feb 21, 2008 at 6:17 AM, Max Williams wrote: > I have a fixture for one of my tables that i use in some model tests. The > data in it is messing up some other tests for a different model, that > doesn't ask for the fixture - isn't the fixture data supposed to be cleared > out of the test db in between tests, and only be present if specifically > asked for? or am i using them wrong? It depends on settings you have in spec_helper.rb. You should have this: config.use_transactional_fixtures = true You should also not be declaring any fixtures in spec_helper.rb, given your situation. HTH, David > > thanks > max > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Thu Feb 21 08:49:24 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Thu, 21 Feb 2008 13:49:24 +0000 Subject: [rspec-users] Unwanted fixture data messing up my other tests In-Reply-To: <57c63afe0802210524w2b8a36a7je765f7c11aaddda1@mail.gmail.com> References: <57c63afe0802210524w2b8a36a7je765f7c11aaddda1@mail.gmail.com> Message-ID: Hi David I have that option set already, and i'm not using any fixtures in spec_helper. My spec helper looks like this: is it the use_instantiated_fixtures option perhaps? (i don't know what that does). thanks, max >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec' require 'spec/rails' require 'spec/custom_matchers' Spec::Runner.configure do |config| # If you're not using ActiveRecord you should remove these # lines, delete config/database.yml and disable :active_record # in your config/boot.rb config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/spec/fixtures/' #custom stuff config.include(CustomMatchers) def mock_login_required(allow_user_to_pass=true) controller.stub!(:login_required).and_return(allow_user_to_pass) end def mock_admin_user?(allow_user_to_pass=true) controller.stub!(:admin_user?).and_return(allow_user_to_pass) end def mock_current_user(id = 1) @user = mock_model(User, :to_param => id.to_s, :id => 1) controller.stub!(:current_user).and_return(@user) end end <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< On 21/02/2008, David Chelimsky wrote: > > On Thu, Feb 21, 2008 at 6:17 AM, Max Williams > wrote: > > I have a fixture for one of my tables that i use in some model > tests. The > > data in it is messing up some other tests for a different model, that > > doesn't ask for the fixture - isn't the fixture data supposed to be > cleared > > out of the test db in between tests, and only be present if specifically > > asked for? or am i using them wrong? > > > It depends on settings you have in spec_helper.rb. You should have this: > > config.use_transactional_fixtures = true > > You should also not be declaring any fixtures in spec_helper.rb, given > your situation. > > HTH, > David > > > > > 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/20080221/a100597e/attachment.html From amjibaly at gmail.com Thu Feb 21 10:21:02 2008 From: amjibaly at gmail.com (Abdullah Jibaly) Date: Thu, 21 Feb 2008 09:21:02 -0600 Subject: [rspec-users] Rspec, stories and web services Message-ID: <43cc3c280802210721p76ee46efx31912cbe6d8d4ab6@mail.gmail.com> Hi All, I'm just getting into Rspec and have a couple questions to get my head around this: 1- Testing web services: is this a good fit for User Stories? 2- The web services run on ActionWebServices, should I be doing additional testing using traditional Rspec/Rails integration (I don't know if I'm asking the right question here so any pointers would be appreciated)? 3- As far as load testing (for the web services), is there any way I can reuse the User Stories for that? Any advice would be appreciated. Thanks, Abdullah From cremes.devlist at mac.com Thu Feb 21 11:09:49 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Thu, 21 Feb 2008 10:09:49 -0600 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? Message-ID: While practicing BDD on my first-ever BDD project, I have come to a point where it makes sense to change my original class to an abstract class and create one (or more) concrete subclasses that implement a specific method. What is the right way to restructure the tests in this scenario? Do I leave the existing tests in place and just create a new spec file that instantiates and tests the concrete subclass? I think I can continue to instantiate my "abstract" parent as long as I don't go near the behavior that will be defined by the concrete subclasses. Is that the right thing to do? Thanks for any hints. cr From joe at pinkpucker.net Thu Feb 21 11:29:54 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Thu, 21 Feb 2008 08:29:54 -0800 Subject: [rspec-users] Run all tests after success In-Reply-To: <57c63afe0802210521u646e6c1bj3a6d3985868a06b3@mail.gmail.com> References: <57c63afe0802160723yfd1d9dfu8085459c05709ceb@mail.gmail.com> <57c63afe0802161039k579d4974q628e0430f7ee84d@mail.gmail.com> <57c63afe0802210521u646e6c1bj3a6d3985868a06b3@mail.gmail.com> Message-ID: On Thu, Feb 21, 2008 at 5:21 AM, David Chelimsky wrote: > > On Wed, Feb 20, 2008 at 10:41 PM, Joe Van Dyk wrote: > > On Sat, Feb 16, 2008 at 10:39 AM, David Chelimsky wrote: > > > On Feb 16, 2008 1:21 PM, Steve wrote: > > > > On Sat, 16 Feb 2008 18:13:51 +0000, Steve wrote: > > > > > What was the nature of the changes. I just updated to r3312, and when I > > > > > run autotest I get: > > > > > > > > > > loading autotest/rails_rspec > > > > > /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts No > > > > > server is running > > > > > > > > > > I've never seen the "No server is running" message before. > > > > > > > > Cancel that. I had --drb in spec.opts, and it looks like there was a > > > > commit to make that work. Funny I never noticed that before. > > > > > > It was broken until a recent changeset :) > > > > I don't think it's working quite right. > > > > 1) > > 'A puzzle if rejected, when resaved, should be re-submitted' FAILED > > expected rejected? to return true, got false > > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations.rb:52:in > > `fail_with' > > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations/handler.rb:21:in > > `handle_matcher' > > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:34:in > > `should' > > ./spec/models/puzzle_spec.rb:187: > > > > Then this is the next executation: > > ruby -S script/spec -O spec/spec.opts spec/models/puzzle_spec.rb > > /Users/joe/projects/tanga/vendor/plugins/rspec/lib/spec/expectations.rb > > > > So it thiks that some rspec file was the cause of the crash. If the > > exception was raised from inside the Rails framework, then it tries to > > re-run the Rails file, and that sometimes really messes things up. > > What rspec revision? trunk as of yesterday. From rick.denatale at gmail.com Thu Feb 21 11:37:43 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 21 Feb 2008 11:37:43 -0500 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? In-Reply-To: References: Message-ID: On 2/21/08, Chuck Remes wrote: > While practicing BDD on my first-ever BDD project, I have come to a > point where it makes sense to change my original class to an abstract > class and create one (or more) concrete subclasses that implement a > specific method. What is the right way to restructure the tests in > this scenario? Do I leave the existing tests in place and just create > a new spec file that instantiates and tests the concrete subclass? > > I think I can continue to instantiate my "abstract" parent as long as > I don't go near the behavior that will be defined by the concrete > subclasses. Is that the right thing to do? Let me respond not so much from a BDD/RSpec point of view, but from a Ruby language perspective. Abstract classes aren't used much in Ruby, most often the job of providing "abstract" methods is done by modules rather than classes. Abstract classes are used in languages which define types via inheritance like C++ or Java , or provide only single inheritance of implementation like Smalltalk. In C++/Java you're pretty much forced to use an abstract class if you want to provide partial implementation of a type to be filled out by subclasses. In Smalltalk they're used to keep things DRY. In Smalltalk, there are quite a few abstract classes, for example Collection provides an implementation of methods like select, map, inject based on subclasses implementing an each method. In Ruby the same thing is done by having the Enumerable module which can be mixed into classes which provide an each method. So the way I'd approach the kind of refactoring you seem to be implying would be to move the abstract methods in the existing class into a module included by that class, and then implement other classes which also include the module. HTH -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From abroad-crawford at within3.com Thu Feb 21 11:40:45 2008 From: abroad-crawford at within3.com (Anthony Broad-Crawford) Date: Thu, 21 Feb 2008 11:40:45 -0500 Subject: [rspec-users] Newbie question ... Message-ID: I am testing an action on a controller and cannot seem to find the syntax to stub a method call off of the controller I am testing. pseudo code class SomeController < < ApplicationController def some_action stuff stuff stuff some_protected_method_call stuff redirect_to something end protected def some_protected_method_call end end describe SomeController do it "should have some description of behavior here" do #how do I stub some_protected_method_call get 'some_action' response.should be_redirect end end From joseph at josephholsten.com Thu Feb 21 14:02:16 2008 From: joseph at josephholsten.com (Joseph Anthony Pasquale Holsten) Date: Thu, 21 Feb 2008 13:02:16 -0600 Subject: [rspec-users] Specs versus Stories In-Reply-To: <57c63afe0802181544g4615eeb1w92409a0aecb04f92@mail.gmail.com> References: <3B87748D-51A3-483D-9A89-9754BAFE9466@civrot.org> <57c63afe0802181544g4615eeb1w92409a0aecb04f92@mail.gmail.com> Message-ID: <5CB219D7-A95E-4E18-87F8-0C640F6C18D6@josephholsten.com> I try to thing of the audience for the work, and it keeps me sane. Stories are to make sure you're holding up your contract with the client or user. They are high level, and don't deal with any implementation details that can be abstracted away. You might relate them to acceptance tests, because when you pass stories, you're passing all the acceptance criteria. You also might compare them integration tests, because they should ensure everything behind the UI (or API) works correctly. It's reasonable to mock external services, but I try to have these be as real as possible. If you and your user disagree about how something works, you make the change in the story. Then you change the specs and code as needed. Specs are to make sure you're holding up your contract with the code and its developers. With so little static checking in ruby, specs are your type checking, exception checking (ala java), the preconditions, postconditions, and invariants (ala DbC), published interface, performance profiler, and possibly even internal documentation. These make sure you know the right way to interact with the code. And of course you should specify the code before you implement it, red-green style. If you and a developer disagree about how something works, you make the change in the specs. Then you change the code as needed. Clear as mud? On 02008:02:18, at 5:44CST, David Chelimsky wrote: > On Feb 18, 2008 6:38 PM, Victor Asteinza wrote: >> Isn't there redundancy between what is in your stories and your >> specs? >> Or are your stories at a higher level and the specs are at a lower >> level? That would make more sense to me. There would be some cross >> over. but the specs expand on what is in the stories.... > > While either tool can technically support either mode of thinking: > > Stories are aimed at describing the behaviour of your applications. > Specs are aimed at describing the behaviour of the objects in your > applications. > > You are correct that there will likely be some cross over, but keep in > mind that there are different audiences and different processes. > > The steps in stories (the descriptive text, not the implementation of > the steps) are typically written in entirety before setting out to > develop a body of work. Stories should be run before a commit, or as > part of a CI build, but are not always run between every step. > > The examples in specs, on the other hand, typically come into > existence in a very granular red-green-refactor cycle, and should be > run between every step. > > HTH, > David > > >> >>> Message: 3 >>> Date: Mon, 18 Feb 2008 11:21:47 -0500 >>> From: "Andrew WC Brown" >>> Subject: Re: [rspec-users] Specs versus Stories >>> To: rspec-users >>> Message-ID: >>> >>> Content-Type: text/plain; charset="iso-8859-1" >> >>> >>> My workflow is the following: >>> Stories->Spec Views->Spec Controllers-Spec Models >>> >>> I'll write a few stories of what I think should it happen. >>> Then I'll write my specs of what should show (and also do some >>> static html >>> page mockups) >>> Then I'll spec my controllers and models >>> I'll go back to my stories to see if they need adjusting because my >>> perceptive of how the app changed >>> Then I run my stories and make them pass. >>> >>> Then I write a few stories and repeat. >>> >>> I constantly step move back and forth. >>> I think Stories and BDD greatly assists you to shape your idea. >>> Write stories for what you can think of and then move on to specing. >>> You don't need complete stories you can also go back and fill them >>> in later. >>> >>> On Feb 18, 2008 2:57 AM, Victor Asteinza wrote: >>> >>>> I am new to BDD and have been doing some reading and playing with >>>> rSpec. I am a little confused. I am not sure what the best >>>> practice >>>> for using stories and specs. Should I be writing stories first, >>>> then >>>> specs that would fulfill those stories, and then write the >>>> implementation code to have everything pass? At first that seems a >>>> little redundant. >>>> >>>> I understand that the stories let you write the behavior in plane >>>> English, which I can see it being useful when dealing with non >>>> technical users. But if I am developing an internal app I am >>>> struggling with whether I should develop the stories first and then >>>> move on to the specs. >>>> >>>> Opinions? Experiences? >>>> >>>> Thanks, >>>> Victor >>>> _______________________________________________ >>>> 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 http:// Joseph Holsten .com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080221/1cf6e73c/attachment.html From dchelimsky at gmail.com Thu Feb 21 17:23:29 2008 From: dchelimsky at gmail.com (dchelimsky at gmail.com) Date: Thu, 21 Feb 2008 14:23:29 -0800 (PST) Subject: [rspec-users] Newbie question ... In-Reply-To: References: Message-ID: On Feb 21, 10:40 am, Anthony Broad-Crawford wrote: > I am testing an action on a controller and cannot seem to find the > syntax to stub a method call off of the controller I am testing. > > pseudo code > > class SomeController < < ApplicationController > > def some_action > > stuff > stuff > stuff > some_protected_method_call > > stuff > redirect_to something > end > > protected > def some_protected_method_call > > end > end > > describe SomeController do > > it "should have some description of behavior here" do > > #how do I stub some_protected_method_call > > get 'some_action' > response.should be_redirect > end > end controller.stub! (:some_protected_method_call).and_return(whatever_it_should_return) That work? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Thu Feb 21 22:07:10 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 21 Feb 2008 22:07:10 -0500 Subject: [rspec-users] Old Style Stories In-Reply-To: <20080221042106.GA562@chello.nl> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> <20080221042106.GA562@chello.nl> Message-ID: <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> On Wed, Feb 20, 2008 at 11:21 PM, Kero wrote: > > > I was working on a past project tonight to trunk which is using the > > > old story format. IE: > > > Given "desc" do / end > > > When "someting "do /end > > > etc.. > > > > > > Is this officially supported, or is this just something that hasn't > > > been ripped out yet? > > > > It's funny to me that this is "Old Style" in your view. It's really > > just another approach. Plain text is great for some situations, but so > > is writing in Ruby :) Depends on the team, really, and how involved > > the customer is in actually doing the typing. > > > > > If it is officially supported how attached are people to the re-using > > > of do/end blocks which match the same description. Every now and then > > > it bites me and I end up having to change one of the descriptions to > > > differ textually then another. > > > > Why would this be specific to scenarios written in Ruby? > > > > > IMO it is kind of annoying. A story > > > part description may have the same description as another in the same > > > scenario. Sometimes the sequence of steps provide the context, > > If I understand you correctly, then we had a discussion on this: > http://rspec.lighthouseapp.com/projects/5645/tickets/167-blocks-provided-to-when-then-clauses-should-always-be-used > and concluded that same-description means exactly-same-step, then continued > http://rspec.lighthouseapp.com/projects/5645/tickets/172-warn-or-fail-on-re-specified-when-then-clause > which is still open. > Thanks for the links Kero. That ticket is the issue that I am talking about. > > > This seems unfinished - was there more to this sentence? There may have been, but I cannot recall at this point. > > > > I think this is just a matter of documentation. If we got rid of > > block-sharing we'd be promoting much more verbose scenarios with a lot > > of redundancy. I think it's here to stay. > An implementation of Kero's second ticket [0] would definitely help. That extra feedback of "Hey, you already implemented this story part! Right there on line 11" would be great. A smaller annoyance associated with this is that story parts without blocks can get lost visually when in a sea of story parts with do/end blocks. I may be biased because on the last few customer driven production projects I've been using test/unit story runner, which I think is simpler and more developer friendly. [1] As you mentioned David, "Plain text is great for some situations, but so is writing in Ruby". This begs the question now that we have plain text stories. Can we make the ruby-based stories more developer friendly? Perhaps remove string identifiers, use symbols. Quit passing in blocks to story parts, assume each story part is a method call, and I'm sure there are other things that could be suggested as well. -- Zach Dennis http://www.continuousthinking.com 0 - http://rspec.lighthouseapp.com/projects/5645/tickets/172-warn-or-fail-on-re-specified-when-then-clause 1 - http://www.continuousthinking.com/2007/11/14/test-unit-story-runner From abroad-crawford at within3.com Thu Feb 21 22:41:01 2008 From: abroad-crawford at within3.com (Anthony Broad-Crawford) Date: Thu, 21 Feb 2008 22:41:01 -0500 Subject: [rspec-users] Newbie question ... In-Reply-To: References: Message-ID: <4C234774-F6C5-440A-8CF3-60B52596C747@within3.com> yes, thank you very much! On Feb 21, 2008, at 5:23 PM, dchelimsky at gmail.com wrote: > On Feb 21, 10:40 am, Anthony Broad-Crawford crawf... at within3.com> wrote: >> I am testing an action on a controller and cannot seem to find the >> syntax to stub a method call off of the controller I am testing. >> >> pseudo code >> >> class SomeController < < ApplicationController >> >> def some_action >> >> stuff >> stuff >> stuff >> some_protected_method_call >> >> stuff >> redirect_to something >> end >> >> protected >> def some_protected_method_call >> >> end >> end >> >> describe SomeController do >> >> it "should have some description of behavior here" do >> >> #how do I stub some_protected_method_call >> >> get 'some_action' >> response.should be_redirect >> end >> end > > controller.stub! > (:some_protected_method_call).and_return(whatever_it_should_return) > > That work? > >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Feb 21 23:26:49 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Feb 2008 22:26:49 -0600 Subject: [rspec-users] Old Style Stories In-Reply-To: <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> <20080221042106.GA562@chello.nl> <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> Message-ID: <57c63afe0802212026g39e5d19bl858c367ffa3f5910@mail.gmail.com> On Thu, Feb 21, 2008 at 9:07 PM, Zach Dennis wrote: > > On Wed, Feb 20, 2008 at 11:21 PM, Kero wrote: > > > > I was working on a past project tonight to trunk which is using the > > > > old story format. IE: > > > > Given "desc" do / end > > > > When "someting "do /end > > > > etc.. > > > > > > > > Is this officially supported, or is this just something that hasn't > > > > been ripped out yet? > > > > > > It's funny to me that this is "Old Style" in your view. It's really > > > just another approach. Plain text is great for some situations, but so > > > is writing in Ruby :) Depends on the team, really, and how involved > > > the customer is in actually doing the typing. > > > > > > > If it is officially supported how attached are people to the re-using > > > > of do/end blocks which match the same description. Every now and then > > > > it bites me and I end up having to change one of the descriptions to > > > > differ textually then another. > > > > > > Why would this be specific to scenarios written in Ruby? > > > > > > > IMO it is kind of annoying. A story > > > > part description may have the same description as another in the same > > > > scenario. Sometimes the sequence of steps provide the context, > > > > If I understand you correctly, then we had a discussion on this: > > http://rspec.lighthouseapp.com/projects/5645/tickets/167-blocks-provided-to-when-then-clauses-should-always-be-used > > and concluded that same-description means exactly-same-step, then continued > > http://rspec.lighthouseapp.com/projects/5645/tickets/172-warn-or-fail-on-re-specified-when-then-clause > > which is still open. > > > > Thanks for the links Kero. That ticket is the issue that I am talking about. > > > > > > > This seems unfinished - was there more to this sentence? > > There may have been, but I cannot recall at this point. > > > > > > > > I think this is just a matter of documentation. If we got rid of > > > block-sharing we'd be promoting much more verbose scenarios with a lot > > > of redundancy. I think it's here to stay. > > > > An implementation of Kero's second ticket [0] would definitely help. > That extra feedback of "Hey, you already implemented this story part! > Right there on line 11" would be great. Agreed. If someone commits a patch with specs, I'll be glad to apply it. Dan has already stated (I think in that ticket) that a message like you suggest would be appropriate, and I agree. > A smaller annoyance associated with this is that story parts without > blocks can get lost visually when in a sea of story parts with do/end > blocks. I may be biased because on the last few customer driven > production projects I've been using test/unit story runner, which I > think is simpler and more developer friendly. [1] > > As you mentioned David, "Plain text is great for some situations, but > so is writing in Ruby". This begs the question now that we have plain > text stories. Can we make the ruby-based stories more developer > friendly? Perhaps remove string identifiers, use symbols. Quit passing > in blocks to story parts, assume each story part is a method call, and > I'm sure there are other things that could be suggested as well. You can do all of this already except using symbols instead of Strings, something which doesn't strike me as more readable. Here's an example: http://pastie.caboo.se/155775 With this approach, the step definitions are decoupled from the steps in scenarios, which function just like method calls only better, because they can include $tokens that get converted to block arguments, supporting re-use of the step definitions. The steps_for block can be in the same file or not, you can have multiple stories in one file, you can associate multiple step groups (the result of steps_for) with the same story. You can define steps with the same identification strings in different groups that operate at different levels (for example you could have two implementations of "When I submit the event creation form", one which works using webrat or similar, and another which uses selenium), allowing you to use the same scenarios to drive both in-memory and in-browser steps. FWIW, David > > -- > > Zach Dennis > http://www.continuousthinking.com > > 0 - http://rspec.lighthouseapp.com/projects/5645/tickets/172-warn-or-fail-on-re-specified-when-then-clause > 1 - http://www.continuousthinking.com/2007/11/14/test-unit-story-runner > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Feb 21 23:40:21 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Feb 2008 22:40:21 -0600 Subject: [rspec-users] Old Style Stories In-Reply-To: <57c63afe0802212026g39e5d19bl858c367ffa3f5910@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> <20080221042106.GA562@chello.nl> <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> <57c63afe0802212026g39e5d19bl858c367ffa3f5910@mail.gmail.com> Message-ID: <57c63afe0802212040i2891f15es382b08bca6241e9c@mail.gmail.com> On Thu, Feb 21, 2008 at 10:26 PM, David Chelimsky wrote: > > On Thu, Feb 21, 2008 at 9:07 PM, Zach Dennis > > As you mentioned David, "Plain text is great for some situations, but > > so is writing in Ruby". This begs the question now that we have plain > > text stories. Can we make the ruby-based stories more developer > > friendly? Perhaps remove string identifiers, use symbols. Quit passing > > in blocks to story parts, assume each story part is a method call, and > > I'm sure there are other things that could be suggested as well. > > You can do all of this already except using symbols instead of > Strings, something which doesn't strike me as more readable. Here's an > example: > > http://pastie.caboo.se/155775 And here's another example with a bit more reuse expressed in the steps at the expense of more complexity in the steps. Which approach is better? I can't really say one is always better than the other. I choose based on readability in a given context. Just exploring possibilities. Cheers, David From toastkid.williams at gmail.com Fri Feb 22 08:26:40 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Fri, 22 Feb 2008 13:26:40 +0000 Subject: [rspec-users] Testing misc methods in ApplicationController Message-ID: I'm already successfully testing before_filters in application_controller courtesy of this blog post: http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller However, i can;'t work out how to test the sort of method that is added to application_controller so that all controllers can use it. It must be something simple that i'm doing wrong/omitting, can anyone help? eg if i have this empty method in application_controller def andreplace(str) end and my spec looks like this: describe ApplicationController do describe "andreplace(str)" do it "should format ands for ferret search" do andreplace("foo and bar").should eql("+foo +bar") end end end Currently, the test breaks, saying: NoMethodError in 'ApplicationController andreplace(str) should format ands for ferret search' undefined method `andreplace' for # What's going wrong here, anyone know? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080222/a5ae09d4/attachment.html From dchelimsky at gmail.com Fri Feb 22 08:46:15 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Feb 2008 07:46:15 -0600 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: References: Message-ID: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> On Fri, Feb 22, 2008 at 7:26 AM, Max Williams wrote: > I'm already successfully testing before_filters in application_controller > courtesy of this blog post: > http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller > > However, i can;'t work out how to test the sort of method that is added to > application_controller so that all controllers can use it. It must be > something simple that i'm doing wrong/omitting, can anyone help? > > eg if i have this empty method in application_controller > > def andreplace(str) > end > > and my spec looks like this: > > describe ApplicationController do > describe "andreplace(str)" do > it "should format ands for ferret search" do > andreplace("foo and bar").should eql("+foo +bar") Try this: controller.andreplace("foo and bar").should eql("+foo +bar") > end > end > end > > Currently, the test breaks, saying: > NoMethodError in 'ApplicationController andreplace(str) should format ands > for ferret search' > undefined method `andreplace' for > # This is a pointer to the problem - the error is telling you that the #andreplace message is going to the ExampleGroup, not the controller. HTH, David > > > What's going wrong here, anyone know? > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Fri Feb 22 08:46:43 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 22 Feb 2008 08:46:43 -0500 Subject: [rspec-users] Old Style Stories In-Reply-To: <57c63afe0802212040i2891f15es382b08bca6241e9c@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> <20080221042106.GA562@chello.nl> <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> <57c63afe0802212026g39e5d19bl858c367ffa3f5910@mail.gmail.com> <57c63afe0802212040i2891f15es382b08bca6241e9c@mail.gmail.com> Message-ID: <85d99afe0802220546o13e8c76p74eb8e0fe63ea71e@mail.gmail.com> On Thu, Feb 21, 2008 at 11:40 PM, David Chelimsky wrote: > On Thu, Feb 21, 2008 at 10:26 PM, David Chelimsky wrote: > > > > On Thu, Feb 21, 2008 at 9:07 PM, Zach Dennis > > As you mentioned David, "Plain text is great for some situations, but > > > > so is writing in Ruby". This begs the question now that we have plain > > > text stories. Can we make the ruby-based stories more developer > > > friendly? Perhaps remove string identifiers, use symbols. Quit passing > > > in blocks to story parts, assume each story part is a method call, and > > > I'm sure there are other things that could be suggested as well. > > > > You can do all of this already except using symbols instead of > > Strings, something which doesn't strike me as more readable. Here's an > > example: > > > > http://pastie.caboo.se/155775 > > And here's another example with a bit more reuse expressed in the > steps at the expense of more complexity in the steps. Which approach > is better? I can't really say one is always better than the other. I > choose based on readability in a given context. I hadn't even considered that using steps with the normal ruby stories was an option. This gives what I am looking for. As for symbols, they reduce a few keystrokes when you have to select them and/or see find them in a file or in the project, or copy them. They are not as readable as the strings as you point out. I may just need to buck up and/or write a macro which gives me the ability to select a string based on quotes. This is not really a story problem, more of my editor lacking a feature I want. > Just exploring possibilities. Ditto. Thanks for the reply and for the code pastes. -- Zach Dennis http://www.continuousthinking.com From mauricio.linhares at gmail.com Fri Feb 22 08:50:49 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Fri, 22 Feb 2008 10:50:49 -0300 Subject: [rspec-users] Problems with redirect_to Message-ID: Hello guys, I have the following spec: describe 'With successful save' do it 'Should redirect to the new page' do do_post response.should be_redirect response.should redirect_to( :action => 'show', :id => @static_page.permalink ) ## this is the line 118 end end And when I try to run it it gives me the following error: 1) ActionController::MethodNotAllowed in 'StaticPagesController Handling POST /pages With successful save Should redirect to the new page' Only get, put, and delete requests are allowed. ./spec/controllers/static_pages_controller_spec.rb:118: script/spec:4: So, the response is a redirect (the "response.should be_redirect" passes) but when i try to be sure that it redirected to the right page it throws this weird error to me. Any ideas about what I've done wrong? I'm using RSpec 1.1.3 and Rails 2.0.2. -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://codeshooter.wordpress.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 From dchelimsky at gmail.com Fri Feb 22 08:54:50 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Feb 2008 07:54:50 -0600 Subject: [rspec-users] Old Style Stories In-Reply-To: <85d99afe0802220546o13e8c76p74eb8e0fe63ea71e@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> <20080221042106.GA562@chello.nl> <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> <57c63afe0802212026g39e5d19bl858c367ffa3f5910@mail.gmail.com> <57c63afe0802212040i2891f15es382b08bca6241e9c@mail.gmail.com> <85d99afe0802220546o13e8c76p74eb8e0fe63ea71e@mail.gmail.com> Message-ID: <57c63afe0802220554i5166174cq49d2c91603b2c8f2@mail.gmail.com> On Fri, Feb 22, 2008 at 7:46 AM, Zach Dennis wrote: > > On Thu, Feb 21, 2008 at 11:40 PM, David Chelimsky wrote: > > On Thu, Feb 21, 2008 at 10:26 PM, David Chelimsky wrote: > > > > > > On Thu, Feb 21, 2008 at 9:07 PM, Zach Dennis > > As you mentioned David, "Plain text is great for some situations, but > > > > > > so is writing in Ruby". This begs the question now that we have plain > > > > text stories. Can we make the ruby-based stories more developer > > > > friendly? Perhaps remove string identifiers, use symbols. Quit passing > > > > in blocks to story parts, assume each story part is a method call, and > > > > I'm sure there are other things that could be suggested as well. > > > > > > You can do all of this already except using symbols instead of > > > Strings, something which doesn't strike me as more readable. Here's an > > > example: > > > > > > http://pastie.caboo.se/155775 > > > > And here's another example with a bit more reuse expressed in the > > steps at the expense of more complexity in the steps. Which approach > > is better? I can't really say one is always better than the other. I > > choose based on readability in a given context. > > I hadn't even considered that using steps with the normal ruby stories > was an option. This gives what I am looking for. Great! Glad to hear it. I need to get this documented. > As for symbols, they reduce a few keystrokes when you have to select > them and/or see find them in a file or in the project, or copy them. > They are not as readable as the strings as you point out. I may just > need to buck up and/or write a macro which gives me the ability to > select a string based on quotes. This is not really a story problem, > more of my editor lacking a feature I want. > > > Just exploring possibilities. > > Ditto. > > Thanks for the reply and for the code pastes. You're welcome. Cheers, David > > -- > > > Zach Dennis > http://www.continuousthinking.com > From toastkid.williams at gmail.com Fri Feb 22 08:58:58 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Fri, 22 Feb 2008 13:58:58 +0000 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> References: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> Message-ID: doh...dammit, i thought i'd tried that. I'm losing it... thanks! On 22/02/2008, David Chelimsky wrote: > > On Fri, Feb 22, 2008 at 7:26 AM, Max Williams > wrote: > > I'm already successfully testing before_filters in > application_controller > > courtesy of this blog post: > > > http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller > > > > However, i can;'t work out how to test the sort of method that is added > to > > application_controller so that all controllers can use it. It must be > > something simple that i'm doing wrong/omitting, can anyone help? > > > > eg if i have this empty method in application_controller > > > > def andreplace(str) > > end > > > > and my spec looks like this: > > > > describe ApplicationController do > > describe "andreplace(str)" do > > it "should format ands for ferret search" do > > andreplace("foo and bar").should eql("+foo +bar") > > > Try this: > > controller.andreplace("foo and bar").should eql("+foo +bar") > > > > end > > end > > end > > > > Currently, the test breaks, saying: > > NoMethodError in 'ApplicationController andreplace(str) should format > ands > > for ferret search' > > undefined method `andreplace' for > > > # > > > This is a pointer to the problem - the error is telling you that the > #andreplace message is going to the ExampleGroup, not the controller. > > HTH, > David > > > > > > > > What's going wrong here, anyone know? > > > > > > > _______________________________________________ > > 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/20080222/3c3edc44/attachment.html From dchelimsky at gmail.com Fri Feb 22 09:00:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Feb 2008 08:00:32 -0600 Subject: [rspec-users] Problems with redirect_to In-Reply-To: References: Message-ID: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> On Fri, Feb 22, 2008 at 7:50 AM, Maur?cio Linhares wrote: > Hello guys, > > I have the following spec: > > describe 'With successful save' do > > it 'Should redirect to the new page' do > do_post > response.should be_redirect > response.should redirect_to( :action => 'show', :id => > @static_page.permalink ) ## this is the line 118 > end > > end > > And when I try to run it it gives me the following error: > > 1) > ActionController::MethodNotAllowed in 'StaticPagesController Handling > POST /pages With successful save Should redirect to the new page' > Only get, put, and delete requests are allowed. > ./spec/controllers/static_pages_controller_spec.rb:118: > script/spec:4: > > So, the response is a redirect (the "response.should be_redirect" > passes) but when i try to be sure that it redirected to the right page > it throws this weird error to me. Any ideas about what I've done > wrong? Can you post the full backtrace? script/spec ./spec/controllers/static_pages_controller_spec.rb -b > > I'm using RSpec 1.1.3 and Rails 2.0.2. > > -- > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | > http://codeshooter.wordpress.com/ (en) > Jo?o Pessoa, PB, +55 83 8867-7208 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Feb 22 09:02:16 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Feb 2008 08:02:16 -0600 Subject: [rspec-users] Testing misc methods in ApplicationController In-Reply-To: References: <57c63afe0802220546k5a8a9c9cn87ac6d00ee88485b@mail.gmail.com> Message-ID: <57c63afe0802220602i5912df8etffb968bceb41d16b@mail.gmail.com> On Fri, Feb 22, 2008 at 7:58 AM, Max Williams wrote: > doh...dammit, i thought i'd tried that. I'm losing it... > > thanks! You're welcome. Cheers, David > > > > On 22/02/2008, David Chelimsky wrote: > > On Fri, Feb 22, 2008 at 7:26 AM, Max Williams > > wrote: > > > I'm already successfully testing before_filters in > application_controller > > > courtesy of this blog post: > > > > http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller > > > > > > However, i can;'t work out how to test the sort of method that is added > to > > > application_controller so that all controllers can use it. It must be > > > something simple that i'm doing wrong/omitting, can anyone help? > > > > > > eg if i have this empty method in application_controller > > > > > > def andreplace(str) > > > end > > > > > > and my spec looks like this: > > > > > > describe ApplicationController do > > > describe "andreplace(str)" do > > > it "should format ands for ferret search" do > > > andreplace("foo and bar").should eql("+foo +bar") > > > > > > Try this: > > > > controller.andreplace("foo and bar").should eql("+foo +bar") > > > > > > > end > > > end > > > end > > > > > > Currently, the test breaks, saying: > > > NoMethodError in 'ApplicationController andreplace(str) should format > ands > > > for ferret search' > > > undefined method `andreplace' for > > > > # > > > > > > This is a pointer to the problem - the error is telling you that the > > #andreplace message is going to the ExampleGroup, not the controller. > > > > HTH, > > David > > > > > > > > > > > > > What's going wrong here, anyone know? > > > > > > > > > > > _______________________________________________ > > > 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 mauricio.linhares at gmail.com Fri Feb 22 09:10:32 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Fri, 22 Feb 2008 11:10:32 -0300 Subject: [rspec-users] Problems with redirect_to In-Reply-To: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> References: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> Message-ID: Using the "path" method the spec passes, but i don't use the path method on my controller. First, here's my controller code: def create @static_page = @event.static_pages.build(params[:static_page]) respond_to do |format| if @static_page.save flash[:notice] = 'Page was successfully created.' format.html { redirect_to(:action => 'show', :id => @static_page.permalink ) } ## thats what i'm testing agains format.xml { render :xml => @static_page, :status => :created, :location => @static_page } else format.html { render :action => "new" } format.xml { render :xml => @static_page.errors, :status => :unprocessable_entity } end end end And here is the spec: it 'Should redirect to the new page' do do_post response.should be_redirect response.should redirect_to( page_path( :action => 'show', :id => @static_page.permalink ) ) ## this one, with the page_path goes fine response.should redirect_to( :action => 'show', :id => @static_page.permalink ) ## this one, without the page_path doesn't work end It seems that the redirect_to matcher doesn't recognize the current controller. And here goes the full backtrace: ActionController::MethodNotAllowed in 'StaticPagesController Handling POST /pages With successful save Should redirect to the new page' Only get, put, and delete requests are allowed. /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1439:in `recognize_path' /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:43:in `path_hash' /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:38:in `hash_from_url' /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:26:in `actual_hash' /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:34:in `actual_redirect_to_valid_route' /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:18:in `matches?' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/expectations/handler.rb:19:in `handle_matcher' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:34:in `should' ./spec/controllers/static_pages_controller_spec.rb:119: /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:78:in `instance_eval' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:78:in `run_with_description_capturing' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:19:in `execute' /usr/lib/ruby/1.8/timeout.rb:48:in `timeout' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:16:in `execute' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:292:in `execute_examples' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:291:in `each' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:291:in `execute_examples' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:121:in `run' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/options.rb:90:in `run_examples' /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run' script/spec:4: On Fri, Feb 22, 2008 at 11:00 AM, David Chelimsky wrote: > On Fri, Feb 22, 2008 at 7:50 AM, Maur?cio Linhares > wrote: > > Hello guys, > > > > I have the following spec: > > > > describe 'With successful save' do > > > > it 'Should redirect to the new page' do > > do_post > > response.should be_redirect > > response.should redirect_to( :action => 'show', :id => > > @static_page.permalink ) ## this is the line 118 > > end > > > > end > > > > And when I try to run it it gives me the following error: > > > > 1) > > ActionController::MethodNotAllowed in 'StaticPagesController Handling > > POST /pages With successful save Should redirect to the new page' > > Only get, put, and delete requests are allowed. > > ./spec/controllers/static_pages_controller_spec.rb:118: > > script/spec:4: > > > > So, the response is a redirect (the "response.should be_redirect" > > passes) but when i try to be sure that it redirected to the right page > > it throws this weird error to me. Any ideas about what I've done > > wrong? > > Can you post the full backtrace? > > script/spec ./spec/controllers/static_pages_controller_spec.rb -b > > > > > > I'm using RSpec 1.1.3 and Rails 2.0.2. > > > > -- > > Maur?cio Linhares > > http://alinhavado.wordpress.com/ (pt-br) | > > http://codeshooter.wordpress.com/ (en) > > Jo?o Pessoa, PB, +55 83 8867-7208 > > _______________________________________________ > > 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 > -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://codeshooter.wordpress.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 From dchelimsky at gmail.com Fri Feb 22 09:25:21 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Feb 2008 08:25:21 -0600 Subject: [rspec-users] Problems with redirect_to In-Reply-To: References: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> Message-ID: <57c63afe0802220625s74d7817s10875cd3ae2e6cb5@mail.gmail.com> On Fri, Feb 22, 2008 at 8:10 AM, Maur?cio Linhares wrote: > Using the "path" method the spec passes, but i don't use the path > method on my controller. First, here's my controller code: > > def create > @static_page = @event.static_pages.build(params[:static_page]) > > respond_to do |format| > if @static_page.save > flash[:notice] = 'Page was successfully created.' > format.html { redirect_to(:action => 'show', :id => > @static_page.permalink ) } ## thats what i'm testing agains > format.xml { render :xml => @static_page, :status => > :created, :location => @static_page } > else > format.html { render :action => "new" } > format.xml { render :xml => @static_page.errors, :status => > :unprocessable_entity } > end > end > end > > And here is the spec: > > > it 'Should redirect to the new page' do > do_post > response.should be_redirect > response.should redirect_to( page_path( :action => 'show', :id > => @static_page.permalink ) ) ## this one, with the page_path goes > fine > > response.should redirect_to( :action => 'show', :id => > @static_page.permalink ) ## this one, without the page_path doesn't > work > end > > It seems that the redirect_to matcher doesn't recognize the current controller. Ah. I missed that the initial example was missing the controller because I was focused on the error message, which is obviously a red herring. Try adding the controller to the hash: esponse.should redirect_to( :controller => 'static_pages', :action => 'show', :id => @static_page.permalink ) If that works, then please submit a bug report to the tracker (that redirect_to does not work with action + id unless you specify the controller). Thanks, David > > And here goes the full backtrace: > > > ActionController::MethodNotAllowed in 'StaticPagesController Handling > POST /pages With successful save Should redirect to the new page' > Only get, put, and delete requests are allowed. > /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1439:in > `recognize_path' > /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:43:in > `path_hash' > /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:38:in > `hash_from_url' > /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:26:in > `actual_hash' > /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:34:in > `actual_redirect_to_valid_route' > /home/mauricio/workspace/antares/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb:18:in > `matches?' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/expectations/handler.rb:19:in > `handle_matcher' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:34:in > `should' > ./spec/controllers/static_pages_controller_spec.rb:119: > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:78:in > `instance_eval' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:78:in > `run_with_description_capturing' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:19:in > `execute' > /usr/lib/ruby/1.8/timeout.rb:48:in `timeout' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_methods.rb:16:in > `execute' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:292:in > `execute_examples' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:291:in > `each' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:291:in > `execute_examples' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:121:in > `run' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in > `run' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in > `each' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in > `run' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/options.rb:90:in > `run_examples' > /home/mauricio/workspace/antares/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in > `run' > script/spec:4: > > > > > On Fri, Feb 22, 2008 at 11:00 AM, David Chelimsky wrote: > > On Fri, Feb 22, 2008 at 7:50 AM, Maur?cio Linhares > > wrote: > > > Hello guys, > > > > > > I have the following spec: > > > > > > describe 'With successful save' do > > > > > > it 'Should redirect to the new page' do > > > do_post > > > response.should be_redirect > > > response.should redirect_to( :action => 'show', :id => > > > @static_page.permalink ) ## this is the line 118 > > > end > > > > > > end > > > > > > And when I try to run it it gives me the following error: > > > > > > 1) > > > ActionController::MethodNotAllowed in 'StaticPagesController Handling > > > POST /pages With successful save Should redirect to the new page' > > > Only get, put, and delete requests are allowed. > > > ./spec/controllers/static_pages_controller_spec.rb:118: > > > script/spec:4: > > > > > > So, the response is a redirect (the "response.should be_redirect" > > > passes) but when i try to be sure that it redirected to the right page > > > it throws this weird error to me. Any ideas about what I've done > > > wrong? > > > > Can you post the full backtrace? > > > > script/spec ./spec/controllers/static_pages_controller_spec.rb -b > > > > > > > > > > I'm using RSpec 1.1.3 and Rails 2.0.2. > > > > > > -- > > > Maur?cio Linhares > > > http://alinhavado.wordpress.com/ (pt-br) | > > > http://codeshooter.wordpress.com/ (en) > > > Jo?o Pessoa, PB, +55 83 8867-7208 > > > _______________________________________________ > > > 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 > > > > > > -- > > > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | > http://codeshooter.wordpress.com/ (en) > Jo?o Pessoa, PB, +55 83 8867-7208 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mauricio.linhares at gmail.com Fri Feb 22 10:20:59 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Fri, 22 Feb 2008 12:20:59 -0300 Subject: [rspec-users] Problems with redirect_to In-Reply-To: <57c63afe0802220625s74d7817s10875cd3ae2e6cb5@mail.gmail.com> References: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> <57c63afe0802220625s74d7817s10875cd3ae2e6cb5@mail.gmail.com> Message-ID: Hi David, First, using the controller doesn't work also :) After some debugging here i found out why it was trowing the error, the RedirectTo matcher uses the ActionController::Routing::Routes.recognize_path method to discover if a path exists and this method takes two parameters, the path and the "environment" that the path is being requested. When my code was being matched, the redirect_to matcher generated the right path "/pages/test" and sent it two the recognize_path method, but this path is a Restful one and only GET, PUT and DELETEs are allowed and the RedirectTo matcher didn't send any :method param, so when the path is being recognized and no method is sent it will never be recognized and thus that weird error is thrown. A simple way to solve this issue is change the path_hash method at the RedirectTo matcher to include the HTTP method being called: def path_hash(url) path = url.sub(%r{^\w+://#{@request.host}}, "").split("?", 2)[0] ActionController::Routing::Routes.recognize_path path, :method => :get end As you can only redirect to GET requests, this should not be a problem. Should i file a patch for this? Now, the two methods are working fine =D it 'Should redirect to the new page' do do_post response.should redirect_to( page_path( :action => 'show', :id => @static_page.permalink ) ) response.should redirect_to( :action => 'show', :id => @static_page.permalink ) end -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://codeshooter.wordpress.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 On Fri, Feb 22, 2008 at 11:25 AM, David Chelimsky wrote: > On Fri, Feb 22, 2008 at 8:10 AM, Maur?cio Linhares > > wrote: > > > > Using the "path" method the spec passes, but i don't use the path > > method on my controller. First, here's my controller code: > > > > def create > > @static_page = @event.static_pages.build(params[:static_page]) > > > > respond_to do |format| > > if @static_page.save > > flash[:notice] = 'Page was successfully created.' > > format.html { redirect_to(:action => 'show', :id => > > @static_page.permalink ) } ## thats what i'm testing agains > > format.xml { render :xml => @static_page, :status => > > :created, :location => @static_page } > > else > > format.html { render :action => "new" } > > format.xml { render :xml => @static_page.errors, :status => > > :unprocessable_entity } > > end > > end > > end > > > > And here is the spec: > > > > > > it 'Should redirect to the new page' do > > do_post > > response.should be_redirect > > response.should redirect_to( page_path( :action => 'show', :id > > => @static_page.permalink ) ) ## this one, with the page_path goes > > fine > > > > response.should redirect_to( :action => 'show', :id => > > @static_page.permalink ) ## this one, without the page_path doesn't > > work > > end > > > > It seems that the redirect_to matcher doesn't recognize the current controller. > > Ah. I missed that the initial example was missing the controller > because I was focused on the error message, which is obviously a red > herring. > > Try adding the controller to the hash: > > esponse.should redirect_to( :controller => 'static_pages', :action => > > 'show', :id => @static_page.permalink ) > > If that works, then please submit a bug report to the tracker (that > redirect_to does not work with action + id unless you specify the > controller). > > Thanks, > David > From dchelimsky at gmail.com Fri Feb 22 10:43:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Feb 2008 09:43:33 -0600 Subject: [rspec-users] Problems with redirect_to In-Reply-To: References: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> <57c63afe0802220625s74d7817s10875cd3ae2e6cb5@mail.gmail.com> Message-ID: <57c63afe0802220743q391a76c8g8a94835e0c85fad1@mail.gmail.com> On Fri, Feb 22, 2008 at 9:20 AM, Maur?cio Linhares wrote: > Hi David, > > First, using the controller doesn't work also :) > > After some debugging here i found out why it was trowing the error, > the RedirectTo matcher uses the > ActionController::Routing::Routes.recognize_path method to discover if > a path exists and this method takes two parameters, the path and the > "environment" that the path is being requested. When my code was being > matched, the redirect_to matcher generated the right path > "/pages/test" and sent it two the recognize_path method, but this path > is a Restful one and only GET, PUT and DELETEs are allowed and the > RedirectTo matcher didn't send any :method param, so when the path is > being recognized and no method is sent it will never be recognized and > thus that weird error is thrown. > > A simple way to solve this issue is change the path_hash method at the > RedirectTo matcher to include the HTTP method being called: > > def path_hash(url) > path = url.sub(%r{^\w+://#{@request.host}}, "").split("?", 2)[0] > ActionController::Routing::Routes.recognize_path path, :method => :get > end > > As you can only redirect to GET requests, this should not be a > problem. Should i file a patch for this? That would be great, thanks! Please do review http://rspec.lighthouseapp.com/projects/5645/how-to-file-a-ticket before you do. Thank you, David > > Now, the two methods are working fine =D > > > it 'Should redirect to the new page' do > do_post > > response.should redirect_to( page_path( :action => 'show', :id > => @static_page.permalink ) ) > > response.should redirect_to( :action => 'show', :id => > @static_page.permalink ) > end > > > -- > > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | > http://codeshooter.wordpress.com/ (en) > Jo?o Pessoa, PB, +55 83 8867-7208 > > > > > On Fri, Feb 22, 2008 at 11:25 AM, David Chelimsky wrote: > > On Fri, Feb 22, 2008 at 8:10 AM, Maur?cio Linhares > > > > wrote: > > > > > > > Using the "path" method the spec passes, but i don't use the path > > > method on my controller. First, here's my controller code: > > > > > > def create > > > @static_page = @event.static_pages.build(params[:static_page]) > > > > > > respond_to do |format| > > > if @static_page.save > > > flash[:notice] = 'Page was successfully created.' > > > format.html { redirect_to(:action => 'show', :id => > > > @static_page.permalink ) } ## thats what i'm testing agains > > > format.xml { render :xml => @static_page, :status => > > > :created, :location => @static_page } > > > else > > > format.html { render :action => "new" } > > > format.xml { render :xml => @static_page.errors, :status => > > > :unprocessable_entity } > > > end > > > end > > > end > > > > > > And here is the spec: > > > > > > > > > it 'Should redirect to the new page' do > > > do_post > > > response.should be_redirect > > > response.should redirect_to( page_path( :action => 'show', :id > > > => @static_page.permalink ) ) ## this one, with the page_path goes > > > fine > > > > > > response.should redirect_to( :action => 'show', :id => > > > @static_page.permalink ) ## this one, without the page_path doesn't > > > work > > > end > > > > > > It seems that the redirect_to matcher doesn't recognize the current controller. > > > > Ah. I missed that the initial example was missing the controller > > because I was focused on the error message, which is obviously a red > > herring. > > > > Try adding the controller to the hash: > > > > esponse.should redirect_to( :controller => 'static_pages', :action => > > > > 'show', :id => @static_page.permalink ) > > > > If that works, then please submit a bug report to the tracker (that > > redirect_to does not work with action + id unless you specify the > > controller). > > > > Thanks, > > David > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From brian.takita at gmail.com Fri Feb 22 16:22:08 2008 From: brian.takita at gmail.com (Brian Takita) Date: Fri, 22 Feb 2008 13:22:08 -0800 Subject: [rspec-users] Specs versus Stories In-Reply-To: <5CB219D7-A95E-4E18-87F8-0C640F6C18D6@josephholsten.com> References: <3B87748D-51A3-483D-9A89-9754BAFE9466@civrot.org> <57c63afe0802181544g4615eeb1w92409a0aecb04f92@mail.gmail.com> <5CB219D7-A95E-4E18-87F8-0C640F6C18D6@josephholsten.com> Message-ID: <1d7ddd110802221322s547e3e4eg90ada3df263de5a2@mail.gmail.com> There are automated & manual tests. Automated customer facing & Automated developer tests. Both customer facing and developer tests can have a unit, functional, and integration scope. That being said, you can have effective high level developer Specs. Stories are great for facilitation communication, especially with nondevelopers. It may also be useful in organizing the developer's thoughts too. There may also be other benefits that I'm missing here. However, there is an additional investment needed to build up your Story dsl, than would be expended in using high level Specs. Does the value of having Stories outweigh the costs in your situation? I think the best practice is what makes the most sense to you. On Thu, Feb 21, 2008 at 11:02 AM, Joseph Anthony Pasquale Holsten wrote: > I try to thing of the audience for the work, and it keeps me sane. > > Stories are to make sure you're holding up your contract with the client or > user. They are high level, and don't deal with any implementation details > that can be abstracted away. You might relate them to acceptance tests, > because when you pass stories, you're passing all the acceptance criteria. > You also might compare them integration tests, because they should ensure > everything behind the UI (or API) works correctly. It's reasonable to mock > external services, but I try to have these be as real as possible. > > If you and your user disagree about how something works, you make the change > in the story. Then you change the specs and code as needed. > > Specs are to make sure you're holding up your contract with the code and its > developers. With so little static checking in ruby, specs are your type > checking, exception checking (ala java), the preconditions, postconditions, > and invariants (ala DbC), published interface, performance profiler, and > possibly even internal documentation. These make sure you know the right way > to interact with the code. And of course you should specify the code before > you implement it, red-green style. > > If you and a developer disagree about how something works, you make the > change in the specs. Then you change the code as needed. > > Clear as mud? > > > > On 02008:02:18, at 5:44CST, David Chelimsky wrote: > > On Feb 18, 2008 6:38 PM, Victor Asteinza wrote: > Isn't there redundancy between what is in your stories and your specs? > Or are your stories at a higher level and the specs are at a lower > level? That would make more sense to me. There would be some cross > over. but the specs expand on what is in the stories.... > > While either tool can technically support either mode of thinking: > > Stories are aimed at describing the behaviour of your applications. > Specs are aimed at describing the behaviour of the objects in your > applications. > > You are correct that there will likely be some cross over, but keep in > mind that there are different audiences and different processes. > > The steps in stories (the descriptive text, not the implementation of > the steps) are typically written in entirety before setting out to > develop a body of work. Stories should be run before a commit, or as > part of a CI build, but are not always run between every step. > > The examples in specs, on the other hand, typically come into > existence in a very granular red-green-refactor cycle, and should be > run between every step. > > HTH, > David > > > > > > Message: 3 > Date: Mon, 18 Feb 2008 11:21:47 -0500 > From: "Andrew WC Brown" > Subject: Re: [rspec-users] Specs versus Stories > To: rspec-users > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > > > My workflow is the following: > Stories->Spec Views->Spec Controllers-Spec Models > > I'll write a few stories of what I think should it happen. > Then I'll write my specs of what should show (and also do some > static html > page mockups) > Then I'll spec my controllers and models > I'll go back to my stories to see if they need adjusting because my > perceptive of how the app changed > Then I run my stories and make them pass. > > Then I write a few stories and repeat. > > I constantly step move back and forth. > I think Stories and BDD greatly assists you to shape your idea. > Write stories for what you can think of and then move on to specing. > You don't need complete stories you can also go back and fill them > in later. > > On Feb 18, 2008 2:57 AM, Victor Asteinza wrote: > > > I am new to BDD and have been doing some reading and playing with > rSpec. I am a little confused. I am not sure what the best practice > for using stories and specs. Should I be writing stories first, then > specs that would fulfill those stories, and then write the > implementation code to have everything pass? At first that seems a > little redundant. > > I understand that the stories let you write the behavior in plane > English, which I can see it being useful when dealing with non > technical users. But if I am developing an internal app I am > struggling with whether I should develop the stories first and then > move on to the specs. > > Opinions? Experiences? > > Thanks, > Victor > _______________________________________________ > 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 > > http:// Joseph Holsten .com > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ed.howland at gmail.com Fri Feb 22 18:02:49 2008 From: ed.howland at gmail.com (Ed Howland) Date: Fri, 22 Feb 2008 17:02:49 -0600 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> Message-ID: <3df642dd0802221502x27e0c408o8623f4f5b8f84176@mail.gmail.com> On Wed, Feb 20, 2008 at 1:02 AM, Jarkko Laine wrote: > > On 19.2.2008, at 20.45, James Deville wrote: > > > I set RAILS_ENV in my stories/helper.rb file. That might be a good > > solution. > > > > > > Using Webrat for 100% of my stories (and running autotest) and loving > it. I also have the env set in stories/helper.rb, but I'm not sure > whether it was there from the beginning (I just copied it from some of > the early posts about stories). > > //jarkko > It is set in stories/helper.rb, but not working. ./script/generate rspec creates a file with: ENV['RAILS_ENV']="test" which is deprecated It should be: RAILS_ENV="test" Changed that and it all worked fine. Ed > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > 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 joe at pinkpucker.net Fri Feb 22 21:00:28 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Fri, 22 Feb 2008 18:00:28 -0800 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> Message-ID: On Tue, Feb 19, 2008 at 11:02 PM, Jarkko Laine wrote: > > On 19.2.2008, at 20.45, James Deville wrote: > > > I set RAILS_ENV in my stories/helper.rb file. That might be a good > > solution. > > > > > > On Feb 19, 2008, at 10:32 AM, Ed Howland wrote: > > > >> Hi, > >> > >> I am trying to get Webrat integrated with RSpec. I've followed the > >> steps in the various blog posts about this, but have one sniggling > >> little issue. It might be a Webrat issue, but I am hoping the RSpec > >> folks might have already solved it. > >> > >> I have the stories run from a Rake task (am hoping for one of these > >> in the main rspec rake task soon,) ut to run webrat stuff in the > >> steps, you need to: > >> > >> rake spec:stories RAILS_ENV=test. > >> > >> The reason is due to the boot order of rake and plugins (of which > >> webrat and rspec are ones), webrat/init.rb doesn't attach itself to > >> ActionController::Integration::Session unless it is on the test > >> environment. Only setting the RAILS_ENV ahead of the boot sequence > >> fixes this. But I am wondering if there is another alternative. > >> > >> Also, has anyone gotten it to run with autotest? > > Using Webrat for 100% of my stories (and running autotest) and loving > it. I also have the env set in stories/helper.rb, but I'm not sure > whether it was there from the beginning (I just copied it from some of > the early posts about stories). How are you using both autotest and the stories? From rspec-users at kero.tmfweb.nl Fri Feb 22 22:23:12 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Sat, 23 Feb 2008 04:23:12 +0100 Subject: [rspec-users] Old Style Stories In-Reply-To: <57c63afe0802212040i2891f15es382b08bca6241e9c@mail.gmail.com> References: <85d99afe0802192106x268b5f69kc498bb8c0a89c9a9@mail.gmail.com> <57c63afe0802200426n8fa1e41x640d799d7fce7282@mail.gmail.com> <20080221042106.GA562@chello.nl> <85d99afe0802211907p10d12e6duda471b87918255f9@mail.gmail.com> <57c63afe0802212026g39e5d19bl858c367ffa3f5910@mail.gmail.com> <57c63afe0802212040i2891f15es382b08bca6241e9c@mail.gmail.com> Message-ID: <20080223032312.GB562@chello.nl> > > > so is writing in Ruby". This begs the question now that we have plain > > > text stories. Can we make the ruby-based stories more developer > > > friendly? Perhaps remove string identifiers, use symbols. Quit passing > > > in blocks to story parts, assume each story part is a method call, and > > > I'm sure there are other things that could be suggested as well. > > > > You can do all of this already except using symbols instead of > > Strings, something which doesn't strike me as more readable. Here's an > > example: > > > > http://pastie.caboo.se/155775 > > And here's another example with a bit more reuse expressed in the > steps at the expense of more complexity in the steps. Which approach > is better? I can't really say one is always better than the other. I > choose based on readability in a given context. Just exploring > possibilities. where? From jarkko at jlaine.net Sat Feb 23 03:11:11 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Sat, 23 Feb 2008 10:11:11 +0200 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> Message-ID: On 23.2.2008, at 4.00, Joe Van Dyk wrote: > How are you using both autotest and the stories? I use Geoffrey's rstakeout (http://nubyonrails.com/articles/automation-with-rstakeout ) to watch a single story (running all stories a la autotest is too slow) and /app, and autotest in a different terminal for normal specs. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20080223/3dc6853f/attachment-0001.bin From a at heitler.com Fri Feb 22 08:29:50 2008 From: a at heitler.com (jesterj) Date: Fri, 22 Feb 2008 05:29:50 -0800 (PST) Subject: [rspec-users] Story teardowns? In-Reply-To: References: <8d961d900801110210j20dafd84kfd054839595afbfa@mail.gmail.com> Message-ID: <15633065.post@talk.nabble.com> Andreas Axelsson-2 wrote: > >> > Does the plain text story framework support teardowns? There doesn't >> seem to >> > be anywhere to put an "after" method. > >>For now I'd stick this in a Given that >> you use at the beginning of each scenario, for example: >> >> Given "the stash is in a clean state" do >> # yank any old residual gunk here >> end > > Another option, which I found more helpful, is to add another step like: And finally, clean up Which enables you to do all the teardown in: Then "finally, clean up" do{ teardown_stuff } -J -- View this message in context: http://www.nabble.com/Story-teardowns--tp14752945p15633065.html Sent from the rspec-users mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080222/0b42a14f/attachment.html From lists at pauldowman.com Fri Feb 22 12:18:53 2008 From: lists at pauldowman.com (Paul Dowman) Date: Fri, 22 Feb 2008 09:18:53 -0800 (PST) Subject: [rspec-users] Autotest with TDD "test-first" problem Message-ID: Hi, I'm mostly quite happy using autotest with rspec, but there's one thing that's been bothering me, and as my test suite grows larger it'd becoming more painful. Autotest re-runs the entire suite whenever a spec that had previously failed passes for the first time. I find that incompatible with writing tests first in classic TDD style. I write the test which fails (because there's no implementation yet), and then just implement the method and watch it pass. But now autotest decides to re-run the entire test suite, which takes a couple of minutes, and in the meantime I'm stuck waiting to see if my next spec will pass or not. Is it possible to change that behavior somehow, so that it doesn't re- run the entire suite every time? Thanks, Paul From lists at pauldowman.com Fri Feb 22 12:21:04 2008 From: lists at pauldowman.com (Paul Dowman) Date: Fri, 22 Feb 2008 09:21:04 -0800 (PST) Subject: [rspec-users] disabling transactional fixtures for one spec Message-ID: Sometimes I need a spec that tests something which can't work inside a transaction. Is it possible to disable transactional fixtures for one spec? I tried: describe "MyClass without transactional fixtures" do before(:all) do Spec::Runner.configure { |config| config.use_transactional_fixtures = false } end after(:all) do Spec::Runner.configure { |config| config.use_transactional_fixtures = true } end end ... but that doesn't work. Thanks, Paul From dchelimsky at gmail.com Sat Feb 23 09:10:21 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Feb 2008 08:10:21 -0600 Subject: [rspec-users] Autotest with TDD "test-first" problem In-Reply-To: References: Message-ID: <57c63afe0802230610v1e650434l8c3220a2a697fecb@mail.gmail.com> On Fri, Feb 22, 2008 at 11:18 AM, Paul Dowman wrote: > Hi, I'm mostly quite happy using autotest with rspec, but there's one > thing that's been bothering me, and as my test suite grows larger it'd > becoming more painful. > > Autotest re-runs the entire suite whenever a spec that had previously > failed passes for the first time. I find that incompatible with > writing tests first in classic TDD style. I write the test which fails > (because there's no implementation yet), and then just implement the > method and watch it pass. But now autotest decides to re-run the > entire test suite, which takes a couple of minutes, and in the > meantime I'm stuck waiting to see if my next spec will pass or not. > > Is it possible to change that behavior somehow, so that it doesn't re- > run the entire suite every time? Interesting idea. How would you want autotest to decide when to run everything? In the end, this belongs in ZenTest, not RSpec, but we can certainly discuss it here :) Cheers, David > > Thanks, > Paul > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Feb 23 09:17:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Feb 2008 08:17:56 -0600 Subject: [rspec-users] disabling transactional fixtures for one spec In-Reply-To: References: Message-ID: <57c63afe0802230617o2f76db7cie98faa013de501e2@mail.gmail.com> On Fri, Feb 22, 2008 at 11:21 AM, Paul Dowman wrote: > Sometimes I need a spec that tests something which can't work inside a > transaction. Is it possible to disable transactional fixtures for one > spec? > > I tried: > > describe "MyClass without transactional fixtures" do > before(:all) do > Spec::Runner.configure { |config| > config.use_transactional_fixtures = false } > end > > after(:all) do > Spec::Runner.configure { |config| > config.use_transactional_fixtures = true } > end > end > > ... but that doesn't work. Try this - don't know if it works but I think it might: describe "MyClass without transactional fixtures" do self.use_transactional_fixtures = true ... end Let us know if it works. Cheers, David > > Thanks, > Paul > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joe at pinkpucker.net Sat Feb 23 13:16:18 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sat, 23 Feb 2008 10:16:18 -0800 Subject: [rspec-users] rake task for stories Message-ID: Any reason why there isn't a rake task for stories yet? (I'm looking in trunk) Someone want to share theirs? Joe From dchelimsky at gmail.com Sat Feb 23 13:41:26 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Feb 2008 12:41:26 -0600 Subject: [rspec-users] rake task for stories In-Reply-To: References: Message-ID: On Feb 23, 2008, at 12:16 PM, "Joe Van Dyk" wrote: > Any reason why there isn't a rake task for stories yet? (I'm > looking in trunk) There is one for rspec_on_rails but it is nothing special. It just calls stories/ all.rb which is up to you to maintain. I know of at least one story command that is in the works. I think that once that exists we'll be in a better spot to wrap it in a rake task. I think, also, that there are still some different conventions at play and it makes sense to wait for a solid convention to emerge in terms of structure and organization. Cheers, David > Someone want to share theirs? > > Joe > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Sat Feb 23 15:01:19 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 23 Feb 2008 15:01:19 -0500 Subject: [rspec-users] Autotest with TDD "test-first" problem In-Reply-To: References: Message-ID: On Feb 22, 2008, at 12:18 PM, Paul Dowman wrote: > Hi, I'm mostly quite happy using autotest with rspec, but there's one > thing that's been bothering me, and as my test suite grows larger it'd > becoming more painful. > > Autotest re-runs the entire suite whenever a spec that had previously > failed passes for the first time. I find that incompatible with > writing tests first in classic TDD style. I write the test which fails > (because there's no implementation yet), and then just implement the > method and watch it pass. But now autotest decides to re-run the > entire test suite, which takes a couple of minutes, and in the > meantime I'm stuck waiting to see if my next spec will pass or not. > > Is it possible to change that behavior somehow, so that it doesn't re- > run the entire suite every time? I had the same problem - and decided that Autotest wasn't for me. I'm much smarter than autotest, so I know which files I should be re- running, and when. If, as David suggests, you can figure out a good strategy on when to rerun the full suite, continue to use it (just modify the mappings in ~/.autotest (or RAILS_ROOT/.autotest)). Otherwise, autotest is pretty much out (unless you want to work on Deeptest, or SpecDistributed). Scott From joseph at josephholsten.com Sat Feb 23 15:09:32 2008 From: joseph at josephholsten.com (Joseph Anthony Pasquale Holsten) Date: Sat, 23 Feb 2008 14:09:32 -0600 Subject: [rspec-users] Specs versus Stories In-Reply-To: <1d7ddd110802221322s547e3e4eg90ada3df263de5a2@mail.gmail.com> References: <3B87748D-51A3-483D-9A89-9754BAFE9466@civrot.org> <57c63afe0802181544g4615eeb1w92409a0aecb04f92@mail.gmail.com> <5CB219D7-A95E-4E18-87F8-0C640F6C18D6@josephholsten.com> <1d7ddd110802221322s547e3e4eg90ada3df263de5a2@mail.gmail.com> Message-ID: <4CD391F9-4CDA-4CAE-8120-06091DAFE0D4@josephholsten.com> Brian Takita wrote: > There are automated & manual tests. > Automated customer facing & Automated developer tests. > Both customer facing and developer tests can have a unit, functional, > and integration scope. > > That being said, you can have effective high level developer Specs. They certainly can, but I wonder who is. Does anyone have experiences with this specification (opposed to story-telling) at a high level they would share? > Stories are great for facilitation communication, especially with > nondevelopers. It may also be useful in organizing the developer's > thoughts too. There may also be other benefits that I'm missing here. So how about that opposite, is anyone using story-telling internally but not getting them from (or even sharing them with) clients? How's that working? > However, there is an additional investment needed to build up your > Story dsl, than would be expended in using high level Specs. > Does the value of having Stories outweigh the costs in your situation? > I think the best practice is what makes the most sense to you. That's how I always defined best! http:// Joseph Holsten .com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080223/35211c29/attachment.html From joe at pinkpucker.net Sat Feb 23 15:35:01 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sat, 23 Feb 2008 12:35:01 -0800 Subject: [rspec-users] rake task for stories In-Reply-To: References: Message-ID: On Sat, Feb 23, 2008 at 10:41 AM, David Chelimsky wrote: > On Feb 23, 2008, at 12:16 PM, "Joe Van Dyk" wrote: > > > Any reason why there isn't a rake task for stories yet? (I'm > > looking in trunk) > > There is one for rspec_on_rails but it is nothing special. It just > calls stories/ all.rb which is up to you to maintain. > > I know of at least one story command that is in the works. I think > that once that exists we'll be in a better spot to wrap it in a rake > task. > > I think, also, that there are still some different conventions at play > and it makes sense to wait for a solid convention to emerge in terms > of structure and organization. I can't seem to find the rspec_on_rails story task. What file is it in? From joe at pinkpucker.net Sat Feb 23 15:39:58 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sat, 23 Feb 2008 12:39:58 -0800 Subject: [rspec-users] Autotest with TDD "test-first" problem In-Reply-To: <57c63afe0802230610v1e650434l8c3220a2a697fecb@mail.gmail.com> References: <57c63afe0802230610v1e650434l8c3220a2a697fecb@mail.gmail.com> Message-ID: On Sat, Feb 23, 2008 at 6:10 AM, David Chelimsky wrote: > On Fri, Feb 22, 2008 at 11:18 AM, Paul Dowman wrote: > > Hi, I'm mostly quite happy using autotest with rspec, but there's one > > thing that's been bothering me, and as my test suite grows larger it'd > > becoming more painful. > > > > Autotest re-runs the entire suite whenever a spec that had previously > > failed passes for the first time. I find that incompatible with > > writing tests first in classic TDD style. I write the test which fails > > (because there's no implementation yet), and then just implement the > > method and watch it pass. But now autotest decides to re-run the > > entire test suite, which takes a couple of minutes, and in the > > meantime I'm stuck waiting to see if my next spec will pass or not. > > > > Is it possible to change that behavior somehow, so that it doesn't re- > > run the entire suite every time? > > Interesting idea. How would you want autotest to decide when to run everything? > > In the end, this belongs in ZenTest, not RSpec, but we can certainly > discuss it here :) Would be interesting to have the ability to run multiple tests at once. For example, one test runner could repeatedly run (or once a minute, or whatever) the entire test suite. And one test runner could run the related tests for the file you change. Perhaps two autotest instances, running off different test databases? From dchelimsky at gmail.com Sat Feb 23 18:06:36 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Feb 2008 17:06:36 -0600 Subject: [rspec-users] rake task for stories In-Reply-To: References: Message-ID: <57c63afe0802231506j3e80d751h294717c06d2c8492@mail.gmail.com> On Sat, Feb 23, 2008 at 2:35 PM, Joe Van Dyk wrote: > On Sat, Feb 23, 2008 at 10:41 AM, David Chelimsky wrote: > > On Feb 23, 2008, at 12:16 PM, "Joe Van Dyk" wrote: > > > > > Any reason why there isn't a rake task for stories yet? (I'm > > > looking in trunk) > > > > There is one for rspec_on_rails but it is nothing special. It just > > calls stories/ all.rb which is up to you to maintain. > > > > I know of at least one story command that is in the works. I think > > that once that exists we'll be in a better spot to wrap it in a rake > > task. > > > > I think, also, that there are still some different conventions at play > > and it makes sense to wait for a solid convention to emerge in terms > > of structure and organization. > > I can't seem to find the rspec_on_rails story task. What file is it in? I take it back. It does not get generated. I've just been adding one to my projects that runs stories/all.rb. Guess it's so trivial that I forgot it wasn't generated :) > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Sat Feb 23 18:19:08 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 23 Feb 2008 15:19:08 -0800 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? In-Reply-To: References: Message-ID: <810a540e0802231519v97659dek9eab36b2fa6836ec@mail.gmail.com> On Thu, Feb 21, 2008 at 8:09 AM, Chuck Remes wrote: > While practicing BDD on my first-ever BDD project, I have come to a > point where it makes sense to change my original class to an abstract > class and create one (or more) concrete subclasses that implement a > specific method. What is the right way to restructure the tests in > this scenario? Do I leave the existing tests in place and just create > a new spec file that instantiates and tests the concrete subclass? > > I think I can continue to instantiate my "abstract" parent as long as > I don't go near the behavior that will be defined by the concrete > subclasses. Is that the right thing to do? > > Thanks for any hints. > > cr > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I think that shared example groups might be useful. Pat From agilejoe at gmail.com Sun Feb 24 06:29:00 2008 From: agilejoe at gmail.com (Joe Ocampo) Date: Sun, 24 Feb 2008 05:29:00 -0600 Subject: [rspec-users] Newbie question Context vs Describe Message-ID: <93cf9750802240329j72a629d1v64291faf0040ae6c@mail.gmail.com> Background just started programming in Ruby literally 12 hours ago and have a question regarding context and describe methods. Reading the RDoc it indicated that "context" is an alias for "describe". So I decided to try to the following syntax seeing this is how I would approach it in C# with NBehave. require 'user' describe User do before(:each) do @user = User.new end context "(adding assigned role)" do before(:each) do @user.assign_role("Manager") end specify "should be in any roles assigned to it" do @user.should be_in_role("Manager") end specify "should not be in any role not assigned to it" do @user.should_not be_in_role("unassigned role") end end context "(adding assigned group)" do end end I thought I could use the "describe" method to indicate the Type that the specifications where going to be concerning. I then would place the type into a behavioral context to assert the intended behavior against that context. This combination resulted in User never being instantiated for the internal context. (nil:NilClass). However! If I flip the "context" and "description" it works. Am I doing something wrong? require 'user' context User do ... describe "(adding assigned role)" do ... end end -- God Bless, Joe Ocampo agilejoe.lostechies.com "How do you benefit if you gain the whole world but lose your soul in the process?" Mark 8:36 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080224/1f07d223/attachment.html From dchelimsky at gmail.com Sun Feb 24 09:26:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 Feb 2008 08:26:40 -0600 Subject: [rspec-users] Newbie question Context vs Describe In-Reply-To: <93cf9750802240329j72a629d1v64291faf0040ae6c@mail.gmail.com> References: <93cf9750802240329j72a629d1v64291faf0040ae6c@mail.gmail.com> Message-ID: <57c63afe0802240626s4e1a3c64x7fca8c0d01f31412@mail.gmail.com> On Sun, Feb 24, 2008 at 5:29 AM, Joe Ocampo wrote: > Background just started programming in Ruby literally 12 hours ago and have > a question regarding context and describe methods. Reading the RDoc it > indicated that "context" is an alias for "describe". So I decided to try to > the following syntax seeing this is how I would approach it in C# with > NBehave. > require 'user' > > describe User do > > before(:each) do > @user = User.new > end > > context "(adding assigned role)" do > before(:each) do > @user.assign_role("Manager") > end > > specify "should be in any roles assigned to it" do > @user.should be_in_role("Manager") > end > > specify "should not be in any role not assigned to it" do > @user.should_not be_in_role("unassigned role") > end > end > > context "(adding assigned group)" do > > end > end > > I thought I could use the "describe" method to indicate the Type that the > specifications where going to be concerning. I then would place the type > into a behavioral context to assert the intended behavior against that > context. At first glance, that is really cool. We've also batted around some other names like #facet or #behaviour. > This combination resulted in User never being instantiated for the internal > context. (nil:NilClass). However! If I flip the "context" and > "description" it works. Am I doing something wrong? No you're not doing something wrong - there are two different places where describe is defined. One in main (the outermost layer) and one inside an ExampleGroup. The one in the example group isn't aliased. So to solve that for the short term in your own code you can do this in your spec_helper.rb file: module Spec::Example::ExampleGroupMethods alias :context :describe end In terms of getting that into RSpec, why don't you enter a feature request at http://rspec.lighthouseapp.com and we can discuss the merits of this there. As I said, I like it at first glance, but I want to think about it and get other opinions before just adding it (as context is only there for backwards compatibility right now). Thanks, David > > require 'user' > > context User do > ... > describe "(adding assigned role)" do > ... > end > end > > -- > God Bless, > > Joe Ocampo > agilejoe.lostechies.com > > "How do you benefit if you gain the whole world but lose your soul in the > process?" Mark 8:36 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From agilejoe at gmail.com Sun Feb 24 14:42:30 2008 From: agilejoe at gmail.com (Joe Ocampo) Date: Sun, 24 Feb 2008 13:42:30 -0600 Subject: [rspec-users] Newbie question Context vs Describe In-Reply-To: <57c63afe0802240626s4e1a3c64x7fca8c0d01f31412@mail.gmail.com> References: <93cf9750802240329j72a629d1v64291faf0040ae6c@mail.gmail.com> <57c63afe0802240626s4e1a3c64x7fca8c0d01f31412@mail.gmail.com> Message-ID: <93cf9750802241142j5b73464wc423057d9b2a457f@mail.gmail.com> >At first glance, that is really cool. We've also batted around some >other names like #facet or #behavior. LOL..I smile because we went through the same semantic struggles as well. The funny thing is the rSpec project led us to our resolve. :-) We basically came to this conclusion every object has a behavior but that behavior is governed by a context or multiple context concerning that type. Given that we are specifying how an object should behave under a certain context, the DSL quickly took shape. About the only difference is we introduced the term [concerning] instead of describe. pseudo DSL: these specs are concerning this [Type] when this [type] is in this context then specify that it should behave this way In C# this DSL creates a lot of noise in the syntax! For example: [Context, Concerning("EquationGenerator")] public class When_initializing_the_EquationGenerator_with_one_and_five : NBehave.NUnitSpecBase { protected override void Before_each_spec() { _generator = new EquationGenerator(_LowerBound, _UpperBound); } [Specification] public void Should_generate_equations_where_the_left_hand_side_is_greater_than_or_equal_to_the_lower_bound() { IList equations = _generator.GenerateEquations(); foreach (Equation equation in equations) { equation.LeftHandSide.should_be_greater_than_or_equal_to (_LowerBound); } } [Specification] public void Should_generate_equations_where_the_left_hand_side_is_less_than_or_equal_to_the_upper_bound()... [Specification] public void Should_generate_equations_where_the_right_hand_side_is_greater_than_or_equal_to_the_lower_bound()... [Specification] public void Should_generate_equations_where_the_right_hand_side_is_less_than_or_equal_to_the_upper_bound()... [Specification] public void Should_generate_twenty_five_equations()... } I think we have taken this as far as it can go for a statically typed language. Hence my interest in rSpec especially once MS gets IronRuby baked! I can easily see Ruby taking over the MS culture once IronRuby is complete. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080224/390f8ba5/attachment.html From grail at goldweb.com.au Sun Feb 24 18:54:11 2008 From: grail at goldweb.com.au (Alex Satrapa) Date: Mon, 25 Feb 2008 10:54:11 +1100 Subject: [rspec-users] How to dump contents produced during spec evaluation? Message-ID: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> In a story, I have the following happening: post("/resources/", 'resource' => request_attrs) response.should render_template('resource/new') response.should have_tag('*', /must have one or more X defined/) In the ResourceController spec, I have the following happening: post( :create, :resource => request_attrs ) response.should render_template('resource/new') response.should have_tag('*', /must have one or more X defined/) The problem I'm having is that the story works just fine, but the spec claims that there are no tags matching '*' in the response. Is there any way I can dump the contents of the response, in the hope that they might tip me off as to the cause of this error? I've checked the stories, and I do not have any steps with the same description as the one that passes in the story but fails in the spec. I've stumbled across this before, especially where a step is "when the user creates a new resource" - often the first one the story runner sees will become the definition of "when the user creates a new resource", and later versions have to be renamed eg: "when the user creates a new resource with special feature X". That's not happening here as far as I can tell. Any clues on where to start looking? Thanks Alex From dchelimsky at gmail.com Sun Feb 24 18:58:25 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 Feb 2008 17:58:25 -0600 Subject: [rspec-users] How to dump contents produced during spec evaluation? In-Reply-To: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> References: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> Message-ID: <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> On Sun, Feb 24, 2008 at 5:54 PM, Alex Satrapa wrote: > In a story, I have the following happening: > post("/resources/", 'resource' => request_attrs) > response.should render_template('resource/new') > response.should have_tag('*', /must have one or more X defined/) > > In the ResourceController spec, I have the following happening: > post( :create, :resource => request_attrs ) > response.should render_template('resource/new') > response.should have_tag('*', /must have one or more X defined/) > > The problem I'm having is that the story works just fine, but the > spec claims that there are no tags matching '*' in the response. > > Is there any way I can dump the contents of the response, in the hope > that they might tip me off as to the cause of this error? puts response.body > > I've checked the stories, and I do not have any steps with the same > description as the one that passes in the story but fails in the > spec. I've stumbled across this before, especially where a step is > "when the user creates a new resource" - often the first one the > story runner sees will become the definition of "when the user > creates a new resource", and later versions have to be renamed eg: > "when the user creates a new resource with special feature X". > That's not happening here as far as I can tell. > > Any clues on where to start looking? > > Thanks > Alex > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From grail at goldweb.com.au Sun Feb 24 19:29:45 2008 From: grail at goldweb.com.au (Alex Satrapa) Date: Mon, 25 Feb 2008 11:29:45 +1100 Subject: [rspec-users] How to dump contents produced during spec evaluation? In-Reply-To: <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> References: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> Message-ID: On 25/02/2008, at 10:58 , David Chelimsky wrote: > On Sun, Feb 24, 2008 at 5:54 PM, Alex Satrapa > wrote: >> In the ResourceController spec, I have the following happening: >> post( :create, :resource => request_attrs ) >> response.should render_template('resource/new') >> response.should have_tag('*', /must have one or more X defined/) >> Is there any way I can dump the contents of the response, in the >> hope >> that they might tip me off as to the cause of this error? > > puts response.body Okay, this is weird. The result seems to indicate that the body of the response is the literal text, "resource/new": My autotest results show (I've changed the name of the resource to 'resource'): > ..........resources/new > F.............. > > 1) > 'ResourcesController on 'POST /resources/', with an invalid request > should generate an error message indicating that magic parts are > missing' FAILED > Expected at least 1 element matching "*", found 0. > is not true. > ./spec/controllers/resources_controller_spec.rb:138: > script/spec:4: > > Finished in 0.753821 seconds > > 25 examples, 1 failure Time to go through all my other specs and check that they're working (or breaking) the same way, to see if I can figure out what I've done wrong. Alex From dchelimsky at gmail.com Sun Feb 24 19:33:39 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 Feb 2008 18:33:39 -0600 Subject: [rspec-users] How to dump contents produced during spec evaluation? In-Reply-To: References: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> Message-ID: <57c63afe0802241633u40722ed5s6a5a3e9de78a9fd4@mail.gmail.com> On Sun, Feb 24, 2008 at 6:29 PM, Alex Satrapa wrote: > On 25/02/2008, at 10:58 , David Chelimsky wrote: > > > On Sun, Feb 24, 2008 at 5:54 PM, Alex Satrapa > > wrote: > > >> In the ResourceController spec, I have the following happening: > >> post( :create, :resource => request_attrs ) > >> response.should render_template('resource/new') > >> response.should have_tag('*', /must have one or more X defined/) > > > >> Is there any way I can dump the contents of the response, in the > >> hope > >> that they might tip me off as to the cause of this error? > > > > puts response.body > > Okay, this is weird. The result seems to indicate that the body of > the response is the literal text, "resource/new": Ah yes - of course. Give this a read and see if it answers your question: http://rspec.info/documentation/rails/writing/controllers.html > > My autotest results show (I've changed the name of the resource to > 'resource'): > > ..........resources/new > > F.............. > > > > 1) > > 'ResourcesController on 'POST /resources/', with an invalid request > > should generate an error message indicating that magic parts are > > missing' FAILED > > Expected at least 1 element matching "*", found 0. > > is not true. > > ./spec/controllers/resources_controller_spec.rb:138: > > script/spec:4: > > > > Finished in 0.753821 seconds > > > > 25 examples, 1 failure > > > Time to go through all my other specs and check that they're working > (or breaking) the same way, to see if I can figure out what I've done > wrong. > > > > Alex > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Sun Feb 24 19:35:02 2008 From: cwdinfo at gmail.com (s.ross) Date: Sun, 24 Feb 2008 16:35:02 -0800 Subject: [rspec-users] How to dump contents produced during spec evaluation? In-Reply-To: References: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> Message-ID: <2825A7F0-374A-4555-B0A7-D5A8CADB837E@gmail.com> On Feb 24, 2008, at 4:29 PM, Alex Satrapa wrote: > Okay, this is weird. The result seems to indicate that the body of > the response is the literal text, "resource/new": > > My autotest results show (I've changed the name of the resource to > 'resource'): >> Try puts response.class puts response.inspect to see whether you have what you think you do. From dchelimsky at gmail.com Sun Feb 24 19:42:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 24 Feb 2008 18:42:56 -0600 Subject: [rspec-users] How to dump contents produced during spec evaluation? In-Reply-To: <2825A7F0-374A-4555-B0A7-D5A8CADB837E@gmail.com> References: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> <2825A7F0-374A-4555-B0A7-D5A8CADB837E@gmail.com> Message-ID: <57c63afe0802241642v6b1499eai6f61bd4b337f315f@mail.gmail.com> On Sun, Feb 24, 2008 at 6:35 PM, s.ross wrote: > On Feb 24, 2008, at 4:29 PM, Alex Satrapa wrote: > > > Okay, this is weird. The result seems to indicate that the body of > > the response is the literal text, "resource/new": > > > > My autotest results show (I've changed the name of the resource to > > 'resource'): > >> > > Try > > puts response.class > puts response.inspect Steve - it's because of isolation - I pointed Alex to the docs. > > to see whether you have what you think you do. > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From grail at goldweb.com.au Sun Feb 24 20:10:22 2008 From: grail at goldweb.com.au (Alex Satrapa) Date: Mon, 25 Feb 2008 12:10:22 +1100 Subject: [rspec-users] How to dump contents produced during spec evaluation? In-Reply-To: <57c63afe0802241642v6b1499eai6f61bd4b337f315f@mail.gmail.com> References: <362AC3D2-8610-47FD-8560-2A9A8715EE52@goldweb.com.au> <57c63afe0802241558g2f17ec82qa17c144d2372cb05@mail.gmail.com> <2825A7F0-374A-4555-B0A7-D5A8CADB837E@gmail.com> <57c63afe0802241642v6b1499eai6f61bd4b337f315f@mail.gmail.com> Message-ID: On 25/02/2008, at 11:42 , David Chelimsky wrote: > Steve - it's because of isolation - I pointed Alex to the docs. Yup, I'm having a low-caffeine day apparently. I'm going to great pains to isolate just the portions of the controller that need to be designed (using mocks and stubs), then slapping a test in there that looks for an output that the mock will never generate. The error message is already specced in the model spec and the view spec, and it's already checked for in the story - do I need more testing for that failure path? Alex From mlangenberg at gmail.com Mon Feb 25 04:30:36 2008 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Mon, 25 Feb 2008 10:30:36 +0100 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? In-Reply-To: <810a540e0802231519v97659dek9eab36b2fa6836ec@mail.gmail.com> References: <810a540e0802231519v97659dek9eab36b2fa6836ec@mail.gmail.com> Message-ID: <27c0ac6d0802250130n24a1c2b6o22d56880f09f3c6d@mail.gmail.com> Question is, would you duplicate the specs for all the classes that include a certain module (through shared behaviour for example), or would you use one set of specs for just the module, and specify that a class should include that module? On Sun, Feb 24, 2008 at 12:19 AM, Pat Maddox wrote: > On Thu, Feb 21, 2008 at 8:09 AM, Chuck Remes > wrote: > > While practicing BDD on my first-ever BDD project, I have come to a > > point where it makes sense to change my original class to an abstract > > class and create one (or more) concrete subclasses that implement a > > specific method. What is the right way to restructure the tests in > > this scenario? Do I leave the existing tests in place and just create > > a new spec file that instantiates and tests the concrete subclass? > > > > I think I can continue to instantiate my "abstract" parent as long as > > I don't go near the behavior that will be defined by the concrete > > subclasses. Is that the right thing to do? > > > > Thanks for any hints. > > > > cr > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > I think that shared example groups might be useful. > > Pat > _______________________________________________ > 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/20080225/0c9a4ac4/attachment.html From win at wincent.com Mon Feb 25 06:09:31 2008 From: win at wincent.com (Wincent Colaiuta) Date: Mon, 25 Feb 2008 12:09:31 +0100 Subject: [rspec-users] Route generation inside mailer specs Message-ID: <8540ADC7-AA51-4AB1-A686-B674B1A83B24@wincent.com> Rails mailers live under "app/models" even though they have some controller-like responsibilities, and I stick the corresponding specs under "spec/models" In one of my mailers I use the kind of dynamic route generation methods that Rails provides, things like foo_bar_path and foo_bar_url. What would I need to do to get access to those methods from within my mailer specs? I basically want to confirm the presence of a url in the generated body, something like: url = foo_bar_url(@foo, @bar) @mail.body.should match(url) Evidently I need to include some module or something, but as it's all dynamically generated I have no idea where to begin looking. Oddly enough, the foo_bar_url _is_ defined within the context of the example (ie. I don't get an "undefined method foo_bar_url in #" exception), but what I _do_ get is: You have a nil object when you didn't expect it! The error occurred while evaluating nil.foo_bar_url So the message is being sent to nil... not what I would have expected. Cheers, Wincent From cremes.devlist at mac.com Mon Feb 25 07:23:24 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Mon, 25 Feb 2008 06:23:24 -0600 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? In-Reply-To: <27c0ac6d0802250130n24a1c2b6o22d56880f09f3c6d@mail.gmail.com> References: <810a540e0802231519v97659dek9eab36b2fa6836ec@mail.gmail.com> <27c0ac6d0802250130n24a1c2b6o22d56880f09f3c6d@mail.gmail.com> Message-ID: Thanks for asking this question. This is exactly what I was going to write, but you beat me to it! (Sorry for the top-post; just following the last responder.) cr On Feb 25, 2008, at 3:30 AM, Matthijs Langenberg wrote: > Question is, would you duplicate the specs for all the classes that > include a certain module (through shared behaviour for example), or > would you use one set of specs for just the module, and specify that > a class should include that module? > > On Sun, Feb 24, 2008 at 12:19 AM, Pat Maddox > wrote: > On Thu, Feb 21, 2008 at 8:09 AM, Chuck Remes > wrote: > > While practicing BDD on my first-ever BDD project, I have come to a > > point where it makes sense to change my original class to an > abstract > > class and create one (or more) concrete subclasses that implement a > > specific method. What is the right way to restructure the tests in > > this scenario? Do I leave the existing tests in place and just > create > > a new spec file that instantiates and tests the concrete subclass? > > > > I think I can continue to instantiate my "abstract" parent as > long as > > I don't go near the behavior that will be defined by the concrete > > subclasses. Is that the right thing to do? > > > > Thanks for any hints. > > > > cr > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > I think that shared example groups might be useful. > > Pat > _______________________________________________ > 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/20080225/74385466/attachment-0001.html From dchelimsky at gmail.com Mon Feb 25 09:30:47 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Feb 2008 08:30:47 -0600 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? In-Reply-To: References: <810a540e0802231519v97659dek9eab36b2fa6836ec@mail.gmail.com> <27c0ac6d0802250130n24a1c2b6o22d56880f09f3c6d@mail.gmail.com> Message-ID: <57c63afe0802250630i38c88d8eh36d4cb17f2364f3c@mail.gmail.com> On Mon, Feb 25, 2008 at 6:23 AM, Chuck Remes wrote: > Thanks for asking this question. This is exactly what I was going to write, > but you beat me to it! > > (Sorry for the top-post; just following the last responder.) > > cr > > > > On Feb 25, 2008, at 3:30 AM, Matthijs Langenberg wrote: > Question is, would you duplicate the specs for all the classes that include > a certain module (through shared behaviour for example), or would you use > one set of specs for just the module, and specify that a class should > include that module? Matthijs - I'd throw the same question back to you. Have you tried both approaches? How have they worked out for you? I won't wait for your answer :). But I am curious about other people's experiences with this. I can tell you this from my own experience - I tend to use shared groups for this for a couple of reasons. One, I like to see the specs for each object. Seeing this .... Thing - should include the Foo module in the spec output doesn't really help me understand what Thing does. Keep in mind that including a module does not guarantee that the methods in that module are used. They can be redefined. They can also behave differently depending on the state of the including object. For these reasons, I generally don't really like to specify module inclusion. I try to approach this from the perspective of "how do I want instances of this type to behave?" When I find duplication in behaviour across types, I may extract a shared example group. The discipline challenge really comes in when I already have a shared group and I'm adding a new type and my inner designer is quite certain that it should include the same module. I can tell you that I've gone at this from two directions - either spec'ing the new type cold or just including the shared group in the spec for the type and including the module. Neither route has been perfect every time :) Hope that helps ... a little. Cheers, David > > On Sun, Feb 24, 2008 at 12:19 AM, Pat Maddox wrote: > > > > > > > > On Thu, Feb 21, 2008 at 8:09 AM, Chuck Remes > wrote: > > > While practicing BDD on my first-ever BDD project, I have come to a > > > point where it makes sense to change my original class to an abstract > > > class and create one (or more) concrete subclasses that implement a > > > specific method. What is the right way to restructure the tests in > > > this scenario? Do I leave the existing tests in place and just create > > > a new spec file that instantiates and tests the concrete subclass? > > > > > > I think I can continue to instantiate my "abstract" parent as long as > > > I don't go near the behavior that will be defined by the concrete > > > subclasses. Is that the right thing to do? > > > > > > Thanks for any hints. > > > > > > cr > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > I think that shared example groups might be useful. > > > > Pat > > > > > > > > _______________________________________________ > > 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 rupert at rupespad.com Mon Feb 25 10:01:55 2008 From: rupert at rupespad.com (Rupert Voelcker) Date: Mon, 25 Feb 2008 15:01:55 +0000 Subject: [rspec-users] Problems running pre-commit Message-ID: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> Have been having some probs getting the pre-commit to run so help would be appreciated (then I can add some specs to my patch) - thanks for the suggestion to post here Dave :) I'm on OS X and have checked out the source from svn://rubyforge.org/var/svn/rspec/trunk (rev 3317) rake check_for_gem_dependencies (nothing to see here) rake install_dependencies (long wait, much network activity, various rails versions appear in example_rails_app) rename database.sqlite3.yml to database.yml in example_rails_app/config rake pre_commit --trace Some tests fail (if this helps) -------------------------------------------------------------- 1) 'ExampleGroup with test/unit/interop with failing examples should return an exit code of 256' FAILED expected: 256, got: # (using ==) Diff: @@ -1,2 +1,2 @@ -256 +# ./spec/spec/interop/test/unit/spec_spec.rb:30: 2) 'ExampleGroup with test/unit/interop with example that raises an error should return an exit code of 256' FAILED expected: 256, got: # (using ==) Diff: @@ -1,2 +1,2 @@ -256 +# ./spec/spec/interop/test/unit/spec_spec.rb:42: 3) 'Test::Unit::TestCase with failing test case should return an exit code of 256' FAILED expected: 256, got: # (using ==) Diff: @@ -1,2 +1,2 @@ -256 +# ./spec/spec/interop/test/unit/testcase_spec.rb:30: 4) 'Test::Unit::TestCase with test case that raises an error should return an exit code of 256' FAILED expected: 256, got: # (using ==) Diff: @@ -1,2 +1,2 @@ -256 +# ./spec/spec/interop/test/unit/testcase_spec.rb:42: Finished in 23.137056 seconds 1305 examples, 4 failures, 8 pending -------------------------------------------------------------- and the pre-commit fails with the trace below Hopefully it's just something silly I've not done or done wrong, but I can't think what.... Cheers Rupert -------------------------------------------------------------- ry_spec.rb" "spec/spec/story/world_spec.rb" "spec/spec/translator_spec.rb" --format html:../doc/output/report.html --backtrace failed ./lib/spec/rake/spectask.rb:184:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1003:in `verbose' ./lib/spec/rake/spectask.rb:153:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/pre_commit.rb:9:in `rake_invoke' /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/core.rb:10:in `website' /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/core.rb:4:in `pre_commit' /Users/rupert/stuff/downloads/rspec_new/rspec/rakefile:162 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 rake aborted! RSpec Core pre_commit failed /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:64:in `pre_commit_core' /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:61:in `chdir' /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:61:in `pre_commit_core' /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:6:in `pre_commit' /Users/rupert/stuff/downloads/rspec_new/rakefile:9 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 From dchelimsky at gmail.com Mon Feb 25 10:14:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Feb 2008 09:14:32 -0600 Subject: [rspec-users] Problems running pre-commit In-Reply-To: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> References: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> Message-ID: <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> On Mon, Feb 25, 2008 at 9:01 AM, Rupert Voelcker wrote: > Have been having some probs getting the pre-commit to run so help > would be appreciated (then I can add some specs to my patch) - thanks > for the suggestion to post here Dave :) > > I'm on OS X and have checked out the source from > svn://rubyforge.org/var/svn/rspec/trunk (rev 3317) > > rake check_for_gem_dependencies (nothing to see here) > rake install_dependencies (long wait, much network activity, various > rails versions appear in example_rails_app) > > rename database.sqlite3.yml to database.yml in example_rails_app/config > > rake pre_commit --trace There are a couple of steps missing. Did you read the README (http://rspec.info/rdoc/files/README.html)? Also - I see you're using sqlite3. I can't run mine with sqlite3 right now. It's probably been this way for a while, because it looks like the error is the "You have 5 pending migrations:" error, which has been around for some time. Try following the directions in the README to the letter (including using mysql instead of sqlite3) and see if that works. > > Some tests fail (if this helps) > > -------------------------------------------------------------- > > 1) > 'ExampleGroup with test/unit/interop with failing examples should > return an exit code of 256' FAILED > expected: 256, > got: # (using ==) > Diff: > @@ -1,2 +1,2 @@ > -256 > +# > > ./spec/spec/interop/test/unit/spec_spec.rb:30: > > 2) > 'ExampleGroup with test/unit/interop with example that raises an error > should return an exit code of 256' FAILED > expected: 256, > got: # (using ==) > Diff: > @@ -1,2 +1,2 @@ > -256 > +# > > ./spec/spec/interop/test/unit/spec_spec.rb:42: > > 3) > 'Test::Unit::TestCase with failing test case should return an exit > code of 256' FAILED > expected: 256, > got: # (using ==) > Diff: > @@ -1,2 +1,2 @@ > -256 > +# > > ./spec/spec/interop/test/unit/testcase_spec.rb:30: > > 4) > 'Test::Unit::TestCase with test case that raises an error should > return an exit code of 256' FAILED > expected: 256, > got: # (using ==) > Diff: > @@ -1,2 +1,2 @@ > -256 > +# > > ./spec/spec/interop/test/unit/testcase_spec.rb:42: > > Finished in 23.137056 seconds > > 1305 examples, 4 failures, 8 pending > > -------------------------------------------------------------- > > and the pre-commit fails with the trace below > > Hopefully it's just something silly I've not done or done wrong, but I > can't think what.... > > Cheers > > Rupert > > -------------------------------------------------------------- > > ry_spec.rb" "spec/spec/story/world_spec.rb" > "spec/spec/translator_spec.rb" --format html:../doc/output/report.html > --backtrace failed > ./lib/spec/rake/spectask.rb:184:in `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1003:in `verbose' > ./lib/spec/rake/spectask.rb:153:in `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/pre_commit.rb:9:in > `rake_invoke' > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/core.rb:10:in > `website' > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/core.rb:4:in > `pre_commit' > /Users/rupert/stuff/downloads/rspec_new/rspec/rakefile:162 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > rake aborted! > RSpec Core pre_commit failed > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:64:in > `pre_commit_core' > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:61:in > `chdir' > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:61:in > `pre_commit_core' > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:6:in > `pre_commit' > /Users/rupert/stuff/downloads/rspec_new/rakefile:9 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Feb 25 10:31:38 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Feb 2008 09:31:38 -0600 Subject: [rspec-users] Problems running pre-commit In-Reply-To: <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> References: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> Message-ID: <57c63afe0802250731o1cd2282dne3388328552174e3@mail.gmail.com> On Mon, Feb 25, 2008 at 9:14 AM, David Chelimsky wrote: > On Mon, Feb 25, 2008 at 9:01 AM, Rupert Voelcker wrote: > > Have been having some probs getting the pre-commit to run so help > > would be appreciated (then I can add some specs to my patch) - thanks > > for the suggestion to post here Dave :) > > > > I'm on OS X and have checked out the source from > > svn://rubyforge.org/var/svn/rspec/trunk (rev 3317) > > > > rake check_for_gem_dependencies (nothing to see here) > > rake install_dependencies (long wait, much network activity, various > > rails versions appear in example_rails_app) > > > > rename database.sqlite3.yml to database.yml in example_rails_app/config > > > > rake pre_commit --trace > > There are a couple of steps missing. Did you read the README > (http://rspec.info/rdoc/files/README.html)? > > Also - I see you're using sqlite3. I can't run mine with sqlite3 right > now. It's probably been this way for a while, because it looks like > the error is the "You have 5 pending migrations:" error, which has > been around for some time. FYI: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/306 > > Try following the directions in the README to the letter (including > using mysql instead of sqlite3) and see if that works. > > > > > > > Some tests fail (if this helps) > > > > -------------------------------------------------------------- > > > > 1) > > 'ExampleGroup with test/unit/interop with failing examples should > > return an exit code of 256' FAILED > > expected: 256, > > got: # (using ==) > > Diff: > > @@ -1,2 +1,2 @@ > > -256 > > +# > > > > ./spec/spec/interop/test/unit/spec_spec.rb:30: > > > > 2) > > 'ExampleGroup with test/unit/interop with example that raises an error > > should return an exit code of 256' FAILED > > expected: 256, > > got: # (using ==) > > Diff: > > @@ -1,2 +1,2 @@ > > -256 > > +# > > > > ./spec/spec/interop/test/unit/spec_spec.rb:42: > > > > 3) > > 'Test::Unit::TestCase with failing test case should return an exit > > code of 256' FAILED > > expected: 256, > > got: # (using ==) > > Diff: > > @@ -1,2 +1,2 @@ > > -256 > > +# > > > > ./spec/spec/interop/test/unit/testcase_spec.rb:30: > > > > 4) > > 'Test::Unit::TestCase with test case that raises an error should > > return an exit code of 256' FAILED > > expected: 256, > > got: # (using ==) > > Diff: > > @@ -1,2 +1,2 @@ > > -256 > > +# > > > > ./spec/spec/interop/test/unit/testcase_spec.rb:42: > > > > Finished in 23.137056 seconds > > > > 1305 examples, 4 failures, 8 pending > > > > -------------------------------------------------------------- > > > > and the pre-commit fails with the trace below > > > > Hopefully it's just something silly I've not done or done wrong, but I > > can't think what.... > > > > Cheers > > > > Rupert > > > > -------------------------------------------------------------- > > > > ry_spec.rb" "spec/spec/story/world_spec.rb" > > "spec/spec/translator_spec.rb" --format html:../doc/output/report.html > > --backtrace failed > > ./lib/spec/rake/spectask.rb:184:in `define' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1003:in `verbose' > > ./lib/spec/rake/spectask.rb:153:in `define' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > > `invoke_with_call_chain' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > > `invoke_with_call_chain' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/pre_commit.rb:9:in > > `rake_invoke' > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/core.rb:10:in > > `website' > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/core.rb:4:in > > `pre_commit' > > /Users/rupert/stuff/downloads/rspec_new/rspec/rakefile:162 > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > > `invoke_with_call_chain' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > > `invoke_with_call_chain' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > > `standard_exception_handling' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > > `standard_exception_handling' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 > > /usr/local/bin/rake:19:in `load' > > /usr/local/bin/rake:19 > > rake aborted! > > RSpec Core pre_commit failed > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:64:in > > `pre_commit_core' > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:61:in > > `chdir' > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:61:in > > `pre_commit_core' > > /Users/rupert/stuff/downloads/rspec_new/rspec/pre_commit/lib/pre_commit/rspec.rb:6:in > > `pre_commit' > > /Users/rupert/stuff/downloads/rspec_new/rakefile:9 > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > > `invoke_with_call_chain' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > > `invoke_with_call_chain' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > > `standard_exception_handling' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > > `standard_exception_handling' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 > > /usr/local/bin/rake:19:in `load' > > /usr/local/bin/rake:19 > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From rupert at rupespad.com Mon Feb 25 11:24:52 2008 From: rupert at rupespad.com (Rupert Voelcker) Date: Mon, 25 Feb 2008 16:24:52 +0000 Subject: [rspec-users] Problems running pre-commit In-Reply-To: <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> References: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> Message-ID: <52138110802250824w64e106fbxb42c409d8430aa66@mail.gmail.com> On 25/02/2008, David Chelimsky wrote: > On Mon, Feb 25, 2008 at 9:01 AM, Rupert Voelcker wrote: > > Have been having some probs getting the pre-commit to run so help > > would be appreciated (then I can add some specs to my patch) - thanks > > for the suggestion to post here Dave :) > > > > I'm on OS X and have checked out the source from > > svn://rubyforge.org/var/svn/rspec/trunk (rev 3317) > > > > rake check_for_gem_dependencies (nothing to see here) > > rake install_dependencies (long wait, much network activity, various > > rails versions appear in example_rails_app) > > > > rename database.sqlite3.yml to database.yml in example_rails_app/config > > > > rake pre_commit --trace > > > There are a couple of steps missing. Did you read the README > (http://rspec.info/rdoc/files/README.html)? > > Also - I see you're using sqlite3. I can't run mine with sqlite3 right > now. It's probably been this way for a while, because it looks like > the error is the "You have 5 pending migrations:" error, which has > been around for some time. > > Try following the directions in the README to the letter (including > using mysql instead of sqlite3) and see if that works. Ah-ha - missed the readme, but unfortunately it hasn't helped. I've followed what it says and I'm still getting the same 4 failures and the same stack trace at the end :( I also cannot run the rails pre-commit and am getting the following when I run rake -f Multirails.rake pre_commit --trace from inside the example_app: running against rails 2.0.2 ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == 5 CreatePurchases: migrating =============================================== -- create_table(:purchases) -> 0.0274s == 5 CreatePurchases: migrated (0.0275s) ====================================== ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump (in /Users/rupert/stuff/downloads/rspec/example_rails_app) running against rails 2.0.2 ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:clone ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute spec running against rails 2.0.2 ................................................................................................ Finished in 0.649869 seconds 96 examples, 0 failures rake aborted! Command ruby -I"/Users/rupert/stuff/downloads/rspec/rspec/lib" "/Users/rupert/stuff/downloads/rspec/rspec/bin/spec" "vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/autotest/rails_rspec_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/configuration_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/model_spec_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/shared_behaviour_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/matchers/errors_on_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb" "vendor/plugins/rspec_on_rails/spec/rails/spec_spec.rb" --options "/Users/rupert/stuff/downloads/rspec/example_rails_app/spec/spec.opts" failed /Users/rupert/stuff/downloads/rspec/rspec/lib/spec/rake/spectask.rb:184:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1003:in `verbose' /Users/rupert/stuff/downloads/rspec/rspec/lib/spec/rake/spectask.rb:153:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 (in /Users/rupert/stuff/downloads/rspec/example_rails_app) running against rails 2.0.2 ** Invoke spec:plugins:rspec_on_rails (first_time) ** Execute spec:plugins:rspec_on_rails running against rails 2.0.2 .FF..............................................................................................................................................................P..........................................................................................P................ .........P................ ..................................... Pending: should have_tag should report the correct line number for a nested failed test/unit assertion (Doesn't work at the moment. Do we want to support this?) A controller spec a spec in a context without controller_name set should fail with a useful warning (need a new way to deal with examples that should_raise) A controller spec a spec in a context without controller_name set should fail with a useful warning (need a new way to deal with examples that should_raise) 1) Timeout::Error in 'script/spec_server file with TextMate bundle runs a spec' execution expired 2) Timeout::Error in 'script/spec_server file without TextMate bundle runs a spec' execution expired Finished in 24.2063 seconds 332 examples, 2 failures, 3 pending rake aborted! ERROR while running rake: rake spec:plugins:rspec_on_rails --trace /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/pre_commit.rb:19:in `rake_sh' /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:44:in `rspec_pre_commit' /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:10:in `pre_commit' /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:6:in `each' /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:6:in `pre_commit' /Users/rupert/stuff/downloads/rspec/example_rails_app/Multirails.rake:7 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 Any ideas? - thanks for trying to get this sorted btw. Rupert From dchelimsky at gmail.com Mon Feb 25 11:51:11 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Feb 2008 10:51:11 -0600 Subject: [rspec-users] Problems running pre-commit In-Reply-To: <52138110802250824w64e106fbxb42c409d8430aa66@mail.gmail.com> References: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> <52138110802250824w64e106fbxb42c409d8430aa66@mail.gmail.com> Message-ID: <57c63afe0802250851m117ab6d0wc2e5cda714031781@mail.gmail.com> On Mon, Feb 25, 2008 at 10:24 AM, Rupert Voelcker wrote: > On 25/02/2008, David Chelimsky wrote: > > On Mon, Feb 25, 2008 at 9:01 AM, Rupert Voelcker wrote: > > > Have been having some probs getting the pre-commit to run so help > > > would be appreciated (then I can add some specs to my patch) - thanks > > > for the suggestion to post here Dave :) > > > > > > I'm on OS X and have checked out the source from > > > svn://rubyforge.org/var/svn/rspec/trunk (rev 3317) > > > > > > rake check_for_gem_dependencies (nothing to see here) > > > rake install_dependencies (long wait, much network activity, various > > > rails versions appear in example_rails_app) > > > > > > rename database.sqlite3.yml to database.yml in example_rails_app/config > > > > > > rake pre_commit --trace > > > > > > There are a couple of steps missing. Did you read the README > > (http://rspec.info/rdoc/files/README.html)? > > > > Also - I see you're using sqlite3. I can't run mine with sqlite3 right > > now. It's probably been this way for a while, because it looks like > > the error is the "You have 5 pending migrations:" error, which has > > been around for some time. > > > > Try following the directions in the README to the letter (including > > using mysql instead of sqlite3) and see if that works. > > Ah-ha - missed the readme, but unfortunately it hasn't helped. I've > followed what it says and I'm still getting the same 4 failures and > the same stack trace at the end :( > > I also cannot run the rails pre-commit and am getting the following > when I run rake -f Multirails.rake pre_commit --trace from inside the > example_app: > > > running against rails 2.0.2 > ** Invoke db:migrate (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:migrate > == 5 CreatePurchases: migrating =============================================== > -- create_table(:purchases) > -> 0.0274s > == 5 CreatePurchases: migrated (0.0275s) ====================================== > > ** Invoke db:schema:dump (first_time) > ** Invoke environment > ** Execute db:schema:dump > (in /Users/rupert/stuff/downloads/rspec/example_rails_app) > running against rails 2.0.2 > ** Invoke spec (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment > ** Execute db:abort_if_pending_migrations > ** Execute db:test:prepare > ** Invoke db:test:clone (first_time) > ** Invoke db:schema:dump (first_time) > ** Invoke environment > ** Execute db:schema:dump > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:clone > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > ** Execute spec > running against rails 2.0.2 > ................................................................................................ > > Finished in 0.649869 seconds > > 96 examples, 0 failures > rake aborted! > Command ruby -I"/Users/rupert/stuff/downloads/rspec/rspec/lib" > "/Users/rupert/stuff/downloads/rspec/rspec/bin/spec" > "vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/autotest/rails_rspec_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/configuration_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/model_spec_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/shared_behaviour_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/matchers/errors_on_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb" > "vendor/plugins/rspec_on_rails/spec/rails/spec_spec.rb" --options > "/Users/rupert/stuff/downloads/rspec/example_rails_app/spec/spec.opts" > failed > /Users/rupert/stuff/downloads/rspec/rspec/lib/spec/rake/spectask.rb:184:in > > `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1003:in `verbose' > /Users/rupert/stuff/downloads/rspec/rspec/lib/spec/rake/spectask.rb:153:in > > `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > (in /Users/rupert/stuff/downloads/rspec/example_rails_app) > running against rails 2.0.2 > ** Invoke spec:plugins:rspec_on_rails (first_time) > ** Execute spec:plugins:rspec_on_rails > running against rails 2.0.2 > .FF..............................................................................................................................................................P..........................................................................................P................ > .........P................ > ..................................... > > Pending: > should have_tag should report the correct line number for a nested > failed test/unit assertion (Doesn't work at the moment. Do we want to > support this?) > A controller spec a spec in a context without controller_name set > should fail with a useful warning (need a new way to deal with > examples that should_raise) > A controller spec a spec in a context without controller_name set > should fail with a useful warning (need a new way to deal with > examples that should_raise) > > 1) > Timeout::Error in 'script/spec_server file with TextMate bundle runs a spec' > execution expired > > > 2) > Timeout::Error in 'script/spec_server file without TextMate bundle runs a spec' > execution expired > > > Finished in 24.2063 seconds > > 332 examples, 2 failures, 3 pending > rake aborted! > ERROR while running rake: rake spec:plugins:rspec_on_rails --trace > /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/pre_commit.rb:19:in > `rake_sh' > /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:44:in > `rspec_pre_commit' > /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:10:in > `pre_commit' > /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:6:in > `each' > /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:6:in > `pre_commit' > /Users/rupert/stuff/downloads/rspec/example_rails_app/Multirails.rake:7 > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > > Any ideas? - thanks for trying to get this sorted btw. Yes - I sometimes get the spec_server timeout as well - but I usually don't. Try running just against just one environment: rake rspec:pre_commit without the -f option. > > Rupert > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rupert at rupespad.com Mon Feb 25 12:16:52 2008 From: rupert at rupespad.com (Rupert Voelcker) Date: Mon, 25 Feb 2008 17:16:52 +0000 Subject: [rspec-users] Problems running pre-commit In-Reply-To: <57c63afe0802250851m117ab6d0wc2e5cda714031781@mail.gmail.com> References: <52138110802250701j50b40cb3ic8bce2664d71058d@mail.gmail.com> <57c63afe0802250714s693a141ai944750630051824b@mail.gmail.com> <52138110802250824w64e106fbxb42c409d8430aa66@mail.gmail.com> <57c63afe0802250851m117ab6d0wc2e5cda714031781@mail.gmail.com> Message-ID: <52138110802250916n16836eacye9eed186988f4ddd@mail.gmail.com> > Yes - I sometimes get the spec_server timeout as well - but I usually don't. > > Try running just against just one environment: > > rake rspec:pre_commit > > without the -f option. tried that (it runs against edge) and it still won't wor. I'm still getting the timeouts: Pending: should have_tag should report the correct line number for a nested failed test/unit assertion (Doesn't work at the moment. Do we want to support this?) A controller spec a spec in a context without controller_name set should fail with a useful warning (need a new way to deal with examples that should_raise) A controller spec a spec in a context without controller_name set should fail with a useful warning (need a new way to deal with examples that should_raise) 1) Timeout::Error in 'script/spec_server file with TextMate bundle runs a spec' execution expired 2) Timeout::Error in 'script/spec_server file without TextMate bundle runs a spec' execution expired Finished in 24.298229 seconds 332 examples, 2 failures, 3 pending rake aborted! ERROR while running rake: rake spec:plugins:rspec_on_rails --trace /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/pre_commit.rb:19:in `rake_sh' /Users/rupert/stuff/downloads/rspec/rspec/pre_commit/lib/pre_commit/rspec_on_rails.rb:44:in `rspec_pre_commit' /Users/rupert/stuff/downloads/rspec/example_rails_app/lib/tasks/bootstrap_rspec.rake:11 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 Is there something I can comment out to remove the offending bits from the run? Cheers Rupert From oli.azevedo.barnes at gmail.com Mon Feb 25 18:23:08 2008 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Mon, 25 Feb 2008 20:23:08 -0300 Subject: [rspec-users] [newbie] rspec textmate bundle problem Message-ID: <6466d9040802251523g1955182ct848f67e98c867e71@mail.gmail.com> Hello, I've just installed the rspec textmate bundle from svn, and I'm getting the following error when I try to run a single example: /Users/oliver/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/mate.rb:2:in `require': No such file to load -- rubygems (LoadError) from /Users/oliver/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/mate.rb:2 from /tmp/temp_textmate.xVeAZb:3:in `require' from /tmp/temp_textmate.xVeAZb:3 I'm using a custom locomotive bundle with the rails 2.0.2 and rspec 1.1.3 gems installed, together with the respective rspec_on_rails plugin. I've been searching for a solution for a couple of hours, and i've tried setting both TM_RUBY and TM_RSPEC_HOME as suggested in other posts, but that didn't solve it. At one point the error changed, complaining about a missing rails 2.0.2 gem though it's installed and declared in the environment config, but I can't remember now what prompted it. appreciate any pointers with this, please bear with me as I'm new to the list and still learning my way around testing and rspec... ;) - Oliver From oli.azevedo.barnes at gmail.com Mon Feb 25 18:41:42 2008 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Mon, 25 Feb 2008 20:41:42 -0300 Subject: [rspec-users] [newbie] rspec textmate bundle problem In-Reply-To: <6466d9040802251523g1955182ct848f67e98c867e71@mail.gmail.com> References: <6466d9040802251523g1955182ct848f67e98c867e71@mail.gmail.com> Message-ID: <6466d9040802251541q11a511r6acf1ee6ccfd5279@mail.gmail.com> ..2 seconds after posting I found this thread from the peepcode users group http://groups.google.com/group/peepcode/browse_thread/thread/089989c61181d39c and so I set the same variables in my .bashrc, and created a new project, which got the bundle to work when opening the project from the command line. it still doesn't work from locomotive though. 2008/2/25, Oliver Barnes : > Hello, > > I've just installed the rspec textmate bundle from svn, and I'm > getting the following error when I try to run a single example: > > /Users/oliver/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/mate.rb:2:in > `require': No such file to load -- rubygems (LoadError) from > /Users/oliver/Library/Application > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/mate.rb:2 > from /tmp/temp_textmate.xVeAZb:3:in `require' from > /tmp/temp_textmate.xVeAZb:3 > > I'm using a custom locomotive bundle with the rails 2.0.2 and rspec > 1.1.3 gems installed, together with the respective rspec_on_rails > plugin. I've been searching for a solution for a couple of hours, and > i've tried setting both TM_RUBY and TM_RSPEC_HOME as suggested in > other posts, but that didn't solve it. At one point the error changed, > complaining about a missing rails 2.0.2 gem though it's installed and > declared in the environment config, but I can't remember now what > prompted it. > > appreciate any pointers with this, please bear with me as I'm new to > the list and still learning my way around testing and rspec... ;) > > > - Oliver > From gilesb at gmail.com Mon Feb 25 21:18:28 2008 From: gilesb at gmail.com (Giles Bowkett) Date: Mon, 25 Feb 2008 18:18:28 -0800 Subject: [rspec-users] bad specs better than none? Message-ID: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> Hi - I've got a bunch of people using specs at a company. Everybody is writing specs, but people are not really practicing BDD. As in, the specs are there, but it doesn't go, write spec, write code, repeat. I recently came across 8 failing specs checked into svn; I think the plan was, I'll write the design as specs, and then implement the entire design to match. Obviously that's not really the way it should be. I also had to go into specs on a project I'm not working on, and found an unholy hive of database-accessing specs. It's disheartening. Basically, it's cargo cult development practices - using the "best practice" without actually understanding it. Should I tell these people to throw away their specs? Should I train them in the BDD "spec first" cycle? What do you do when you have specs that are not really that useful? This is mostly Rails stuff; there's a lot of controller specs that duplicate model specs instead of stubbing out the behavior. It's driving me nuts but I have no idea what the solution is yet. -- 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 Mon Feb 25 21:39:19 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Mon, 25 Feb 2008 21:39:19 -0500 Subject: [rspec-users] bad specs better than none? In-Reply-To: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> Message-ID: A better question would be do you have that authority to retrain them?That sounds awful to say the least. It could be worse, you could be the guy that is the test driven development library that manually goes in and see what breaks and what doesn't. When I refer to you "could be the guy", I'm actaully stating I am that guy. I wish my company understood the concept or the need for BDD or at least TDD. I'm trapped and its so painful. On Mon, Feb 25, 2008 at 9:18 PM, Giles Bowkett wrote: > Hi - I've got a bunch of people using specs at a company. Everybody is > writing specs, but people are not really practicing BDD. As in, the > specs are there, but it doesn't go, write spec, write code, repeat. I > recently came across 8 failing specs checked into svn; I think the > plan was, I'll write the design as specs, and then implement the > entire design to match. Obviously that's not really the way it should > be. > > I also had to go into specs on a project I'm not working on, and found > an unholy hive of database-accessing specs. It's disheartening. > Basically, it's cargo cult development practices - using the "best > practice" without actually understanding it. > > Should I tell these people to throw away their specs? Should I train > them in the BDD "spec first" cycle? What do you do when you have specs > that are not really that useful? This is mostly Rails stuff; there's a > lot of controller specs that duplicate model specs instead of stubbing > out the behavior. It's driving me nuts but I have no idea what the > solution is yet. > > -- > 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/20080225/b9f7b1a7/attachment.html From dchelimsky at gmail.com Mon Feb 25 23:13:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Feb 2008 22:13:56 -0600 Subject: [rspec-users] bad specs better than none? In-Reply-To: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> Message-ID: <57c63afe0802252013y112de342hcb8c2097052e9229@mail.gmail.com> On Mon, Feb 25, 2008 at 8:18 PM, Giles Bowkett wrote: > Hi - I've got a bunch of people using specs at a company. Everybody is > writing specs, but people are not really practicing BDD. As in, the > specs are there, but it doesn't go, write spec, write code, repeat. I > recently came across 8 failing specs checked into svn; I think the > plan was, I'll write the design as specs, and then implement the > entire design to match. Obviously that's not really the way it should > be. This is a fairly common misconception about what BDD is all about. You can move in the right direction by making those failing specs pending so the suite still passes. Then remove pending from one example, watch it fail, get it to pass, then the next pending example, etc. > I also had to go into specs on a project I'm not working on, and found > an unholy hive of database-accessing specs. It's disheartening. > Basically, it's cargo cult development practices - using the "best > practice" without actually understanding it. This is a really tough problem. The whole motivation for BDD was "people don't get TDD, so let's come up with some new ways to frame it so people get it." Now people don't get the new frame. In that respect we've made things twice as bad. > Should I tell these people to throw away their specs? Should I train > them in the BDD "spec first" cycle? What do you do when you have specs > that are not really that useful? This is mostly Rails stuff; there's a > lot of controller specs that duplicate model specs instead of stubbing > out the behavior. It's driving me nuts but I have no idea what the > solution is yet. If you're pair programming with these folks, then I'd recommend simply pushing the pairing sessions in the right direction. Focus on the task at hand, do it with good discipline, and change anything that's not right as you go. If you're working from afar, then I'm not sure what to recommend. There are some people who are going to respond favorably to your advise and others who will think you're nuts. The subject of this thread is "bad specs better than none?" If "bad" means "wrong" and the examples don't test what they say they're testing, then I'd point that out and ditch them - but probably one at a time. If "bad" means that there is poor balance, too much focus on structure, duplication, etc, then as long as they are really testing things, I'd leave them and gradually refactor them to a better place. Or maybe I'd just crack open a beer, grab my guitar and call it a day :) Cheers, 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 aslak.hellesoy at gmail.com Mon Feb 25 23:37:28 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 26 Feb 2008 05:37:28 +0100 Subject: [rspec-users] [newbie] rspec textmate bundle problem In-Reply-To: <6466d9040802251541q11a511r6acf1ee6ccfd5279@mail.gmail.com> References: <6466d9040802251523g1955182ct848f67e98c867e71@mail.gmail.com> <6466d9040802251541q11a511r6acf1ee6ccfd5279@mail.gmail.com> Message-ID: <8d961d900802252037g285e9adbl75f7ca280e2dd215@mail.gmail.com> There is also this: http://rspec.info/documentation/tools/extensions/editors/textmate.html Aslak On Tue, Feb 26, 2008 at 12:41 AM, Oliver Barnes wrote: > ..2 seconds after posting I found this thread from the peepcode users group > > http://groups.google.com/group/peepcode/browse_thread/thread/089989c61181d39c > > and so I set the same variables in my .bashrc, and created a new > project, which got the bundle to work when opening the project from > the command line. it still doesn't work from locomotive though. > > 2008/2/25, Oliver Barnes : > > > > Hello, > > > > I've just installed the rspec textmate bundle from svn, and I'm > > getting the following error when I try to run a single example: > > > > /Users/oliver/Library/Application > > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/mate.rb:2:in > > `require': No such file to load -- rubygems (LoadError) from > > /Users/oliver/Library/Application > > Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/mate.rb:2 > > from /tmp/temp_textmate.xVeAZb:3:in `require' from > > /tmp/temp_textmate.xVeAZb:3 > > > > I'm using a custom locomotive bundle with the rails 2.0.2 and rspec > > 1.1.3 gems installed, together with the respective rspec_on_rails > > plugin. I've been searching for a solution for a couple of hours, and > > i've tried setting both TM_RUBY and TM_RSPEC_HOME as suggested in > > other posts, but that didn't solve it. At one point the error changed, > > complaining about a missing rails 2.0.2 gem though it's installed and > > declared in the environment config, but I can't remember now what > > prompted it. > > > > appreciate any pointers with this, please bear with me as I'm new to > > the list and still learning my way around testing and rspec... ;) > > > > > > - Oliver > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From edvard at majakari.net Tue Feb 26 00:35:36 2008 From: edvard at majakari.net (Edvard Majakari) Date: Tue, 26 Feb 2008 07:35:36 +0200 Subject: [rspec-users] Autotest with TDD "test-first" problem In-Reply-To: References: <57c63afe0802230610v1e650434l8c3220a2a697fecb@mail.gmail.com> Message-ID: On Sat, Feb 23, 2008 at 10:39 PM, Joe Van Dyk wrote: > For example, one test runner could repeatedly run (or once a minute, > or whatever) the entire test suite. And one test runner could run the > related tests for the file you change. > > Perhaps two autotest instances, running off different test databases? That's exactly my approach. I have 3 separate tests running, of which "rake test:recent" is run whenever the files change, and the re-check interval is just one second. However, "rake test:units" and "rake test:functionals" -- sorry, my tests are still in Test::Unit :( -- check the files only once a minute now. I use rstakeout.rb for the task. I added simple file locking support to prevent multiple instances running on the same time when requested (by default, it allows concurrency). See this pastie: http://pastie.caboo.se/pastes/152014 and use is as follows: # save this as mystakeout.sh or similar ruby rstakeout.rb -t 1 --sync "rake test:recent" "spec/**/*.rb" "app/**/*.rb" ruby rstakeout.rb -t 60 --sync "rake test:all_but_integration" "spec/**/*.rb" "app/**/*.rb" ..or something. -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From aslak.hellesoy at gmail.com Tue Feb 26 00:59:14 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 26 Feb 2008 06:59:14 +0100 Subject: [rspec-users] bad specs better than none? In-Reply-To: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> Message-ID: <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> On Tue, Feb 26, 2008 at 3:18 AM, Giles Bowkett wrote: > Hi - I've got a bunch of people using specs at a company. Everybody is > writing specs, but people are not really practicing BDD. As in, the > specs are there, but it doesn't go, write spec, write code, repeat. I > recently came across 8 failing specs checked into svn; I think the > plan was, I'll write the design as specs, and then implement the > entire design to match. Obviously that's not really the way it should > be. > Here is how I would deal with this (and have dealt with it in the past) 1) In your standup meeting (if you have one) say you have an obstacle, and that it's failing specs in svn. Don't explain why it's an obstacle, just say you'd like to discuss it with the other devs after the standup. 2) Explain that you can't check in more code because you can't know whether your new code is any good. When something fails you can't know for sure whether it's due to "old" or new failing specs. 3) Try to get everyone to understand the benefits of a green SCM and the dangers of a red one. This can take days and weeks. Only then can you address the failing specs. 4) Set up Continuous Integration 5) Invest in some lamps and hook them up to your CI > I also had to go into specs on a project I'm not working on, and found > an unholy hive of database-accessing specs. It's disheartening. > Basically, it's cargo cult development practices - using the "best > practice" without actually understanding it. > What "best practice" are you referring to? > Should I tell these people to throw away their specs? Should I train > them in the BDD "spec first" cycle? What do you do when you have specs > that are not really that useful? This is mostly Rails stuff; there's a > lot of controller specs that duplicate model specs instead of stubbing > out the behavior. It's driving me nuts but I have no idea what the > solution is yet. > I don't know if your developers chose BDD/RSpec themselves (and got it wrong) or if they were "assigned". In any case, it sounds like there has been a lack of attention to collective code ownership and staffing with appropriate skills. Patience and pair programming would be my best suggestion. Have someone who gets BDD (you?) pair with the whole team till they get it too. And till they also get that they should fix bad code when they see it. Aslak > -- > 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 pergesu at gmail.com Tue Feb 26 01:34:34 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 25 Feb 2008 22:34:34 -0800 Subject: [rspec-users] bad specs better than none? In-Reply-To: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> Message-ID: <810a540e0802252234m50e42cdege71d5430ee32d74f@mail.gmail.com> Are you on site or is this remote work? What role are you supposed to be fulfilling? Pat From toastkid.williams at gmail.com Tue Feb 26 05:55:12 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Tue, 26 Feb 2008 10:55:12 +0000 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) Message-ID: Hi all I'm having problems with data in my specs - i'm probably just going about things the wrong way though. I'm testing a model (called Property) that uses acts_as_tree, and for now have just done some specs for the basic acts_as_tree functionality - just as a sanity check, i thought, but i'm getting fails. In a before(:all) block, i'm creating a bunch of objects and saving them to the database - like this: describe Property, "with a fresh property tree" do before(:all) do @root = Property.new(:name => "Root") @root.id = 0 #root.id must be 0 for acts as tree to work properly @root.save @role = @root.children.create(:name => "Job Role") @dept = @root.children.create(:name => "Department") ...etc end describe ",standard acts_as_tree methods," do #this test is failing it "class.root" do Property.root.should eql(@root) end end and the fail report from the above test: 'Property with a fresh property tree ,standard acts_as_tree methods, class.root' FAILED expected #, got # (using .eql?) ./spec/models/property_spec.rb:50: script/spec:4: My problems seem to be arising from the fact that when i run the test, the objects i created last time are still in the database. Shouldn't they be cleared out automatically? This in turn is preventing me from saving root with an id of 0. If i test all of this stuff in the console it works fine, but it's failing in my tests, suggesting that my tests are broken. Am i setting up my data in the wrong way? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080226/3dcb43b4/attachment.html From edvard at majakari.net Tue Feb 26 06:41:21 2008 From: edvard at majakari.net (Edvard Majakari) Date: Tue, 26 Feb 2008 13:41:21 +0200 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: References: Message-ID: > My problems seem to be arising from the fact that when i run the test, the > objects i created last time are still in the database. Shouldn't they be > cleared out automatically? This in turn is preventing me from saving root I don't know RSpec that well, but I'd guess before(:all) is run only once in a describe block (and as such torn down only after the block is finished), whereas before(:each) is run before every example (and torn down respectively). So, I guess you'll want to use before(:each) version. Was that it? -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From dchelimsky at gmail.com Tue Feb 26 07:09:11 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Feb 2008 06:09:11 -0600 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: References: Message-ID: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> On Tue, Feb 26, 2008 at 5:41 AM, Edvard Majakari wrote: > > My problems seem to be arising from the fact that when i run the test, the > > objects i created last time are still in the database. Shouldn't they be > > cleared out automatically? This in turn is preventing me from saving root > > I don't know RSpec that well, but I'd guess before(:all) is run only > once in a describe block (and as such torn down only after the block > is finished), whereas before(:each) is run before every example (and > torn down respectively). So, I guess you'll want to use before(:each) > version. > > Was that it? Yep. Use before(:each) and all should be well. > > -- > "One day, when he was naughty, Mr Bunnsy looked over the hedge into > Farmer Fred's field and it was full of fresh green lettuces. Mr > Bunnsy, however, was not full of lettuces. This did not seem fair." > -- Terry Pratchett, Mr. Bunnsy Has An Adventure > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Tue Feb 26 08:39:37 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Tue, 26 Feb 2008 13:39:37 +0000 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> Message-ID: I'm using before(:all) because i want to create a single 'family' of tree objects and then run tests against it. If i have all the object creation as a before(:each) then the database will be even more full of duplications, won't it? My problem, though, is that the data is left over from the last time (in fact all previous times) that i ran the spec file, where i thought that it was cleared out. Do i need to explicitly tell the database to clear all the records in an 'after' block? On 26/02/2008, David Chelimsky wrote: > > On Tue, Feb 26, 2008 at 5:41 AM, Edvard Majakari > wrote: > > > My problems seem to be arising from the fact that when i run the test, > the > > > objects i created last time are still in the database. Shouldn't > they be > > > cleared out automatically? This in turn is preventing me from saving > root > > > > I don't know RSpec that well, but I'd guess before(:all) is run only > > once in a describe block (and as such torn down only after the block > > is finished), whereas before(:each) is run before every example (and > > torn down respectively). So, I guess you'll want to use before(:each) > > version. > > > > Was that it? > > > Yep. Use before(:each) and all should be well. > > > > > -- > > > "One day, when he was naughty, Mr Bunnsy looked over the hedge into > > Farmer Fred's field and it was full of fresh green lettuces. Mr > > Bunnsy, however, was not full of lettuces. This did not seem fair." > > -- Terry Pratchett, Mr. Bunnsy Has An Adventure > > _______________________________________________ > > 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/20080226/14103881/attachment.html From a at heitler.com Tue Feb 26 08:16:29 2008 From: a at heitler.com (JH) Date: Tue, 26 Feb 2008 13:16:29 +0000 Subject: [rspec-users] A Jedit mode for stories Message-ID: <47C4112D.1070402@heitler.com> For other folks who use jedit, here is a little Mode script for editing stories to keep things looking nice: Just place this in your ~/.jedit/modes/ directory and add the MODE NAME tag to the catalog file in that same directory. It will become the editing mode for files that start with "story-". --- Story: Scenario: Given When Then And --- Cheers, -J From dchelimsky at gmail.com Tue Feb 26 08:59:31 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Feb 2008 07:59:31 -0600 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> Message-ID: <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> On Tue, Feb 26, 2008 at 7:39 AM, Max Williams wrote: > I'm using before(:all) because i want to create a single 'family' of tree > objects and then run tests against it. If i have all the object creation as > a before(:each) then the database will be even more full of duplications, > won't it? No. If you have use_transactional_fixtures set to true, each example is run in a transaction, which is rolled back at the end of the example. This does not happen for you implicitly when you use before(:all) because there is no mechanism for running a group of examples in a transaction. > My problem, though, is that the data is left over from the last time (in > fact all previous times) that i ran the spec file, where i thought that it > was cleared out. Do i need to explicitly tell the database to clear all the > records in an 'after' block? Yes. If you want to use before(:all) to set up data, you need to use after(:all) to clean it up explicitly. Please beware that this approach is extremely error prone over time. If you ever introduce a side effect (intentionally or accidentally) that modifies the data, you're going to look at the spec, see the data you're setting up and incorrectly think that that's the data every example is using. It is much, much safer (and more sane) to use before(:each) even though it may slow things down a bit. HTH, David > > > > On 26/02/2008, David Chelimsky wrote: > > On Tue, Feb 26, 2008 at 5:41 AM, Edvard Majakari > wrote: > > > > My problems seem to be arising from the fact that when i run the test, > the > > > > objects i created last time are still in the database. Shouldn't > they be > > > > cleared out automatically? This in turn is preventing me from saving > root > > > > > > I don't know RSpec that well, but I'd guess before(:all) is run only > > > once in a describe block (and as such torn down only after the block > > > is finished), whereas before(:each) is run before every example (and > > > torn down respectively). So, I guess you'll want to use before(:each) > > > version. > > > > > > Was that it? > > > > > > Yep. Use before(:each) and all should be well. > > > > > > > > -- > > > > > "One day, when he was naughty, Mr Bunnsy looked over the hedge into > > > Farmer Fred's field and it was full of fresh green lettuces. Mr > > > Bunnsy, however, was not full of lettuces. This did not seem fair." > > > -- Terry Pratchett, Mr. Bunnsy Has An Adventure > > > _______________________________________________ > > > 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 Tue Feb 26 09:08:30 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Tue, 26 Feb 2008 14:08:30 +0000 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> Message-ID: On 26/02/2008, David Chelimsky wrote: > > On Tue, Feb 26, 2008 at 7:39 AM, Max Williams > wrote: > > > This does not happen for you implicitly when you use before(:all) > because there is no mechanism for running a group of examples in a > transaction. ah...i see. I didn't know about that last bit. :) > My problem, though, is that the data is left over from the last time (in > > fact all previous times) that i ran the spec file, where i thought that > it > > was cleared out. Do i need to explicitly tell the database to clear all > the > > records in an 'after' block? > > > Yes. If you want to use before(:all) to set up data, you need to use > after(:all) to clean it up explicitly. > > Please beware that this approach is extremely error prone over time. > If you ever introduce a side effect (intentionally or accidentally) > that modifies the data, you're going to look at the spec, see the data > you're setting up and incorrectly think that that's the data every > example is using. It is much, much safer (and more sane) to use > before(:each) even though it may slow things down a bit. Gotcha. Thanks! HTH, > > David > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080226/070b194b/attachment-0001.html From dchelimsky at gmail.com Tue Feb 26 09:16:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Feb 2008 08:16:33 -0600 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> Message-ID: <57c63afe0802260616l689a08dema966707e5feef3e8@mail.gmail.com> On Tue, Feb 26, 2008 at 8:08 AM, Max Williams wrote: > > > > On 26/02/2008, David Chelimsky wrote: > > > > On Tue, Feb 26, 2008 at 7:39 AM, Max Williams > > wrote: > > > > > > > > This does not happen for you implicitly when you use before(:all) > > because there is no mechanism for running a group of examples in a > > transaction. > > ah...i see. I didn't know about that last bit. :) FYI: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/310 Cheers, David > > > > My problem, though, is that the data is left over from the last time (in > > > fact all previous times) that i ran the spec file, where i thought that > it > > > was cleared out. Do i need to explicitly tell the database to clear all > the > > > records in an 'after' block? > > > > > > Yes. If you want to use before(:all) to set up data, you need to use > > after(:all) to clean it up explicitly. > > > > Please beware that this approach is extremely error prone over time. > > If you ever introduce a side effect (intentionally or accidentally) > > that modifies the data, you're going to look at the spec, see the data > > you're setting up and incorrectly think that that's the data every > > example is using. It is much, much safer (and more sane) to use > > before(:each) even though it may slow things down a bit. > > Gotcha. Thanks! > > > HTH, > > > > David > > > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From toastkid.williams at gmail.com Tue Feb 26 09:31:17 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Tue, 26 Feb 2008 14:31:17 +0000 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: <57c63afe0802260616l689a08dema966707e5feef3e8@mail.gmail.com> References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> <57c63afe0802260616l689a08dema966707e5feef3e8@mail.gmail.com> Message-ID: hehe, tbh even if the documentation had been there i probably wouldn't have read it :) thanks! On 26/02/2008, David Chelimsky wrote: > > On Tue, Feb 26, 2008 at 8:08 AM, Max Williams > > wrote: > > > > > > > > On 26/02/2008, David Chelimsky wrote: > > > > > > On Tue, Feb 26, 2008 at 7:39 AM, Max Williams > > > wrote: > > > > > > > > > > > > This does not happen for you implicitly when you use before(:all) > > > because there is no mechanism for running a group of examples in a > > > transaction. > > > > ah...i see. I didn't know about that last bit. :) > > > FYI: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/310 > > Cheers, > > David > > > > > > > > My problem, though, is that the data is left over from the last time > (in > > > > fact all previous times) that i ran the spec file, where i thought > that > > it > > > > was cleared out. Do i need to explicitly tell the database to clear > all > > the > > > > records in an 'after' block? > > > > > > > > > Yes. If you want to use before(:all) to set up data, you need to use > > > after(:all) to clean it up explicitly. > > > > > > Please beware that this approach is extremely error prone over time. > > > If you ever introduce a side effect (intentionally or accidentally) > > > that modifies the data, you're going to look at the spec, see the data > > > you're setting up and incorrectly think that that's the data every > > > example is using. It is much, much safer (and more sane) to use > > > before(:each) even though it may slow things down a bit. > > > > Gotcha. Thanks! > > > > > HTH, > > > > > > 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/20080226/1b9dfbd4/attachment.html From dchelimsky at gmail.com Tue Feb 26 09:33:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Feb 2008 08:33:23 -0600 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> <57c63afe0802260616l689a08dema966707e5feef3e8@mail.gmail.com> Message-ID: <57c63afe0802260633j373b6425i57a1aae29bcbfc15@mail.gmail.com> On Tue, Feb 26, 2008 at 8:31 AM, Max Williams wrote: > hehe, tbh even if the documentation had been there i probably wouldn't have > read it :) Yeah but then I get to say RTFM. Right now, TFM doesn't exist :( > > thanks! > > > > On 26/02/2008, David Chelimsky wrote: > > On Tue, Feb 26, 2008 at 8:08 AM, Max Williams > > > > wrote: > > > > > > > > > > > > On 26/02/2008, David Chelimsky wrote: > > > > > > > > On Tue, Feb 26, 2008 at 7:39 AM, Max Williams > > > > wrote: > > > > > > > > > > > > > > > > This does not happen for you implicitly when you use before(:all) > > > > because there is no mechanism for running a group of examples in a > > > > transaction. > > > > > > ah...i see. I didn't know about that last bit. :) > > > > > > FYI: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/310 > > > > Cheers, > > > > David > > > > > > > > > > > > My problem, though, is that the data is left over from the last time > (in > > > > > fact all previous times) that i ran the spec file, where i thought > that > > > it > > > > > was cleared out. Do i need to explicitly tell the database to clear > all > > > the > > > > > records in an 'after' block? > > > > > > > > > > > > Yes. If you want to use before(:all) to set up data, you need to use > > > > after(:all) to clean it up explicitly. > > > > > > > > Please beware that this approach is extremely error prone over time. > > > > If you ever introduce a side effect (intentionally or accidentally) > > > > that modifies the data, you're going to look at the spec, see the data > > > > you're setting up and incorrectly think that that's the data every > > > > example is using. It is much, much safer (and more sane) to use > > > > before(:each) even though it may slow things down a bit. > > > > > > Gotcha. Thanks! > > > > > > > HTH, > > > > > > > > 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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Tue Feb 26 10:18:22 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 26 Feb 2008 07:18:22 -0800 Subject: [rspec-users] Newbie question Context vs Describe In-Reply-To: <57c63afe0802240626s4e1a3c64x7fca8c0d01f31412@mail.gmail.com> References: <93cf9750802240329j72a629d1v64291faf0040ae6c@mail.gmail.com> <57c63afe0802240626s4e1a3c64x7fca8c0d01f31412@mail.gmail.com> Message-ID: <810a540e0802260718g4af4a4cbr9effbaa3461bcacd@mail.gmail.com> On Sun, Feb 24, 2008 at 6:26 AM, David Chelimsky wrote: > In terms of getting that into RSpec, why don't you enter a feature > request at http://rspec.lighthouseapp.com and we can discuss the > merits of this there. As I said, I like it at first glance, but I want > to think about it and get other opinions before just adding it (as > context is only there for backwards compatibility right now). I like it. I always say that you can't really specify an object's behavior without considering its context. This seems like it would be a nice organizational tool, and contribute to the over all vision of BDD. Pat From edvard at majakari.net Tue Feb 26 13:10:39 2008 From: edvard at majakari.net (Edvard Majakari) Date: Tue, 26 Feb 2008 20:10:39 +0200 Subject: [rspec-users] Test data problem (in general and with acts_as_tree) In-Reply-To: <57c63afe0802260633j373b6425i57a1aae29bcbfc15@mail.gmail.com> References: <57c63afe0802260409v54ac5522n6a020f4e43356649@mail.gmail.com> <57c63afe0802260559g50069685m5956d6dccb6aab47@mail.gmail.com> <57c63afe0802260616l689a08dema966707e5feef3e8@mail.gmail.com> <57c63afe0802260633j373b6425i57a1aae29bcbfc15@mail.gmail.com> Message-ID: > Yeah but then I get to say RTFM. Right now, TFM doesn't exist :( rant << EOF Indeed. People see much trouble in writing documentation so that they don't have to answer the same questions ad nauseam. It would be nice if we appreciated their efforts and check the documentation first. EOF -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From cremes.devlist at mac.com Tue Feb 26 14:22:35 2008 From: cremes.devlist at mac.com (Chuck Remes) Date: Tue, 26 Feb 2008 13:22:35 -0600 Subject: [rspec-users] [Q] how to restructure tests for an abstract class? In-Reply-To: <57c63afe0802250630i38c88d8eh36d4cb17f2364f3c@mail.gmail.com> References: <810a540e0802231519v97659dek9eab36b2fa6836ec@mail.gmail.com> <27c0ac6d0802250130n24a1c2b6o22d56880f09f3c6d@mail.gmail.com> <57c63afe0802250630i38c88d8eh36d4cb17f2364f3c@mail.gmail.com> Message-ID: <62F17A77-A573-41C4-8EF6-FBC38FDA5E06@mac.com> On Feb 25, 2008, at 8:30 AM, David Chelimsky wrote: > On Mon, Feb 25, 2008 at 6:23 AM, Chuck Remes > wrote: >> Thanks for asking this question. This is exactly what I was going >> to write, >> but you beat me to it! >> >> (Sorry for the top-post; just following the last responder.) >> >> cr >> >> >> >> On Feb 25, 2008, at 3:30 AM, Matthijs Langenberg wrote: >> Question is, would you duplicate the specs for all the classes that >> include >> a certain module (through shared behaviour for example), or would >> you use >> one set of specs for just the module, and specify that a class should >> include that module? > > Matthijs - I'd throw the same question back to you. Have you tried > both approaches? How have they worked out for you? > > I won't wait for your answer :). But I am curious about other people's > experiences with this. > > I can tell you this from my own experience - I tend to use shared > groups for this for a couple of reasons. One, I like to see the specs > for each object. I thought I'd share my experiences with the group. Please recall I'm new at BDD/TDD so I may get some of the terminology wrong or whatever. So I have a class that, by itself, doesn't do anything. Concrete subclasses are necessary to flesh out a few characteristics before the parent class code can perform its magic. This is an abstract class which I'm told isn't the Ruby Way, so I'm looking at turning it into a module (a topic for another message). Originally, I was curious how to refactor my classes (and tests). I decided to write a second concrete subclass to see what kind of problems I might run into. I figured *any* problem I encountered was just more information for me to figure out the correct direction. The second subclass started out normally enough. I spec'd some behavior unique to that subclass. So far, so good. Then it occurred to me that I had no idea if the parent class was really being exercised by my new tests; turns out it wasn't being exercised. To resolve this I started adding some tests to make sure I covered the original behavior of the parent class. Now I had code duplication. The parent class tests and my *first* subclass were duping some of the same behavior. Looking into the examples directory I saw the concept of #shared_examples_for. I refactored my tests using shared examples. Most of these went into the parent class (perhaps soon to be a module). All the tests in my subclasses then focused exclusively on the behavior unique to that specific class while the describe blocks called #it_should_behave_like for shared behaviors. This DRY'ed the code up considerably. An added benefit was some test breakage I ran across while refactoring the tests. My second subclass had some rather tight coupling to the tests, so when I made it shared the subclass test broke. It forced me to rethink some of the test and class design to loosen the coupling. Ultimately it led to a better class api. So, that's my rambling summary. Kudos to you if you read this far. My next goal is to DRY up some of my 'before (:each)' blocks. I continually do the same setup operations across #describe blocks (@buf = Buf.new; @msg = blah, etc). It looks like I may want to define subclasses of a parent Spec::ExampleGroup so the subclasses can inherit some of the #before setup. I'd love to hear experiences from others on this technique. Lastly, I thought I'd say a word on the resulting class code. This BDD project was a learning experience. I rewrote a set of classes that I had originally written the old-fashioned way; puzzle through the logic in my head, write the code, and then debug the crap out of it until it worked. The original classes are rather short (LOC) with only a few methods (3 or 4). The classes I wrote via BDD are longer, maybe by 40% in terms of LOC. Plus, I now have around 10 methods none of which exceeds 5 lines of "real" code. It's more readable, more logical, and *far* easier to subclass. I'm now a believer. YMMV. cr From lists at ruby-forum.com Tue Feb 26 15:57:22 2008 From: lists at ruby-forum.com (Dave Myron) Date: Tue, 26 Feb 2008 21:57:22 +0100 Subject: [rspec-users] Rspec Textmate bundle errors In-Reply-To: <43362a720710120841u305422f7se5ed5ecdb1b7f47e@mail.gmail.com> References: <2E61B430-A2FC-4588-B35A-95AE51254512@kozmo.co.uk> <57c63afe0710101703k1476a37cu2897b9e61262a74f@mail.gmail.com> <8487E755-9FBC-4D6E-8A53-AB13239A84A2@kozmo.co.uk> <57c63afe0710101820x119f7289jfd1263b947361684@mail.gmail.com> <079D220E-DBC8-4C00-82FE-E596F1F2148C@gmail.com> <57c63afe0710110603y669f3e35v62f226ca8186e2cb@mail.gmail.com> <43362a720710120841u305422f7se5ed5ecdb1b7f47e@mail.gmail.com> Message-ID: Mel Riffe wrote: > This is what worked for me (just did this last night): > > 1. I removed everything rspec to have a clean slate: > - gem uninstall rspec > - rm -fr vendor/plugins/rpec > - rm -fr vendor/plugins/rpec_on_rails > - using BundleEditor, removed RSpec Bundle > > 2. I then installed the rspec plugins according to the website: > - script/plugin install svn://..../tags/CURRENT/rspec > - script/plugin install svn://..../tags/CURRENT/rspec_on_rails > - script/generate spec > - i then created a model rspec and ran 'rake spec' > > 3. I then installed the RSpec Bundle with the following SVN URL: > - svn co .../tags/CURRENT/RSpec.tmbundle > - Reloaded the Bundles > - ran the same model spec from within TM. Digging up an old thread here. I've done the above (and am at r3317). But getting a strange error when I run the example with the TextMate bundle (from within a project directory in TM): System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- image_science (MissingSourceFile) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' from /myapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' from /myapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in' from /myapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' from /myapp/app/models/custom.rb:1 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' from /myapp/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in `require' ... 14 levels... from /Users/user/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:31:in `chdir' from /Users/user/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:31:in `run' from /Users/user/Library/Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:14:in `run_file' from /tmp/temp_textmate.eFFxZt:4 The line generating that error is a simple: require 'image_science'. Doing `gem which image_science` returns the correct value and running the spec from the command line works fine too. Strange? Dave -- Posted via http://www.ruby-forum.com/. From libei.twer at gmail.com Tue Feb 26 23:53:36 2008 From: libei.twer at gmail.com (Bei) Date: Tue, 26 Feb 2008 20:53:36 -0800 (PST) Subject: [rspec-users] how to set up data before story runner steps? Message-ID: <4086be02-537e-4e93-b6ac-aba4903c3ddd@71g2000hse.googlegroups.com> Hi I'm using story runner of RSpec now. What I'm trying to do is initializing the @selenium before any steps of one story is executing, and stop @selenium after any story is finished. just as @BeforeClass and @AfterClass in jUnit Any suggestions on this? Thanks!!! Bei here is my code for STEPS: steps_for(:search) do Given("user could access search page") do @google_page = GooglePage.new(@selenium) @google_page.open; end Given("user enter search test: $search_text") do |$search_text| @google_page.search_text=$search_text end When("do search") do @search_result_page = @google_page.search end Then("show search result") do @search_result_page.should_not == nil end end STORY: Story: #000 As A command human I want to get information quickly So that I could save me time on doing real things Scenario: could search Given user could access search page And user enter search test: asdfasdfasdfas When do search Then show search result GLUE: with_steps_for :search do run 'stories/000.story' end From dchelimsky at gmail.com Wed Feb 27 00:31:32 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 26 Feb 2008 23:31:32 -0600 Subject: [rspec-users] how to set up data before story runner steps? In-Reply-To: <4086be02-537e-4e93-b6ac-aba4903c3ddd@71g2000hse.googlegroups.com> References: <4086be02-537e-4e93-b6ac-aba4903c3ddd@71g2000hse.googlegroups.com> Message-ID: <57c63afe0802262131y79bf32f9v2ef0c701318e7448@mail.gmail.com> On Tue, Feb 26, 2008 at 10:53 PM, Bei wrote: > Hi > > I'm using story runner of RSpec now. What I'm trying to do is > initializing the @selenium before any steps of one story is executing, > and stop @selenium after any story is finished. just as @BeforeClass > and @AfterClass in jUnit > Any suggestions on this? There is no way built in to handle this yet. Is anybody doing this yet? If not, you'll have to experiment. If you're interested, I think the way to handle it is to register a listener like this: Spec::Story::Runner.register_listener(listener) The listener object should receive messages like run_started, story_started, scenario_started and story_ended, run_ended and scenario_failed or scenario_pending. Be sure to implement method_missing to ignore everything else. Good luck, and let us know what works. Cheers, David > > Thanks!!! > > > Bei > > here is my code for > STEPS: > > steps_for(:search) do > > Given("user could access search page") do > @google_page = GooglePage.new(@selenium) > @google_page.open; > end > > Given("user enter search test: $search_text") do |$search_text| > @google_page.search_text=$search_text > end > > When("do search") do > @search_result_page = @google_page.search > end > > Then("show search result") do > @search_result_page.should_not == nil > end > end > > > STORY: > > Story: #000 > As A command human > I want to get information quickly > So that I could save me time on doing real things > > Scenario: could search > Given user could access search page > And user enter search test: asdfasdfasdfas > When do search > Then show search result > > > GLUE: > with_steps_for :search do > run 'stories/000.story' > end > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 27 01:00:16 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Feb 2008 00:00:16 -0600 Subject: [rspec-users] the git experiment Message-ID: <57c63afe0802262200o6bd5ef9fy112034c9c5d276f5@mail.gmail.com> Hey all, A while back I mentioned that we were going to move to git or hg. We decided that we'd experiment with each for a month and see how it goes. We're going to start with git. Obviously if all goes well we'll have to reassess whether or not to also give hg a try. We have a repo set up at gitorious: Project page: http://gitorious.org/projects/rspec. Clone the repo: git clone git at gitorious.org:rspec/mainline.git We'll be setting up synchronization with subversion, so you'll be able to keep the rails plugins up to date, but it's a few days out before that's set up. In the meantime, you rails'ers who want to keep up with the plugins will have to clone the repo and move stuff around locally. Keep in mind that this is an experiment. The official repo is still the subversion repo at rubyforge until further notice. Cheers, David From thomasmarek_ at web.de Wed Feb 27 05:02:49 2008 From: thomasmarek_ at web.de (Thomas Marek) Date: Wed, 27 Feb 2008 11:02:49 +0100 Subject: [rspec-users] how to set up data before story runner steps? In-Reply-To: <4086be02-537e-4e93-b6ac-aba4903c3ddd@71g2000hse.googlegroups.com> References: <4086be02-537e-4e93-b6ac-aba4903c3ddd@71g2000hse.googlegroups.com> Message-ID: <47C53549.7040806@web.de> Bei schrieb: > Hi > > I'm using story runner of RSpec now. What I'm trying to do is > initializing the @selenium before any steps of one story is executing, > and stop @selenium after any story is finished. just as @BeforeClass > and @AfterClass in jUnit > Any suggestions on this? > > Thanks!!! > Hi, my helpers/selenium_helper.rb file look like that: # Alias some more ruby-like methods on SeleniumDriver, to make it play # better with rspec matchers. module Selenium class SeleniumDriver alias_method :original_method_missing, :method_missing def method_missing method_name, *args if method_name.to_s =~ /^has_.*\?$/ real_method = method_name.to_s.sub /has_(.*)\?$/, 'is_\1' if respond_to? real_method return send(real_method, args) end elsif respond_to?(real_method = "get_" + method_name.to_s) return send(real_method) end return original_method_missing(method_name, args) end end end $selenium_driver = nil unless $selenium_driver $selenium_listener_added = false unless $selenium_listener_added module StoryHelper def selenium $selenium_driver end Spec::Story::World.send :include, self end class SeleniumListener include Singleton def scenario_started(*args) $selenium_driver = Selenium::SeleniumDriver.new('localhost', 4444, '*firefox', 'http://localhost:3000/', 15000) $selenium_driver.start end def scenario_succeeded(*args) $selenium_driver.stop $selenium_driver = nil end alias :scenario_pending :scenario_succeeded alias :scenario_failed :scenario_succeeded end unless $selenium_listener_added Spec::Story::Runner.scenario_runner.add_listener(SeleniumListener.instance) $selenium_listener_added = true end Best wishes, Thomas From coreyhaines at gmail.com Wed Feb 27 07:08:05 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 27 Feb 2008 07:08:05 -0500 Subject: [rspec-users] OT local version control? In-Reply-To: <6bdacb70802051116r66200b0fk477667ae00162adc@mail.gmail.com> References: <6bdacb70801271333y5825321dp67936e236030aae5@mail.gmail.com> <71166b3b0802030923u268a7d7cs5bcb694802b495c1@mail.gmail.com> <6bdacb70802030945u7209d4d3tf171de576c16e93a@mail.gmail.com> <71166b3b0802031000h65c66560vc8760b09269cf839@mail.gmail.com> <6bdacb70802031028k493d394ds793ca969792e2af6@mail.gmail.com> <6bdacb70802041528n308d5023i12be5a05f9b06e65@mail.gmail.com> <71166b3b0802041609k5f71461dpa1a0501f4506bec4@mail.gmail.com> <6bdacb70802041633v63dfe9e5x1d4a4fa8b0548238@mail.gmail.com> <6bdacb70802051116r66200b0fk477667ae00162adc@mail.gmail.com> Message-ID: <6bdacb70802270408u71e00093od9ec3cd307a92344@mail.gmail.com> Joe Fiorino, the faithful geek, recorded a conversation we had last Saturday about DSCM and my early experiences with it for his podcast. If anyone is inclined to listen and comment on anything I said, I'd appreciate it. I'm especially interested in any possible fallacious understandings of DSCM, since you all know that I'm new at it. http://www.faithfulgeek.org/2008/2/24/distributed-source-control-with-corey-haines Thanks. -Corey On Tue, Feb 5, 2008 at 2:16 PM, Corey Haines wrote: > Thanks, Dan, I'll check that out. > > -Corey > > On Feb 5, 2008 5:19 AM, Dan North wrote: > > > Hi Corey. > > > > I recently discovered a rather excellent online book: > > http://hgbook.red-bean.com/ > > > > It's about mercurial but it's a) largely scm-agnostic and b) really well > > written, with some useful diagrams about how changesets work in the small > > and collaboration models in the large (i.e. exactly what you were asking > > about). > > > > I also discovered a "deal-breaker" feature of mercurial that I hadn't > > realised before, which is that it tracks changes across copies and renames > > of files. Or rather, what I hadn't realised is that other SCMs don't do > > this. This was what was crippling me with subversion - I had a branch where > > I had done some quite aggressive refactoring (which means files getting > > moved and/or renamed), and subversion wouldn't merge the changes from the > > branch onto trunk. > > > > > > On 05/02/2008, Corey Haines wrote: > > > > > > Thanks for the response, Luis. > > > > > > I'm going through the user manual, and it looks like I can set up a > > > main branch, make a clone, work on the clone with its own > > > repository/revisions, then merge the changes back to the main branch when > > > I'm ready. I like the idea of being able to work on several things at once. > > > I'll let you guys know how it goes. > > > > > > -Corey > > > > > > > > > > _______________________________________________ > > 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 > -- 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/20080227/ed04908d/attachment.html From toastkid.williams at gmail.com Wed Feb 27 07:12:20 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 27 Feb 2008 12:12:20 +0000 Subject: [rspec-users] has_many_polymorphs is breaking my testing Message-ID: I have a class Property that was testing fine until i added the following to it: has_many_polymorphs :labelled, :from => [:instructional_objects, :lessons, :courses], :through => :labels, :dependent => :destroy (in other words, 'labels' is a join table through which various objects can be labelled with a property) Now my spec file crashes, saying that Property isn't defined in property.rb: does anyone know what's gone wrong here? /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) from /home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing' from /home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:464:in `const_missing' from ./spec/models/property_spec.rb:3 ... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080227/01ae53a0/attachment.html From toastkid.williams at gmail.com Wed Feb 27 08:14:49 2008 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 27 Feb 2008 13:14:49 +0000 Subject: [rspec-users] has_many_polymorphs is breaking my testing In-Reply-To: References: Message-ID: Never mind, i'm an idiot, the problem was that i broke my Property class with the has_many_polymorphs declaration, so the spec couldn't load it. Sorry! On 27/02/2008, Max Williams wrote: > > I have a class Property that was testing fine until i added the following > to it: > > has_many_polymorphs :labelled, > :from => [:instructional_objects, :lessons, :courses], > :through => :labels, > :dependent => :destroy > > (in other words, 'labels' is a join table through which various objects > can be labelled with a property) > > Now my spec file crashes, saying that Property isn't defined in > property.rb: does anyone know what's gone wrong here? > > /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) > from > /home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in > `const_missing' > from > /home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:464:in > `const_missing' > from ./spec/models/property_spec.rb:3 > ... > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080227/ce0fee39/attachment-0001.html From lists at ruby-forum.com Wed Feb 27 09:14:35 2008 From: lists at ruby-forum.com (Greg Gigon) Date: Wed, 27 Feb 2008 15:14:35 +0100 Subject: [rspec-users] Problem with Plain Text Story Runner Message-ID: <193b74fd637be61803523a100f74d2fd@ruby-forum.com> Hi Guys I'm new to Ruby and BDD. I'm having a problem while running my story in plain text. This is the console OUTPUT. /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/story_mediator.rb:51:in `current_scenario': undefined method `current_scenario' for nil:NilClass (NoMethodError) from /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/story_mediator.rb:26:in `create_given' from /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/story_parser.rb:61:in `create_given' from /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/story_parser.rb:107:in `given' from /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/story_parser.rb:31:in `process_line' from /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/story_parser.rb:21:in `parse' from /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/plain_text_story_runner.rb:35:in `run' I was fallowing David Chelimsky article http://blog.davidchelimsky.net/articles/2007/10/21/story-runner-in-plain-english I got RB file with Steps defined, RB file with runner and a text file with Stories. Doing the same thing in Ruby code and not a plain text works fine. Any suggestions ? Greg -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Feb 27 09:27:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Feb 2008 08:27:03 -0600 Subject: [rspec-users] the git experiment In-Reply-To: <57c63afe0802262200o6bd5ef9fy112034c9c5d276f5@mail.gmail.com> References: <57c63afe0802262200o6bd5ef9fy112034c9c5d276f5@mail.gmail.com> Message-ID: <57c63afe0802270627k6a7321f2k6f66de92fba1228e@mail.gmail.com> On Wed, Feb 27, 2008 at 12:00 AM, David Chelimsky wrote: > Hey all, > > A while back I mentioned that we were going to move to git or hg. We > decided that we'd experiment with each for a month and see how it > goes. > > We're going to start with git. Obviously if all goes well we'll have > to reassess whether or not to also give hg a try. > > We have a repo set up at gitorious: > > Project page: > http://gitorious.org/projects/rspec. > > Clone the repo: > git clone git at gitorious.org:rspec/mainline.git Correction: this should be: git clone git://gitorious.org/rspec/mainline.git > > We'll be setting up synchronization with subversion, so you'll be able > to keep the rails plugins up to date, but it's a few days out before > that's set up. In the meantime, you rails'ers who want to keep up with > the plugins will have to clone the repo and move stuff around locally. > > Keep in mind that this is an experiment. The official repo is still > the subversion repo at rubyforge until further notice. > > Cheers, > David > From matt-lists at reprocessed.org Wed Feb 27 09:13:47 2008 From: matt-lists at reprocessed.org (Matt Patterson) Date: Wed, 27 Feb 2008 14:13:47 +0000 Subject: [rspec-users] Passing options into Story Runner (like --format) Message-ID: <519C56C5-E4E4-448A-B0A1-0324B5491E0F@reprocessed.org> Hey, I've been trying to hook in the HTML formatter for story output, with zero success - passing the --format option to me stories/all.rb script was doing nothing. So, I slapped in some puts statements and figured out that ARGV was getting cleared before Spec::Story::Runner.run_options was ever being called... I broke out the debugger and discovered that this is happening because when spec/ rails/story_adapter is required, the extension of Test::Unit::TestCase with Spec::Example::ExampleGroupMethods in spec/ interop/test/unit/testcase.rb means that the Spec::Rails::Example::RailsExampleGroup inheritance of Test::Unit::TestCase causes Spec::Example::ExampleGroupMethods.inherited to fire, which winds up calling Spec::Example::ExampleGroupMethods#inherited, which calls rspec_options, which consumes ARGV and clears it out. Given that you then end up with a globally accessible Spec::Runner::Options instance, is there any reason for Spec::Story::Runner.run_options, since it tries to do exactly the same thing? I'm only asking in case I'm missing something obvious, behaviour- wise. Otherwise I'll look into fixing it and post a patch to Lighthouse Matt -- Matt Patterson | Design & Code | http://www.reprocessed.org/ From rspec-users at kero.tmfweb.nl Wed Feb 27 22:45:03 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Thu, 28 Feb 2008 04:45:03 +0100 Subject: [rspec-users] bad specs better than none? In-Reply-To: <57c63afe0802252013y112de342hcb8c2097052e9229@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <57c63afe0802252013y112de342hcb8c2097052e9229@mail.gmail.com> Message-ID: <20080228034503.GA5500@chello.nl> > > I also had to go into specs on a project I'm not working on, and found > > an unholy hive of database-accessing specs. It's disheartening. > > Basically, it's cargo cult development practices - using the "best > > practice" without actually understanding it. > > This is a really tough problem. The whole motivation for BDD was > "people don't get TDD, so let's come up with some new ways to frame it > so people get it." Now people don't get the new frame. In that respect > we've made things twice as bad. What did you expect? Honestly? You need to show people the Right way, otherwise they're unlikely to figure it out by themselves. But as the fortune cookies go: "To make the right decision, one needs experience. To gain experience, one needs to make the wrong decision." It is easier for me to explain this from the point of view of aikido: I've been shown the right moves thousands of times. I can not even see what sensei does, let alone reproduce it. I can not perceive the balance, the timing, the acceptance of an attacker and the reflection of his/her energy to -ultimately- unbalance. How could I learn by trying even tens or hundreds of thousands of time? After seven years, I'm still a puny beginner. And I need other people to show me my mistakes. Again, again and again. To the original poster: yes, teach BDD. Make sure they accept you as a teacher, then teach, small steps at a time, by showing what is wrong. when they figure out a solution by themselves, encourage them, accept that solution (use it yourself). When they don't figure it out by themselves (likely enough), show how you would do it. And be prepared to repeat yourself. HtH, Kero. From mauricio.linhares at gmail.com Wed Feb 27 23:01:04 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Thu, 28 Feb 2008 01:01:04 -0300 Subject: [rspec-users] bad specs better than none? In-Reply-To: <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> Message-ID: On Tue, Feb 26, 2008 at 2:59 AM, aslak hellesoy wrote: > > I also had to go into specs on a project I'm not working on, and found > > an unholy hive of database-accessing specs. It's disheartening. > > Basically, it's cargo cult development practices - using the "best > > practice" without actually understanding it. > > > > What "best practice" are you referring to? > I'm also interested in discovering what is this "best practice". I can't see any problem in specs running against a database, that's exactly what integration testing is about, shouldn't we do integration testing just because we're using BDD? I really don't think so. The big problem about specs running against a database is not knowing that it's integration testing and also that specs that access databases run slower than "pure" unit tests, but you can't be sure that your app works without a bunch of integration tests. -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://codeshooter.wordpress.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 From joseph at josephholsten.com Thu Feb 28 00:09:52 2008 From: joseph at josephholsten.com (Joseph Anthony Pasquale Holsten) Date: Wed, 27 Feb 2008 23:09:52 -0600 Subject: [rspec-users] bad specs better than none? In-Reply-To: References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> Message-ID: <99FAFCD2-A7B5-4F0C-83FE-82CD913757B2@josephholsten.com> On 02008:02:27, at 10:01CST, Maur?cio Linhares wrote: > On Tue, Feb 26, 2008 at 2:59 AM, aslak hellesoy > wrote: >>> I also had to go into specs on a project I'm not working on, and >>> found >>> an unholy hive of database-accessing specs. It's disheartening. >>> Basically, it's cargo cult development practices - using the "best >>> practice" without actually understanding it. >>> >> >> What "best practice" are you referring to? >> > > I'm also interested in discovering what is this "best practice". > > I can't see any problem in specs running against a database, that's > exactly what integration testing is about, shouldn't we do integration > testing just because we're using BDD? I really don't think so. > > The big problem about specs running against a database is not knowing > that it's integration testing and also that specs that access > databases run slower than "pure" unit tests, but you can't be sure > that your app works without a bunch of integration tests. I'm reminded of one of my heros, Matthias Felleisen. If you don't know exactly what I'm talking about, go here: . His mission in life is to teach the pattern to design programs. His approach draws more from the Design by Contract paradigm than TDD, but it's the same goal. If you can ever stop in at Northeastern University in Boston, drop in on a class. Especially the freshman intro to programming. If we can't teach the method as well as him, we're screwed. Because he's been working on it for twenty years. Of course, my hope is that hackety.org + bdd = hdtp++. I can dream, no? http:// Joseph Holsten .com From omen.king at gmail.com Thu Feb 28 00:31:15 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Thu, 28 Feb 2008 00:31:15 -0500 Subject: [rspec-users] bad specs better than none? In-Reply-To: <99FAFCD2-A7B5-4F0C-83FE-82CD913757B2@josephholsten.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> <99FAFCD2-A7B5-4F0C-83FE-82CD913757B2@josephholsten.com> Message-ID: I replied before in this topic saying that I was doing manual testing.I should state that I am now using Selenium + Ruby + RSpec. ASP 0 - Ruby 1 On Thu, Feb 28, 2008 at 12:09 AM, Joseph Anthony Pasquale Holsten < joseph at josephholsten.com> wrote: > > On 02008:02:27, at 10:01CST, Maur?cio Linhares wrote: > > > On Tue, Feb 26, 2008 at 2:59 AM, aslak hellesoy > > wrote: > >>> I also had to go into specs on a project I'm not working on, and > >>> found > >>> an unholy hive of database-accessing specs. It's disheartening. > >>> Basically, it's cargo cult development practices - using the "best > >>> practice" without actually understanding it. > >>> > >> > >> What "best practice" are you referring to? > >> > > > > I'm also interested in discovering what is this "best practice". > > > > I can't see any problem in specs running against a database, that's > > exactly what integration testing is about, shouldn't we do integration > > testing just because we're using BDD? I really don't think so. > > > > The big problem about specs running against a database is not knowing > > that it's integration testing and also that specs that access > > databases run slower than "pure" unit tests, but you can't be sure > > that your app works without a bunch of integration tests. > > I'm reminded of one of my heros, Matthias Felleisen. If you don't > know exactly what I'm talking about, go here: . His > mission in life is to teach the pattern to design programs. His > approach draws more from the Design by Contract paradigm than TDD, > but it's the same goal. > > If you can ever stop in at Northeastern University in Boston, drop in > on a class. Especially the freshman intro to programming. If we can't > teach the method as well as him, we're screwed. Because he's been > working on it for twenty years. > > Of course, my hope is that hackety.org + bdd = hdtp++. I can dream, no? > > http:// Joseph Holsten .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/20080228/7a223c0b/attachment.html From pergesu at gmail.com Thu Feb 28 00:50:10 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 27 Feb 2008 21:50:10 -0800 Subject: [rspec-users] bad specs better than none? In-Reply-To: <99FAFCD2-A7B5-4F0C-83FE-82CD913757B2@josephholsten.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> <99FAFCD2-A7B5-4F0C-83FE-82CD913757B2@josephholsten.com> Message-ID: <810a540e0802272150q33098642k13ed9fdee149da4c@mail.gmail.com> On Wed, Feb 27, 2008 at 9:09 PM, Joseph Anthony Pasquale Holsten wrote: > If you can ever stop in at Northeastern University in Boston, drop in > on a class. Especially the freshman intro to programming. If we can't > teach the method as well as him, we're screwed. Because he's been > working on it for twenty years. Pick up one/several of his books, too. The Little/Seasoned/Reasoned Schemer, Little MLer, A Little Java A Few Patterns. HTDP is a good book as well, it's kind of like SICP's little brother. The ones I listed above are quite different - written in a Socratic dialog format - and very enjoyable. Plus you can get them all off of ebay for like 10 bucks. Pat From korny at sietsma.com Thu Feb 28 01:49:41 2008 From: korny at sietsma.com (Korny Sietsma) Date: Thu, 28 Feb 2008 17:49:41 +1100 Subject: [rspec-users] bad specs better than none? In-Reply-To: References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> Message-ID: <8e15872b0802272249r4edb1290q95f85b11b19b95d9@mail.gmail.com> Totally agree with this - I'm happy to work with specs that just define a single bit of the system's behaviour (i.e. "unit tests") and specs that define behaviour across several different parts of the system (i.e. "integration tests") - but it drives me mad when they are all mixed in together, rather than in different directory trees. Incidentally, is there a good naming scheme for this distinction in the BDD world? I'm used to saying "unit tests", "integration tests", "acceptance tests" (though the precise meaning of the last two seems to vary widely between different organisations!) but I'm not sure what to call them in rspec-land. "unit specs"? "stories" in story-runner? - Korny On Thu, Feb 28, 2008 at 3:01 PM, Maur?cio Linhares < mauricio.linhares at gmail.com> wrote: > On Tue, Feb 26, 2008 at 2:59 AM, aslak hellesoy > wrote: > > > I also had to go into specs on a project I'm not working on, and > found > > > an unholy hive of database-accessing specs. It's disheartening. > > > Basically, it's cargo cult development practices - using the "best > > > practice" without actually understanding it. > > > > > > > What "best practice" are you referring to? > > > > I'm also interested in discovering what is this "best practice". > > I can't see any problem in specs running against a database, that's > exactly what integration testing is about, shouldn't we do integration > testing just because we're using BDD? I really don't think so. > > The big problem about specs running against a database is not knowing > that it's integration testing and also that specs that access > databases run slower than "pure" unit tests, but you can't be sure > that your app works without a bunch of integration tests. > > -- > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | > http://codeshooter.wordpress.com/ (en) > Jo?o Pessoa, PB, +55 83 8867-7208 > _______________________________________________ > 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/20080228/dc4f1e14/attachment-0001.html From dchelimsky at gmail.com Thu Feb 28 02:28:31 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Feb 2008 01:28:31 -0600 Subject: [rspec-users] bad specs better than none? In-Reply-To: <8e15872b0802272249r4edb1290q95f85b11b19b95d9@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <8d961d900802252159j2b83c7ads80bd89594880e77f@mail.gmail.com> <8e15872b0802272249r4edb1290q95f85b11b19b95d9@mail.gmail.com> Message-ID: <57c63afe0802272328r558f4249q32bf850fd0226a9f@mail.gmail.com> On Thu, Feb 28, 2008 at 12:49 AM, Korny Sietsma wrote: > Totally agree with this - I'm happy to work with specs that just define a > single bit of the system's behaviour (i.e. "unit tests") and specs that > define behaviour across several different parts of the system (i.e. > "integration tests") - but it drives me mad when they are all mixed in > together, rather than in different directory trees. > > Incidentally, is there a good naming scheme for this distinction in the BDD > world? I'm used to saying "unit tests", "integration tests", "acceptance > tests" (though the precise meaning of the last two seems to vary widely > between different organisations!) but I'm not sure what to call them in > rspec-land. "unit specs"? "stories" in story-runner? I've been using "Stories" and "Object Specs". David > > - Korny > > > > On Thu, Feb 28, 2008 at 3:01 PM, Maur?cio Linhares > wrote: > > > > On Tue, Feb 26, 2008 at 2:59 AM, aslak hellesoy > > wrote: > > > > I also had to go into specs on a project I'm not working on, and > found > > > > an unholy hive of database-accessing specs. It's disheartening. > > > > Basically, it's cargo cult development practices - using the "best > > > > practice" without actually understanding it. > > > > > > > > > > What "best practice" are you referring to? > > > > > > > I'm also interested in discovering what is this "best practice". > > > > I can't see any problem in specs running against a database, that's > > exactly what integration testing is about, shouldn't we do integration > > testing just because we're using BDD? I really don't think so. > > > > The big problem about specs running against a database is not knowing > > that it's integration testing and also that specs that access > > databases run slower than "pure" unit tests, but you can't be sure > > that your app works without a bunch of integration tests. > > > > -- > > Maur?cio Linhares > > http://alinhavado.wordpress.com/ (pt-br) | > > http://codeshooter.wordpress.com/ (en) > > Jo?o Pessoa, PB, +55 83 8867-7208 > > > > > > > > _______________________________________________ > > 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 > From pergesu at gmail.com Thu Feb 28 02:57:10 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 27 Feb 2008 23:57:10 -0800 Subject: [rspec-users] bad specs better than none? In-Reply-To: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> Message-ID: <810a540e0802272357u7ec4440x32d1c9201531f86e@mail.gmail.com> On Mon, Feb 25, 2008 at 6:18 PM, Giles Bowkett wrote: > Hi - I've got a bunch of people using specs at a company. Everybody is > writing specs, but people are not really practicing BDD. As in, the > specs are there, but it doesn't go, write spec, write code, repeat. I > recently came across 8 failing specs checked into svn; I think the > plan was, I'll write the design as specs, and then implement the > entire design to match. Obviously that's not really the way it should > be. Here's my theory. Ranked, in ascending order of desirability: No tests Green suite, poor tests Red suite, poor tests Red suite, quality tests Green suite, quality tests A passing suite of high-quality tests gives you confidence that your system works well. If your tests are of low quality, then you will be confident, but your confidence will be misguided, and so you disrupt the balance of what the team knows vs what the team thinks it knows. The team has good values but does not understand the principles. A broken suite of low-quality tests sounds discouraging, but I believe it is a positive situation, because the team's understanding of the values and principles can grow at the same rate, rather than one dominating the other like a weed. Some teams and team members will be cynical, some will be eager but struggle. Most importantly though, they will be realistic. A broken suite of high-quality tests signifies a breakdown in process. Unlike before, the problem at this stage is no longer a matter of growth and understanding within the developers, it is managerial or political. They may be under tight deadlines and so have to let practices slip slightly, urged on by misinformed project managers. Removing political obstacles is difficult and requires skill in itself, but I think it's a tedious work compared to the personal growth that developers must experience. Willfully choosing not to write tests means you are stupid. Pat From lists at ruby-forum.com Thu Feb 28 04:54:10 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Thu, 28 Feb 2008 10:54:10 +0100 Subject: [rspec-users] rspec controller action list Message-ID: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> This action will list all the articles according to city. Please, can some one guide me through this spec. def list @articles = find_city.articles.paginate :all, :page => params[:page] , :order => "live_on DESC", :conditions => { :type_for => "blog" } end it "should list all articles" do get :list controller.stub!(:find_city) controller.should_receive(:find_city) controller.stub!(:articles) controller.should_receive(:articles) articles.should_receive(:paginate).and_return(@articles) response.should render_template('articles/list') end I get the following error when I run the spec. NameError in 'ArticlesController should list all articles' undefined local variable or method `articles' for # spec/controllers/articles_controller_spec.rb:212: spec/controllers/articles_controller_spec.rb:3: -- Posted via http://www.ruby-forum.com/. From mhennemeyer at googlemail.com Thu Feb 28 05:32:08 2008 From: mhennemeyer at googlemail.com (Matthias Hennemeyer) Date: Thu, 28 Feb 2008 11:32:08 +0100 Subject: [rspec-users] Problem with Plain Text Story Runner In-Reply-To: <193b74fd637be61803523a100f74d2fd@ruby-forum.com> References: <193b74fd637be61803523a100f74d2fd@ruby-forum.com> Message-ID: Hi Greg, maybe you did not append a colon to the word 'Story' in the plain text file. The runner want it this way: Story: Story Title ... Matthias Am 27.02.2008 um 15:14 schrieb Greg Gigon: > Hi Guys > I'm new to Ruby and BDD. > I'm having a problem while running my story in plain text. > This is the console OUTPUT. > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > story_mediator.rb:51:in > `current_scenario': undefined method `current_scenario' for > nil:NilClass > (NoMethodError) > from > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > story_mediator.rb:26:in > `create_given' > from > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > story_parser.rb:61:in > `create_given' > from > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > story_parser.rb:107:in > `given' > from > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > story_parser.rb:31:in > `process_line' > from > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > story_parser.rb:21:in > `parse' > from > /var/lib/gems/1.8/gems/rspec-1.1.3/lib/spec/story/runner/ > plain_text_story_runner.rb:35:in > `run' > > I was fallowing David Chelimsky article > http://blog.davidchelimsky.net/articles/2007/10/21/story-runner-in- > plain-english > I got RB file with Steps defined, RB file with runner and a text file > with Stories. > > Doing the same thing in Ruby code and not a plain text works fine. > Any suggestions ? > > Greg > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From glenn at aldenta.com Thu Feb 28 08:22:38 2008 From: glenn at aldenta.com (Glenn Ford) Date: Thu, 28 Feb 2008 08:22:38 -0500 Subject: [rspec-users] bad specs better than none? In-Reply-To: <20080228034503.GA5500@chello.nl> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <57c63afe0802252013y112de342hcb8c2097052e9229@mail.gmail.com> <20080228034503.GA5500@chello.nl> Message-ID: I have a similar perspective from my own personal experience. I am still quite the novice, but I'm as much of a novice in RSpec as I am in Ruby / RoR. Honestly, a lot of my specs in new sections end up having great coverage, but are full of real models and few of the "purist" BDD practices. Before I started with BDD I did a lot of reading so I feel that I have a good understanding of the goal, and I do have some specs with little database access and great implementation of the MVC "goodness" that RoR supports, but I simply can't always keep this up even when I want to. A lot of times if I'm writing some code for a challenging piece, it's challenging to me because I don't already know how to do it. I can write the basic "here's the setup, result.should eql(this_thing)" but I can't write any mocks/stubs/should_receives in the middle because at every step, I just honestly have no idea how it should work!! So I throw in real models and try to make it as real as possible, rather than as "pure" as possible. It's not until after I get things working that I even know what the solution should remotely look like. This is due to my inexperience that I have to hack around a lot before I figure out how to make things work. Unfortunately, I know this means I write code that is more complicated than it should be, but if I can't figure out a better way, I have to write something that still works! So while I have a lot of the knowledge behind the theory of good BDD practice, I can't always implement it even when I want to. My Ruby / RoR inexperience is what holds me back the most in that department. It's just something I have to cultivate really. Until then I'm happy with my green specs with excellent coverage that slam the database like crazy and take a long time and have few mocks/stubs/ should_receives. Glenn On Feb 27, 2008, at 10:45 PM, Kero wrote: >>> I also had to go into specs on a project I'm not working on, and >>> found >>> an unholy hive of database-accessing specs. It's disheartening. >>> Basically, it's cargo cult development practices - using the "best >>> practice" without actually understanding it. >> >> This is a really tough problem. The whole motivation for BDD was >> "people don't get TDD, so let's come up with some new ways to frame >> it >> so people get it." Now people don't get the new frame. In that >> respect >> we've made things twice as bad. > > What did you expect? Honestly? > You need to show people the Right way, otherwise they're unlikely to > figure > it out by themselves. But as the fortune cookies go: > "To make the right decision, one needs experience. > To gain experience, one needs to make the wrong decision." > > It is easier for me to explain this from the point of view of aikido: > I've been shown the right moves thousands of times. I can not even see > what sensei does, let alone reproduce it. I can not perceive the > balance, > the timing, the acceptance of an attacker and the reflection of his/ > her > energy to -ultimately- unbalance. How could I learn by trying even > tens > or hundreds of thousands of time? > After seven years, I'm still a puny beginner. And I need other people > to show me my mistakes. Again, again and again. > > To the original poster: yes, teach BDD. > Make sure they accept you as a teacher, > then teach, small steps at a time, by showing what is wrong. > when they figure out a solution by themselves, encourage them, accept > that solution (use it yourself). When they don't figure it out by > themselves (likely enough), show how you would do it. > And be prepared to repeat yourself. > > HtH, > Kero. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Feb 28 09:05:54 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Feb 2008 08:05:54 -0600 Subject: [rspec-users] rspec controller action list In-Reply-To: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> Message-ID: <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> On Thu, Feb 28, 2008 at 3:54 AM, Namrata Tiwari wrote: > This action will list all the articles according to city. Please, can > some one guide me through this spec. > > def list > @articles = find_city.articles.paginate :all, :page => params[:page] This line has what we call a train wreck. Don't be alarmed! It sounds dramatic, but that's a common term for a series of objects strung together with dots: find_city returns the first object, on which articles gets called. articles returns the second object, on which paginate is called. As soon as you have that second dot you have a train wreck. More below ... > , :order > => "live_on DESC", :conditions => { :type_for => "blog" } > end > > > it "should list all articles" do > get :list Here the action is called before setting up all the expectations. When using mocks and stubs, they have to be set up before the action. > controller.stub!(:find_city) Because the code has find_city returning an object, the stub has to return an object. Because the object returned by find_city gets sent paginate, it must be able to respond to that so it needs to either be the kind of object (an AssociationProxy) or a substitute. > controller.should_receive(:find_city) > controller.stub!(:articles) > controller.should_receive(:articles) > > articles.should_receive(:paginate).and_return(@articles) > response.should render_template('articles/list') > end Given the code above, the spec needs to do this: articles = mock("articles") articles.should_receive(:paginate). with(order => "live_on DESC", :conditions => { :type_for => "blog" }) controller.should_receive(:find_city).and_return(articles) get :list HTH, David > > I get the following error when I run the spec. > > NameError in 'ArticlesController should list all articles' > undefined local variable or method `articles' for > # llerExampleGroup::Subclass_1:0xa7b57dc> > spec/controllers/articles_controller_spec.rb:212: > spec/controllers/articles_controller_spec.rb:3: > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Feb 28 09:16:17 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Feb 2008 08:16:17 -0600 Subject: [rspec-users] bad specs better than none? In-Reply-To: References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <57c63afe0802252013y112de342hcb8c2097052e9229@mail.gmail.com> <20080228034503.GA5500@chello.nl> Message-ID: <57c63afe0802280616o5c17ce98o4f2f754ffa457513@mail.gmail.com> On Thu, Feb 28, 2008 at 7:22 AM, Glenn Ford wrote: > I have a similar perspective from my own personal experience. I am > still quite the novice, but I'm as much of a novice in RSpec as I am > in Ruby / RoR. Honestly, a lot of my specs in new sections end up > having great coverage, but are full of real models and few of the > "purist" BDD practices. Before I started with BDD I did a lot of > reading so I feel that I have a good understanding of the goal, and I > do have some specs with little database access and great > implementation of the MVC "goodness" that RoR supports, but I simply > can't always keep this up even when I want to. > > A lot of times if I'm writing some code for a challenging piece, it's > challenging to me because I don't already know how to do it. I can > write the basic "here's the setup, result.should eql(this_thing)" but > I can't write any mocks/stubs/should_receives in the middle because at > every step, I just honestly have no idea how it should work!! So I > throw in real models and try to make it as real as possible, rather > than as "pure" as possible. It's not until after I get things working > that I even know what the solution should remotely look like. This is > due to my inexperience that I have to hack around a lot before I > figure out how to make things work. Unfortunately, I know this means > I write code that is more complicated than it should be, but if I > can't figure out a better way, I have to write something that still > works! > > So while I have a lot of the knowledge behind the theory of good BDD > practice, I can't always implement it even when I want to. My Ruby / > RoR inexperience is what holds me back the most in that department. > It's just something I have to cultivate really. Until then I'm happy > with my green specs with excellent coverage that slam the database > like crazy and take a long time and have few mocks/stubs/ > should_receives. And you *should* be happy with that! The beauty of your situation is that even though you are admittedly new at this you are able to deliver code in which you have confidence. Clearly you recognize that you have some growth ahead, but you're posing much less risk for your clients. Additionally, as you do learn, because you have good coverage, you'll be in a good position to address design decisions that you later decide are poor based on new understanding. Naturally, since you are not 100% clear about what's going on you may be missing a step here and there. Test quality is every bit as important as test coverage, but good coverage is a better place to start than poor coverage. Keep up the good work! Cheers, David > > Glenn > > > > On Feb 27, 2008, at 10:45 PM, Kero wrote: > > >>> I also had to go into specs on a project I'm not working on, and > >>> found > >>> an unholy hive of database-accessing specs. It's disheartening. > >>> Basically, it's cargo cult development practices - using the "best > >>> practice" without actually understanding it. > >> > >> This is a really tough problem. The whole motivation for BDD was > >> "people don't get TDD, so let's come up with some new ways to frame > >> it > >> so people get it." Now people don't get the new frame. In that > >> respect > >> we've made things twice as bad. > > > > What did you expect? Honestly? > > You need to show people the Right way, otherwise they're unlikely to > > figure > > it out by themselves. But as the fortune cookies go: > > "To make the right decision, one needs experience. > > To gain experience, one needs to make the wrong decision." > > > > It is easier for me to explain this from the point of view of aikido: > > I've been shown the right moves thousands of times. I can not even see > > what sensei does, let alone reproduce it. I can not perceive the > > balance, > > the timing, the acceptance of an attacker and the reflection of his/ > > her > > energy to -ultimately- unbalance. How could I learn by trying even > > tens > > or hundreds of thousands of time? > > After seven years, I'm still a puny beginner. And I need other people > > to show me my mistakes. Again, again and again. > > > > To the original poster: yes, teach BDD. > > Make sure they accept you as a teacher, > > then teach, small steps at a time, by showing what is wrong. > > when they figure out a solution by themselves, encourage them, accept > > that solution (use it yourself). When they don't figure it out by > > themselves (likely enough), show how you would do it. > > And be prepared to repeat yourself. > > > > HtH, > > Kero. > > _______________________________________________ > > 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 Thu Feb 28 13:19:16 2008 From: lists at ruby-forum.com (Greg Gigon) Date: Thu, 28 Feb 2008 19:19:16 +0100 Subject: [rspec-users] Problem with Plain Text Story Runner In-Reply-To: References: <193b74fd637be61803523a100f74d2fd@ruby-forum.com> Message-ID: <3f2ddb4a7c4069e1c6249b6b1cc7e7d5@ruby-forum.com> Hey Mtthias Thank you for your help. The issue actually was that I didn't have spaces after colons.Like: Story:Blabla Now when I added the spaces it works fine. Cheers for that :) Greg Matthias Hennemeyer wrote: > Hi Greg, > maybe you did not append a colon to the word 'Story' in the plain > text file. > The runner want it this way: > Story: Story Title ... > Matthias > > Am 27.02.2008 um 15:14 schrieb Greg Gigon: -- Posted via http://www.ruby-forum.com/. From ed.howland at gmail.com Thu Feb 28 15:24:41 2008 From: ed.howland at gmail.com (Ed Howland) Date: Thu, 28 Feb 2008 14:24:41 -0600 Subject: [rspec-users] Webrat integration with Rspec and Rake tasks In-Reply-To: <3df642dd0802221502x27e0c408o8623f4f5b8f84176@mail.gmail.com> References: <3df642dd0802191032m63ddad28s53cfbdf8af660b3a@mail.gmail.com> <20EBC997-4643-47DA-88A0-FE854BB5BD1F@gmail.com> <3df642dd0802221502x27e0c408o8623f4f5b8f84176@mail.gmail.com> Message-ID: <3df642dd0802281224j1f9b3b3ai5be815bec927fdf2@mail.gmail.com> > > It is set in stories/helper.rb, but not working. ./script/generate > rspec creates a file with: > ENV['RAILS_ENV']="test" > > which is deprecated It should be: > RAILS_ENV="test" > > Changed that and it all worked fine. > > Ed which then promptly broke migrations and other Rakeish things. I don't have a solution that works for both yet, so I an commenting and un commenting this as needed. Ed -- Ed Howland http://greenprogrammer.blogspot.com From bryansray at gmail.com Thu Feb 28 15:59:58 2008 From: bryansray at gmail.com (Bryan Ray) Date: Thu, 28 Feb 2008 14:59:58 -0600 Subject: [rspec-users] Autotest file Message-ID: <29a0119e0802281259m252cb05r433bb2ca0a79163a@mail.gmail.com> I'm using rSpec 1.1.3 and ZenTest 3.9.1 and every time I run a test I get "All Tests Passed" ... perhaps I should just leave it that way? :p Anyways, I've attempted to construct my own ~/.autotest file and it's extremely basic, but for some reason whenever I make one test fail (on purpose) it still kicks off the :green hook rather than the :red one ... Anybody have any ideas? # My ~/.autotest file require 'autotest/redgreen' module Autotest::Growl def self.growl(title, msg, image="", priority=0, sticky="") system "growlnotify -n autotest #{sticky} --priority #{priority} --message '#{msg}' '#{title}'" end Autotest::add_hook :green do |at| growl "Tests Passed!", "All tests passed!" end Autotest::add_hook :red do |at| growl "Tests Failed!", "Tests have failed!" end end -- 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/20080228/12c2f08d/attachment.html From dchelimsky at gmail.com Thu Feb 28 16:12:00 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Feb 2008 15:12:00 -0600 Subject: [rspec-users] Autotest file In-Reply-To: <29a0119e0802281259m252cb05r433bb2ca0a79163a@mail.gmail.com> References: <29a0119e0802281259m252cb05r433bb2ca0a79163a@mail.gmail.com> Message-ID: <57c63afe0802281312g70c05290u91ad4e330ea0d05c@mail.gmail.com> On Thu, Feb 28, 2008 at 2:59 PM, Bryan Ray wrote: > I'm using rSpec 1.1.3 and ZenTest 3.9.1 and every time I run a test I get > "All Tests Passed" ... perhaps I should just leave it that way? :p > > Anyways, I've attempted to construct my own ~/.autotest file and it's > extremely basic, but for some reason whenever I make one test fail (on > purpose) it still kicks off the :green hook rather than the :red one ... This is already fixed in trunk: svn checkout http://rspec.rubyforge.org/svn/trunk or git clone git://gitorious.org/rspec/mainline.git If you're using git you have to clone the whole repo and copy over the plugins. > > Anybody have any ideas? > > # My ~/.autotest file > require 'autotest/redgreen' > > module Autotest::Growl > def self.growl(title, msg, image="", priority=0, sticky="") > system "growlnotify -n autotest #{sticky} --priority #{priority} > --message '#{msg}' '#{title}'" > end > > Autotest::add_hook :green do |at| > growl "Tests Passed!", "All tests passed!" > end > > Autotest::add_hook :red do |at| > growl "Tests Failed!", "Tests have failed!" > end > end > > -- > 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." > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bryansray at gmail.com Thu Feb 28 16:45:20 2008 From: bryansray at gmail.com (Bryan Ray) Date: Thu, 28 Feb 2008 15:45:20 -0600 Subject: [rspec-users] Autotest file In-Reply-To: <57c63afe0802281312g70c05290u91ad4e330ea0d05c@mail.gmail.com> References: <29a0119e0802281259m252cb05r433bb2ca0a79163a@mail.gmail.com> <57c63afe0802281312g70c05290u91ad4e330ea0d05c@mail.gmail.com> Message-ID: <29a0119e0802281345s4303e9b8yd7d4a236535e04dd@mail.gmail.com> Yup ... was just about to respond. A little more google finally turned up http://rspec.lighthouseapp.com/projects/5645/tickets/279-autotest-never-calls-the-red-hook Thanks for the quick reply, David. On Thu, Feb 28, 2008 at 3:12 PM, David Chelimsky wrote: > On Thu, Feb 28, 2008 at 2:59 PM, Bryan Ray wrote: > > I'm using rSpec 1.1.3 and ZenTest 3.9.1 and every time I run a test I > get > > "All Tests Passed" ... perhaps I should just leave it that way? :p > > > > Anyways, I've attempted to construct my own ~/.autotest file and it's > > extremely basic, but for some reason whenever I make one test fail (on > > purpose) it still kicks off the :green hook rather than the :red one ... > > This is already fixed in trunk: > > svn checkout http://rspec.rubyforge.org/svn/trunk > or > git clone git://gitorious.org/rspec/mainline.git > > If you're using git you have to clone the whole repo and copy over the > plugins. > > > > > Anybody have any ideas? > > > > # My ~/.autotest file > > require 'autotest/redgreen' > > > > module Autotest::Growl > > def self.growl(title, msg, image="", priority=0, sticky="") > > system "growlnotify -n autotest #{sticky} --priority #{priority} > > --message '#{msg}' '#{title}'" > > end > > > > Autotest::add_hook :green do |at| > > growl "Tests Passed!", "All tests passed!" > > end > > > > Autotest::add_hook :red do |at| > > growl "Tests Failed!", "Tests have failed!" > > end > > end > > > > -- > > 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." > > _______________________________________________ > > 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 > -- 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/20080228/29e27c65/attachment.html From rspec-users at kero.tmfweb.nl Thu Feb 28 23:18:06 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Fri, 29 Feb 2008 05:18:06 +0100 Subject: [rspec-users] New generated RSpec Video, demonstrating a GTK app Message-ID: <20080229041806.GB5500@chello.nl> Hi all, With some time spent last Tue on the nyc.rb hackfest, I have a second video today of my endeavours with RSpec and recordings. It shows a handful of When&Then steps, with the accompanying GTK2 GUI executing these steps. One nasty thing about Gtk (and virtually all other toolkits) is that they think they are all-important. You have to call Gtk.main, which only returns when the GUI is dead. Of course, my test is all-important here. The consequence is that I can not rely on the default exit hooks of rspec. we get: Thread.new { run_tests exit } Gtk::main where I need to register my own story runner, define the tests and run it: def run_tests narrator = Narrator.new({}, "here") sr = Spec::Story::Runner::ScenarioRunner.new story_r = Spec::Story::Runner::StoryRunner.new(sr) story_r.add_listener narrator Spec::Story::World.add_listener narrator story_r.instance_eval { define_tests } story_r.run_stories end where Narrator is my class with step_upcoming, step_succeeded, method_missing and then a few; where define_tests is a method that contains Story() { Scenario() { ... } } Note that I need to register my narrator _twice_ to get all methods called (bug? should I file a ticket?). If I use Spec::Story::Runner.register_listener narrator instead, the World / steps are executed, but the runner / scenario_started callbacks are not. Unexpectedly, I get a free PlainTextFormatter (wtf?) I have no qualms with a good formatter like PlainText, that frees me from redoing the work. But, when I try to register one by hand, in the way that seems to be done in rspec/lib/spec/story/runner.rb : Spec::Story::Runner.register_listener Spec::Runner::Formatter::Story::PlainTextFormatter.new({}, STDOUT) I get rspec/lib/spec/runner/formatter/base_text_formatter.rb:97:in `colour?': undefined method `colour' for {:colour=>false}:Hash (NoMethodError) which isn't neither too weird, nor too comforting. Any hints for a shortcut, before I fake option parsing (or decide I want the arguments from my own command-line, regardless)? And then of course, what you've been reading/waiting for: http://chmeee.dyndns.org/ruby/List%20tasks%20in%20a%20Gtk%20Tree.wmv (only 5.5 MB, including snippets of the code that generated it). mencoder does not really play nice and synchronization of audio+video has been tweaked by hand (that's not necessary when playing directly from running the story, of course; look at the clock in the bottom right and you'll understand), and it is still a mess near the end. So I'm still looking for alternative tools to do speech synthesis (sox refuses to play some of the shorter espeak wavfiles, I bet sox is right and espeak is wrong) and encoding video. Bye, Kero. From lists at ruby-forum.com Thu Feb 28 23:27:02 2008 From: lists at ruby-forum.com (Namrata Tiwari) Date: Fri, 29 Feb 2008 05:27:02 +0100 Subject: [rspec-users] rspec controller action list In-Reply-To: <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> Message-ID: <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> Thanks Mr David for your reply. This gives me a better understanding of so called train wreck. I am still facing problems with this spec. firstly - I think I need to put a colon before order(e.g. :order=> "live_on DESC") #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) get :list end but this gives me 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 rspec-users at kero.tmfweb.nl Thu Feb 28 23:30:33 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Fri, 29 Feb 2008 05:30:33 +0100 Subject: [rspec-users] bad specs better than none? In-Reply-To: <810a540e0802272357u7ec4440x32d1c9201531f86e@mail.gmail.com> References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <810a540e0802272357u7ec4440x32d1c9201531f86e@mail.gmail.com> Message-ID: <20080229043033.GC5500@chello.nl> > Here's my theory. You remind me of the four stages of learning > Ranked, in ascending order of desirability: > No tests > Green suite, poor tests Unconsciously Incompetent > Red suite, poor tests Consciously Incompetent > Red suite, quality tests Consciously Competent > Green suite, quality tests Unconsiously Competent where the fourth stage flows back into the first stage, either because you stop learning, get stuck ("vastgeroest" in Dutch), and cease to be competent, or because you pick up new, additional things, and therefor have to start at the first stage again. Bye, Kero. From siemenbaader at gmail.com Fri Feb 29 02:55:57 2008 From: siemenbaader at gmail.com (Siemen Baader) Date: Fri, 29 Feb 2008 08:55:57 +0100 Subject: [rspec-users] bad specs better than none? In-Reply-To: References: <2d81dedb0802251818p59d1c727l1e121736daf07366@mail.gmail.com> <57c63afe0802252013y112de342hcb8c2097052e9229@mail.gmail.com> <20080228034503.GA5500@chello.nl> Message-ID: On Thu, Feb 28, 2008 at 2:22 PM, Glenn Ford wrote: I agree with David - you are certainly on the right track. I also think you are doing the right thing when you write specs even if they seem not perfect to you at first attempt - once you have written the code you can evaluate why they could be better and then make your adjustments as you learn more. A lot of times if I'm writing some code for a challenging piece, it's > challenging to me because I don't already know how to do it. I can > write the basic "here's the setup, result.should eql(this_thing)" but > I can't write any mocks/stubs/should_receives in the middle because at > every step, I just honestly have no idea how it should work!! So I > throw in real models and try to make it as real as possible, rather > than as "pure" as possible. It's not until after I get things working > that I even know what the solution should remotely look like. This is > due to my inexperience that I have to hack around a lot before I > figure out how to make things work. Unfortunately, I know this means > I write code that is more complicated than it should be, but if I > can't figure out a better way, I have to write something that still > works! I also often find it hard to implement a new solution from scratch using the BDD / TDD test-first approach. Sometimes it works for me to make a very crude spike solution to figure out how this part of the program actually should work (often writing no automated tests at all). Once I have an idea of the outline I put the spike away and start implementing the real solution in the real codebase, writing tests first etc. Interestingly, it seems to me that the whole task actually _is_ accomplished quicker this way because I don't have to keep the production code clean & tested while experimenting and because I don't have to sit and figure out the design while writing the production code. As a gain experience I think there will be more solutions that I can implement without having to spike them before. -- Siemen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080229/bbef9a45/attachment-0001.html From bryansray at gmail.com Fri Feb 29 08:52:10 2008 From: bryansray at gmail.com (Bryan Ray) Date: Fri, 29 Feb 2008 07:52:10 -0600 Subject: [rspec-users] rspec controller action list In-Reply-To: <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> References: <36a1f08323bd82582ae8b5df7e4f4072@ruby-forum.com> <57c63afe0802280605o5f0be241r522961fd5e04c55a@mail.gmail.com> <1289886a79437bf85fc8ce94a55bc4ce@ruby-forum.com> Message-ID: <29a0119e0802290552i44369de8u5d6f77728115d184@mail.gmail.com> 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. Hope that helps, buddy. On Thu, Feb 28, 2008 at 10:27 PM, Namrata Tiwari wrote: > Thanks Mr David for your reply. This gives me a better understanding of > so called train wreck. I am still facing problems with this spec. > firstly - I think I need to put a colon before order(e.g. :order=> > "live_on DESC") > > #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) > get :list > end > > > but this gives me 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/. > _______________________________________________ > 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/20080229/f5d7e2b9/attachment.html From jaydonnell at yahoo.com Fri Feb 29 13:57:14 2008 From: jaydonnell at yahoo.com (Jay Donnell) Date: Fri, 29 Feb 2008 10:57:14 -0800 (PST) Subject: [rspec-users] running a specific describe block Message-ID: <169689.56966.qm@web56008.mail.re3.yahoo.com> I use a lot of nested describe blocks and am wondering if there is a way to run a specific describe block similar to the -e option for running specific examples. Jay ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From jaydonnell at yahoo.com Fri Feb 29 13:57:14 2008 From: jaydonnell at yahoo.com (Jay Donnell) Date: Fri, 29 Feb 2008 10:57:14 -0800 (PST) Subject: [rspec-users] running a specific describe block Message-ID: <169689.56966.qm@web56008.mail.re3.yahoo.com> I use a lot of nested describe blocks and am wondering if there is a way to run a specific describe block similar to the -e option for running specific examples. Jay ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From jed.hurt at gmail.com Fri Feb 29 14:08:36 2008 From: jed.hurt at gmail.com (Jed Hurt) Date: Fri, 29 Feb 2008 12:08:36 -0700 Subject: [rspec-users] Quiet Backtrace in RSpec In-Reply-To: <57c63afe0802210521x625ad9efg1c87a37f2c113cf8@mail.gmail.com> References: <8d961d900801190039x7c973fb3xad1052df557c2e45@mail.gmail.com> <57c63afe0802210521x625ad9efg1c87a37f2c113cf8@mail.gmail.com> Message-ID: 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? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080229/5b6768b7/attachment.html From dchelimsky at gmail.com Fri Feb 29 16:52:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Feb 2008 15:52:33 -0600 Subject: [rspec-users] Quiet Backtrace in RSpec In-Reply-To: References: <8d961d900801190039x7c973fb3xad1052df557c2e45@mail.gmail.com> <57c63afe0802210521x625ad9efg1c87a37f2c113cf8@mail.gmail.com> Message-ID: <57c63afe0802291352na6db27x99b501815383c30e@mail.gmail.com> 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 > From lists at ruby-forum.com Fri Feb 29 18:15:40 2008 From: lists at ruby-forum.com (Spencer Roan) Date: Sat, 1 Mar 2008 00:15:40 +0100 Subject: [rspec-users] how do i get color with autotest on XP? Message-ID: when i run "rake spec" i get color, if have --colour in spec.opts. when i run autotest the output isn't displayed(i can tell the tests have run thanks to snarl), unless i get rid of --colour. however, now the output is plain-jane white! adding require 'autotest/redgreen' to .autotest seems to have no effect. when i run "ruby -S script/spec -O spec/spec.opts spec/models/user_spec.rb(which is what is echoed when i run autotest), i also get color only if --colour is in spec.opts any thoughts would be appreciated XP sp2 ruby 1.8.6 rails 2.02 gems that i think are of relevance: diff-lcs 1.1.2 redgreen 1.2.2 rspec 1.1.3 ruby-snarl 0.0.8 win32console 1.0.8 ZenTest 3.9.1 plugins: (i'm not sure how to check versions for these, but they are the newest stable versions) rspec rspec_on_rails -- Posted via http://www.ruby-forum.com/. From dbitsolutions at gmail.com Fri Feb 29 18:33:17 2008 From: dbitsolutions at gmail.com (David Beckwith) Date: Fri, 29 Feb 2008 15:33:17 -0800 Subject: [rspec-users] outside-in = integration tests on views? Message-ID: <93ddac20802291533y167fcc58p4e1e2bbf017c39e7@mail.gmail.com> Hi, In the spirit of "outside-in" are given-when-then scenarios supposed to be integration tests of views? Or should we be accessing the model interfaces directly (not through a view)? Thanks, David :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080229/dc6b1660/attachment.html From dchelimsky at gmail.com Fri Feb 29 19:06:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 29 Feb 2008 18:06:03 -0600 Subject: [rspec-users] outside-in = integration tests on views? In-Reply-To: <93ddac20802291533y167fcc58p4e1e2bbf017c39e7@mail.gmail.com> References: <93ddac20802291533y167fcc58p4e1e2bbf017c39e7@mail.gmail.com> Message-ID: <57c63afe0802291606i322b68f1t1dbc3873fb573e4f@mail.gmail.com> On Fri, Feb 29, 2008 at 5:33 PM, David Beckwith wrote: > Hi, > > In the spirit of "outside-in" are given-when-then scenarios supposed to be > integration tests of views? Do you mean "through views?" - i.e. view down to the db? If so, that is one part of the picture. > Or should we be accessing the model interfaces > directly (not through a view)? Why is this an either/or question? I think it depends on the nature of the story. If the story is about transferring money from checking to savings, then the domain objects are fair game. If the story talks about an error message, or some sort of user experience, then go through the views. What I try to do when dealing with views, though, is keep things as high level and general as I can while respecting the requirements. For example, you're more likely to see "When I go to the list of employees" than "When I go to /employees." Or "When I enter David for Name" rather than "When I fill in the Name field with David." The reason is that "When I enter David for Name" can be talking about a web interface, a desktop interface, a batch job or a command line interface. If you think of :steps_for as a factory, because the step definitions are decoupled from the scenarios, you can use the same scenarios to drive steps that go through any of these different UIs, or no UIs at all. HTH, David > > Thanks, > David :) > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From luislavena at gmail.com Fri Feb 29 20:08:51 2008 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 29 Feb 2008 23:08:51 -0200 Subject: [rspec-users] how do i get color with autotest on XP? In-Reply-To: References: Message-ID: <71166b3b0802291708t52b6aac6v564faa4133e4d82b@mail.gmail.com> On Fri, Feb 29, 2008 at 9:15 PM, Spencer Roan wrote: > when i run "rake spec" i get color, if have --colour in spec.opts. > > when i run autotest the output isn't displayed(i can tell the tests have > run thanks to snarl), unless i get rid of --colour. however, now the > output is plain-jane white! > > adding require 'autotest/redgreen' to .autotest seems to have no effect. > > when i run "ruby -S script/spec -O spec/spec.opts > spec/models/user_spec.rb(which is what is echoed when i run autotest), i > also get color only if --colour is in spec.opts > > any thoughts would be appreciated > For the Windows console process and display correctly the color, special care should be taken from the normal ANSi escape code and redirected to some Win32API functions. Doing that, autotest is no longer capable of capturing the STDOUT/STDERR of the child process and thus, not displaying the result. I'm aware that win32console author is working on workaround this limitation, but no other news. HTH, -- Luis Lavena Multimedia systems - A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. Douglas Adams From lists at ruby-forum.com Fri Feb 29 22:15:22 2008 From: lists at ruby-forum.com (Spencer Roan) Date: Sat, 1 Mar 2008 04:15:22 +0100 Subject: [rspec-users] how do i get color with autotest on XP? In-Reply-To: <71166b3b0802291708t52b6aac6v564faa4133e4d82b@mail.gmail.com> References: <71166b3b0802291708t52b6aac6v564faa4133e4d82b@mail.gmail.com> Message-ID: <81d544a3ff8319219dfb3518d2aa3d61@ruby-forum.com> @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/.