From dchelimsky at gmail.com Fri Dec 1 04:33:45 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 1 Dec 2006 04:33:45 -0500 Subject: [rspec-users] view specs with partials In-Reply-To: References: <5CA33372-9938-4EDE-8615-871B9BB0A607@8thlight.com> <810a540e0611281540x5646455eu34082578f1b21d4d@mail.gmail.com> <57c63afe0611282235g62378b84l4168a35c46fc7413@mail.gmail.com> <57c63afe0611291605k34e90b5areb9332be15d16987@mail.gmail.com> Message-ID: <57c63afe0612010133l386f5a59ka02ec75a284e46fe@mail.gmail.com> On 11/30/06, Mathias Biilmann Christensen wrote: > Thanks a lot - that helped a great deal. > > I still seem to have problems with helper methods that are not > defined in a helper module. In my Application controller I have a > current_user method and then uses " helper_method :current_user" to > be make it usable for my views. Any way to stub that method in a > view test? (I suspect a way to do this would also solve Michael > Johnston's error_messages_for problem) By design, view specs do not include any controllers in your application. The point is to minimize coupling w/ other parts of your application. We offer the helpers because they are really part of the view infrastructure. Would it be unreasonable to add methods that you want in both your controllers and views to a helper that you include in the controller? It's backwards from what you're doing, but it would solve the problem without sacrificing the good separation that we've achieved. David > > Regards, > Mathias > > > On Nov 30, 2006, at 1:05 AM, David Chelimsky wrote: > > > On 11/29/06, Mathias Biilmann Christensen > biilmann.net> wrote: > >> Great to finally having view specs work with edge rails! > >> > >> To bad I can't actually use them, since I use helper methods in my > >> views. Has anybody gotten calls to helper methods to work in view > >> tests under Rails 1.2 RC1? > >> > >> Currently I get "undefined method `crumbs' for #<#: > >> 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs > >> (@var) %>) > >> > >> Hope there's a solution out there! > > > > There IS!!!!! Incomplete though they are, the specs are the best > > source of documentation for questions like this. Take a look at > > vendor/plugins/rspec/spec/view_spec_spec. It has the answer to your > > question. I'll give you the highlights, but check out the spec if > > you're unsure of anything: > > > > context "/some/template" do > > setup do > > render '/some/template', :helper => :some_other #_helper will > > get appended > > end > > ... > > end > > > > OR, if you need more than one: > > > > context "/some/template" do > > setup do > > render '/some/template', :helpers => > > [:one, :another, :yet_another] > > end > > ... > > end > > > > Cheers, > > David > > > >> > >> Regards, > >> Mathias > >> > >> > >> On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: > >> > >>> On 11/28/06, Micah Martin wrote: > >>>> That did the trick. Thanks Pat. > >>>> > >>>> > >>>> Micah Martin > >>>> > >>>> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > >>>> > >>>> Basically in the mean time, just do > >>>> render :partial => "controller_name/partial_name" > >>>> > >>>> So like if the partial is named "person" and it's under the > >>>> "people" > >>>> views dir, it'd be > >>>> render :partial => "people/person" > >>>> > >>>> That'll work until we get it fixed in the plugin. > >>> > >>> We got it fixed in the plugin. In trunk (rev 1174). > >>> > >>> 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 > >> > > _______________________________________________ > > 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 Fri Dec 1 04:37:12 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 1 Dec 2006 04:37:12 -0500 Subject: [rspec-users] response is null when using should_render_rjs In-Reply-To: References: <32743271-6B61-4B0D-B96C-A295BAE88A18@mac.com> Message-ID: <57c63afe0612010137q34c56f58i5d994da19a050d85@mail.gmail.com> On 11/30/06, Mathias Biilmann Christensen wrote: > And a response to my own question :) : > > I put this in the end of my view spec: > > module ViewSpecsHelper > def current_user > nil > end > end > > and then used render => 'controller/template', :helper => :view_specs Cool! Nice solution. David > > That worked - should be easy to use something similar to that to mock > error_messages_for as well > > Regards, > Mathias > > > > On Nov 30, 2006, at 10:37 AM, Mathias Biilmann Christensen wrote: > > Thanks a lot - that helped a great deal. > > > > I still seem to have problems with helper methods that are not > > defined in a helper module. In my Application controller I have a > > current_user method and then uses " helper_method :current_user" > > to be make it usable for my views. Any way to stub that method in > > a view test? (I suspect a way to do this would also solve Michael > > Johnston's error_messages_for problem) > > > > Regards, > > Mathias > > > > > > On Nov 30, 2006, at 1:05 AM, David Chelimsky wrote: > > > >> On 11/29/06, Mathias Biilmann Christensen >> biilmann.net> wrote: > >>> Great to finally having view specs work with edge rails! > >>> > >>> To bad I can't actually use them, since I use helper methods in my > >>> views. Has anybody gotten calls to helper methods to work in view > >>> tests under Rails 1.2 RC1? > >>> > >>> Currently I get "undefined method `crumbs' for #<#: > >>> 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs > >>> (@var) %>) > >>> > >>> Hope there's a solution out there! > >> > >> There IS!!!!! Incomplete though they are, the specs are the best > >> source of documentation for questions like this. Take a look at > >> vendor/plugins/rspec/spec/view_spec_spec. It has the answer to your > >> question. I'll give you the highlights, but check out the spec if > >> you're unsure of anything: > >> > >> context "/some/template" do > >> setup do > >> render '/some/template', :helper => :some_other #_helper will > >> get appended > >> end > >> ... > >> end > >> > >> OR, if you need more than one: > >> > >> context "/some/template" do > >> setup do > >> render '/some/template', :helpers => > >> [:one, :another, :yet_another] > >> end > >> ... > >> end > >> > >> Cheers, > >> David > >> > >>> > >>> Regards, > >>> Mathias > >>> > >>> > >>> On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: > >>> > >>>> On 11/28/06, Micah Martin wrote: > >>>>> That did the trick. Thanks Pat. > >>>>> > >>>>> > >>>>> Micah Martin > >>>>> > >>>>> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > >>>>> > >>>>> Basically in the mean time, just do > >>>>> render :partial => "controller_name/partial_name" > >>>>> > >>>>> So like if the partial is named "person" and it's under the > >>>>> "people" > >>>>> views dir, it'd be > >>>>> render :partial => "people/person" > >>>>> > >>>>> That'll work until we get it fixed in the plugin. > >>>> > >>>> We got it fixed in the plugin. In trunk (rev 1174). > >>>> > >>>> 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 > >>> > >> _______________________________________________ > >> 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 steve.tooke at gmail.com Fri Dec 1 07:18:16 2006 From: steve.tooke at gmail.com (Steve Tooke) Date: Fri, 1 Dec 2006 12:18:16 +0000 Subject: [rspec-users] Specifying lib classes in a Rails app Message-ID: <78d462040612010418n756c96a6ud1c18e9c83346272@mail.gmail.com> The rpsec-on-rails app defines a great structure for specifying all of the constituent parts of a rails app. Does anybody have any advice for where to put tests for lib code that you include to support your app, and how to fit it in to the rake:spec rake task. Cheers Steve From aslak.hellesoy at gmail.com Fri Dec 1 12:13:10 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 1 Dec 2006 18:13:10 +0100 Subject: [rspec-users] RSpec on JRuby on InfoQ Message-ID: <8d961d900612010913j34232925ke40dc0f00afd7e84@mail.gmail.com> http://www.infoq.com/news/2006/11/RSpecOnJRuby From aslak.hellesoy at gmail.com Fri Dec 1 12:49:05 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 1 Dec 2006 18:49:05 +0100 Subject: [rspec-users] RSpec on JRuby on InfoQ In-Reply-To: <8d961d900612010913j34232925ke40dc0f00afd7e84@mail.gmail.com> References: <8d961d900612010913j34232925ke40dc0f00afd7e84@mail.gmail.com> Message-ID: <8d961d900612010949x50160140i511f5c58bc3dbb9f@mail.gmail.com> And here is the full version: http://on-ruby.blogspot.com/2006/12/jruby-and-rspec-leftovers.html On 12/1/06, aslak hellesoy wrote: > http://www.infoq.com/news/2006/11/RSpecOnJRuby > From aslak.hellesoy at gmail.com Sat Dec 2 20:24:26 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 3 Dec 2006 02:24:26 +0100 Subject: [rspec-users] Watir reports with screenshots using RSpec and Win32::Screenshot Message-ID: <8d961d900612021724m758a49f7s8ee98986ff654cd4@mail.gmail.com> You can read all about it here: http://blog.aslakhellesoy.com/articles/2006/12/02/getting-screenshots-from-watir (Yes, this is my new blog wohoo) From jed.hurt at gmail.com Sat Dec 2 21:10:04 2006 From: jed.hurt at gmail.com (Jed Hurt) Date: Sat, 2 Dec 2006 19:10:04 -0700 Subject: [rspec-users] view specs with partials In-Reply-To: References: <5CA33372-9938-4EDE-8615-871B9BB0A607@8thlight.com> <810a540e0611281540x5646455eu34082578f1b21d4d@mail.gmail.com> <57c63afe0611282235g62378b84l4168a35c46fc7413@mail.gmail.com> Message-ID: OFF TOPIC: I couldn't help but notice that the helper you're using is "crumbs". Is this an implementation of breadcrumbs? I have been trying to think of some elegant ways to implement breadcrumbs in my app. Care to share a bit? On 11/29/06, Mathias Biilmann Christensen wrote: > Great to finally having view specs work with edge rails! > > To bad I can't actually use them, since I use helper methods in my > views. Has anybody gotten calls to helper methods to work in view > tests under Rails 1.2 RC1? > > Currently I get "undefined method `crumbs' for #<#: > 0x340ab40>" when the view is calling the crumbs helper (<%= crumbs > (@var) %>) > > Hope there's a solution out there! > > Regards, > Mathias > > > On Nov 29, 2006, at 7:35 AM, David Chelimsky wrote: > > > On 11/28/06, Micah Martin wrote: > >> That did the trick. Thanks Pat. > >> > >> > >> Micah Martin > >> > >> On Nov 28, 2006, at 5:40 PM, Pat Maddox wrote: > >> > >> Basically in the mean time, just do > >> render :partial => "controller_name/partial_name" > >> > >> So like if the partial is named "person" and it's under the "people" > >> views dir, it'd be > >> render :partial => "people/person" > >> > >> That'll work until we get it fixed in the plugin. > > > > We got it fixed in the plugin. In trunk (rev 1174). > > > > 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 > From aslak.hellesoy at gmail.com Sun Dec 3 13:41:32 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 3 Dec 2006 19:41:32 +0100 Subject: [rspec-users] [ANN] RSpec 0.7.4 released Message-ID: <8d961d900612031041n6fc41294x2ee4073b406f4f52@mail.gmail.com> Hi all, I released RSpec 0.7.4 yesterday, and by now the gems should have rsync'ed to all the mirrors. This release features a complete redesign of the reports generated with --format html. You can see some examples of it here: http://rspec.rubyforge.org/report.html http://rspec.rubyforge.org/tools/failing_examples.html As usual there are many bug fixes - mostly related to spec/rails. If you run into problems, please report bugs, patches or feature requests in the tracker at rubyforge: http://rubyforge.org/tracker/?group_id=797 Full release notes: http://rubyforge.org/frs/shownotes.php?release_id=8243 Cheers, Aslak From david at davelee.com.au Sun Dec 3 19:22:02 2006 From: david at davelee.com.au (David Lee) Date: Mon, 4 Dec 2006 11:22:02 +1100 Subject: [rspec-users] [ANN] RSpec 0.7.4 released In-Reply-To: <8d961d900612031041n6fc41294x2ee4073b406f4f52@mail.gmail.com> References: <8d961d900612031041n6fc41294x2ee4073b406f4f52@mail.gmail.com> Message-ID: <660A202E-5451-434B-960C-DCDA3E5ADFAB@davelee.com.au> Hi i noticed a typo in the default generated rails model spec violation FWIW thanks for the nice work! D On 04/12/2006, at 5:41 AM, aslak hellesoy wrote: > Hi all, > > I released RSpec 0.7.4 yesterday, and by now the gems should have > rsync'ed to all the mirrors. > > This release features a complete redesign of the reports generated > with --format html. > You can see some examples of it here: > http://rspec.rubyforge.org/report.html > http://rspec.rubyforge.org/tools/failing_examples.html > > As usual there are many bug fixes - mostly related to spec/rails. > > If you run into problems, please report bugs, patches or feature > requests in > the tracker at rubyforge: http://rubyforge.org/tracker/?group_id=797 > > Full release notes: http://rubyforge.org/frs/shownotes.php? > release_id=8243 > > Cheers, > Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Sun Dec 3 20:34:03 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 4 Dec 2006 02:34:03 +0100 Subject: [rspec-users] [ANN] RSpec 0.7.4 released In-Reply-To: <660A202E-5451-434B-960C-DCDA3E5ADFAB@davelee.com.au> References: <8d961d900612031041n6fc41294x2ee4073b406f4f52@mail.gmail.com> <660A202E-5451-434B-960C-DCDA3E5ADFAB@davelee.com.au> Message-ID: <8d961d900612031734x7195a196g4e6d5547560f6ab0@mail.gmail.com> On 12/4/06, David Lee wrote: > Hi > > i noticed a typo in the default generated rails model spec violation > FWIW > What's the typo and where is it? > thanks for the nice work! > > D > > > On 04/12/2006, at 5:41 AM, aslak hellesoy wrote: > > > Hi all, > > > > I released RSpec 0.7.4 yesterday, and by now the gems should have > > rsync'ed to all the mirrors. > > > > This release features a complete redesign of the reports generated > > with --format html. > > You can see some examples of it here: > > http://rspec.rubyforge.org/report.html > > http://rspec.rubyforge.org/tools/failing_examples.html > > > > As usual there are many bug fixes - mostly related to spec/rails. > > > > If you run into problems, please report bugs, patches or feature > > requests in > > the tracker at rubyforge: http://rubyforge.org/tracker/?group_id=797 > > > > Full release notes: http://rubyforge.org/frs/shownotes.php? > > release_id=8243 > > > > Cheers, > > 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 > From dchelimsky at gmail.com Sun Dec 3 20:44:02 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 3 Dec 2006 19:44:02 -0600 Subject: [rspec-users] [ANN] RSpec 0.7.4 released In-Reply-To: <8d961d900612031734x7195a196g4e6d5547560f6ab0@mail.gmail.com> References: <8d961d900612031041n6fc41294x2ee4073b406f4f52@mail.gmail.com> <660A202E-5451-434B-960C-DCDA3E5ADFAB@davelee.com.au> <8d961d900612031734x7195a196g4e6d5547560f6ab0@mail.gmail.com> Message-ID: <57c63afe0612031744v256e0707n7c7100937ee2ca0a@mail.gmail.com> On 12/3/06, aslak hellesoy wrote: > On 12/4/06, David Lee wrote: > > Hi > > > > i noticed a typo in the default generated rails model spec violation > > FWIW > > > > What's the typo and where is it? I was going to write the same question, but opened the file and it is quite obvious. I'll commit the fix w/ my next commit (working on some docs now). David, in the future, even for something small like this, please raise a bug w/ details. It shouldn't take any longer than an email and it helps us keep everything on the radar for prioritization. Thanks! Cheers, David > > > thanks for the nice work! > > > > D > > > > > > On 04/12/2006, at 5:41 AM, aslak hellesoy wrote: > > > > > Hi all, > > > > > > I released RSpec 0.7.4 yesterday, and by now the gems should have > > > rsync'ed to all the mirrors. > > > > > > This release features a complete redesign of the reports generated > > > with --format html. > > > You can see some examples of it here: > > > http://rspec.rubyforge.org/report.html > > > http://rspec.rubyforge.org/tools/failing_examples.html > > > > > > As usual there are many bug fixes - mostly related to spec/rails. > > > > > > If you run into problems, please report bugs, patches or feature > > > requests in > > > the tracker at rubyforge: http://rubyforge.org/tracker/?group_id=797 > > > > > > Full release notes: http://rubyforge.org/frs/shownotes.php? > > > release_id=8243 > > > > > > Cheers, > > > 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 Sun Dec 3 22:08:56 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 3 Dec 2006 21:08:56 -0600 Subject: [rspec-users] directory structure change Message-ID: <57c63afe0612031908t20b50051l661ab557c819425b@mail.gmail.com> IMPORTANT NOTE FOR THOSE OF YOU WHO CHECK OUT SOURCE FROM SUBVERSION AT SOURCEFORGE (the rest of you may press delete now.....) ======================================================== Hi all, Just a heads up that sometime on Monday the directory structure of RSpec is going to be changed in subversion. The goal is cleaner separation of various components, especially the rails plugin. I'll email a few minutes before the change with details about where to find what, and then immediately after the change to let you know that it's done. Cheers, David From david at davelee.com.au Mon Dec 4 00:07:42 2006 From: david at davelee.com.au (David Lee) Date: Mon, 4 Dec 2006 16:07:42 +1100 Subject: [rspec-users] [ANN] RSpec 0.7.4 released In-Reply-To: <57c63afe0612031744v256e0707n7c7100937ee2ca0a@mail.gmail.com> References: <8d961d900612031041n6fc41294x2ee4073b406f4f52@mail.gmail.com> <660A202E-5451-434B-960C-DCDA3E5ADFAB@davelee.com.au> <8d961d900612031734x7195a196g4e6d5547560f6ab0@mail.gmail.com> <57c63afe0612031744v256e0707n7c7100937ee2ca0a@mail.gmail.com> Message-ID: <8AD89C2F-CAB0-4C16-9BC2-89C118E1148B@davelee.com.au> sure thing cheers D On 04/12/2006, at 12:44 PM, David Chelimsky wrote: > On 12/3/06, aslak hellesoy wrote: >> On 12/4/06, David Lee wrote: >>> Hi >>> >>> i noticed a typo in the default generated rails model spec >>> violation >>> FWIW >>> >> >> What's the typo and where is it? > > I was going to write the same question, but opened the file and it is > quite obvious. > > I'll commit the fix w/ my next commit (working on some docs now). > > David, in the future, even for something small like this, please raise > a bug w/ details. It shouldn't take any longer than an email and it > helps us keep everything on the radar for prioritization. > > Thanks! > > Cheers, > David > > > >> >>> thanks for the nice work! >>> >>> D >>> >>> >>> On 04/12/2006, at 5:41 AM, aslak hellesoy wrote: >>> >>>> Hi all, >>>> >>>> I released RSpec 0.7.4 yesterday, and by now the gems should have >>>> rsync'ed to all the mirrors. >>>> >>>> This release features a complete redesign of the reports generated >>>> with --format html. >>>> You can see some examples of it here: >>>> http://rspec.rubyforge.org/report.html >>>> http://rspec.rubyforge.org/tools/failing_examples.html >>>> >>>> As usual there are many bug fixes - mostly related to spec/rails. >>>> >>>> If you run into problems, please report bugs, patches or feature >>>> requests in >>>> the tracker at rubyforge: http://rubyforge.org/tracker/? >>>> group_id=797 >>>> >>>> Full release notes: http://rubyforge.org/frs/shownotes.php? >>>> release_id=8243 >>>> >>>> Cheers, >>>> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cwdinfo at gmail.com Mon Dec 4 12:27:58 2006 From: cwdinfo at gmail.com (s.ross) Date: Mon, 4 Dec 2006 09:27:58 -0800 Subject: [rspec-users] should_be_different -- possible implementation Message-ID: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> There is an assert_difference helper for Test::Unit (you can read about it at http://blog.caboo.se/articles/2006/06/13/a-better- assert_difference and to some it should look familiar -- you know who you are :), so I took a shot at one for rSpec on Rails. class Object def should_be_different(method = nil, difference = nil) return self.should_not_eql(yield) if method.nil? before = self.send(method) yield return self.send(method).should_not_eql(before) if difference.nil? (self.send(method) - before).should_eql difference end end Usage: specify "should be able to create a new user" do Person.create(:name => 'joe') Person.should_be_different :count do Person.create(:name => 'bob') end end This has probably already been done, but I thought I'd put it out here for comment in case it hadn't. Note that if you omit the method, the objects are tested for equality (however the object defines it). If you include the method but omit the difference, then any amount difference is ok. Testing destroy might indicate using -1 for the difference to indicate that the count has gone down. My implementation works, but a more natural syntax would be: Person.count.should_be_different do blah end and: Person.count.should_be_different_by 1 do blah, blah end Comments? Steve From dchelimsky at gmail.com Mon Dec 4 12:36:10 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Dec 2006 11:36:10 -0600 Subject: [rspec-users] should_be_different -- possible implementation In-Reply-To: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> References: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> Message-ID: <57c63afe0612040936y3e3c7dax4323d39f0d956ec3@mail.gmail.com> On 12/4/06, s.ross wrote: > There is an assert_difference helper for Test::Unit (you can read > about it at http://blog.caboo.se/articles/2006/06/13/a-better- > assert_difference and to some it should look familiar -- you know who > you are :), so I took a shot at one for rSpec on Rails. We've already got this in 0.7.4. It's called assert_change, but it's the same functionality you're looking for: http://rspec.rubyforge.org/documentation/expectations.html Cheers, David > > > class Object > def should_be_different(method = nil, difference = nil) > return self.should_not_eql(yield) if method.nil? > > before = self.send(method) > yield > return self.send(method).should_not_eql(before) if > difference.nil? > (self.send(method) - before).should_eql difference > end > end > > > Usage: > > specify "should be able to create a new user" do > Person.create(:name => 'joe') > Person.should_be_different :count do > Person.create(:name => 'bob') > end > end > > This has probably already been done, but I thought I'd put it out > here for comment in case it hadn't. Note that if you omit the method, > the objects are tested for equality (however the object defines it). > If you include the method but omit the difference, then any amount > difference is ok. Testing destroy might indicate using -1 for the > difference to indicate that the count has gone down. > > My implementation works, but a more natural syntax would be: > > Person.count.should_be_different do > blah > end > > and: > > Person.count.should_be_different_by 1 do > blah, blah > end > > Comments? > > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Mon Dec 4 13:15:35 2006 From: cwdinfo at gmail.com (s.ross) Date: Mon, 4 Dec 2006 10:15:35 -0800 Subject: [rspec-users] Model Testings with Observers Message-ID: <583F977C-0659-49B4-A86F-9C0A69BF338B@gmail.com> I have a Rails model that has an observer. The function of the observer is to send an email when a particular state change occurs in the model. Because the template rendering code is not loaded when doing model testing, I've had to shut off the email functionality of the observer for testing. Is there a better way to handle this? Thanks From aslak.hellesoy at gmail.com Mon Dec 4 13:28:14 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 4 Dec 2006 19:28:14 +0100 Subject: [rspec-users] should_be_different -- possible implementation In-Reply-To: <57c63afe0612040936y3e3c7dax4323d39f0d956ec3@mail.gmail.com> References: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> <57c63afe0612040936y3e3c7dax4323d39f0d956ec3@mail.gmail.com> Message-ID: <8d961d900612041028t154083a5h46ca61e596f935a5@mail.gmail.com> On 12/4/06, David Chelimsky wrote: > On 12/4/06, s.ross wrote: > > There is an assert_difference helper for Test::Unit (you can read > > about it at http://blog.caboo.se/articles/2006/06/13/a-better- > > assert_difference and to some it should look familiar -- you know who > > you are :), so I took a shot at one for rSpec on Rails. > > We've already got this in 0.7.4. It's called assert_change, but it's > the same functionality you're looking for: > Typo: It's called should_change > http://rspec.rubyforge.org/documentation/expectations.html > > Cheers, > David > > > > > > > class Object > > def should_be_different(method = nil, difference = nil) > > return self.should_not_eql(yield) if method.nil? > > > > before = self.send(method) > > yield > > return self.send(method).should_not_eql(before) if > > difference.nil? > > (self.send(method) - before).should_eql difference > > end > > end > > > > > > Usage: > > > > specify "should be able to create a new user" do > > Person.create(:name => 'joe') > > Person.should_be_different :count do > > Person.create(:name => 'bob') > > end > > end > > > > This has probably already been done, but I thought I'd put it out > > here for comment in case it hadn't. Note that if you omit the method, > > the objects are tested for equality (however the object defines it). > > If you include the method but omit the difference, then any amount > > difference is ok. Testing destroy might indicate using -1 for the > > difference to indicate that the count has gone down. > > > > My implementation works, but a more natural syntax would be: > > > > Person.count.should_be_different do > > blah > > end > > > > and: > > > > Person.count.should_be_different_by 1 do > > blah, blah > > end > > > > Comments? > > > > 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 dchelimsky at gmail.com Mon Dec 4 13:33:57 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Dec 2006 12:33:57 -0600 Subject: [rspec-users] should_be_different -- possible implementation In-Reply-To: <8d961d900612041028t154083a5h46ca61e596f935a5@mail.gmail.com> References: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> <57c63afe0612040936y3e3c7dax4323d39f0d956ec3@mail.gmail.com> <8d961d900612041028t154083a5h46ca61e596f935a5@mail.gmail.com> Message-ID: <57c63afe0612041033m6df2c67fm2042328cc90c660@mail.gmail.com> On 12/4/06, aslak hellesoy wrote: > On 12/4/06, David Chelimsky wrote: > > On 12/4/06, s.ross wrote: > > > There is an assert_difference helper for Test::Unit (you can read > > > about it at http://blog.caboo.se/articles/2006/06/13/a-better- > > > assert_difference and to some it should look familiar -- you know who > > > you are :), so I took a shot at one for rSpec on Rails. > > > > We've already got this in 0.7.4. It's called assert_change, but it's > > the same functionality you're looking for: > > > > Typo: It's called should_change LOL I got half way there. > > > http://rspec.rubyforge.org/documentation/expectations.html > > > > Cheers, > > David > > > > > > > > > > > class Object > > > def should_be_different(method = nil, difference = nil) > > > return self.should_not_eql(yield) if method.nil? > > > > > > before = self.send(method) > > > yield > > > return self.send(method).should_not_eql(before) if > > > difference.nil? > > > (self.send(method) - before).should_eql difference > > > end > > > end > > > > > > > > > Usage: > > > > > > specify "should be able to create a new user" do > > > Person.create(:name => 'joe') > > > Person.should_be_different :count do > > > Person.create(:name => 'bob') > > > end > > > end > > > > > > This has probably already been done, but I thought I'd put it out > > > here for comment in case it hadn't. Note that if you omit the method, > > > the objects are tested for equality (however the object defines it). > > > If you include the method but omit the difference, then any amount > > > difference is ok. Testing destroy might indicate using -1 for the > > > difference to indicate that the count has gone down. > > > > > > My implementation works, but a more natural syntax would be: > > > > > > Person.count.should_be_different do > > > blah > > > end > > > > > > and: > > > > > > Person.count.should_be_different_by 1 do > > > blah, blah > > > end > > > > > > Comments? > > > > > > 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Dec 4 13:44:42 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 4 Dec 2006 19:44:42 +0100 Subject: [rspec-users] Model Testings with Observers In-Reply-To: <583F977C-0659-49B4-A86F-9C0A69BF338B@gmail.com> References: <583F977C-0659-49B4-A86F-9C0A69BF338B@gmail.com> Message-ID: <8d961d900612041044w5c2b2d05r10f9ea6fbc729cba@mail.gmail.com> On 12/4/06, s.ross wrote: > I have a Rails model that has an observer. The function of the > observer is to send an email when a particular state change occurs in > the model. Because the template rendering code is not loaded when > doing model testing, I've had to shut off the email functionality of > the observer for testing. > > Is there a better way to handle this? > Submit an RFE to Rubyforge with some code describing how you would like it to work. Aslak > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Mon Dec 4 13:51:34 2006 From: cwdinfo at gmail.com (s.ross) Date: Mon, 4 Dec 2006 10:51:34 -0800 Subject: [rspec-users] should_be_different -- possible implementation In-Reply-To: <57c63afe0612041033m6df2c67fm2042328cc90c660@mail.gmail.com> References: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> <57c63afe0612040936y3e3c7dax4323d39f0d956ec3@mail.gmail.com> <8d961d900612041028t154083a5h46ca61e596f935a5@mail.gmail.com> <57c63afe0612041033m6df2c67fm2042328cc90c660@mail.gmail.com> Message-ID: <0E961C6E-AA5E-4854-A8B6-AC8344DD425C@gmail.com> Did the syntax discussion ever get settled. The signature is should_change(receiver, message) but there were discussions in this thread: http://rubyforge.org/pipermail/rspec-devel/2006-November/001251.html That discussed lots of cool syntactic sugar. What was settled upon? Person.should_change :count do Person.create(:name => 'ozzy osbourne') end How do you specify by how much? Thx On Dec 4, 2006, at 10:33 AM, David Chelimsky wrote: > On 12/4/06, aslak hellesoy wrote: >> On 12/4/06, David Chelimsky wrote: >>> On 12/4/06, s.ross wrote: >>>> There is an assert_difference helper for Test::Unit (you can read >>>> about it at http://blog.caboo.se/articles/2006/06/13/a-better- >>>> assert_difference and to some it should look familiar -- you >>>> know who >>>> you are :), so I took a shot at one for rSpec on Rails. >>> >>> We've already got this in 0.7.4. It's called assert_change, but it's >>> the same functionality you're looking for: >>> >> >> Typo: It's called should_change > > LOL > > I got half way there. > > >> >>> http://rspec.rubyforge.org/documentation/expectations.html >>> >>> Cheers, >>> David >>> >>>> >>>> >>>> class Object >>>> def should_be_different(method = nil, difference = nil) >>>> return self.should_not_eql(yield) if method.nil? >>>> >>>> before = self.send(method) >>>> yield >>>> return self.send(method).should_not_eql(before) if >>>> difference.nil? >>>> (self.send(method) - before).should_eql difference >>>> end >>>> end >>>> >>>> >>>> Usage: >>>> >>>> specify "should be able to create a new user" do >>>> Person.create(:name => 'joe') >>>> Person.should_be_different :count do >>>> Person.create(:name => 'bob') >>>> end >>>> end >>>> >>>> This has probably already been done, but I thought I'd put it out >>>> here for comment in case it hadn't. Note that if you omit the >>>> method, >>>> the objects are tested for equality (however the object defines >>>> it). >>>> If you include the method but omit the difference, then any amount >>>> difference is ok. Testing destroy might indicate using -1 for the >>>> difference to indicate that the count has gone down. >>>> >>>> My implementation works, but a more natural syntax would be: >>>> >>>> Person.count.should_be_different do >>>> blah >>>> end >>>> >>>> and: >>>> >>>> Person.count.should_be_different_by 1 do >>>> blah, blah >>>> end >>>> >>>> Comments? >>>> >>>> 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 >>> >> _______________________________________________ >> 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 Dec 4 14:02:05 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Dec 2006 13:02:05 -0600 Subject: [rspec-users] should_be_different -- possible implementation In-Reply-To: <0E961C6E-AA5E-4854-A8B6-AC8344DD425C@gmail.com> References: <4A0812CD-48AF-43CC-B91F-5AD721998539@gmail.com> <57c63afe0612040936y3e3c7dax4323d39f0d956ec3@mail.gmail.com> <8d961d900612041028t154083a5h46ca61e596f935a5@mail.gmail.com> <57c63afe0612041033m6df2c67fm2042328cc90c660@mail.gmail.com> <0E961C6E-AA5E-4854-A8B6-AC8344DD425C@gmail.com> Message-ID: <57c63afe0612041102y37533761qf0f7a9fb45efa4d5@mail.gmail.com> On 12/4/06, s.ross wrote: > Did the syntax discussion ever get settled. http://rspec.rubyforge.org/documentation/expectations.html > The signature is > should_change(receiver, message) but there were discussions in this > thread: > > http://rubyforge.org/pipermail/rspec-devel/2006-November/001251.html > > That discussed lots of cool syntactic sugar. What was settled upon? > > Person.should_change :count do > Person.create(:name => 'ozzy osbourne') > end > > How do you specify by how much? > > Thx > > > On Dec 4, 2006, at 10:33 AM, David Chelimsky wrote: > > > On 12/4/06, aslak hellesoy wrote: > >> On 12/4/06, David Chelimsky wrote: > >>> On 12/4/06, s.ross wrote: > >>>> There is an assert_difference helper for Test::Unit (you can read > >>>> about it at http://blog.caboo.se/articles/2006/06/13/a-better- > >>>> assert_difference and to some it should look familiar -- you > >>>> know who > >>>> you are :), so I took a shot at one for rSpec on Rails. > >>> > >>> We've already got this in 0.7.4. It's called assert_change, but it's > >>> the same functionality you're looking for: > >>> > >> > >> Typo: It's called should_change > > > > LOL > > > > I got half way there. > > > > > >> > >>> http://rspec.rubyforge.org/documentation/expectations.html > >>> > >>> Cheers, > >>> David > >>> > >>>> > >>>> > >>>> class Object > >>>> def should_be_different(method = nil, difference = nil) > >>>> return self.should_not_eql(yield) if method.nil? > >>>> > >>>> before = self.send(method) > >>>> yield > >>>> return self.send(method).should_not_eql(before) if > >>>> difference.nil? > >>>> (self.send(method) - before).should_eql difference > >>>> end > >>>> end > >>>> > >>>> > >>>> Usage: > >>>> > >>>> specify "should be able to create a new user" do > >>>> Person.create(:name => 'joe') > >>>> Person.should_be_different :count do > >>>> Person.create(:name => 'bob') > >>>> end > >>>> end > >>>> > >>>> This has probably already been done, but I thought I'd put it out > >>>> here for comment in case it hadn't. Note that if you omit the > >>>> method, > >>>> the objects are tested for equality (however the object defines > >>>> it). > >>>> If you include the method but omit the difference, then any amount > >>>> difference is ok. Testing destroy might indicate using -1 for the > >>>> difference to indicate that the count has gone down. > >>>> > >>>> My implementation works, but a more natural syntax would be: > >>>> > >>>> Person.count.should_be_different do > >>>> blah > >>>> end > >>>> > >>>> and: > >>>> > >>>> Person.count.should_be_different_by 1 do > >>>> blah, blah > >>>> end > >>>> > >>>> Comments? > >>>> > >>>> 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 > >>> > >> _______________________________________________ > >> 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 philipreedtech at gmail.com Mon Dec 4 15:24:52 2006 From: philipreedtech at gmail.com (philip reed) Date: Mon, 4 Dec 2006 15:24:52 -0500 Subject: [rspec-users] rspec tutorial - "one item" should equal "one item" Message-ID: Apologies in advance if this is a Ruby-ignorant question. I'm working my way through the tutorial, and I made it to page 3, where I found a discrepancy. In the 5th code block, preceded by "What's the simplest thing we can add to meet all of the current expectations?" I add the trivial return value to the top method as shown. Now the stack is supposed to be returning "one item", but instead of passing the test as show in the tutorial, I get: 1) 'A stack with one item should return top when you send it 'top'' FAILED "one item" should equal "one item" ./stack_spec.rb:28: Finished in 0.0 seconds 3 specifications, 1 failure I would guess this is some sort of issue about equivalence of two instances versus having the same instance in Ruby. Am I right? At any rate, is this behavior that's changed since the tutorial, or do I need to look harder in my tutorial code to make sure I didn't implement anything wrong? I can post a snapshot of the code if needed. Regards, Philip -- Philip Reed, Web developer http://philipreedtech.com Web. Made simple. From dchelimsky at gmail.com Mon Dec 4 15:44:31 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 4 Dec 2006 14:44:31 -0600 Subject: [rspec-users] rspec tutorial - "one item" should equal "one item" In-Reply-To: References: Message-ID: <57c63afe0612041244gc8a13efx3bb5a7de82a9e445@mail.gmail.com> On 12/4/06, philip reed wrote: > Apologies in advance if this is a Ruby-ignorant question. > > I'm working my way through the tutorial, and I made it to page 3, > where I found a discrepancy. In the 5th code block, preceded by > "What's the simplest thing we can add to meet all of the current > expectations?" I add the trivial return value to the top method as > shown. Now the stack is supposed to be returning "one item", but > instead of passing the test as show in the tutorial, I get: > > 1) > 'A stack with one item should return top when you send it 'top'' FAILED > "one item" should equal "one item" > ./stack_spec.rb:28: > > Finished in 0.0 seconds > > 3 specifications, 1 failure > > > > I would guess this is some sort of issue about equivalence of two > instances versus having the same instance in Ruby. Am I right? Yep - the tutorial is outdated. Use should == instead. I'll update the tutorial. Thanks, David > At > any rate, is this behavior that's changed since the tutorial, or do I > need to look harder in my tutorial code to make sure I didn't > implement anything wrong? > > I can post a snapshot of the code if needed. > > Regards, > > Philip > -- > Philip Reed, Web developer > > http://philipreedtech.com > > Web. Made simple. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Dec 5 10:33:29 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 5 Dec 2006 09:33:29 -0600 Subject: [rspec-users] new directory structure in svn Message-ID: <57c63afe0612050733o1db36ebej720e9b8c02ea4d89@mail.gmail.com> NOTE - this only applies to those who are checking out source or downloading the rspec_on_rails plugin from trunk. Hi All, The directory structure change is finished. The new location for the rspec core is: svn://rubyforge.org/var/svn/rspec/trunk/rspec The new location for the rspec_on_rails plugin is: svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails If you're a contributor, I'd recommend blowing away your local copy of the trunk and checking it out anew. You'll do your work on rspec core in the trunk/rspec, and the rails plugin in trunk/rspec_on_rails. Please be sure to run rake pre_commit from the root before committing (if your a committer) or submitting patches. Thanks, David From allan.m.miller at gmail.com Thu Dec 7 03:35:03 2006 From: allan.m.miller at gmail.com (allan miller) Date: Thu, 7 Dec 2006 00:35:03 -0800 Subject: [rspec-users] Newbie Error Running specs Message-ID: I'm new to rspec. I just installed these: rspec (0.7.4) RSpec-0.7.4 (r1201) (rspec gem) rspec_on_rails .3 plugin (on vendor/plugin) I've set up a simple spec - spec/library/test_spec.rb: require File.dirname(__FILE__) + '/../spec_helper' context "test context" do setup do #nothing end specify "nothing to specify" do #nothing end end When I run this spec as follows: spec spec/library/test_spec.rb (or any spec for that matter), I get the following error: $> spec spec/library/test_spec.rb ./spec/library/../../vendor/plugins/rspec_on_rails/lib/rspec_on_rails.rb:38:in `run': You have a nil object when you didn't expect it! (NoMethodError) You might have expected an instance of Array. The error occured while evaluating nil.each from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/context_runner.rb:23:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/context_runner.rb:22:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/command_line.rb:26:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/bin/spec:4 from /usr/local/bin/spec:18 I don't have any idea what is causing this, or how to fix it. Any suggestions would be greatly appreciated. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061207/1d708751/attachment.html From steve.tooke at gmail.com Thu Dec 7 04:32:05 2006 From: steve.tooke at gmail.com (Steve Tooke) Date: Thu, 7 Dec 2006 09:32:05 +0000 Subject: [rspec-users] Newbie Error Running specs In-Reply-To: References: Message-ID: <78d462040612070132h3b1fcdbaq7aa67c52dfcf723b@mail.gmail.com> I tried recreating this outside of the rails environment, so just a spec file like this test_spec.rb - context "test context" do setup do #nothing end specify "nothing to specify" do #nothing end end and running that with spec it works fine. Your rails plugin version should always match the gem version you have installed, so it may be worth upgrading the plugin and see if that fixes your problem? Steve On 12/7/06, allan miller wrote: > I'm new to rspec. I just installed these: > > rspec (0.7.4) RSpec-0.7.4 (r1201) (rspec gem) > rspec_on_rails .3 plugin (on vendor/plugin) From aslak.hellesoy at gmail.com Thu Dec 7 08:22:10 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 7 Dec 2006 14:22:10 +0100 Subject: [rspec-users] Newbie Error Running specs In-Reply-To: References: Message-ID: <8d961d900612070522l4e8f17ebldfc74299183cf9a@mail.gmail.com> > rspec (0.7.4) RSpec-0.7.4 (r1201) (rspec gem) > rspec_on_rails .3 plugin (on vendor/plugin) What exactly did you mean with "rspec_on_rails .3 plugin"? Aslak From allan.m.miller at gmail.com Thu Dec 7 16:11:30 2006 From: allan.m.miller at gmail.com (allan miller) Date: Thu, 7 Dec 2006 13:11:30 -0800 Subject: [rspec-users] Newbie Error Running specs Message-ID: >>* rspec (0.7.4) RSpec-0.7.4 (r1201) (rspec gem) *>*> rspec_on_rails .3 plugin (on vendor/plugin) * >What exactly did you mean with "rspec_on_rails .3 plugin"? >Aslak You were right, it was a version mismatch between rspec and the rspec_on_rails plugin I was using. Once I uninstalled rspec, removed the spec directory, cleared out plugins and generators under vendor, and obtained and carried out the following from Keith, it all worked: >$ sudo gem install rspec >(Should automatically upgrade to 0.7.4) >$ cd ${RAILS_APP} >$ ./script/plugin install --force svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_4/vendor/rspec_on_rails/vendor/plugins/rspec >(I think you need the --force switch to overwrite the 0.7.2 plugin with 0.7.4) Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061207/f8ba6bce/attachment.html From brixen at gmail.com Thu Dec 7 19:33:06 2006 From: brixen at gmail.com (brian ford) Date: Thu, 7 Dec 2006 16:33:06 -0800 Subject: [rspec-users] UJS plugin incompatible with RSpec? Message-ID: <8b80ba590612071633p6477768bvd0bf075d1db2f1ea@mail.gmail.com> Hi all, Anyone using UJS with RSpec? I have the following view spec: ---- edit_spec.rb context "accounts/edit" do fixtures :users setup do assigns[:user] = users(:consumer) end specify "should display the user info to edit" do render '/accounts/edit' end end ---- end that causes this exception: ---- exception ActionView::TemplateError in 'accounts/edit should display the user info to edit' undefined method `set_default_external!' for #<#:0x362ed98> On line #3 of app/views/accounts/edit.rhtml 1:
2:

Update user information

3: <%= form_tag account_url(@user), :method => :put %> 4: <%= render :partial => 'user' %> /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/expectations/sugar.rb:13:in `call' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/expectations/sugar.rb:13:in `_method_missing' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/expectations/sugar.rb:9:in `method_missing' #{RAILS_ROOT}/vendor/plugins/unobtrusive_javascript/lib/tag_helper_patches.rb:17:in `tag_options' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb:14:in `tag' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb:47:in `form_tag' #{RAILS_ROOT}/app/views//accounts/edit.rhtml:3:in `_run_rhtml_47app47views47accounts47edit46rhtml' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:328:in `compile_and_render_template' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:303:in `render_template' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:263:in `render_file' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:786:in `render_file' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:724:in `render_with_no_layout' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in `render_without_benchmark' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in `render' /opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in `render' /Users/brian/devel/deluxe/TRY-ujs-fix/vendor/plugins/rspec/lib/spec/rails/context/view.rb:74:in `render' spec/views/accounts/edit_spec.rb:11 /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/specification.rb:55:in `execute_spec' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/specification.rb:30:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/context.rb:45:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/context.rb:44:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/context_runner.rb:23:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/context_runner.rb:22:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/command_line.rb:26:in `run' /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/bin/spec:4 ---- end RSpec and rspec_on_rails are 0.7.4. UJS is installed from http://source.ujs4rails.com/current/unobtrusive_javascript. The same error happens regardless of whether I use form_for or form_tag. It renders fine from a normal request. TIA, Brian From jchris at mfdz.com Fri Dec 8 04:26:47 2006 From: jchris at mfdz.com (Chris Anderson) Date: Fri, 8 Dec 2006 01:26:47 -0800 Subject: [rspec-users] RSpec impressions Message-ID: After a long week agonizing over a scheduling library, and then specing it out rather quickly, I've got some work I'm pretty happy with. As a contrast to Test::Unit, I like the way RSpec spreads my attention around the codebase while I concentrate on implementing specific behaviours. In Test::Unit, I tend to write tests around the private methods of the object under test. I enjoyed thinking about the library through its public API. A few months ago, I made an attempt at writing this library with Test::Unit, and results were nigh unrefactorable. Writing from scratch with RSpec gave me a faster library, in less time, with less code, while worrying less about code duplication. With RSpec, I build up behaviour, a little at a time, filling in the methods only when I need to. More taste, less filling. The full length of my ramblings are posted on the blog: http://jchris.mfdz.com/code/2006/12/rspec_and_recurring__schedule -- Chris Anderson http://jchris.mfdz.com From jeremy.burks at gmail.com Fri Dec 8 11:03:29 2006 From: jeremy.burks at gmail.com (Jeremy Burks) Date: Fri, 8 Dec 2006 10:03:29 -0600 Subject: [rspec-users] verifying the assignment to flash Message-ID: Hello, I apologize if this has been answered before. Is it possible to verify an assignment to the flash in your controller specs? I want to verify this in an action: flash.now[:error] = "an error message" Thanks for the great project. jeremy From hughes.james at gmail.com Fri Dec 8 17:19:48 2006 From: hughes.james at gmail.com (James Hughes) Date: Fri, 8 Dec 2006 14:19:48 -0800 Subject: [rspec-users] Specifying lib classes in a Rails app In-Reply-To: <78d462040612010418n756c96a6ud1c18e9c83346272@mail.gmail.com> References: <78d462040612010418n756c96a6ud1c18e9c83346272@mail.gmail.com> Message-ID: <765a2c230612081419h40854865x37b5ca52068cb4f9@mail.gmail.com> On 12/1/06, Steve Tooke wrote: > The rpsec-on-rails app defines a great structure for specifying all of > the constituent parts of a rails app. Does anybody have any advice for > where to put tests for lib code that you include to support your app, > and how to fit it in to the rake:spec rake task. > I'm bumping this in the hopes that there's something to say on it. I'm currently doing this and it means a restart of the rails_spec_server whenever you change the lib file. James From adamjroth at gmail.com Mon Dec 11 02:57:01 2006 From: adamjroth at gmail.com (Adam Roth) Date: Mon, 11 Dec 2006 01:57:01 -0600 Subject: [rspec-users] FAILED: "test" should equal "test" - what? Message-ID: <390fc99d0612102357v58a818b5l5da90d77d1611a81@mail.gmail.com> I'm trying out rspec_on_rails with a very simple test: ... specify "product name should be 'test'" do Product.find( :all ).first.name.should_equal 'test' end ... with this fixture: first: id: 1 name: test When I run it: .F 1) 'Given a generated product_spec.rb with fixtures loaded product name should be test' FAILED "test" should equal "test" ./spec/models/product_spec.rb:12: Finished in 0.015563 seconds 2 specifications, 1 failure rake aborted! ------------------------- "test" should equal "test", well, it does. Why is this failing? (Installed rspec gem, installed 0_7_4 of rspec on rails plugin) Thanks Adam -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061211/7b040b3a/attachment-0001.html From aslak.hellesoy at gmail.com Mon Dec 11 03:35:43 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 11 Dec 2006 09:35:43 +0100 Subject: [rspec-users] FAILED: "test" should equal "test" - what? In-Reply-To: <390fc99d0612102357v58a818b5l5da90d77d1611a81@mail.gmail.com> References: <390fc99d0612102357v58a818b5l5da90d77d1611a81@mail.gmail.com> Message-ID: <8d961d900612110035v57e11e4bia4af197ac949ada5@mail.gmail.com> On 12/11/06, Adam Roth wrote: > I'm trying out rspec_on_rails with a very simple test: > > ... > specify "product name should be 'test'" do > Product.find( :all ).first.name.should_equal 'test' > end > ... > > with this fixture: > > first: > id: 1 > name: test > > When I run it: > > .F > > 1) > 'Given a generated product_spec.rb with fixtures loaded product name should > be test' FAILED > "test" should equal "test" > ./spec/models/product_spec.rb:12: > > Finished in 0.015563 seconds > > 2 specifications, 1 failure > rake aborted! > > ------------------------- > > "test" should equal "test", well, it does. Why is this failing? Because "test" is not *equal* to "test" - according to Ruby. Use should_eql or should == instead. http://rspec.rubyforge.org/documentation/expectations.html > > (Installed rspec gem, installed 0_7_4 of rspec on rails plugin) > > > Thanks > Adam > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From bryan at osesm.com Tue Dec 12 13:31:25 2006 From: bryan at osesm.com (Bryan Liles) Date: Tue, 12 Dec 2006 13:31:25 -0500 Subject: [rspec-users] rpec 0.7.4/ rails 1.2rc1 troubles Message-ID: <023948F8-04A4-437B-A626-9359F93654C0@osesm.com> I believe that I have followed these directions exactly: http:// rspec.rubyforge.org/documentation/rails/install.html My new spec tests work, but my old Test::Unit test don't produce any output. The only clue I have anything is happening at all are these messages in log/test.log: Spec::Rails::HelperEvalContextController: missing default helper path spec/rails/helper_eval_context_helper Spec::Rails::ViewSpecController: missing default helper path spec/ rails/view_spec_helper What am I missing, and I how do I solve this? From dgoodlad at gmail.com Tue Dec 12 14:34:16 2006 From: dgoodlad at gmail.com (David Goodlad) Date: Tue, 12 Dec 2006 11:34:16 -0800 Subject: [rspec-users] Stubs breaking other things Message-ID: Hi All I'm working on converting some existing controller specs to use mocks and stubs rather than real ActiveRecord objects in a Rails project. In one of my controller actions, I use a database transaction. So, the obvious thing to do is have this in my setup block: Project.stub!(:transaction) Firstly, is there an easy way to have that stub yield to the block passed to any #transaction calls? I'm sure there's an easy way to do it but I can't seem to find it. Secondly, it seems that stubbing the transaction method in one context breaks all sorts of other stuff. I'm assuming that since AR uses transactions for saving records, any project that gets saved in code that actually uses the real Project model instead of a mock is now broken. Is the stub code, in the case of a partial mock, supposed to revert any methods it overrides upon teardown? Thanks Dave -- Dave Goodlad dgoodlad at gmail.com or dave at goodlad.ca http://david.goodlad.ca/ From bryan at osesm.com Tue Dec 12 13:31:25 2006 From: bryan at osesm.com (Bryan Liles) Date: Tue, 12 Dec 2006 13:31:25 -0500 Subject: [rspec-users] rpec 0.7.4/ rails 1.2rc1 troubles Message-ID: <908F771E-1E7D-4487-9712-2716AF41F4A0@osesm.com> I believe that I have followed these directions exactly: http:// rspec.rubyforge.org/documentation/rails/install.html My new spec tests work, but my old Test::Unit test don't produce any output. The only clue I have anything is happening at all are these messages in log/test.log: Spec::Rails::HelperEvalContextController: missing default helper path spec/rails/helper_eval_context_helper Spec::Rails::ViewSpecController: missing default helper path spec/ rails/view_spec_helper What am I missing, and I how do I solve this? From aslak.hellesoy at gmail.com Tue Dec 12 14:53:13 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 12 Dec 2006 20:53:13 +0100 Subject: [rspec-users] rpec 0.7.4/ rails 1.2rc1 troubles In-Reply-To: <023948F8-04A4-437B-A626-9359F93654C0@osesm.com> References: <023948F8-04A4-437B-A626-9359F93654C0@osesm.com> Message-ID: <8d961d900612121153t74c5138eu18440923e12146dc@mail.gmail.com> On 12/12/06, Bryan Liles wrote: > I believe that I have followed these directions exactly: http:// > rspec.rubyforge.org/documentation/rails/install.html > > My new spec tests work, but my old Test::Unit test don't produce any > output. The only clue I have anything is happening at all are these > messages in log/test.log: > > Spec::Rails::HelperEvalContextController: missing default helper path > spec/rails/helper_eval_context_helper > Spec::Rails::ViewSpecController: missing default helper path spec/ > rails/view_spec_helper > > What am I missing, and I how do I solve this? Try to remove all the code from vendor/plugins/rspec_on_rails/init.rb (but don't remove the file). This is fixed on trunk. Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bryan at osesm.com Tue Dec 12 15:15:07 2006 From: bryan at osesm.com (Bryan Liles) Date: Tue, 12 Dec 2006 15:15:07 -0500 Subject: [rspec-users] rpec 0.7.4/ rails 1.2rc1 troubles In-Reply-To: <8d961d900612121153t74c5138eu18440923e12146dc@mail.gmail.com> References: <023948F8-04A4-437B-A626-9359F93654C0@osesm.com> <8d961d900612121153t74c5138eu18440923e12146dc@mail.gmail.com> Message-ID: <64326B24-EA84-4AF5-9C86-ECBA6F1DCA78@osesm.com> On Dec 12, 2006, at 2:53 PM, aslak hellesoy wrote: > On 12/12/06, Bryan Liles wrote: >> I believe that I have followed these directions exactly: http:// >> rspec.rubyforge.org/documentation/rails/install.html >> >> My new spec tests work, but my old Test::Unit test don't produce any >> output. The only clue I have anything is happening at all are these >> messages in log/test.log: >> >> Spec::Rails::HelperEvalContextController: missing default helper path >> spec/rails/helper_eval_context_helper >> Spec::Rails::ViewSpecController: missing default helper path spec/ >> rails/view_spec_helper >> >> What am I missing, and I how do I solve this? > > Try to remove all the code from vendor/plugins/rspec_on_rails/init.rb > (but don't remove the file). > > This is fixed on trunk. > > Aslak Thanks Aslak. This solved my problem. From cwdinfo at gmail.com Tue Dec 12 19:48:45 2006 From: cwdinfo at gmail.com (s.ross) Date: Tue, 12 Dec 2006 16:48:45 -0800 Subject: [rspec-users] Testing has_many :through Message-ID: I'm working with a has_many :through association, where a Member has_many Projects through ProjectViewers. The problem I'm running into is that Rails doesn't load the association so line (3) fails until I explicitly access a member of the collection (in this case, I iterated it). Is there a better way? Thanks, Steve 1. assigns[:member].should_not_be_nil 2. assigns[:member].projects.each{|p| puts "project #{p.name}"} # force association to be loaded 3. assigns[:member].projects.size.should_be 1 From lourens at rentacarhire.com Tue Dec 12 21:54:03 2006 From: lourens at rentacarhire.com (Lourens Naude) Date: Wed, 13 Dec 2006 02:54:03 +0000 Subject: [rspec-users] Testing has_many :through In-Reply-To: References: Message-ID: <6B87ED60-F7F3-43C2-B3C8-BE88844F9710@rentacarhire.com> Hi, Instead of assigns[:member].projects.size.should_be 1 use assigns [:member].projects.count.should_be 1 AR associations is returned as enumerable (Array) where Enumerable#size wouldn't force a DB query with the recent association loading patches on Edge ( likely 1.2 as well ). association.count forces roundtrip to the DB, effectively dealing with your line #2 in the process. Just a thought, works fine for me with #count, been using Rspec since 0.7.2 on Edge and most of these little quirks/errors occur at a higher level than Rspec itself. - Lourens On 2006/12/13, at 00:48, s.ross wrote: > I'm working with a has_many :through association, where a Member > has_many Projects through ProjectViewers. The problem I'm running > into is that Rails doesn't load the association so line (3) fails > until I explicitly access a member of the collection (in this case, I > iterated it). Is there a better way? > > Thanks, > > Steve > > 1. assigns[:member].should_not_be_nil > 2. assigns[:member].projects.each{|p| puts "project #{p.name}"} # > force association to be loaded > 3. assigns[:member].projects.size.should_be 1 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cwdinfo at gmail.com Wed Dec 13 01:30:43 2006 From: cwdinfo at gmail.com (s.ross) Date: Tue, 12 Dec 2006 22:30:43 -0800 Subject: [rspec-users] Testing has_many :through In-Reply-To: <6B87ED60-F7F3-43C2-B3C8-BE88844F9710@rentacarhire.com> References: <6B87ED60-F7F3-43C2-B3C8-BE88844F9710@rentacarhire.com> Message-ID: Right you are. Using count works perfectly. Steve On Dec 12, 2006, at 6:54 PM, Lourens Naude wrote: > Hi, > > Instead of assigns[:member].projects.size.should_be 1 use assigns > [:member].projects.count.should_be 1 > AR associations is returned as enumerable (Array) where > Enumerable#size wouldn't force a DB query with the recent association > loading patches on Edge ( likely 1.2 as well ). > > association.count forces roundtrip to the DB, effectively dealing > with your line #2 in the process. > > Just a thought, works fine for me with #count, been using Rspec since > 0.7.2 on Edge and most of these little quirks/errors occur at a > higher level than Rspec itself. > > - Lourens > > On 2006/12/13, at 00:48, s.ross wrote: > >> I'm working with a has_many :through association, where a Member >> has_many Projects through ProjectViewers. The problem I'm running >> into is that Rails doesn't load the association so line (3) fails >> until I explicitly access a member of the collection (in this case, I >> iterated it). Is there a better way? >> >> Thanks, >> >> Steve >> >> 1. assigns[:member].should_not_be_nil >> 2. assigns[:member].projects.each{|p| puts "project #{p.name}"} # >> force association to be loaded >> 3. assigns[:member].projects.size.should_be 1 >> >> >> _______________________________________________ >> 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 dgoodlad at gmail.com Wed Dec 13 01:30:43 2006 From: dgoodlad at gmail.com (David Goodlad) Date: Tue, 12 Dec 2006 22:30:43 -0800 Subject: [rspec-users] RSpec and simply_helpful Message-ID: Hi All I'm having some problems running my view specs when using simply_helpful. I have it semi-working via the following: module SimplyHelpfulHelper def self.included(base) base.send :include, SimplyHelpful::RecordIdentificationHelper base.send :include, SimplyHelpful::RecordTagHelper end end context "The index template" do setup do @shift = mock("shift") @shift.stub!(:class).and_return(Shift) @shift.stub!(:id).and_return(1) assigns[:shifts] = [@shift] end specify "should have a div tag for the shift" do render 'shifts/index', :helper => 'simply_helpful' response.should_have_tag 'div', :attributes => { :id => 'shift_1' } end end My template just makes a call like this: <%= render :partial => @shifts %> I've done some experimentation, and it seems that RSpec's implementation of 'render_partial' is rewriting the partial path trying to be smart about it but breaking things. The partial_path, once it reaches render_partial_with_record_identification, ends up being "/shifts//#". This is caused by the method being overwritten in rspec_on_rails/lib/extensions/action_view/base.rb. I suggest that there be a second condition attached to the unless statement on line 5, to ensure that the partial_path is a String; if it is not, the partial_path should be passed straight on through... Thoughts? Dave -- Dave Goodlad dgoodlad at gmail.com or dave at goodlad.ca http://david.goodlad.ca/ From jchris at mfdz.com Wed Dec 13 02:13:04 2006 From: jchris at mfdz.com (Chris Anderson) Date: Tue, 12 Dec 2006 23:13:04 -0800 Subject: [rspec-users] RSpec and simply_helpful In-Reply-To: References: Message-ID: Specrs, Just a fly on the wall perspective here, but based on the behaviour I'm seeing, it seems like RSpec is reimplementing a lot of the Rails test goodies. Is there a reason not to write simple wrappers for Rails' asserts, or something, so RSpec doesn't have to work so hard to keep up with changes in core? I speak as someone who's only glanced at the RSpec code, so maybe I should just keep it to myself. I do enjoy using RSpec with Ruby code, and I can't wait for the day the Rails implementation is stable. Also, why not package the Rails plugin in the gem releases? It might help with the version mismatch problems. I know; I should PDI. If a core developer could do a walk through of RSpec internals, like Jamis has been doing with ActiveRecord, surely I'm not the only one who would appreciate it. Chris On 12/12/06, David Goodlad wrote: > I've done some experimentation, and it seems that RSpec's > implementation of 'render_partial' is rewriting the partial path > trying to be smart about it but breaking things. > > Thoughts? > > Dave > -- Chris Anderson http://jchris.mfdz.com From dchelimsky at gmail.com Wed Dec 13 04:12:10 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Dec 2006 07:12:10 -0200 Subject: [rspec-users] RSpec and simply_helpful In-Reply-To: References: Message-ID: <57c63afe0612130112p1e1bd509l9d3a269a62ed8169@mail.gmail.com> On 12/13/06, David Goodlad wrote: > Hi All > > I'm having some problems running my view specs when using > simply_helpful. I have it semi-working via the following: > > module SimplyHelpfulHelper > def self.included(base) > base.send :include, SimplyHelpful::RecordIdentificationHelper > base.send :include, SimplyHelpful::RecordTagHelper > end > end > > context "The index template" do > setup do > @shift = mock("shift") > @shift.stub!(:class).and_return(Shift) > @shift.stub!(:id).and_return(1) > > assigns[:shifts] = [@shift] > end > > specify "should have a div tag for the shift" do > render 'shifts/index', :helper => 'simply_helpful' > response.should_have_tag 'div', :attributes => { :id => 'shift_1' } > end > end > > My template just makes a call like this: > > <%= render :partial => @shifts %> > > I've done some experimentation, and it seems that RSpec's > implementation of 'render_partial' is rewriting the partial path > trying to be smart about it but breaking things. The partial_path, > once it reaches render_partial_with_record_identification, ends up > being "/shifts//#". This is caused by > the method being overwritten in > rspec_on_rails/lib/extensions/action_view/base.rb. > > I suggest that there be a second condition attached to the unless > statement on line 5, to ensure that the partial_path is a String; if > it is not, the partial_path should be passed straight on through... > > Thoughts? Dave - it would be quite awesome if you would submit a patch for this w/ specs. Thanks, David > > Dave > > -- > Dave Goodlad > dgoodlad at gmail.com or dave at goodlad.ca > http://david.goodlad.ca/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Dec 13 04:25:53 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Dec 2006 07:25:53 -0200 Subject: [rspec-users] RSpec and simply_helpful In-Reply-To: References: Message-ID: <57c63afe0612130125l4d22e823re1cb512d354fcd89@mail.gmail.com> On 12/13/06, Chris Anderson wrote: > Specrs, > Just a fly on the wall perspective here, but based on the behaviour > I'm seeing, it seems like RSpec is reimplementing a lot of the Rails > test goodies. Is there a reason not to write simple wrappers for > Rails' asserts, or something, so RSpec doesn't have to work so hard to > keep up with changes in core? Ah, that would be lovely! Many of the goodies use different approaches, so I'm not sure a single wrapper mechanism would work. What would be fantastic in the long run would be a world in which the various goodies were not tied so directly to test/unit, allowing either framework to use it. But that would require a critical mass of rails developers who prefer to work w/ rspec and I think that's a LONG way off if even possible. > > I speak as someone who's only glanced at the RSpec code, so maybe I > should just keep it to myself. Not at all. We want this to be usable and useful. > I do enjoy using RSpec with Ruby code, > and I can't wait for the day the Rails implementation is stable. You are NOT alone! > Also, why not package the Rails plugin in the gem releases? It might > help with the version mismatch problems. I know; I should PDI. We've been talking about that. Originally it was a gem, but we made it a plugin sometime ago - I think it was when we added the generators. But the mismatch problem is a pain in the ass, so perhaps a gem is the right approach. > If a core developer could do a walk through of RSpec internals, like > Jamis has been doing with ActiveRecord, surely I'm not the only one > who would appreciate it. Are you talking about RSpec core or the rails plugin? I'm not sure when time will allow for this, but I'll take it under advisement. It could provide a great opportunity for us all to better understand where things are now and the most pragmatic path to where we want to be. Thanks, David > > > Chris > > > On 12/12/06, David Goodlad wrote: > > I've done some experimentation, and it seems that RSpec's > > implementation of 'render_partial' is rewriting the partial path > > trying to be smart about it but breaking things. > > > > Thoughts? > > > > Dave > > > > -- > Chris Anderson > http://jchris.mfdz.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Dec 13 04:38:00 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Dec 2006 07:38:00 -0200 Subject: [rspec-users] Stubs breaking other things In-Reply-To: References: Message-ID: <57c63afe0612130138g6e1488a8l2caa6c08ebf70dd6@mail.gmail.com> On 12/12/06, David Goodlad wrote: > Hi All > > I'm working on converting some existing controller specs to use mocks > and stubs rather than real ActiveRecord objects in a Rails project. > In one of my controller actions, I use a database transaction. So, > the obvious thing to do is have this in my setup block: > > Project.stub!(:transaction) > > Firstly, is there an easy way to have that stub yield to the block > passed to any #transaction calls? Stubs won't do this right now (feel free to add an RFE saying they should), but you can do this w/ a mock. Just set it to any_number_of_times and it works just like a stub: Project.should_receive(:transaction).any_number_of_times.and_yield(whatever_you_like) > I'm sure there's an easy way to do > it but I can't seem to find it. > > Secondly, it seems that stubbing the transaction method in one context > breaks all sorts of other stuff. I'm assuming that since AR uses > transactions for saving records, any project that gets saved in code > that actually uses the real Project model instead of a mock is now > broken. Is the stub code, in the case of a partial mock, supposed to > revert any methods it overrides upon teardown? It is supposed to, and there was a problem with this a while ago, but we *believe* that we fixed it in 0.7.4. Which version are you using? From dchelimsky at gmail.com Wed Dec 13 05:07:35 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Dec 2006 08:07:35 -0200 Subject: [rspec-users] Stubs breaking other things In-Reply-To: <57c63afe0612130138g6e1488a8l2caa6c08ebf70dd6@mail.gmail.com> References: <57c63afe0612130138g6e1488a8l2caa6c08ebf70dd6@mail.gmail.com> Message-ID: <57c63afe0612130207n35669a70q3968d76a0553642f@mail.gmail.com> On 12/13/06, David Chelimsky wrote: > On 12/12/06, David Goodlad wrote: > > Hi All > > > > I'm working on converting some existing controller specs to use mocks > > and stubs rather than real ActiveRecord objects in a Rails project. > > In one of my controller actions, I use a database transaction. So, > > the obvious thing to do is have this in my setup block: > > > > Project.stub!(:transaction) > > > > Firstly, is there an easy way to have that stub yield to the block > > passed to any #transaction calls? > > Stubs won't do this right now (feel free to add an RFE saying they > should), but you can do this w/ a mock. Just set it to > any_number_of_times and it works just like a stub: > > Project.should_receive(:transaction).any_number_of_times.and_yield(whatever_you_like) I went ahead and added this support directly to stubs as of rev 1284. Cheers, David > > > > I'm sure there's an easy way to do > > it but I can't seem to find it. > > > > Secondly, it seems that stubbing the transaction method in one context > > breaks all sorts of other stuff. I'm assuming that since AR uses > > transactions for saving records, any project that gets saved in code > > that actually uses the real Project model instead of a mock is now > > broken. Is the stub code, in the case of a partial mock, supposed to > > revert any methods it overrides upon teardown? > > It is supposed to, and there was a problem with this a while ago, but > we *believe* that we fixed it in 0.7.4. Which version are you using? > From dchelimsky at gmail.com Wed Dec 13 05:34:28 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 13 Dec 2006 08:34:28 -0200 Subject: [rspec-users] Testing has_many :through In-Reply-To: References: <6B87ED60-F7F3-43C2-B3C8-BE88844F9710@rentacarhire.com> Message-ID: <57c63afe0612130234r4d24e6d3w6c91d4eaed1f02c3@mail.gmail.com> On 12/13/06, s.ross wrote: > Right you are. Using count works perfectly. > > Steve > > On Dec 12, 2006, at 6:54 PM, Lourens Naude wrote: > > > Hi, > > > > Instead of assigns[:member].projects.size.should_be 1 use assigns > > [:member].projects.count.should_be 1 > > AR associations is returned as enumerable (Array) where > > Enumerable#size wouldn't force a DB query with the recent association > > loading patches on Edge ( likely 1.2 as well ). I believe that this will work as well: assigns[:member].should_have(1).projects This uses #length under the hood when available, which seems to have the same effect as #count. > > > > association.count forces roundtrip to the DB, effectively dealing > > with your line #2 in the process. > > > > Just a thought, works fine for me with #count, been using Rspec since > > 0.7.2 on Edge and most of these little quirks/errors occur at a > > higher level than Rspec itself. > > > > - Lourens > > > > On 2006/12/13, at 00:48, s.ross wrote: > > > >> I'm working with a has_many :through association, where a Member > >> has_many Projects through ProjectViewers. The problem I'm running > >> into is that Rails doesn't load the association so line (3) fails > >> until I explicitly access a member of the collection (in this case, I > >> iterated it). Is there a better way? > >> > >> Thanks, > >> > >> Steve > >> > >> 1. assigns[:member].should_not_be_nil > >> 2. assigns[:member].projects.each{|p| puts "project #{p.name}"} # > >> force association to be loaded > >> 3. assigns[:member].projects.size.should_be 1 > >> > >> > >> _______________________________________________ > >> 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 dgoodlad at gmail.com Wed Dec 13 12:03:19 2006 From: dgoodlad at gmail.com (David Goodlad) Date: Wed, 13 Dec 2006 09:03:19 -0800 Subject: [rspec-users] Stubs breaking other things In-Reply-To: <57c63afe0612130138g6e1488a8l2caa6c08ebf70dd6@mail.gmail.com> References: <57c63afe0612130138g6e1488a8l2caa6c08ebf70dd6@mail.gmail.com> Message-ID: On 12/13/06, David Chelimsky wrote: > On 12/12/06, David Goodlad wrote: > > Firstly, is there an easy way to have that stub yield to the block > > passed to any #transaction calls? > > Stubs won't do this right now (feel free to add an RFE saying they > should), but you can do this w/ a mock. Just set it to > any_number_of_times and it works just like a stub: Right, I ended up finding this after I sent out my email; I just had the idea in my head that I really wanted it to be a stub because I didn't want to check that the call was made. However, now that you've added it to stubs, I'll probably go back to a stub when the next release is made. > > Secondly, it seems that stubbing the transaction method in one context > > breaks all sorts of other stuff. I'm assuming that since AR uses > > transactions for saving records, any project that gets saved in code > > that actually uses the real Project model instead of a mock is now > > broken. Is the stub code, in the case of a partial mock, supposed to > > revert any methods it overrides upon teardown? > > It is supposed to, and there was a problem with this a while ago, but > we *believe* that we fixed it in 0.7.4. Which version are you using? I'm using 0.7.4 (yes, matching rspec and rails plugin versions). I'll see if I can create a minimal test case to reproduce this. Dave -- Dave Goodlad dgoodlad at gmail.com or dave at goodlad.ca http://david.goodlad.ca/ From bryan at osesm.com Wed Dec 13 17:07:51 2006 From: bryan at osesm.com (Bryan Liles) Date: Wed, 13 Dec 2006 17:07:51 -0500 Subject: [rspec-users] rspec with rails controllers in subdirectories Message-ID: <29473900-A18C-4234-AE90-2DE31A3A9895@osesm.com> Does the rspec rails plugin support controllers in subdirectories under app/controller? From aslak.hellesoy at gmail.com Wed Dec 13 17:28:37 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 13 Dec 2006 23:28:37 +0100 Subject: [rspec-users] rspec with rails controllers in subdirectories In-Reply-To: <29473900-A18C-4234-AE90-2DE31A3A9895@osesm.com> References: <29473900-A18C-4234-AE90-2DE31A3A9895@osesm.com> Message-ID: <8d961d900612131428u78086f31i728695c95a2c1541@mail.gmail.com> On 12/13/06, Bryan Liles wrote: > Does the rspec rails plugin support controllers in subdirectories > under app/controller? > I'm not sure - I haven't tried. I don't think we have done anything to support them, but maybe it just works? Let us know if it doesn't Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Dec 13 18:03:33 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 14 Dec 2006 00:03:33 +0100 Subject: [rspec-users] RSpec the video Message-ID: <8d961d900612131503x4ece8cdcvb1f57628f095708c@mail.gmail.com> Hilarious => http://www.reevoo.com/blogs/bengriffiths/2006/12/12/rspec-video/ From dgoodlad at gmail.com Thu Dec 14 02:42:37 2006 From: dgoodlad at gmail.com (David Goodlad) Date: Wed, 13 Dec 2006 23:42:37 -0800 Subject: [rspec-users] RSpec and simply_helpful In-Reply-To: <57c63afe0612130112p1e1bd509l9d3a269a62ed8169@mail.gmail.com> References: <57c63afe0612130112p1e1bd509l9d3a269a62ed8169@mail.gmail.com> Message-ID: On 12/13/06, David Chelimsky wrote: > On 12/13/06, David Goodlad wrote: > > Hi All > > > > I'm having some problems running my view specs when using > > simply_helpful. I have it semi-working via the following: > > > > module SimplyHelpfulHelper > > def self.included(base) > > base.send :include, SimplyHelpful::RecordIdentificationHelper > > base.send :include, SimplyHelpful::RecordTagHelper > > end > > end > > > > context "The index template" do > > setup do > > @shift = mock("shift") > > @shift.stub!(:class).and_return(Shift) > > @shift.stub!(:id).and_return(1) > > > > assigns[:shifts] = [@shift] > > end > > > > specify "should have a div tag for the shift" do > > render 'shifts/index', :helper => 'simply_helpful' > > response.should_have_tag 'div', :attributes => { :id => 'shift_1' } > > end > > end > > > > My template just makes a call like this: > > > > <%= render :partial => @shifts %> > > > > I've done some experimentation, and it seems that RSpec's > > implementation of 'render_partial' is rewriting the partial path > > trying to be smart about it but breaking things. The partial_path, > > once it reaches render_partial_with_record_identification, ends up > > being "/shifts//#". This is caused by > > the method being overwritten in > > rspec_on_rails/lib/extensions/action_view/base.rb. > > > > I suggest that there be a second condition attached to the unless > > statement on line 5, to ensure that the partial_path is a String; if > > it is not, the partial_path should be passed straight on through... > > > > Thoughts? > > Dave - it would be quite awesome if you would submit a patch for this w/ specs. Hi David I've submitted my patch: https://rubyforge.org/tracker/index.php?func=detail&aid=7270&group_id=797&atid=3151 As I note in the patch description, I am not happy with the way I ended up specifying the behavior. However, it's a bit of a sticky thing to test, since the actual rails code we pass the value on to normally doesn't support an Array being passed as the partial_path! So, I kludged it, by chaining my own method in front of Rails' render_partial to allow the use of an Array. This is ugly, I know. If you can think of a better way, please post it here as I'd like to know about it! :) Dave -- Dave Goodlad dgoodlad at gmail.com or dave at goodlad.ca http://david.goodlad.ca/ From work at ashleymoran.me.uk Fri Dec 15 12:39:19 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Fri, 15 Dec 2006 17:39:19 +0000 Subject: [rspec-users] Partial mock when a complex return value is required Message-ID: Hi I've come up with a problem using RSpec on a model class in my rails app. I wanted to test that some data was being cached for some calculations, so rather than do state-based testing I tried to specify that the method that fetches the data should NOT be called when I call the calculate method. However in doing so I have to simulate the return value, which is about 27 ActiveRecord objects with about 7 parameters. The only way I could stop the spec failing (because the rest of the method depends on this return value) was to duplicate the code in the spec. Here is a cut-down version of my class: class CapDerivativeInRegistrationBand < SimpleDelegator ... def cap_future_residuals @cap_future_residuals ||= cap_future_residuals_for_registration_date(registration_year, registration_month) end def residual_value(request_mileage, request_term) ... cap_future_residuals.each do |r| ... end ... # LOADS of other stuff going on here that relies on stuff produced from the above loop ... end end And here is the offending spec: specify "should prefetch the future residuals" do TODO: ask rspec team about duplicating this logic to get a nice error message @derivatives_by_id[26149].should_not_receive (:cap_future_residuals_for_registration_date).and_return( CapFutureResidual.find_all_by_derivative_id_and_registration_year_and_re gistration_month(26149, 2003, 9) ) end Sorry for the car finance jargon!!! How can I get round this? Here is my attempt at an alternative spec - is this better or worse? specify "should prefetch the future residuals" do # TODO: get rid of evil state testing residuals = @derivatives_by_id[26149].instance_variable_get ("@cap_future_residuals") @derivatives_by_id[26149].cap_future_residuals.should_equal residuals end Thanks for any advice Ashley From listaccount at e-tobi.net Sat Dec 16 08:15:06 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Sat, 16 Dec 2006 14:15:06 +0100 Subject: [rspec-users] RSpec with Rails but without any database Message-ID: <4583F15A.4030408@e-tobi.net> Hi! Any hints on how I can get RSpec/Rails to work without any database? I've got the Test::Unit tests working by adding a file in lib/tasks which clears the prerequisites of the rake targets "test:units", "test:functionals" and so on. What's the shortest way to make RSpec work without any database? bye, Tobias From pergesu at gmail.com Sat Dec 16 09:04:48 2006 From: pergesu at gmail.com (Pat Maddox) Date: Sat, 16 Dec 2006 07:04:48 -0700 Subject: [rspec-users] RSpec with Rails but without any database In-Reply-To: <4583F15A.4030408@e-tobi.net> References: <4583F15A.4030408@e-tobi.net> Message-ID: <810a540e0612160604p2413dbb2g2091253dcf101c32@mail.gmail.com> On 12/16/06, Tobias Grimm wrote: > Hi! > > Any hints on how I can get RSpec/Rails to work without any database? > I've got the Test::Unit tests working by adding a file in lib/tasks > which clears the prerequisites of the rake targets "test:units", > "test:functionals" and so on. What's the shortest way to make RSpec work > without any database? I haven't done this, but I presume you'd apply the same method to the spec tasks. So clear the prerequisites of spec:models, spec:controllers, spec:views. And let me know if it works :) Pat From listaccount at e-tobi.net Sat Dec 16 12:40:25 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Sat, 16 Dec 2006 18:40:25 +0100 Subject: [rspec-users] RSpec with Rails but without any database In-Reply-To: <810a540e0612160604p2413dbb2g2091253dcf101c32@mail.gmail.com> References: <4583F15A.4030408@e-tobi.net> <810a540e0612160604p2413dbb2g2091253dcf101c32@mail.gmail.com> Message-ID: <45842F89.4060206@e-tobi.net> Pat Maddox wrote: > I haven't done this, but I presume you'd apply the same method to the > spec tasks. So clear the prerequisites of spec:models, > spec:controllers, spec:views. And let me know if it works :) > No, it doesn't. db:test:prepare gets skipped now, but it still tries to connect to a database somewhere, but I can't figure out where. Tobias From dchelimsky at gmail.com Sat Dec 16 17:12:12 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 16 Dec 2006 16:12:12 -0600 Subject: [rspec-users] Partial mock when a complex return value is required In-Reply-To: References: Message-ID: <57c63afe0612161412g7ed8f2bdg38af1fa29d3b3fca@mail.gmail.com> On 12/15/06, Ashley Moran wrote: > Hi > > I've come up with a problem using RSpec on a model class in my rails > app. I wanted to test that some data was being cached for some > calculations, so rather than do state-based testing I tried to > specify that the method that fetches the data should NOT be called > when I call the calculate method. However in doing so I have to > simulate the return value, which is about 27 ActiveRecord objects > with about 7 parameters. The only way I could stop the spec failing > (because the rest of the method depends on this return value) was to > duplicate the code in the spec. This is confusing to me. You say you DON'T want the method called, but its return value is important to the rest of the method. Please explain. > > > Here is a cut-down version of my class: > > class CapDerivativeInRegistrationBand < SimpleDelegator > ... > > def cap_future_residuals > @cap_future_residuals ||= > cap_future_residuals_for_registration_date(registration_year, > registration_month) > end > > def residual_value(request_mileage, request_term) > ... > > cap_future_residuals.each do |r| > ... > end > > ... > # LOADS of other stuff going on here that relies on stuff > produced from the above loop > ... > end > end > > > And here is the offending spec: > > specify "should prefetch the future residuals" do > TODO: ask rspec team about duplicating this logic to get a nice > error message > @derivatives_by_id[26149].should_not_receive > (:cap_future_residuals_for_registration_date).and_return( > > CapFutureResidual.find_all_by_derivative_id_and_registration_year_and_re > gistration_month(26149, 2003, 9) > ) > end > > Sorry for the car finance jargon!!! > > How can I get round this? Here is my attempt at an alternative spec > - is this better or worse? > > specify "should prefetch the future residuals" do > # TODO: get rid of evil state testing > residuals = @derivatives_by_id[26149].instance_variable_get > ("@cap_future_residuals") > @derivatives_by_id[26149].cap_future_residuals.should_equal > residuals > end > > Thanks for any advice > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From bachase at gmail.com Sat Dec 16 23:10:04 2006 From: bachase at gmail.com (Brad Chase) Date: Sat, 16 Dec 2006 23:10:04 -0500 Subject: [rspec-users] UJS plugin incompatible with RSpec? Message-ID: <272402400612162010t1f64694an2f34d8f1623808e9@mail.gmail.com> I was having the same problem with UJS and rspec. If I move if ENV['RAILS_ENV'] == 'test' then require 'rspec_on_rails' end from the rspec init.rb to the end of my environment.rb, then things work fine. I think there is some recent additions to rails edge that handle the order plugins are loaded, but I have yet to investigate it. From dchelimsky at gmail.com Sun Dec 17 02:55:22 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Dec 2006 01:55:22 -0600 Subject: [rspec-users] UJS plugin incompatible with RSpec? In-Reply-To: <272402400612162010t1f64694an2f34d8f1623808e9@mail.gmail.com> References: <272402400612162010t1f64694an2f34d8f1623808e9@mail.gmail.com> Message-ID: <57c63afe0612162355t3f2e9a2aj97c00d722d29bf81@mail.gmail.com> On 12/16/06, Brad Chase wrote: > I was having the same problem with UJS and rspec. If I move > > if ENV['RAILS_ENV'] == 'test' then > require 'rspec_on_rails' > end This is gone in trunk (and in the next release). > > from the rspec init.rb to the end of my environment.rb, then things > work fine. I think there is some recent additions to rails edge that > handle the order plugins are loaded, but I have yet to investigate it. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Sun Dec 17 08:19:12 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Sun, 17 Dec 2006 13:19:12 +0000 Subject: [rspec-users] Partial mock when a complex return value is required In-Reply-To: <57c63afe0612161412g7ed8f2bdg38af1fa29d3b3fca@mail.gmail.com> References: <57c63afe0612161412g7ed8f2bdg38af1fa29d3b3fca@mail.gmail.com> Message-ID: <9F606EFA-D0F7-48CA-9C1C-0E6AAC1B6D71@ashleymoran.me.uk> On Dec 16, 2006, at 10:12 pm, David Chelimsky wrote: > This is confusing to me. You say you DON'T want the method called, but > its return value is important to the rest of the method. Please > explain. When you put it like that, I got confused too lol. I just tried it again without the extra return value and it works fine (which makes sense). I must have assumed that method was being called some other way... because when I wrote the spec it gave me an error about a nil object, but then the should_not_receive passed when I put the return value in. God only knows what I wrote to do that... Sorry for the noise! Ashley From dchelimsky at gmail.com Sun Dec 17 09:03:46 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 17 Dec 2006 08:03:46 -0600 Subject: [rspec-users] Partial mock when a complex return value is required In-Reply-To: <9F606EFA-D0F7-48CA-9C1C-0E6AAC1B6D71@ashleymoran.me.uk> References: <57c63afe0612161412g7ed8f2bdg38af1fa29d3b3fca@mail.gmail.com> <9F606EFA-D0F7-48CA-9C1C-0E6AAC1B6D71@ashleymoran.me.uk> Message-ID: <57c63afe0612170603q5babc1d8v5dcf13cbdef43526@mail.gmail.com> On 12/17/06, Ashley Moran wrote: > > On Dec 16, 2006, at 10:12 pm, David Chelimsky wrote: > > > This is confusing to me. You say you DON'T want the method called, but > > its return value is important to the rest of the method. Please > > explain. > > > When you put it like that, I got confused too lol. I just tried it > again without the extra return value and it works fine (which makes > sense). I must have assumed that method was being called some other > way... because when I wrote the spec it gave me an error about a nil > object, but then the should_not_receive passed when I put the return > value in. God only knows what I wrote to do that... > > Sorry for the noise! No worries. Glad it's resolved. Cheers, David > > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Sun Dec 17 09:24:24 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Sun, 17 Dec 2006 14:24:24 +0000 Subject: [rspec-users] Best way to do automated acceptance tests Message-ID: <493F2277-838E-44C0-AA32-0C563A283E6F@ashleymoran.me.uk> Hi This is only part related to rspec but I asked the Rails list and didn't get a reply so I thought I'd try here. Basically, since rspec_on_rails doesn't have an equivalent to rails integration tests, I'm trying to find a way of doing automated acceptance tests. I've found selenium and watir, but I'm struggling to tell the two apart. Watir looks more accessible and less coupled to the browser (for those that have drivers). Does either have a clear advantage over the other? This post got me excited: http://blog.aslakhellesoy.com/articles/ 2006/12/02/getting-screenshots-from-watir Thanks to TextMate I pretty much live off the rspec HTML output. I might try and get that working this afternoon, and if it's ok I'll probably just go with watir. On a more rspec note, what are the plans for rspec acceptance specs (aka rails integration tests)? Surely if you can do full-stack testing *including* the browser, there's little need for a direct port of the rails integration tests. The only thing I can think it would be useful for is for testing web services, where the client would be a library in some other system. In that case though, I suppose you would ideally want a scriptable version of their client library, and either way, your web service should be part of their integration tests. Any opinions on this? (While I'm at it, I'd like to make a suggestion... *please* call any port of the rails "integration tests" acceptance or functional tests or something, not integration tests like Rails does- I know it will confuse the hell out of our developers when we come to write actual system integration tests). Thanks Ashley From znmeb at cesmail.net Sun Dec 17 15:42:12 2006 From: znmeb at cesmail.net (M. Edward (Ed) Borasky) Date: Sun, 17 Dec 2006 12:42:12 -0800 Subject: [rspec-users] Rspec/Ruby to test software written in other languages? Message-ID: <4585ABA4.6070600@cesmail.net> Is anyone here using Rspec and Ruby to test software written in other languages? I'm about to start an R language project, and may also be doing some work in another language (I'm not sure which one yet, but it's one of the ones that's part of the Axiom symbolic math package). I'd dearly love a test framework that can handle all three languages, rather than using Rspec for Ruby, R's own "RUnit" for the R code, and yet another framework, if even one exists, for the third language. I've spent a couple of weeks familiarizing myself with the basic Rspec tool set. A lot of this is new to me, and seems very strange. Most of the projects I work on involve translating known algorithms on known data types into working code in some language, and there are usually test cases given in the books. So my typical modus operandi is to punch the whole algorithm into a file, punch the test case into another file, and iterate until everything works. -- M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P) http://borasky-research.blogspot.com/ If God had meant for carrots to be eaten cooked, He would have given rabbits fire. From aslak.hellesoy at gmail.com Sun Dec 17 17:52:17 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 17 Dec 2006 23:52:17 +0100 Subject: [rspec-users] Rspec/Ruby to test software written in other languages? In-Reply-To: <4585ABA4.6070600@cesmail.net> References: <4585ABA4.6070600@cesmail.net> Message-ID: <8d961d900612171452y6ea9fbfao5ebbedf9dc582865@mail.gmail.com> On 12/17/06, M. Edward (Ed) Borasky wrote: > Is anyone here using Rspec and Ruby to test software written in other > languages? Java. At work we're using RSpec (and Watir) to specify the behaviour of a web application written in Java. The specs are written up-front, prior to the Java code. You can read more about it here: http://blog.aslakhellesoy.com/articles/2006/12/02/getting-screenshots-from-watir Although I haven't done so beyond toying with it, you can also use RSpec on JRuby to verify behaviour of arbitrary Java code. More info here: http://www.infoq.com/news/2006/11/RSpecOnJRuby Cheers, Aslak From work at ashleymoran.me.uk Mon Dec 18 07:04:05 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 18 Dec 2006 12:04:05 +0000 Subject: [rspec-users] should_receive and multiple return values Message-ID: Hi I just got bit by a misunderstanding about and_return. I've got this controller method parse_parameters that loops over query string parameters and parses out vehicle registration dates. We have to turn these into one of three bands (Jan-Feb, Mar-Aug, Sep- Dec) so I wrote a method (registration_date_to_band_year_and_month) takes a date and returns two return values, the year and month of the band. I thought this would work: specify "should turn the provided registration date into a CAP band" do CapFutureResidual.should_receive (:registration_date_to_band_year_and_month).with(Date.new(2003, 9, 30)).and_return(2003, 9) CapFutureResidual.should_receive (:registration_date_to_band_year_and_month).with(Date.new(2005, 3, 1)).and_return(2005, 3) controller.parse_parameters( { :capid26149 => "rd2003-09-30,mi40000,ft15", :capid30125 => "rd2005-03-01,mi73825,ft42" } ) end But it doesn't because and_return is setting up multiple method calls, not multiple return values. I don't imagine multiple return values are used that often, but they can be handy. Would there be any use in another method, maybe and_return_values or something to allow you to specify them? Since they are possible in Ruby, it makes sense that you should be able to specify them in RSpec. I got around it, of course, using an array return and the * expand operator, but I avoid that when I can Ashley From pergesu at gmail.com Mon Dec 18 07:31:41 2006 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 18 Dec 2006 05:31:41 -0700 Subject: [rspec-users] should_receive and multiple return values In-Reply-To: References: Message-ID: <810a540e0612180431i241faadbg8c9e26309d6ed722@mail.gmail.com> On 12/18/06, Ashley Moran wrote: > Hi > > I just got bit by a misunderstanding about and_return. > > I've got this controller method parse_parameters that loops over > query string parameters and parses out vehicle registration dates. > We have to turn these into one of three bands (Jan-Feb, Mar-Aug, Sep- > Dec) so I wrote a method (registration_date_to_band_year_and_month) > takes a date and returns two return values, the year and month of the > band. > > I thought this would work: > > specify "should turn the provided registration date into a CAP > band" do > CapFutureResidual.should_receive > (:registration_date_to_band_year_and_month).with(Date.new(2003, 9, > 30)).and_return(2003, 9) > CapFutureResidual.should_receive > (:registration_date_to_band_year_and_month).with(Date.new(2005, 3, > 1)).and_return(2005, 3) > controller.parse_parameters( > { :capid26149 => "rd2003-09-30,mi40000,ft15", :capid30125 => > "rd2005-03-01,mi73825,ft42" } > ) > end > > But it doesn't because and_return is setting up multiple method > calls, not multiple return values. > > I don't imagine multiple return values are used that often, but they > can be handy. Would there be any use in another method, maybe > and_return_values or something to allow you to specify them? Since > they are possible in Ruby, it makes sense that you should be able to > specify them in RSpec. > > I got around it, of course, using an array return and the * expand > operator, but I avoid that when I can > > Ashley hrm...when you return multiple values, isn't it actually returning an array? irb(main):001:0> def foo; return 1, 2; end => nil irb(main):002:0> a = foo => [1, 2] irb(main):003:0> b, c = foo => [1, 2] irb(main):004:0> a => [1, 2] irb(main):005:0> b => 1 irb(main):006:0> c => 2 It's just that Ruby is smart enough that you don't need the [] in the return value. Also, doing multiple assignment works even if you explicitly return an array: irb(main):001:0> def foo; return [1, 2]; end => nil irb(main):002:0> a, b = foo => [1, 2] irb(main):003:0> a => 1 irb(main):004:0> b => 2 So it really should just be and_return([2005, 3]) Pat From work at ashleymoran.me.uk Mon Dec 18 08:52:17 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 18 Dec 2006 13:52:17 +0000 Subject: [rspec-users] should_receive and multiple return values In-Reply-To: <810a540e0612180431i241faadbg8c9e26309d6ed722@mail.gmail.com> References: <810a540e0612180431i241faadbg8c9e26309d6ed722@mail.gmail.com> Message-ID: <621F059B-0FE6-43CD-94DC-A816399DB852@ashleymoran.me.uk> On 18 Dec 2006, at 12:31, Pat Maddox wrote: > So it really should just be and_return([2005, 3]) > > Pat Cool. I never realised that... if I'd changed my spec *first* like I'm supposed to I would have noticed it worked :) Thanks Ashley From coda.hale at gmail.com Mon Dec 18 17:28:45 2006 From: coda.hale at gmail.com (Coda Hale) Date: Mon, 18 Dec 2006 14:28:45 -0800 Subject: [rspec-users] How to keep mocks consistent? Message-ID: Hey all, Here's a question for everyone: how do you keep your mocks and stubs consistent with your real objects? I'm dipping my toes into the RSpec world, and it's absolutely delightful (running dozens of tests in less than a second is nice as well), but I'm concerned about my ability to keep the mocks in my specs consistent with the behavior of their real-world equivalents. I'm writing specs for a controller in a Rails application, and I've got stuff like this: ComplicatedObject.should_receive(:execute).and_return(800.00) If I change ComplicatedObject.execute down the line to return something besides a float, this spec will still pass, and the controller will only fail in real life. So I could have full test coverage, green lights across the board, and massive amounts of bugs in the way my classes interact. Is there any mechanism in RSpec to keep this from happening? Any methodology beyond "be careful"? Should I even be mocking my own objects? How do you manage this? -- Coda Hale http://blog.codahale.com From dchelimsky at gmail.com Mon Dec 18 17:49:03 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 18 Dec 2006 16:49:03 -0600 Subject: [rspec-users] How to keep mocks consistent? In-Reply-To: References: Message-ID: <57c63afe0612181449m74611a1cwa8ae02841ad73602@mail.gmail.com> On 12/18/06, Coda Hale wrote: > Hey all, > > Here's a question for everyone: how do you keep your mocks and stubs > consistent with your real objects? > > I'm dipping my toes into the RSpec world, and it's absolutely > delightful (running dozens of tests in less than a second is nice as > well), but I'm concerned about my ability to keep the mocks in my > specs consistent with the behavior of their real-world equivalents. > > I'm writing specs for a controller in a Rails application, and I've > got stuff like this: > > ComplicatedObject.should_receive(:execute).and_return(800.00) > > If I change ComplicatedObject.execute down the line to return > something besides a float, this spec will still pass, and the > controller will only fail in real life. So I could have full test > coverage, green lights across the board, and massive amounts of bugs > in the way my classes interact. > > Is there any mechanism in RSpec to keep this from happening? Any > methodology beyond "be careful"? Should I even be mocking my own > objects? > > How do you manage this? The isolated unit level testing that you're getting from using mocks should (MUST) be coupled with some level of integration testing. Right now I'm using either rails integration testing and/or selenium. David > > -- > Coda Hale > http://blog.codahale.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Tue Dec 19 11:07:24 2006 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 19 Dec 2006 09:07:24 -0700 Subject: [rspec-users] something.should_be_open blows up? Message-ID: <810a540e0612190807na2ca7aaq381845bcc9f2195a@mail.gmail.com> context "A new Foo" specify "should be open" do Foo.new.should_be_open end end ArgumentError in 'A new Foo should be open' wrong number of arguments (0 for 1) ./foo_spec.rb:9: class Foo def open?; true; end end What's the deal with that? I looked in the RDoc and nothing seems to define open?. I can get around it for now by doing the opposite (should_not_be_closed), but that seems sorta weird. Anyone else have issues? Pat From aslak.hellesoy at gmail.com Tue Dec 19 12:32:11 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 19 Dec 2006 18:32:11 +0100 Subject: [rspec-users] something.should_be_open blows up? In-Reply-To: <810a540e0612190807na2ca7aaq381845bcc9f2195a@mail.gmail.com> References: <810a540e0612190807na2ca7aaq381845bcc9f2195a@mail.gmail.com> Message-ID: <8d961d900612190932q5e82371akedcff225ee9fde7@mail.gmail.com> On 12/19/06, Pat Maddox wrote: > context "A new Foo" > specify "should be open" do > Foo.new.should_be_open > end > end > > ArgumentError in 'A new Foo should be open' > wrong number of arguments (0 for 1) > ./foo_spec.rb:9: > > class Foo > def open?; true; end > end > > What's the deal with that? I looked in the RDoc and nothing seems to > define open?. I can get around it for now by doing the opposite > (should_not_be_closed), but that seems sorta weird. Anyone else have > issues? > Looks like a bug. A patch or bug report would be great. > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Wed Dec 20 05:47:48 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 03:47:48 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? Message-ID: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> Started a new Rails project, and installed RSpec and the Rails plugin vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 vendor/plugins/rspec_on_rails (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) - 1332 Generated the rspec file, created a model...the spec runs fine if I do ruby spec/models/foo_spec.rb. Running rake though gives me the Your RSpec on Rails plugin is incompatible with your installed RSpec. RSpec : 0.7.5 (r1330) RSpec on Rails : r1332 error. So apparently it's looking at the gem rspec instead of the one I installed in my plugins folder. I've got an existing Rails app that uses edge RSpec, so I updated it to see if it broke, but it runs fine. I'm really really confused, I can't tell what the difference is. Both apps are at the same revision, there's nothing special about the config, but the old app works fine and the brand new one doesn't. Any clues on what to do? I don't remember doing anything special to get RSpec working. Just really confused now. Pat From dchelimsky at gmail.com Wed Dec 20 10:16:29 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 09:16:29 -0600 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> Message-ID: <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> On 12/20/06, Pat Maddox wrote: > Started a new Rails project, and installed RSpec and the Rails plugin > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > vendor/plugins/rspec_on_rails > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > - 1332 > > Generated the rspec file, created a model...the spec runs fine if I do > ruby spec/models/foo_spec.rb. Running rake though gives me the > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > RSpec : 0.7.5 (r1330) > RSpec on Rails : r1332 > > error. So apparently it's looking at the gem rspec instead of the one > I installed in my plugins folder. I've got an existing Rails app that > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > I'm really really confused, I can't tell what the difference is. > Both apps are at the same revision, there's nothing special about the > config, but the old app works fine and the brand new one doesn't. The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > Any clues on what to do? I don't remember doing anything special to > get RSpec working. Just really confused now. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Wed Dec 20 10:58:30 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 08:58:30 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> Message-ID: <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> On 12/20/06, David Chelimsky wrote: > On 12/20/06, Pat Maddox wrote: > > Started a new Rails project, and installed RSpec and the Rails plugin > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > vendor/plugins/rspec_on_rails > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > - 1332 > > > > Generated the rspec file, created a model...the spec runs fine if I do > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > RSpec : 0.7.5 (r1330) > > RSpec on Rails : r1332 > > > > error. So apparently it's looking at the gem rspec instead of the one > > I installed in my plugins folder. I've got an existing Rails app that > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > I'm really really confused, I can't tell what the difference is. > > Both apps are at the same revision, there's nothing special about the > > config, but the old app works fine and the brand new one doesn't. > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? It's something to do with Rails...my old app didn't have the very latest edge. r5734 works fine, and the latest doesn't. I'm gonna step through the revisions to find out just what broke RSpec. Pat From pergesu at gmail.com Wed Dec 20 11:13:17 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 09:13:17 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> Message-ID: <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> On 12/20/06, Pat Maddox wrote: > On 12/20/06, David Chelimsky wrote: > > On 12/20/06, Pat Maddox wrote: > > > Started a new Rails project, and installed RSpec and the Rails plugin > > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > > vendor/plugins/rspec_on_rails > > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > > - 1332 > > > > > > Generated the rspec file, created a model...the spec runs fine if I do > > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > > > RSpec : 0.7.5 (r1330) > > > RSpec on Rails : r1332 > > > > > > error. So apparently it's looking at the gem rspec instead of the one > > > I installed in my plugins folder. I've got an existing Rails app that > > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > > I'm really really confused, I can't tell what the difference is. > > > Both apps are at the same revision, there's nothing special about the > > > config, but the old app works fine and the brand new one doesn't. > > > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > It's something to do with Rails...my old app didn't have the very > latest edge. r5734 works fine, and the latest doesn't. I'm gonna > step through the revisions to find out just what broke RSpec. > > Pat > Okay, Rails edge r5738 breaks it. The changeset is at http://dev.rubyonrails.org/changeset/5720 You can't replicate it in the demo app because of how the app loads everything (I guess). The demo app doesn't break at all, but if you've just installed rspec as a plugin and the Rails plugin then it breaks at 5738. Pat From pergesu at gmail.com Wed Dec 20 11:32:31 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 09:32:31 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> Message-ID: <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> On 12/20/06, Pat Maddox wrote: > On 12/20/06, Pat Maddox wrote: > > On 12/20/06, David Chelimsky wrote: > > > On 12/20/06, Pat Maddox wrote: > > > > Started a new Rails project, and installed RSpec and the Rails plugin > > > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > > > vendor/plugins/rspec_on_rails > > > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > > > - 1332 > > > > > > > > Generated the rspec file, created a model...the spec runs fine if I do > > > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > > > > > RSpec : 0.7.5 (r1330) > > > > RSpec on Rails : r1332 > > > > > > > > error. So apparently it's looking at the gem rspec instead of the one > > > > I installed in my plugins folder. I've got an existing Rails app that > > > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > > > I'm really really confused, I can't tell what the difference is. > > > > Both apps are at the same revision, there's nothing special about the > > > > config, but the old app works fine and the brand new one doesn't. > > > > > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > > > It's something to do with Rails...my old app didn't have the very > > latest edge. r5734 works fine, and the latest doesn't. I'm gonna > > step through the revisions to find out just what broke RSpec. > > > > Pat > > > > Okay, Rails edge r5738 breaks it. The changeset is at > http://dev.rubyonrails.org/changeset/5720 > > You can't replicate it in the demo app because of how the app loads > everything (I guess). The demo app doesn't break at all, but if > you've just installed rspec as a plugin and the Rails plugin then it > breaks at 5738. > > Pat > Sorry, changeset should be http://dev.rubyonrails.org/changeset/5738 The problem is that initializer.rb is no longer calling paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] in the default_load_paths method. I've tried adding config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) to the config block in environment.rb but it's not doing anything. So I haven't been able to fix it, but at least we have a place to look. Pat From pergesu at gmail.com Wed Dec 20 12:49:01 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 10:49:01 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> Message-ID: <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> On 12/20/06, Pat Maddox wrote: > On 12/20/06, Pat Maddox wrote: > > On 12/20/06, Pat Maddox wrote: > > > On 12/20/06, David Chelimsky wrote: > > > > On 12/20/06, Pat Maddox wrote: > > > > > Started a new Rails project, and installed RSpec and the Rails plugin > > > > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > > > > vendor/plugins/rspec_on_rails > > > > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > > > > - 1332 > > > > > > > > > > Generated the rspec file, created a model...the spec runs fine if I do > > > > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > > > > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > > > > > > > RSpec : 0.7.5 (r1330) > > > > > RSpec on Rails : r1332 > > > > > > > > > > error. So apparently it's looking at the gem rspec instead of the one > > > > > I installed in my plugins folder. I've got an existing Rails app that > > > > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > > > > I'm really really confused, I can't tell what the difference is. > > > > > Both apps are at the same revision, there's nothing special about the > > > > > config, but the old app works fine and the brand new one doesn't. > > > > > > > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > > > > > It's something to do with Rails...my old app didn't have the very > > > latest edge. r5734 works fine, and the latest doesn't. I'm gonna > > > step through the revisions to find out just what broke RSpec. > > > > > > Pat > > > > > > > Okay, Rails edge r5738 breaks it. The changeset is at > > http://dev.rubyonrails.org/changeset/5720 > > > > You can't replicate it in the demo app because of how the app loads > > everything (I guess). The demo app doesn't break at all, but if > > you've just installed rspec as a plugin and the Rails plugin then it > > breaks at 5738. > > > > Pat > > > > Sorry, changeset should be http://dev.rubyonrails.org/changeset/5738 > > The problem is that initializer.rb is no longer calling > > paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] > > in the default_load_paths method. > > I've tried adding > > config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib > #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) > > to the config block in environment.rb but it's not doing anything. > > So I haven't been able to fix it, but at least we have a place to look. > > Pat > Has to do with some path issues, the rake tasks got broken. Patch on the way. Pat From dchelimsky at gmail.com Wed Dec 20 12:58:17 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 11:58:17 -0600 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> Message-ID: <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> On 12/20/06, Pat Maddox wrote: > On 12/20/06, Pat Maddox wrote: > > On 12/20/06, Pat Maddox wrote: > > > On 12/20/06, Pat Maddox wrote: > > > > On 12/20/06, David Chelimsky wrote: > > > > > On 12/20/06, Pat Maddox wrote: > > > > > > Started a new Rails project, and installed RSpec and the Rails plugin > > > > > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > > > > > vendor/plugins/rspec_on_rails > > > > > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > > > > > - 1332 > > > > > > > > > > > > Generated the rspec file, created a model...the spec runs fine if I do > > > > > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > > > > > > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > > > > > > > > > RSpec : 0.7.5 (r1330) > > > > > > RSpec on Rails : r1332 > > > > > > > > > > > > error. So apparently it's looking at the gem rspec instead of the one > > > > > > I installed in my plugins folder. I've got an existing Rails app that > > > > > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > > > > > I'm really really confused, I can't tell what the difference is. > > > > > > Both apps are at the same revision, there's nothing special about the > > > > > > config, but the old app works fine and the brand new one doesn't. > > > > > > > > > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > > > > > > > It's something to do with Rails...my old app didn't have the very > > > > latest edge. r5734 works fine, and the latest doesn't. I'm gonna > > > > step through the revisions to find out just what broke RSpec. > > > > > > > > Pat > > > > > > > > > > Okay, Rails edge r5738 breaks it. The changeset is at > > > http://dev.rubyonrails.org/changeset/5720 > > > > > > You can't replicate it in the demo app because of how the app loads > > > everything (I guess). The demo app doesn't break at all, but if > > > you've just installed rspec as a plugin and the Rails plugin then it > > > breaks at 5738. > > > > > > Pat > > > > > > > Sorry, changeset should be http://dev.rubyonrails.org/changeset/5738 > > > > The problem is that initializer.rb is no longer calling > > > > paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] > > > > in the default_load_paths method. > > > > I've tried adding > > > > config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib > > #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) > > > > to the config block in environment.rb but it's not doing anything. > > > > So I haven't been able to fix it, but at least we have a place to look. > > > > Pat > > > > Has to do with some path issues, the rake tasks got broken. Patch on the way. An rspec patch or a rails patch? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Dec 20 13:04:55 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 12:04:55 -0600 Subject: [rspec-users] [ANN] RSpec 0.7.5 Message-ID: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> The RSpec Development Team is pleased to announce the release of RSpec 0.7.5. This release adds support for Heckle - Seattle'rb's code mutation tool. There are also several bug fixes to the RSpec core and the RSpec on Rails plugin. Changes: http://rspec.rubyforge.org/changes.html Download: http://rubyforge.org/frs/?group_id=797 or gem install rspec Happy spec'ing, and now heckling! The RSpec Development Team From pergesu at gmail.com Wed Dec 20 13:30:26 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 11:30:26 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> Message-ID: <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> On 12/20/06, David Chelimsky wrote: > On 12/20/06, Pat Maddox wrote: > > On 12/20/06, Pat Maddox wrote: > > > On 12/20/06, Pat Maddox wrote: > > > > On 12/20/06, Pat Maddox wrote: > > > > > On 12/20/06, David Chelimsky wrote: > > > > > > On 12/20/06, Pat Maddox wrote: > > > > > > > Started a new Rails project, and installed RSpec and the Rails plugin > > > > > > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > > > > > > vendor/plugins/rspec_on_rails > > > > > > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > > > > > > - 1332 > > > > > > > > > > > > > > Generated the rspec file, created a model...the spec runs fine if I do > > > > > > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > > > > > > > > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > > > > > > > > > > > RSpec : 0.7.5 (r1330) > > > > > > > RSpec on Rails : r1332 > > > > > > > > > > > > > > error. So apparently it's looking at the gem rspec instead of the one > > > > > > > I installed in my plugins folder. I've got an existing Rails app that > > > > > > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > > > > > > I'm really really confused, I can't tell what the difference is. > > > > > > > Both apps are at the same revision, there's nothing special about the > > > > > > > config, but the old app works fine and the brand new one doesn't. > > > > > > > > > > > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > > > > > > > > > It's something to do with Rails...my old app didn't have the very > > > > > latest edge. r5734 works fine, and the latest doesn't. I'm gonna > > > > > step through the revisions to find out just what broke RSpec. > > > > > > > > > > Pat > > > > > > > > > > > > > Okay, Rails edge r5738 breaks it. The changeset is at > > > > http://dev.rubyonrails.org/changeset/5720 > > > > > > > > You can't replicate it in the demo app because of how the app loads > > > > everything (I guess). The demo app doesn't break at all, but if > > > > you've just installed rspec as a plugin and the Rails plugin then it > > > > breaks at 5738. > > > > > > > > Pat > > > > > > > > > > Sorry, changeset should be http://dev.rubyonrails.org/changeset/5738 > > > > > > The problem is that initializer.rb is no longer calling > > > > > > paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] > > > > > > in the default_load_paths method. > > > > > > I've tried adding > > > > > > config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib > > > #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) > > > > > > to the config block in environment.rb but it's not doing anything. > > > > > > So I haven't been able to fix it, but at least we have a place to look. > > > > > > Pat > > > > > > > Has to do with some path issues, the rake tasks got broken. Patch on the way. > > An rspec patch or a rails patch? > RSpec. I accidentally filed it in bugs, but https://rubyforge.org/tracker/index.php?func=detail&aid=7393&group_id=797&atid=3149 has the info and the patch. Over all pretty simple, but it was a bitch to figure out. No errors or anything...Rails just silently ignored the task file. Pat From work at ashleymoran.me.uk Wed Dec 20 13:34:40 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Wed, 20 Dec 2006 18:34:40 +0000 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> Message-ID: On Dec 20, 2006, at 6:04 pm, David Chelimsky wrote: > This release adds support for Heckle - Seattle'rb's code mutation > tool. > There are also several bug fixes to the RSpec core and the RSpec on > Rails plugin. I only found out about Jester/Heckle a week ago and it's already in RSpec! How does this project add stuff so fast? assert_select is in there too, although I haven't had chance to try it. Is it me or are the days of Test::Unit already numbered? > Happy spec'ing, and now heckling! Does heckle work with RSpec on Rails? Is there an easy way to run heckled MVC unit tests? Ashley From dchelimsky at gmail.com Wed Dec 20 13:45:33 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 12:45:33 -0600 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> Message-ID: <57c63afe0612201045na320f52x5297a3678bd498c0@mail.gmail.com> On 12/20/06, Ashley Moran wrote: > On Dec 20, 2006, at 6:04 pm, David Chelimsky wrote: > > > This release adds support for Heckle - Seattle'rb's code mutation > > tool. > > There are also several bug fixes to the RSpec core and the RSpec on > > Rails plugin. > > I only found out about Jester/Heckle a week ago and it's already in > RSpec! How does this project add stuff so fast? assert_select is in > there too, although I haven't had chance to try it. Beware assert_select - it is there but unofficial and likely to change in syntax (we need to reconcile the existing should_have_tag, etc w/ should_have). > Is it me or are > the days of Test::Unit already numbered? > > > > Happy spec'ing, and now heckling! > > Does heckle work with RSpec on Rails? Is there an easy way to run > heckled MVC unit tests? spec spec/models --heckle MyModelClass Cheers! > > > Ashley > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Dec 20 14:19:07 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 13:19:07 -0600 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> Message-ID: <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> On 12/20/06, Pat Maddox wrote: > On 12/20/06, David Chelimsky wrote: > > On 12/20/06, Pat Maddox wrote: > > > On 12/20/06, Pat Maddox wrote: > > > > On 12/20/06, Pat Maddox wrote: > > > > > On 12/20/06, Pat Maddox wrote: > > > > > > On 12/20/06, David Chelimsky wrote: > > > > > > > On 12/20/06, Pat Maddox wrote: > > > > > > > > Started a new Rails project, and installed RSpec and the Rails plugin > > > > > > > > vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/trunk/rspec) - 1332 > > > > > > > > vendor/plugins/rspec_on_rails > > > > > > > > (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/vendor/plugins/rspec_on_rails) > > > > > > > > - 1332 > > > > > > > > > > > > > > > > Generated the rspec file, created a model...the spec runs fine if I do > > > > > > > > ruby spec/models/foo_spec.rb. Running rake though gives me the > > > > > > > > > > > > > > > > Your RSpec on Rails plugin is incompatible with your installed RSpec. > > > > > > > > > > > > > > > > RSpec : 0.7.5 (r1330) > > > > > > > > RSpec on Rails : r1332 > > > > > > > > > > > > > > > > error. So apparently it's looking at the gem rspec instead of the one > > > > > > > > I installed in my plugins folder. I've got an existing Rails app that > > > > > > > > uses edge RSpec, so I updated it to see if it broke, but it runs fine. > > > > > > > > I'm really really confused, I can't tell what the difference is. > > > > > > > > Both apps are at the same revision, there's nothing special about the > > > > > > > > config, but the old app works fine and the brand new one doesn't. > > > > > > > > > > > > > > The only diff would be in ~/spec/spec_helper.rb. Any differences in there? > > > > > > > > > > > > It's something to do with Rails...my old app didn't have the very > > > > > > latest edge. r5734 works fine, and the latest doesn't. I'm gonna > > > > > > step through the revisions to find out just what broke RSpec. > > > > > > > > > > > > Pat > > > > > > > > > > > > > > > > Okay, Rails edge r5738 breaks it. The changeset is at > > > > > http://dev.rubyonrails.org/changeset/5720 > > > > > > > > > > You can't replicate it in the demo app because of how the app loads > > > > > everything (I guess). The demo app doesn't break at all, but if > > > > > you've just installed rspec as a plugin and the Rails plugin then it > > > > > breaks at 5738. > > > > > > > > > > Pat > > > > > > > > > > > > > Sorry, changeset should be http://dev.rubyonrails.org/changeset/5738 > > > > > > > > The problem is that initializer.rb is no longer calling > > > > > > > > paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] > > > > > > > > in the default_load_paths method. > > > > > > > > I've tried adding > > > > > > > > config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib > > > > #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) > > > > > > > > to the config block in environment.rb but it's not doing anything. > > > > > > > > So I haven't been able to fix it, but at least we have a place to look. > > > > > > > > Pat > > > > > > > > > > Has to do with some path issues, the rake tasks got broken. Patch on the way. > > > > An rspec patch or a rails patch? > > > > > RSpec. I accidentally filed it in bugs, but > https://rubyforge.org/tracker/index.php?func=detail&aid=7393&group_id=797&atid=3149 > has the info and the patch. > > Over all pretty simple, but it was a bitch to figure out. No errors > or anything...Rails just silently ignored the task file. Nice work Pat. Thanks. I moved it to patches and will commit it later today. Cheers, David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Wed Dec 20 16:48:05 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Wed, 20 Dec 2006 21:48:05 +0000 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <57c63afe0612201045na320f52x5297a3678bd498c0@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> <57c63afe0612201045na320f52x5297a3678bd498c0@mail.gmail.com> Message-ID: On Dec 20, 2006, at 6:45 pm, David Chelimsky wrote: > Beware assert_select - it is there but unofficial and likely to change > in syntax (we need to reconcile the existing should_have_tag, etc w/ > should_have). Thanks for the warning. I've kinda got used to api changes, pretty much everything we've started lately has been bleeding edge - Rails 1.2 RC 1, rspec on rails, soon rspec + (safari)watir. It seems that since the world (ruby world at least) went TDD, 0.x software is good enough for production if you can live with changing your own code every release. If I get chance to work on the view code for our apps myself I'll be back with some feedback on assert_select > spec spec/models --heckle MyModelClass Cheers for the tip :) Ashley From pergesu at gmail.com Wed Dec 20 17:27:34 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 15:27:34 -0700 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <57c63afe0612201045na320f52x5297a3678bd498c0@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> <57c63afe0612201045na320f52x5297a3678bd498c0@mail.gmail.com> Message-ID: <810a540e0612201427j4cd9bc90s131d055918c5f0f6@mail.gmail.com> On 12/20/06, David Chelimsky wrote: > On 12/20/06, Ashley Moran wrote: > > > > Does heckle work with RSpec on Rails? Is there an easy way to run > > heckled MVC unit tests? > > spec spec/models --heckle MyModelClass Is there an easier way to get at the spec binary for edge? Right now I'm having to do ./vendor/plugins/rspec/bin/spec spec/models/ --heckle MyModelClass symlinks aren't working at all. Just wondering if there's a shorter way. Also I get a lot of weird errors from permutations that aren't in my code...just briefly ran it, I'll have to take a closer look. Pat From jaydonnell at yahoo.com Wed Dec 20 14:53:15 2006 From: jaydonnell at yahoo.com (jshen) Date: Wed, 20 Dec 2006 11:53:15 -0800 (PST) Subject: [rspec-users] How to keep mocks consistent? In-Reply-To: <57c63afe0612181449m74611a1cwa8ae02841ad73602@mail.gmail.com> References: <57c63afe0612181449m74611a1cwa8ae02841ad73602@mail.gmail.com> Message-ID: <7996667.post@talk.nabble.com> "The isolated unit level testing that you're getting from using mocks should (MUST) be coupled with some level of integration testing. Right now I'm using either rails integration testing and/or selenium." I have similar concerns and this doesn't quite address them. He asked how to manage changes that affect mocks that could be in many places. It seems like something that would be very easy to forget or miss. Also, catching the errors at the integration level is forcing yourself to test the same functionality twice. I'm just starting with rspec and my standard tests in rails would test functionality once at the rails unit test level. At the integration level I would assume the functionality worked and mainly test that the controllers and views handled different cases (i.e. errors) properly. I know this isn't ideal, but I'm wondering if the duplication of work, both in testing and in mock building, is worth the effort on medium sized projects done by small teams. -- View this message in context: http://www.nabble.com/How-to-keep-mocks-consistent--tf2842806.html#a7996667 Sent from the rspec-users mailing list archive at Nabble.com. From david at davelee.com.au Wed Dec 20 17:36:08 2006 From: david at davelee.com.au (David Lee) Date: Thu, 21 Dec 2006 09:36:08 +1100 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> Message-ID: <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> Should I take this flurry of concerted activity to mean that RSpec ( or at least a few committed committers ) now support edge rails, and people are using it fine for Edge projects ? cheers, David On 21/12/2006, at 6:19 AM, David Chelimsky wrote: > On 12/20/06, Pat Maddox wrote: >> On 12/20/06, David Chelimsky wrote: >>> On 12/20/06, Pat Maddox wrote: >>>> On 12/20/06, Pat Maddox wrote: >>>>> On 12/20/06, Pat Maddox wrote: >>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>> On 12/20/06, David Chelimsky wrote: >>>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>>> Started a new Rails project, and installed RSpec and the >>>>>>>>> Rails plugin >>>>>>>>> vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/ >>>>>>>>> trunk/rspec) - 1332 >>>>>>>>> vendor/plugins/rspec_on_rails >>>>>>>>> (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/ >>>>>>>>> vendor/plugins/rspec_on_rails) >>>>>>>>> - 1332 >>>>>>>>> >>>>>>>>> Generated the rspec file, created a model...the spec runs >>>>>>>>> fine if I do >>>>>>>>> ruby spec/models/foo_spec.rb. Running rake though gives me >>>>>>>>> the >>>>>>>>> >>>>>>>>> Your RSpec on Rails plugin is incompatible with your >>>>>>>>> installed RSpec. >>>>>>>>> >>>>>>>>> RSpec : 0.7.5 (r1330) >>>>>>>>> RSpec on Rails : r1332 >>>>>>>>> >>>>>>>>> error. So apparently it's looking at the gem rspec instead >>>>>>>>> of the one >>>>>>>>> I installed in my plugins folder. I've got an existing >>>>>>>>> Rails app that >>>>>>>>> uses edge RSpec, so I updated it to see if it broke, but it >>>>>>>>> runs fine. >>>>>>>>> I'm really really confused, I can't tell what the >>>>>>>>> difference is. >>>>>>>>> Both apps are at the same revision, there's nothing special >>>>>>>>> about the >>>>>>>>> config, but the old app works fine and the brand new one >>>>>>>>> doesn't. >>>>>>>> >>>>>>>> The only diff would be in ~/spec/spec_helper.rb. Any >>>>>>>> differences in there? >>>>>>> >>>>>>> It's something to do with Rails...my old app didn't have the >>>>>>> very >>>>>>> latest edge. r5734 works fine, and the latest doesn't. I'm >>>>>>> gonna >>>>>>> step through the revisions to find out just what broke RSpec. >>>>>>> >>>>>>> Pat >>>>>>> >>>>>> >>>>>> Okay, Rails edge r5738 breaks it. The changeset is at >>>>>> http://dev.rubyonrails.org/changeset/5720 >>>>>> >>>>>> You can't replicate it in the demo app because of how the app >>>>>> loads >>>>>> everything (I guess). The demo app doesn't break at all, but if >>>>>> you've just installed rspec as a plugin and the Rails plugin >>>>>> then it >>>>>> breaks at 5738. >>>>>> >>>>>> Pat >>>>>> >>>>> >>>>> Sorry, changeset should be http://dev.rubyonrails.org/changeset/ >>>>> 5738 >>>>> >>>>> The problem is that initializer.rb is no longer calling >>>>> >>>>> paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] >>>>> >>>>> in the default_load_paths method. >>>>> >>>>> I've tried adding >>>>> >>>>> config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib >>>>> #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) >>>>> >>>>> to the config block in environment.rb but it's not doing anything. >>>>> >>>>> So I haven't been able to fix it, but at least we have a place >>>>> to look. >>>>> >>>>> Pat >>>>> >>>> >>>> Has to do with some path issues, the rake tasks got broken. >>>> Patch on the way. >>> >>> An rspec patch or a rails patch? >>> >> >> >> RSpec. I accidentally filed it in bugs, but >> https://rubyforge.org/tracker/index.php? >> func=detail&aid=7393&group_id=797&atid=3149 >> has the info and the patch. >> >> Over all pretty simple, but it was a bitch to figure out. No errors >> or anything...Rails just silently ignored the task file. > > Nice work Pat. Thanks. > > I moved it to patches and will commit it later today. > > Cheers, > David > >> >> 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 From work at ashleymoran.me.uk Wed Dec 20 17:48:41 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Wed, 20 Dec 2006 22:48:41 +0000 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <810a540e0612201427j4cd9bc90s131d055918c5f0f6@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> <57c63afe0612201045na320f52x5297a3678bd498c0@mail.gmail.com> <810a540e0612201427j4cd9bc90s131d055918c5f0f6@mail.gmail.com> Message-ID: <96C07941-0306-4BB8-B1C4-E4D45FB8A771@ashleymoran.me.uk> On Dec 20, 2006, at 10:27 pm, Pat Maddox wrote: > Is there an easier way to get at the spec binary for edge? Right now > I'm having to do > ./vendor/plugins/rspec/bin/spec spec/models/ --heckle MyModelClass Could always export PATH=./vendor/plugins/rspec/bin:$PATH in ~/.profile Including . in $PATH isn't considered good security practice though but it's an option Ashley From dchelimsky at gmail.com Wed Dec 20 17:51:18 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 16:51:18 -0600 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> Message-ID: <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> On 12/20/06, David Lee wrote: > Should I take this flurry of concerted activity to mean that RSpec > ( or at least a few committed committers ) now support edge rails, > and people are using it fine for Edge projects ? NO, NO, NO, NO. There is absolutely NO guarantee or even formalized attempt to keep up w/ edge rails. We do NOT recommend that you use rspec_on_rails w/ anything other than the current stable release of rails (1.1.6) unless YOU are prepared to maintain it yourself!!!!!! That said, we do try to keep up ;) Cheers, David > > cheers, > David > > On 21/12/2006, at 6:19 AM, David Chelimsky wrote: > > > On 12/20/06, Pat Maddox wrote: > >> On 12/20/06, David Chelimsky wrote: > >>> On 12/20/06, Pat Maddox wrote: > >>>> On 12/20/06, Pat Maddox wrote: > >>>>> On 12/20/06, Pat Maddox wrote: > >>>>>> On 12/20/06, Pat Maddox wrote: > >>>>>>> On 12/20/06, David Chelimsky wrote: > >>>>>>>> On 12/20/06, Pat Maddox wrote: > >>>>>>>>> Started a new Rails project, and installed RSpec and the > >>>>>>>>> Rails plugin > >>>>>>>>> vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/ > >>>>>>>>> trunk/rspec) - 1332 > >>>>>>>>> vendor/plugins/rspec_on_rails > >>>>>>>>> (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/ > >>>>>>>>> vendor/plugins/rspec_on_rails) > >>>>>>>>> - 1332 > >>>>>>>>> > >>>>>>>>> Generated the rspec file, created a model...the spec runs > >>>>>>>>> fine if I do > >>>>>>>>> ruby spec/models/foo_spec.rb. Running rake though gives me > >>>>>>>>> the > >>>>>>>>> > >>>>>>>>> Your RSpec on Rails plugin is incompatible with your > >>>>>>>>> installed RSpec. > >>>>>>>>> > >>>>>>>>> RSpec : 0.7.5 (r1330) > >>>>>>>>> RSpec on Rails : r1332 > >>>>>>>>> > >>>>>>>>> error. So apparently it's looking at the gem rspec instead > >>>>>>>>> of the one > >>>>>>>>> I installed in my plugins folder. I've got an existing > >>>>>>>>> Rails app that > >>>>>>>>> uses edge RSpec, so I updated it to see if it broke, but it > >>>>>>>>> runs fine. > >>>>>>>>> I'm really really confused, I can't tell what the > >>>>>>>>> difference is. > >>>>>>>>> Both apps are at the same revision, there's nothing special > >>>>>>>>> about the > >>>>>>>>> config, but the old app works fine and the brand new one > >>>>>>>>> doesn't. > >>>>>>>> > >>>>>>>> The only diff would be in ~/spec/spec_helper.rb. Any > >>>>>>>> differences in there? > >>>>>>> > >>>>>>> It's something to do with Rails...my old app didn't have the > >>>>>>> very > >>>>>>> latest edge. r5734 works fine, and the latest doesn't. I'm > >>>>>>> gonna > >>>>>>> step through the revisions to find out just what broke RSpec. > >>>>>>> > >>>>>>> Pat > >>>>>>> > >>>>>> > >>>>>> Okay, Rails edge r5738 breaks it. The changeset is at > >>>>>> http://dev.rubyonrails.org/changeset/5720 > >>>>>> > >>>>>> You can't replicate it in the demo app because of how the app > >>>>>> loads > >>>>>> everything (I guess). The demo app doesn't break at all, but if > >>>>>> you've just installed rspec as a plugin and the Rails plugin > >>>>>> then it > >>>>>> breaks at 5738. > >>>>>> > >>>>>> Pat > >>>>>> > >>>>> > >>>>> Sorry, changeset should be http://dev.rubyonrails.org/changeset/ > >>>>> 5738 > >>>>> > >>>>> The problem is that initializer.rb is no longer calling > >>>>> > >>>>> paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] > >>>>> > >>>>> in the default_load_paths method. > >>>>> > >>>>> I've tried adding > >>>>> > >>>>> config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib > >>>>> #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) > >>>>> > >>>>> to the config block in environment.rb but it's not doing anything. > >>>>> > >>>>> So I haven't been able to fix it, but at least we have a place > >>>>> to look. > >>>>> > >>>>> Pat > >>>>> > >>>> > >>>> Has to do with some path issues, the rake tasks got broken. > >>>> Patch on the way. > >>> > >>> An rspec patch or a rails patch? > >>> > >> > >> > >> RSpec. I accidentally filed it in bugs, but > >> https://rubyforge.org/tracker/index.php? > >> func=detail&aid=7393&group_id=797&atid=3149 > >> has the info and the patch. > >> > >> Over all pretty simple, but it was a bitch to figure out. No errors > >> or anything...Rails just silently ignored the task file. > > > > Nice work Pat. Thanks. > > > > I moved it to patches and will commit it later today. > > > > Cheers, > > David > > > >> > >> 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 brixen at gmail.com Wed Dec 20 18:33:19 2006 From: brixen at gmail.com (brian ford) Date: Wed, 20 Dec 2006 15:33:19 -0800 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> Message-ID: <8b80ba590612201533m310656e4xcbd0689888321d83@mail.gmail.com> Hello, I've read the changes for 0.7.5. I'm not sure what this means: * Removed svn:externals on rails versions and plugins So, I'm not sure if something has changed with the installation procedure for the rspec_on_rails plugin. When I do svn list svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/rails there are no files listed. No errors, but no files. I've been using rspec for a while, through 0.7.4, so I'm confused. Am I doing something wrong? Thanks, Brian On 12/20/06, David Chelimsky wrote: > The RSpec Development Team is pleased to announce the release of RSpec 0.7.5. > > This release adds support for Heckle - Seattle'rb's code mutation tool. > There are also several bug fixes to the RSpec core and the RSpec on > Rails plugin. > > Changes: http://rspec.rubyforge.org/changes.html > Download: http://rubyforge.org/frs/?group_id=797 > or > gem install rspec > > > Happy spec'ing, and now heckling! > > The RSpec Development Team > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lourens at rentacarhire.com Wed Dec 20 18:33:54 2006 From: lourens at rentacarhire.com (Lourens Naude) Date: Wed, 20 Dec 2006 23:33:54 +0000 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> Message-ID: <0257BF5C-EF36-4B77-8317-341689E9DAB7@rentacarhire.com> David, Been using rspec releases for 2 months with daily updated Edge without major glitches. For the odd edge cases, there's always temp. monkey patching. Will tackle 0.7.5 tonight. - Lourens http://blog.methodmissing.com On 2006/12/20, at 22:51, David Chelimsky wrote: > On 12/20/06, David Lee wrote: >> Should I take this flurry of concerted activity to mean that RSpec >> ( or at least a few committed committers ) now support edge rails, >> and people are using it fine for Edge projects ? > > NO, NO, NO, NO. There is absolutely NO guarantee or even formalized > attempt to keep up w/ edge rails. We do NOT recommend that you use > rspec_on_rails w/ anything other than the current stable release of > rails (1.1.6) unless YOU are prepared to maintain it yourself!!!!!! > > That said, we do try to keep up ;) > > Cheers, > David > >> >> cheers, >> David >> >> On 21/12/2006, at 6:19 AM, David Chelimsky wrote: >> >>> On 12/20/06, Pat Maddox wrote: >>>> On 12/20/06, David Chelimsky wrote: >>>>> On 12/20/06, Pat Maddox wrote: >>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>>> On 12/20/06, David Chelimsky wrote: >>>>>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>>>>> Started a new Rails project, and installed RSpec and the >>>>>>>>>>> Rails plugin >>>>>>>>>>> vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/ >>>>>>>>>>> trunk/rspec) - 1332 >>>>>>>>>>> vendor/plugins/rspec_on_rails >>>>>>>>>>> (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/ >>>>>>>>>>> vendor/plugins/rspec_on_rails) >>>>>>>>>>> - 1332 >>>>>>>>>>> >>>>>>>>>>> Generated the rspec file, created a model...the spec runs >>>>>>>>>>> fine if I do >>>>>>>>>>> ruby spec/models/foo_spec.rb. Running rake though gives me >>>>>>>>>>> the >>>>>>>>>>> >>>>>>>>>>> Your RSpec on Rails plugin is incompatible with your >>>>>>>>>>> installed RSpec. >>>>>>>>>>> >>>>>>>>>>> RSpec : 0.7.5 (r1330) >>>>>>>>>>> RSpec on Rails : r1332 >>>>>>>>>>> >>>>>>>>>>> error. So apparently it's looking at the gem rspec instead >>>>>>>>>>> of the one >>>>>>>>>>> I installed in my plugins folder. I've got an existing >>>>>>>>>>> Rails app that >>>>>>>>>>> uses edge RSpec, so I updated it to see if it broke, but it >>>>>>>>>>> runs fine. >>>>>>>>>>> I'm really really confused, I can't tell what the >>>>>>>>>>> difference is. >>>>>>>>>>> Both apps are at the same revision, there's nothing special >>>>>>>>>>> about the >>>>>>>>>>> config, but the old app works fine and the brand new one >>>>>>>>>>> doesn't. >>>>>>>>>> >>>>>>>>>> The only diff would be in ~/spec/spec_helper.rb. Any >>>>>>>>>> differences in there? >>>>>>>>> >>>>>>>>> It's something to do with Rails...my old app didn't have the >>>>>>>>> very >>>>>>>>> latest edge. r5734 works fine, and the latest doesn't. I'm >>>>>>>>> gonna >>>>>>>>> step through the revisions to find out just what broke RSpec. >>>>>>>>> >>>>>>>>> Pat >>>>>>>>> >>>>>>>> >>>>>>>> Okay, Rails edge r5738 breaks it. The changeset is at >>>>>>>> http://dev.rubyonrails.org/changeset/5720 >>>>>>>> >>>>>>>> You can't replicate it in the demo app because of how the app >>>>>>>> loads >>>>>>>> everything (I guess). The demo app doesn't break at all, >>>>>>>> but if >>>>>>>> you've just installed rspec as a plugin and the Rails plugin >>>>>>>> then it >>>>>>>> breaks at 5738. >>>>>>>> >>>>>>>> Pat >>>>>>>> >>>>>>> >>>>>>> Sorry, changeset should be http://dev.rubyonrails.org/changeset/ >>>>>>> 5738 >>>>>>> >>>>>>> The problem is that initializer.rb is no longer calling >>>>>>> >>>>>>> paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] >>>>>>> >>>>>>> in the default_load_paths method. >>>>>>> >>>>>>> I've tried adding >>>>>>> >>>>>>> config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib >>>>>>> #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) >>>>>>> >>>>>>> to the config block in environment.rb but it's not doing >>>>>>> anything. >>>>>>> >>>>>>> So I haven't been able to fix it, but at least we have a place >>>>>>> to look. >>>>>>> >>>>>>> Pat >>>>>>> >>>>>> >>>>>> Has to do with some path issues, the rake tasks got broken. >>>>>> Patch on the way. >>>>> >>>>> An rspec patch or a rails patch? >>>>> >>>> >>>> >>>> RSpec. I accidentally filed it in bugs, but >>>> https://rubyforge.org/tracker/index.php? >>>> func=detail&aid=7393&group_id=797&atid=3149 >>>> has the info and the patch. >>>> >>>> Over all pretty simple, but it was a bitch to figure out. No >>>> errors >>>> or anything...Rails just silently ignored the task file. >>> >>> Nice work Pat. Thanks. >>> >>> I moved it to patches and will commit it later today. >>> >>> Cheers, >>> David >>> >>>> >>>> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From brixen at gmail.com Wed Dec 20 18:49:12 2006 From: brixen at gmail.com (brian ford) Date: Wed, 20 Dec 2006 15:49:12 -0800 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <8b80ba590612201533m310656e4xcbd0689888321d83@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> <8b80ba590612201533m310656e4xcbd0689888321d83@mail.gmail.com> Message-ID: <8b80ba590612201549kd9ecf6bva1ca7547ea73d59c@mail.gmail.com> Hmm, seems this URL works: svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/plugins/rspec_on_rails the only difference is *plugins* rather than *plugin* The wiki has: svn://rubyforge.org/var/svn/rspec/tags/REL_X_Y_Z/rspec_on_rails/vendor/plugin/rspec_on_rails Thanks, Brian On 12/20/06, brian ford wrote: > Hello, > > I've read the changes for 0.7.5. I'm not sure what this means: > * Removed svn:externals on rails versions and plugins > > So, I'm not sure if something has changed with the installation > procedure for the rspec_on_rails plugin. When I do > > svn list svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/rails > > there are no files listed. No errors, but no files. > > I've been using rspec for a while, through 0.7.4, so I'm confused. Am > I doing something wrong? > > Thanks, > Brian > > On 12/20/06, David Chelimsky wrote: > > The RSpec Development Team is pleased to announce the release of RSpec 0.7.5. > > > > This release adds support for Heckle - Seattle'rb's code mutation tool. > > There are also several bug fixes to the RSpec core and the RSpec on > > Rails plugin. > > > > Changes: http://rspec.rubyforge.org/changes.html > > Download: http://rubyforge.org/frs/?group_id=797 > > or > > gem install rspec > > > > > > Happy spec'ing, and now heckling! > > > > The RSpec Development Team > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From david at davelee.com.au Wed Dec 20 19:41:54 2006 From: david at davelee.com.au (David Lee) Date: Thu, 21 Dec 2006 11:41:54 +1100 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200716i68ffb2f2x64f5489d7ff69d1c@mail.gmail.com> <810a540e0612200758ifc2eb3cvcd30c5450c7f2d25@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> Message-ID: <0B392E42-5CD0-470B-948D-CB1744931F6D@davelee.com.au> ah well, it was worth a try - thanks for the extremely clear response :) thanks, - David On 21/12/2006, at 9:51 AM, David Chelimsky wrote: > On 12/20/06, David Lee wrote: >> Should I take this flurry of concerted activity to mean that RSpec >> ( or at least a few committed committers ) now support edge rails, >> and people are using it fine for Edge projects ? > > NO, NO, NO, NO. There is absolutely NO guarantee or even formalized > attempt to keep up w/ edge rails. We do NOT recommend that you use > rspec_on_rails w/ anything other than the current stable release of > rails (1.1.6) unless YOU are prepared to maintain it yourself!!!!!! > > That said, we do try to keep up ;) > > Cheers, > David > v >> >> cheers, >> David >> >> On 21/12/2006, at 6:19 AM, David Chelimsky wrote: >> >>> On 12/20/06, Pat Maddox wrote: >>>> On 12/20/06, David Chelimsky wrote: >>>>> On 12/20/06, Pat Maddox wrote: >>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>>> On 12/20/06, David Chelimsky wrote: >>>>>>>>>> On 12/20/06, Pat Maddox wrote: >>>>>>>>>>> Started a new Rails project, and installed RSpec and the >>>>>>>>>>> Rails plugin >>>>>>>>>>> vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/ >>>>>>>>>>> trunk/rspec) - 1332 >>>>>>>>>>> vendor/plugins/rspec_on_rails >>>>>>>>>>> (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/ >>>>>>>>>>> vendor/plugins/rspec_on_rails) >>>>>>>>>>> - 1332 >>>>>>>>>>> >>>>>>>>>>> Generated the rspec file, created a model...the spec runs >>>>>>>>>>> fine if I do >>>>>>>>>>> ruby spec/models/foo_spec.rb. Running rake though gives me >>>>>>>>>>> the >>>>>>>>>>> >>>>>>>>>>> Your RSpec on Rails plugin is incompatible with your >>>>>>>>>>> installed RSpec. >>>>>>>>>>> >>>>>>>>>>> RSpec : 0.7.5 (r1330) >>>>>>>>>>> RSpec on Rails : r1332 >>>>>>>>>>> >>>>>>>>>>> error. So apparently it's looking at the gem rspec instead >>>>>>>>>>> of the one >>>>>>>>>>> I installed in my plugins folder. I've got an existing >>>>>>>>>>> Rails app that >>>>>>>>>>> uses edge RSpec, so I updated it to see if it broke, but it >>>>>>>>>>> runs fine. >>>>>>>>>>> I'm really really confused, I can't tell what the >>>>>>>>>>> difference is. >>>>>>>>>>> Both apps are at the same revision, there's nothing special >>>>>>>>>>> about the >>>>>>>>>>> config, but the old app works fine and the brand new one >>>>>>>>>>> doesn't. >>>>>>>>>> >>>>>>>>>> The only diff would be in ~/spec/spec_helper.rb. Any >>>>>>>>>> differences in there? >>>>>>>>> >>>>>>>>> It's something to do with Rails...my old app didn't have the >>>>>>>>> very >>>>>>>>> latest edge. r5734 works fine, and the latest doesn't. I'm >>>>>>>>> gonna >>>>>>>>> step through the revisions to find out just what broke RSpec. >>>>>>>>> >>>>>>>>> Pat >>>>>>>>> >>>>>>>> >>>>>>>> Okay, Rails edge r5738 breaks it. The changeset is at >>>>>>>> http://dev.rubyonrails.org/changeset/5720 >>>>>>>> >>>>>>>> You can't replicate it in the demo app because of how the app >>>>>>>> loads >>>>>>>> everything (I guess). The demo app doesn't break at all, >>>>>>>> but if >>>>>>>> you've just installed rspec as a plugin and the Rails plugin >>>>>>>> then it >>>>>>>> breaks at 5738. >>>>>>>> >>>>>>>> Pat >>>>>>>> >>>>>>> >>>>>>> Sorry, changeset should be http://dev.rubyonrails.org/changeset/ >>>>>>> 5738 >>>>>>> >>>>>>> The problem is that initializer.rb is no longer calling >>>>>>> >>>>>>> paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] >>>>>>> >>>>>>> in the default_load_paths method. >>>>>>> >>>>>>> I've tried adding >>>>>>> >>>>>>> config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib >>>>>>> #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) >>>>>>> >>>>>>> to the config block in environment.rb but it's not doing >>>>>>> anything. >>>>>>> >>>>>>> So I haven't been able to fix it, but at least we have a place >>>>>>> to look. >>>>>>> >>>>>>> Pat >>>>>>> >>>>>> >>>>>> Has to do with some path issues, the rake tasks got broken. >>>>>> Patch on the way. >>>>> >>>>> An rspec patch or a rails patch? >>>>> >>>> >>>> >>>> RSpec. I accidentally filed it in bugs, but >>>> https://rubyforge.org/tracker/index.php? >>>> func=detail&aid=7393&group_id=797&atid=3149 >>>> has the info and the patch. >>>> >>>> Over all pretty simple, but it was a bitch to figure out. No >>>> errors >>>> or anything...Rails just silently ignored the task file. >>> >>> Nice work Pat. Thanks. >>> >>> I moved it to patches and will commit it later today. >>> >>> Cheers, >>> David >>> >>>> >>>> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From brixen at gmail.com Wed Dec 20 20:45:09 2006 From: brixen at gmail.com (brian ford) Date: Wed, 20 Dec 2006 17:45:09 -0800 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <0B392E42-5CD0-470B-948D-CB1744931F6D@davelee.com.au> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <810a540e0612200813t47e38efcw756bc88d6c792f5c@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> <0B392E42-5CD0-470B-948D-CB1744931F6D@davelee.com.au> Message-ID: <8b80ba590612201745q3ce6d6a6pfa77041b82371a38@mail.gmail.com> David, I've been developing on edge rails for months and using rspec plugin (latest release, updating as soon as another is released) for at least one month and rarely have trouble. If you can, I'd say do it because it may flush out stuff that wouldn't be seen otherwise. If it really breaks, you can always revert to last release (unless you can't live without edge features, which is why I use it). One thing I do, I link to a particular version of edge, not just trunk. That way I can update it when convenient. Cheers, Brian On 12/20/06, David Lee wrote: > ah well, it was worth a try - thanks for the extremely clear response :) > > thanks, > > - David > > > > On 21/12/2006, at 9:51 AM, David Chelimsky wrote: > > > On 12/20/06, David Lee wrote: > >> Should I take this flurry of concerted activity to mean that RSpec > >> ( or at least a few committed committers ) now support edge rails, > >> and people are using it fine for Edge projects ? > > > > NO, NO, NO, NO. There is absolutely NO guarantee or even formalized > > attempt to keep up w/ edge rails. We do NOT recommend that you use > > rspec_on_rails w/ anything other than the current stable release of > > rails (1.1.6) unless YOU are prepared to maintain it yourself!!!!!! > > > > That said, we do try to keep up ;) > > > > Cheers, > > David > > v > >> > >> cheers, > >> David > >> > >> On 21/12/2006, at 6:19 AM, David Chelimsky wrote: > >> > >>> On 12/20/06, Pat Maddox wrote: > >>>> On 12/20/06, David Chelimsky wrote: > >>>>> On 12/20/06, Pat Maddox wrote: > >>>>>> On 12/20/06, Pat Maddox wrote: > >>>>>>> On 12/20/06, Pat Maddox wrote: > >>>>>>>> On 12/20/06, Pat Maddox wrote: > >>>>>>>>> On 12/20/06, David Chelimsky wrote: > >>>>>>>>>> On 12/20/06, Pat Maddox wrote: > >>>>>>>>>>> Started a new Rails project, and installed RSpec and the > >>>>>>>>>>> Rails plugin > >>>>>>>>>>> vendor/plugins/rspec (svn://rubyforge.org/var/svn/rspec/ > >>>>>>>>>>> trunk/rspec) - 1332 > >>>>>>>>>>> vendor/plugins/rspec_on_rails > >>>>>>>>>>> (svn://rubyforge.org/var/svn/rspec/trunk/rspec_on_rails/ > >>>>>>>>>>> vendor/plugins/rspec_on_rails) > >>>>>>>>>>> - 1332 > >>>>>>>>>>> > >>>>>>>>>>> Generated the rspec file, created a model...the spec runs > >>>>>>>>>>> fine if I do > >>>>>>>>>>> ruby spec/models/foo_spec.rb. Running rake though gives me > >>>>>>>>>>> the > >>>>>>>>>>> > >>>>>>>>>>> Your RSpec on Rails plugin is incompatible with your > >>>>>>>>>>> installed RSpec. > >>>>>>>>>>> > >>>>>>>>>>> RSpec : 0.7.5 (r1330) > >>>>>>>>>>> RSpec on Rails : r1332 > >>>>>>>>>>> > >>>>>>>>>>> error. So apparently it's looking at the gem rspec instead > >>>>>>>>>>> of the one > >>>>>>>>>>> I installed in my plugins folder. I've got an existing > >>>>>>>>>>> Rails app that > >>>>>>>>>>> uses edge RSpec, so I updated it to see if it broke, but it > >>>>>>>>>>> runs fine. > >>>>>>>>>>> I'm really really confused, I can't tell what the > >>>>>>>>>>> difference is. > >>>>>>>>>>> Both apps are at the same revision, there's nothing special > >>>>>>>>>>> about the > >>>>>>>>>>> config, but the old app works fine and the brand new one > >>>>>>>>>>> doesn't. > >>>>>>>>>> > >>>>>>>>>> The only diff would be in ~/spec/spec_helper.rb. Any > >>>>>>>>>> differences in there? > >>>>>>>>> > >>>>>>>>> It's something to do with Rails...my old app didn't have the > >>>>>>>>> very > >>>>>>>>> latest edge. r5734 works fine, and the latest doesn't. I'm > >>>>>>>>> gonna > >>>>>>>>> step through the revisions to find out just what broke RSpec. > >>>>>>>>> > >>>>>>>>> Pat > >>>>>>>>> > >>>>>>>> > >>>>>>>> Okay, Rails edge r5738 breaks it. The changeset is at > >>>>>>>> http://dev.rubyonrails.org/changeset/5720 > >>>>>>>> > >>>>>>>> You can't replicate it in the demo app because of how the app > >>>>>>>> loads > >>>>>>>> everything (I guess). The demo app doesn't break at all, > >>>>>>>> but if > >>>>>>>> you've just installed rspec as a plugin and the Rails plugin > >>>>>>>> then it > >>>>>>>> breaks at 5738. > >>>>>>>> > >>>>>>>> Pat > >>>>>>>> > >>>>>>> > >>>>>>> Sorry, changeset should be http://dev.rubyonrails.org/changeset/ > >>>>>>> 5738 > >>>>>>> > >>>>>>> The problem is that initializer.rb is no longer calling > >>>>>>> > >>>>>>> paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] > >>>>>>> > >>>>>>> in the default_load_paths method. > >>>>>>> > >>>>>>> I've tried adding > >>>>>>> > >>>>>>> config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/rspec/lib > >>>>>>> #{RAILS_ROOT}/vendor/plugins/rspec_on_rails/lib ) > >>>>>>> > >>>>>>> to the config block in environment.rb but it's not doing > >>>>>>> anything. > >>>>>>> > >>>>>>> So I haven't been able to fix it, but at least we have a place > >>>>>>> to look. > >>>>>>> > >>>>>>> Pat > >>>>>>> > >>>>>> > >>>>>> Has to do with some path issues, the rake tasks got broken. > >>>>>> Patch on the way. > >>>>> > >>>>> An rspec patch or a rails patch? > >>>>> > >>>> > >>>> > >>>> RSpec. I accidentally filed it in bugs, but > >>>> https://rubyforge.org/tracker/index.php? > >>>> func=detail&aid=7393&group_id=797&atid=3149 > >>>> has the info and the patch. > >>>> > >>>> Over all pretty simple, but it was a bitch to figure out. No > >>>> errors > >>>> or anything...Rails just silently ignored the task file. > >>> > >>> Nice work Pat. Thanks. > >>> > >>> I moved it to patches and will commit it later today. > >>> > >>> Cheers, > >>> David > >>> > >>>> > >>>> 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 > >> > > _______________________________________________ > > 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 Wed Dec 20 22:54:13 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 21:54:13 -0600 Subject: [rspec-users] How to keep mocks consistent? In-Reply-To: <7996667.post@talk.nabble.com> References: <57c63afe0612181449m74611a1cwa8ae02841ad73602@mail.gmail.com> <7996667.post@talk.nabble.com> Message-ID: <57c63afe0612201954l62480b51xd2914391616f87f7@mail.gmail.com> On 12/20/06, jshen wrote: > > "The isolated unit level testing that you're getting from using mocks > should (MUST) be coupled with some level of integration testing. > Right now I'm using either rails integration testing and/or selenium." > > I have similar concerns and this doesn't quite address them. He asked how to > manage changes that affect mocks that could be in many places. I wasn't clear about this. I think that you just have to absorb that risk if you chose to take this approach. Because I combine very granular and very coarse testing in the same project, I'm comfortable with the idea that what isn't caught by one will be caught by the other. For the most part. We are, after all, talking about automated tests. You still need exploratory testing, but that's another matter. > It seems like > something that would be very easy to forget or miss. Also, catching the > errors at the integration level is forcing yourself to test the same > functionality twice. The coverage you get from end to end testing should touch everything in the system. If everything isn't touched, then why is it in your system? That said, a world filled with nothing but end to end tests makes it very difficult to understand where problems lie. It also doesn't provide the granular design assistance that you get from writing specs before code. As soon as you enter a world in which you have both granular specs and end to end tests, you're going to be testing everything twice. But you do so in very different ways which help each other to gain a better sense of coverage (and therefore security that your code works). So yes, you do cover things twice. But I view that as a GOOD thing because it does so in different ways. > > I'm just starting with rspec and my standard tests in rails would test > functionality once at the rails unit test level. At the integration level I > would assume the functionality worked and mainly test that the controllers > and views handled different cases (i.e. errors) properly. I know this isn't > ideal, but I'm wondering if the duplication of work, both in testing and in > mock building, is worth the effort on medium sized projects done by small > teams. The benefit you get from using mocks and stubs to isolate the small parts of the system from other parts in a test is that your tests/specs run FAST! That means you run them more often. That means you get rapid feedback when you introduce bugs. That means you spend less time trying to track them down. Some bugs won't be caught until you run your integration suite, so this is not perfect. But in my experience, in the end the cost of the duplication you're talking about is seriously outweighed by the ability to keep moving, adjust to changes, and confidently deliver robust software without spending your life deciding whether to step over or into. > -- > View this message in context: http://www.nabble.com/How-to-keep-mocks-consistent--tf2842806.html#a7996667 > 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 dchelimsky at gmail.com Wed Dec 20 22:58:30 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 20 Dec 2006 21:58:30 -0600 Subject: [rspec-users] [ANN] RSpec 0.7.5 In-Reply-To: <8b80ba590612201549kd9ecf6bva1ca7547ea73d59c@mail.gmail.com> References: <57c63afe0612201004q1a5085cn228b1268487c2d84@mail.gmail.com> <8b80ba590612201533m310656e4xcbd0689888321d83@mail.gmail.com> <8b80ba590612201549kd9ecf6bva1ca7547ea73d59c@mail.gmail.com> Message-ID: <57c63afe0612201958r22988084n459795288d62143a@mail.gmail.com> On 12/20/06, brian ford wrote: > Hmm, seems this URL works: > > svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/plugins/rspec_on_rails > > the only difference is *plugins* rather than *plugin* > > The wiki has: > > svn://rubyforge.org/var/svn/rspec/tags/REL_X_Y_Z/rspec_on_rails/vendor/plugin/rspec_on_rails Fixed. Thanks. > > Thanks, > Brian > > On 12/20/06, brian ford wrote: > > Hello, > > > > I've read the changes for 0.7.5. I'm not sure what this means: > > * Removed svn:externals on rails versions and plugins > > > > So, I'm not sure if something has changed with the installation > > procedure for the rspec_on_rails plugin. When I do > > > > svn list svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/rails > > > > there are no files listed. No errors, but no files. > > > > I've been using rspec for a while, through 0.7.4, so I'm confused. Am > > I doing something wrong? > > > > Thanks, > > Brian > > > > On 12/20/06, David Chelimsky wrote: > > > The RSpec Development Team is pleased to announce the release of RSpec 0.7.5. > > > > > > This release adds support for Heckle - Seattle'rb's code mutation tool. > > > There are also several bug fixes to the RSpec core and the RSpec on > > > Rails plugin. > > > > > > Changes: http://rspec.rubyforge.org/changes.html > > > Download: http://rubyforge.org/frs/?group_id=797 > > > or > > > gem install rspec > > > > > > > > > Happy spec'ing, and now heckling! > > > > > > The RSpec Development Team > > > _______________________________________________ > > > 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 Wed Dec 20 23:20:30 2006 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 20 Dec 2006 21:20:30 -0700 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <8b80ba590612201745q3ce6d6a6pfa77041b82371a38@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> <0B392E42-5CD0-470B-948D-CB1744931F6D@davelee.com.au> <8b80ba590612201745q3ce6d6a6pfa77041b82371a38@mail.gmail.com> Message-ID: <810a540e0612202020s1ad5662csae0f7a3e18c128ae@mail.gmail.com> On 12/20/06, brian ford wrote: > David, > > I've been developing on edge rails for months and using rspec plugin > (latest release, updating as soon as another is released) for at least > one month and rarely have trouble. > > If you can, I'd say do it because it may flush out stuff that wouldn't > be seen otherwise. If it really breaks, you can always revert to last > release (unless you can't live without edge features, which is why I > use it). > > One thing I do, I link to a particular version of edge, not just > trunk. That way I can update it when convenient. I know RSpec may not officially be keeping up with edge rails, but they do a very good job of it regardless. I use edge everything, so when something breaks I try to get a patch in as well. If you want to use rspec entirely without any hassles, it's probably best not to use edge. Use the latest rspec, freeze rails to a certain revision, and develop away. If you don't mind the occasional problem, use edge everything, because it'll help us make rspec better. Pat From brixen at gmail.com Thu Dec 21 00:25:49 2006 From: brixen at gmail.com (brian ford) Date: Wed, 20 Dec 2006 21:25:49 -0800 Subject: [rspec-users] Stubbing an instance method on a class Message-ID: <8b80ba590612202125w5ff835bflec5ec3af9a60ec9b@mail.gmail.com> Hi all, I'm not sure if I've missed it, but I couldn't find any docs for stubbing an instance method on a class. For example: class Foo; end Foo.stub!(:my_instance_method).and_return(nil) The reason (I think) I need this is because a certain class (Test::Unit::TestCase) expects an argument (name of method) to new and throws an exception if that instance method doesn't exist. Thanks, Brian From lastobelus at mac.com Thu Dec 21 05:54:38 2006 From: lastobelus at mac.com (Michael Johnston) Date: Thu, 21 Dec 2006 02:54:38 -0800 Subject: [rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5 Message-ID: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> Has anyone else encountered this problem? What I mean is, rspec_autotest runs all specs, then waits. When you change a spec, it reruns that spec. However, if that spec now passes, it should run the whole suite again, so you can see the next one to work on. It no longer does this. This renders it somewhat useless. Does anyone have autotest working with rspec 0.7.5, or does anyone have any idea of what may be causing this issue or how to go about fixing it? Cheers, Michael Johnston From lastobelus at mac.com Thu Dec 21 06:04:05 2006 From: lastobelus at mac.com (Michael Johnston) Date: Thu, 21 Dec 2006 03:04:05 -0800 Subject: [rspec-users] heres how to get color output in rspec_autotest with rspec 0.7.5 Message-ID: In case anyone else is trying to make this work, here is what I did (Before 0.7.4 I had patched the regex in zentest redgreen, but that is not used any more) To use directly, it is very simple. In rspec_autotest/lib/ rspec_autotest.rb, add a -c to the spec_command in the initializer function: @spec_command = "spec -c --diff unified" This won't help however if you want to use rails_spec_server. To do that I patched rspec_0.7.5 to add an option to force the adding of colour codes (I did it this way because I assumed the check for output==Kernel was important for some other situation and I didn't want to just throw it away): diff -upr rspec-0.7.5/lib/spec/runner/formatter/ base_text_formatter.rb rspec-0.7.5_with_colour_patch/lib/spec/runner/ formatter/base_text_formatter.rb --- rspec-0.7.5/lib/spec/runner/formatter/base_text_formatter.rb 2006-12-21 01:42:44.000000000 -0800 +++ rspec-0.7.5_with_colour_patch/lib/spec/runner/formatter/ base_text_formatter.rb 2006-12-21 01:47:16.000000000 -0800 @@ -5,10 +5,11 @@ module Spec # non-text based ones too - just ignore the +output+ constructor # argument. class BaseTextFormatter - def initialize(output, dry_run=false, colour=false) + def initialize(output, dry_run=false, colour=false, force_colour=false) @output = output @dry_run = dry_run - @colour = colour + @colour = colour || force_colour + @force_colour = force_colour begin ; require 'Win32/Console/ANSI' if @colour && PLATFORM =~ /win32/ ; rescue LoadError ; raise "You must gem install win32console to use colour on Windows" ; end end @@ -96,7 +97,7 @@ module Spec end def colour(text, colour_code) - return text unless @colour && @output == Kernel + return text unless @force_colour || (@colour && @output == Kernel) "#{colour_code}#{text}\e[0m" end diff -upr rspec-0.7.5/lib/spec/runner/option_parser.rb rspec-0.7.5_with_colour_patch/lib/spec/runner/option_parser.rb --- rspec-0.7.5/lib/spec/runner/option_parser.rb 2006-12-21 01:42:44.000000000 -0800 +++ rspec-0.7.5_with_colour_patch/lib/spec/runner/option_parser.rb 2006-12-21 01:38:15.000000000 -0800 @@ -11,8 +11,7 @@ module Spec def create_context_runner(args, err, out, warn_if_no_files) options = parse(args, err, out, warn_if_no_files) - - formatter = options.formatter_type.new(options.out, options.dry_run, options.colour) + formatter = options.formatter_type.new(options.out, options.dry_run, options.colour, options.force_colour) options.reporter = Reporter.new(formatter, options.backtrace_tweaker) # this doesn't really belong here. @@ -71,6 +70,10 @@ module Spec options.colour = true end + opts.on("-C", "--force-colour", "--force-color", "force adding color codes regardless of output method") do + options.force_colour = true + end + opts.on("-s", "--spec SPECIFICATION_NAME", "Execute context or specification with matching name") do |spec_name| options.spec_name = spec_name end then you can set the spec_command in rspec_autotest/lib/ rspec_autotest.rb to: @spec_command = "script/rails_spec -C --diff unified" Cheers, Michael From dchelimsky at gmail.com Thu Dec 21 06:48:21 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 05:48:21 -0600 Subject: [rspec-users] Stubbing an instance method on a class In-Reply-To: <8b80ba590612202125w5ff835bflec5ec3af9a60ec9b@mail.gmail.com> References: <8b80ba590612202125w5ff835bflec5ec3af9a60ec9b@mail.gmail.com> Message-ID: <57c63afe0612210348m4e3e9a15obea2ac59a13885c@mail.gmail.com> On 12/20/06, brian ford wrote: > Hi all, > > I'm not sure if I've missed it, but I couldn't find any docs for > stubbing an instance method on a class. For example: > > class Foo; end > > Foo.stub!(:my_instance_method).and_return(nil) Hasn't been implemented yet, but there is an RFE: http://rubyforge.org/tracker/index.php?func=detail&aid=6791&group_id=797&atid=3152 > > The reason (I think) I need this is because a certain class > (Test::Unit::TestCase) expects an argument (name of method) to new and > throws an exception if that instance method doesn't exist. > > Thanks, > Brian > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Thu Dec 21 07:07:24 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Thu, 21 Dec 2006 12:07:24 +0000 Subject: [rspec-users] Speccing private class methods Message-ID: <70F19155-D60F-4B9D-B4E3-B9DA0D8D4FFD@ashleymoran.me.uk> Hi How can I specify that a private method of a class gets called? If you run the code below, only spec (1) passes. Spec (2) is what I found causing problems in my code, and class (3) is my failed attempt to work around it. (3 really puzzles me - why is a private class method not accessible via send?) Another problem is that stub! makes public methods, which changes the behaviour of a class if you stub a private method. Ashley require 'spec' class MyClass class << self def call_private_method private_method.upcase end private def private_method "this is private" end end end context "MyClass" do specify "(1) call_private_method should upcase the private_method" do MyClass.call_private_method.should == "THIS IS PRIVATE" end specify "(2) call_private_method should call private_method" do MyClass.should_receive(:private_method).and_return("this is private") end specify "(3) private_method should return 'this is private'" do MyClass.send(:private_method).should == "this is private" end end From jaydonnell at yahoo.com Thu Dec 21 00:32:13 2006 From: jaydonnell at yahoo.com (jshen) Date: Wed, 20 Dec 2006 21:32:13 -0800 (PST) Subject: [rspec-users] need some guidance with a test Message-ID: <8003040.post@talk.nabble.com> This is part of a rails project. The following method is part of the Ams class (a rails model). I'm a bit unsure of the rspec/bdd way of testing this method. def persist_as_domains @current_domains.each do |d| dom = Domain.new dom.domain = d dom.source_id = 1 dom.at = Time.now dom.save end end The following is what came out when I tried to write my test. Notice that the only thing I'm testing here is that each method is called a certain number of times. This doesn't test that the proper values are passed to the Domain model which is something I'd like to test, but I don't know how to do that since the methods are called in a loop with a different value each time. Am I even approaching this the right way? context "persisting as Domain" do setup do @ams = Ams.new @ams.get @ams.process puts Domain.class Domain.should_receive(:new).exactly(10).times Domain.should_receive(:domain).exactly(10).times Domain.should_receive(:source_id).exactly(10).times Domain.should_receive(:at).exactly(10).times Domain.should_receive(:save).exactly(10).times puts Domain.class end specify "should create new domain and save" do @ams.persist_as_domains end end -- View this message in context: http://www.nabble.com/need-some-guidance-with-a-test-tf2863821.html#a8003040 Sent from the rspec-users mailing list archive at Nabble.com. From jaydonnell at yahoo.com Thu Dec 21 00:42:08 2006 From: jaydonnell at yahoo.com (jshen) Date: Wed, 20 Dec 2006 21:42:08 -0800 (PST) Subject: [rspec-users] How to keep mocks consistent? In-Reply-To: <57c63afe0612201954l62480b51xd2914391616f87f7@mail.gmail.com> References: <57c63afe0612181449m74611a1cwa8ae02841ad73602@mail.gmail.com> <7996667.post@talk.nabble.com> <57c63afe0612201954l62480b51xd2914391616f87f7@mail.gmail.com> Message-ID: <8003101.post@talk.nabble.com> The benefit you get from using mocks and stubs to isolate the small parts of the system from other parts in a test is that your tests/specs run FAST! This is the big draw for me. One of my current rails projects is taking around 20 minutes to run the non integration tests. This is way to long for the reasons you point out. I also love the rspec syntax and mock/stub features. I've only been playing with rspec for the past day and a half so I'm probably hitting all the usual beginner hiccups. p.s. - the rspec site/documentation is excellent. You guys did an amazing job on that. the mocks/stubs could use some complete examples (i.e. use in an actual spec) :) -- View this message in context: http://www.nabble.com/How-to-keep-mocks-consistent--tf2842806.html#a8003101 Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Thu Dec 21 07:59:45 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 06:59:45 -0600 Subject: [rspec-users] Speccing private class methods In-Reply-To: <70F19155-D60F-4B9D-B4E3-B9DA0D8D4FFD@ashleymoran.me.uk> References: <70F19155-D60F-4B9D-B4E3-B9DA0D8D4FFD@ashleymoran.me.uk> Message-ID: <57c63afe0612210459l388de625n96361b2cc598fa4b@mail.gmail.com> On 12/21/06, Ashley Moran wrote: > Hi > > How can I specify that a private method of a class gets called? If > you run the code below, only spec (1) passes. Spec (2) is what I > found causing problems in my code, and class (3) is my failed attempt > to work around it. (3 really puzzles me - why is a private class > method not accessible via send?) > > Another problem is that stub! makes public methods, which changes the > behaviour of a class if you stub a private method. In theory you shouldn't be specifying anything about private methods. The only reason we support partial mocks at all (which is a mocking no-no) is because Rails forces us to. You won't find a solution to your problem within RSpec, but you can do this: specify "(2) call_private_method should call private_method" do begin MyClass.send :public, 'private_method' MyClass.should_receive(:private_method).and_return("this is private") ensure MyClass.send :private, 'private_method' end end So, for this spec only, you can access the method to spec that it gets called, but then restore the method to its private state. > > Ashley > > > require 'spec' > > class MyClass > class << self > def call_private_method > private_method.upcase > end > > private > def private_method > "this is private" > end > end > end > > context "MyClass" do > specify "(1) call_private_method should upcase the > private_method" do > MyClass.call_private_method.should == "THIS IS PRIVATE" > end > > specify "(2) call_private_method should call private_method" do > MyClass.should_receive(:private_method).and_return("this is > private") > end > > specify "(3) private_method should return 'this is private'" do > MyClass.send(:private_method).should == "this is private" > end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Dec 21 08:26:06 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 07:26:06 -0600 Subject: [rspec-users] need some guidance with a test In-Reply-To: <8003040.post@talk.nabble.com> References: <8003040.post@talk.nabble.com> Message-ID: <57c63afe0612210526v596f0ec1j5a21ae8562f88a53@mail.gmail.com> On 12/20/06, jshen wrote: > > This is part of a rails project. The following method is part of the Ams > class (a rails model). I'm a bit unsure of the rspec/bdd way of testing this > method. > > def persist_as_domains > @current_domains.each do |d| > dom = Domain.new > dom.domain = d > dom.source_id = 1 > dom.at = Time.now > dom.save > end > end > > The following is what came out when I tried to write my test. Notice that > the only thing I'm testing here is that each method is called a certain > number of times. This doesn't test that the proper values are passed to the > Domain model which is something I'd like to test, but I don't know how to do > that since the methods are called in a loop with a different value each > time. Am I even approaching this the right way? > > context "persisting as Domain" do > setup do > @ams = Ams.new > @ams.get > @ams.process > puts Domain.class > Domain.should_receive(:new).exactly(10).times > Domain.should_receive(:domain).exactly(10).times > Domain.should_receive(:source_id).exactly(10).times > Domain.should_receive(:at).exactly(10).times > Domain.should_receive(:save).exactly(10).times > puts Domain.class > end > > specify "should create new domain and save" do > @ams.persist_as_domains > end > end > -- I strive to write specs BEFORE code. That helps me to create better designs. In this case, you can save yourself a lot of headache by using create on your Domain and taking control of the number of domains in @ams (I'm guessing at some internals here, so sorry if I don't get this exactly right): context "persisting as Domain with one domain" do setup do @ams = Ams.new @ams.instance_eval {@current_domains = ["http://somewhere.com"]} Domain.should_receive(:create).once.with("http://somewhere.com",1,Time.now) end specify "should create new domain and save" do @ams.persist_as_domains end end class Ams def initialize @current_domains = [] end def persist_as_domains @current_domains.each {|d| Domain.create(d, 1, Time.now) } end end The Time.now thing will probably break here so you may want to create a time source other than Time: context "persisting as Domain with one domain" do setup do @ams = Ams.new mock_time = mock("time") mock_time.stub!(:now)and_return(Time.now) @ams.instance_eval {@time_source = mock_time} @ams.instance_eval {@current_domains = ["http://somewhere.com"]} Domain.should_receive(:create).once.with("http://somewhere.com",1,mock_time.now) end specify "should create new domain and save" do @ams.persist_as_domains end end class Ams def initialize @current_domains = [] @time_source = Time end def persist_as_domains @current_domains.each {|d| Domain.create(d, 1, Time.now) } end end I recognize that using time_source seems somehow offensive, but there's a general truth that statics and singletons, etc, make testing difficult. It is quite common among strong TDD/BDD'ers to do this sort of thing, though the specific approach may vary (i.e. some may prefer explicit dependency injection rather than sneaking in values through instance_eval). Hope this helps. David > View this message in context: http://www.nabble.com/need-some-guidance-with-a-test-tf2863821.html#a8003040 > 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 papipo at gmail.com Thu Dec 21 09:48:47 2006 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Thu, 21 Dec 2006 15:48:47 +0100 Subject: [rspec-users] Advice with Model tests Message-ID: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> Hi! I'm developing a rails applicaton with specify-before approach, with nice results so far. I use mocks and stubs in both Controller and views tests, but the main issue is with model testing. Since I've seen many examples here and there, I don't know if the right way is to use fixtures or not at all (in model specs). Atm, I'm using them, but I don't know if I should use mocks for associations, all real fixture data... This example http://rspec.rubyforge.org/documentation/rails/writing/models.html uses both approachs (data generated on setup (but no mocks), and data from fixtures). Please, help me! Apart from that, I really like this way of testing. I just want to do it the right way. Regards, Rodrigo. From work at ashleymoran.me.uk Thu Dec 21 10:16:24 2006 From: work at ashleymoran.me.uk (Ashley Moran) Date: Thu, 21 Dec 2006 15:16:24 +0000 Subject: [rspec-users] Speccing private class methods In-Reply-To: <57c63afe0612210459l388de625n96361b2cc598fa4b@mail.gmail.com> References: <70F19155-D60F-4B9D-B4E3-B9DA0D8D4FFD@ashleymoran.me.uk> <57c63afe0612210459l388de625n96361b2cc598fa4b@mail.gmail.com> Message-ID: On 21 Dec 2006, at 12:59, David Chelimsky wrote: > In theory you shouldn't be specifying anything about private methods. Hmmm... Here is my original thinking: - I've written a method somewhere (private or otherwise) that is specified independently - I know the algorithm must use this method to behave correctly - therefore I should specify that the main method calls the auxillary one Not testing the private methods seems to increase the granularity of the specs too much. There's a lot of stuff we do has complex but decomposable algorithms, and it makes sense to test the parts of these even if they are not part of the public interface. Not doing so seems similar to not unit testing ActiveRecord models because you can test their behaviour in the controller specs (which is what Rails does with Test::Unit) > The only reason we support partial mocks at all (which is a mocking > no-no) is because Rails forces us to. Why is this so wrong and what about about Rails forces it? I'm new to mocking and I'm not sure I'm clear on the definition. (Does the following code count as partial mocking, seeing how "date" is required in the CapFutureResidual model class file?) Here is a spec I wrote today that tests a really simple (private) method: context "CapFutureResidual.registration_date_recent?" do setup do Date.stub!(:today).and_return(Date.new(2006, 12, 20)) end specify "should find the current date" do Date.should_receive(:today).with(:no_args).and_return(Date.new (2006, 12, 20)) CapFutureResidual.send(:registration_date_recent?, Date.new (2006, 06, 25)) end specify "should define a data under six months old (approx) as recent" do CapFutureResidual.send(:registration_date_recent?, Date.new (2006, 06, 23)).should == true end specify "should define a date over six months old (approx) as not recent" do CapFutureResidual.send(:registration_date_recent?, Date.new (2006, 06, 22)).should == false end end Again, I don't see how specifying Date.should_receive(:today) is different from specifying that a private method is called, or should I not be doing this either... > > You won't find a solution to your problem within RSpec, but you can > do this: > > specify "(2) call_private_method should call private_method" do > begin > MyClass.send :public, 'private_method' > MyClass.should_receive(:private_method).and_return("this is > private") > ensure > MyClass.send :private, 'private_method' > end > end > > So, for this spec only, you can access the method to spec that it gets > called, but then restore the method to its private state. Hmmm... not sure if I'd like to write specs like this... might just drop that spec entirely and include the behaviour of the private method in the spec for the calling method. Ashley From dchelimsky at gmail.com Thu Dec 21 10:50:20 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 09:50:20 -0600 Subject: [rspec-users] Advice with Model tests In-Reply-To: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> References: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> Message-ID: <57c63afe0612210750w2bec2a84p4532131790569c15@mail.gmail.com> On 12/21/06, Rodrigo Alvarez Fern?ndez wrote: > Hi! > > I'm developing a rails applicaton with specify-before approach, with > nice results so far. > > I use mocks and stubs in both Controller and views tests, but the main > issue is with model testing. Since I've seen many examples here and > there, I don't know if the right way is to use fixtures or not at all > (in model specs). > > Atm, I'm using them, but I don't know if I should use mocks for > associations, all real fixture data... > > This example http://rspec.rubyforge.org/documentation/rails/writing/models.html > uses both approachs (data generated on setup (but no mocks), and data > from fixtures). > > Please, help me! > > Apart from that, I really like this way of testing. I just want to do > it the right way. The "right" way doesn't really exist. It depends largely on the nature and complexity of your app. That said, my personal preference is to avoid fixtures and just create what I need in each spec. That's because I like to see everything I need to understand the context. This approach creates more duplication in specs, but less binding between them. For me, the isolation is *usually* more important than the duplication. David > > Regards, > Rodrigo. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Dec 21 12:14:25 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 21 Dec 2006 11:14:25 -0600 Subject: [rspec-users] heres how to get color output in rspec_autotest with rspec 0.7.5 In-Reply-To: References: Message-ID: <8d961d900612210914p4e16487atd78f7c2546031c8d@mail.gmail.com> Thanks, I saw the patch in the tracker. On 12/21/06, Michael Johnston wrote: > In case anyone else is trying to make this work, here is what I did > (Before 0.7.4 I had patched the regex in zentest redgreen, but that > is not used any more) > > To use directly, it is very simple. In rspec_autotest/lib/ > rspec_autotest.rb, add a -c to the spec_command in the initializer > function: > > @spec_command = "spec -c --diff unified" > > This won't help however if you want to use rails_spec_server. To do > that I patched rspec_0.7.5 to add an option to force the adding of > colour codes (I did it this way because I assumed the check for > output==Kernel was important for some other situation and I didn't > want to just throw it away): > > diff -upr rspec-0.7.5/lib/spec/runner/formatter/ > base_text_formatter.rb rspec-0.7.5_with_colour_patch/lib/spec/runner/ > formatter/base_text_formatter.rb > --- rspec-0.7.5/lib/spec/runner/formatter/base_text_formatter.rb > 2006-12-21 01:42:44.000000000 -0800 > +++ rspec-0.7.5_with_colour_patch/lib/spec/runner/formatter/ > base_text_formatter.rb 2006-12-21 01:47:16.000000000 -0800 > @@ -5,10 +5,11 @@ module Spec > # non-text based ones too - just ignore the +output+ constructor > # argument. > class BaseTextFormatter > - def initialize(output, dry_run=false, colour=false) > + def initialize(output, dry_run=false, colour=false, > force_colour=false) > @output = output > @dry_run = dry_run > - @colour = colour > + @colour = colour || force_colour > + @force_colour = force_colour > begin ; require 'Win32/Console/ANSI' if @colour && > PLATFORM =~ /win32/ ; rescue LoadError ; raise "You must gem install > win32console to use colour on Windows" ; end > end > @@ -96,7 +97,7 @@ module Spec > end > def colour(text, colour_code) > - return text unless @colour && @output == Kernel > + return text unless @force_colour || (@colour && @output == > Kernel) > "#{colour_code}#{text}\e[0m" > end > > diff -upr rspec-0.7.5/lib/spec/runner/option_parser.rb > rspec-0.7.5_with_colour_patch/lib/spec/runner/option_parser.rb > --- rspec-0.7.5/lib/spec/runner/option_parser.rb 2006-12-21 > 01:42:44.000000000 -0800 > +++ rspec-0.7.5_with_colour_patch/lib/spec/runner/option_parser.rb > 2006-12-21 01:38:15.000000000 -0800 > @@ -11,8 +11,7 @@ module Spec > def create_context_runner(args, err, out, warn_if_no_files) > options = parse(args, err, out, warn_if_no_files) > - > - formatter = options.formatter_type.new(options.out, > options.dry_run, options.colour) > + formatter = options.formatter_type.new(options.out, > options.dry_run, options.colour, options.force_colour) > options.reporter = Reporter.new(formatter, > options.backtrace_tweaker) > # this doesn't really belong here. > @@ -71,6 +70,10 @@ module Spec > options.colour = true > end > > + opts.on("-C", "--force-colour", "--force-color", "force > adding color codes regardless of output method") do > + options.force_colour = true > + end > + > opts.on("-s", "--spec SPECIFICATION_NAME", "Execute > context or specification with matching name") do |spec_name| > options.spec_name = spec_name > end > > > > > > > then you can set the spec_command in rspec_autotest/lib/ > rspec_autotest.rb to: > > @spec_command = "script/rails_spec -C --diff unified" > > > > Cheers, > Michael > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Dec 21 12:14:27 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 11:14:27 -0600 Subject: [rspec-users] Speccing private class methods In-Reply-To: References: <70F19155-D60F-4B9D-B4E3-B9DA0D8D4FFD@ashleymoran.me.uk> <57c63afe0612210459l388de625n96361b2cc598fa4b@mail.gmail.com> Message-ID: <57c63afe0612210914u611da96x886d7b0c6bf1b9f4@mail.gmail.com> On 12/21/06, Ashley Moran wrote: > > On 21 Dec 2006, at 12:59, David Chelimsky wrote: > > > In theory you shouldn't be specifying anything about private methods. > > Hmmm... > > Here is my original thinking: > - I've written a method somewhere (private or otherwise) that is > specified independently > - I know the algorithm must use this method to behave correctly > - therefore I should specify that the main method calls the > auxillary one > > Not testing the private methods seems to increase the granularity of > the specs too much. There's a lot of stuff we do has complex but > decomposable algorithms, and it makes sense to test the parts of > these even if they are not part of the public interface. Not doing > so seems similar to not unit testing ActiveRecord models because you > can test their behaviour in the controller specs (which is what Rails > does with Test::Unit) "Not testing the private methods seems to increase the granularity of the specs too much." I assume you mean that it decreases the granularity, yes? There is a school of thought that you should only test through public APIs of your classes. So in your case, there would be tests on the public method that would specify how it should behave. As your algorithm becomes more complex you would refactor out the private method internally. There are divergent schools of thought as to whether the new private method gets its own test. The one to which I subscribe is that if the method is so interesting that it needs its own test, it probably belongs in another class because the current class is probably violating the Single Responsibility Principle. If so, then I'd move the method to a new class and make it public on that class. Bear in mind that these are all guidelines and schools of thought. There is no RIGHT way. > > > The only reason we support partial mocks at all (which is a mocking > > no-no) is because Rails forces us to. > > Why is this so wrong and what about about Rails forces it? Partial mocking is riddled with pitfalls. The most obvious one is the scenario in which you mock method :a and a new method :b comes into play later which uses :a internally. Now :b won't behave the way you expect any longer because you're mocking :a. These things lead to long, painful debug sessions. Rails forces us to use partial mocks because ActiveRecord uses static finder methods and forces us to use inheritance for models instead of composition. Another alternative would be to introduce a ModelSearch class into your controllers. So instead of this: def index @people = Person.find(:all) end you might have this: def index @people = model_finder.find(:all, Person) end def model_finder @model_finder ||= ModelFinder.new end def model_finder=(model_finder) @model_finder = model_finder end Now you can set the model_finder in your specs and you don't have to do any partial mocking of the Person static methods. Not recommending this. It's got its own drawbacks, but it's just another way you could handle things. > I'm new > to mocking and I'm not sure I'm clear on the definition. (Does the > following code count as partial mocking, seeing how "date" is > required in the CapFutureResidual model class file?) > > Here is a spec I wrote today that tests a really simple (private) > method: > > context "CapFutureResidual.registration_date_recent?" do > setup do > Date.stub!(:today).and_return(Date.new(2006, 12, 20)) > end > > specify "should find the current date" do > Date.should_receive(:today).with(:no_args).and_return(Date.new > (2006, 12, 20)) > CapFutureResidual.send(:registration_date_recent?, Date.new > (2006, 06, 25)) > end > > specify "should define a data under six months old (approx) as > recent" do > CapFutureResidual.send(:registration_date_recent?, Date.new > (2006, 06, 23)).should == true > end > > specify "should define a date over six months old (approx) as not > recent" do > CapFutureResidual.send(:registration_date_recent?, Date.new > (2006, 06, 22)).should == false > end > end > > Again, I don't see how specifying Date.should_receive(:today) is > different from specifying that a private method is called, or should > I not be doing this either... > > > > > You won't find a solution to your problem within RSpec, but you can > > do this: > > > > specify "(2) call_private_method should call private_method" do > > begin > > MyClass.send :public, 'private_method' > > MyClass.should_receive(:private_method).and_return("this is > > private") > > ensure > > MyClass.send :private, 'private_method' > > end > > end > > > > So, for this spec only, you can access the method to spec that it gets > > called, but then restore the method to its private state. > > Hmmm... not sure if I'd like to write specs like this... might just > drop that spec entirely and include the behaviour of the private > method in the spec for the calling method. That's what I'd do. If this makes your specs too complicated for the one method, then maybe it's trying to do too much. Hope this all helps. David > > > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Thu Dec 21 12:16:08 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 21 Dec 2006 11:16:08 -0600 Subject: [rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5 In-Reply-To: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> References: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> Message-ID: <8d961d900612210916x8ebcfcnaa288ef57653278c@mail.gmail.com> rspec_autotest is not something we support in rspec. It's not our code. Have you tried contacting the author? Aslak On 12/21/06, Michael Johnston wrote: > Has anyone else encountered this problem? > > What I mean is, rspec_autotest runs all specs, then waits. When you > change a spec, it reruns that spec. However, if that spec now passes, > it should run the whole suite again, so you can see the next one to > work on. It no longer does this. This renders it somewhat useless. > > Does anyone have autotest working with rspec 0.7.5, or does anyone > have any idea of what may be causing this issue or how to go about > fixing it? > > Cheers, > Michael Johnston > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From papipo at gmail.com Thu Dec 21 12:40:56 2006 From: papipo at gmail.com (=?ISO-8859-1?Q?Rodrigo_Alvarez_Fern=E1ndez?=) Date: Thu, 21 Dec 2006 18:40:56 +0100 Subject: [rspec-users] Advice with Model tests In-Reply-To: <57c63afe0612210750w2bec2a84p4532131790569c15@mail.gmail.com> References: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> <57c63afe0612210750w2bec2a84p4532131790569c15@mail.gmail.com> Message-ID: <6d2bdda0612210940o7decf0c1r5ba6498f47672264@mail.gmail.com> On 12/21/06, David Chelimsky wrote: > On 12/21/06, Rodrigo Alvarez Fern?ndez wrote: > > Hi! > > > > I'm developing a rails applicaton with specify-before approach, with > > nice results so far. > > > > I use mocks and stubs in both Controller and views tests, but the main > > issue is with model testing. Since I've seen many examples here and > > there, I don't know if the right way is to use fixtures or not at all > > (in model specs). > > > > Atm, I'm using them, but I don't know if I should use mocks for > > associations, all real fixture data... > > > > This example http://rspec.rubyforge.org/documentation/rails/writing/models.html > > uses both approachs (data generated on setup (but no mocks), and data > > from fixtures). > > > > Please, help me! > > > > Apart from that, I really like this way of testing. I just want to do > > it the right way. > > The "right" way doesn't really exist. It depends largely on the nature > and complexity of your app. That said, my personal preference is to > avoid fixtures and just create what I need in each spec. That's > because I like to see everything I need to understand the context. > What about models that need a lot of attributes? Do you create them in the setup method? I suppose that the answer is "yes". > This approach creates more duplication in specs, but less binding > between them. For me, the isolation is *usually* more important than > the duplication. > Thinking about it... with fixtures the environment is shared between specs and tries to satisfy all of them. In fact, you must write specs that "fit" in the fixtures, or write/modify the current fixtures to satisfy the new specs required environment. It seems thar isolating is much better. Thank you. > David From pergesu at gmail.com Thu Dec 21 13:02:17 2006 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 21 Dec 2006 11:02:17 -0700 Subject: [rspec-users] Advice with Model tests In-Reply-To: <57c63afe0612210750w2bec2a84p4532131790569c15@mail.gmail.com> References: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> <57c63afe0612210750w2bec2a84p4532131790569c15@mail.gmail.com> Message-ID: <810a540e0612211002i4bb263b6s63b21148afe7795@mail.gmail.com> On 12/21/06, David Chelimsky wrote: > On 12/21/06, Rodrigo Alvarez Fern?ndez wrote: > > Hi! > > > > I'm developing a rails applicaton with specify-before approach, with > > nice results so far. > > > > I use mocks and stubs in both Controller and views tests, but the main > > issue is with model testing. Since I've seen many examples here and > > there, I don't know if the right way is to use fixtures or not at all > > (in model specs). > > > > Atm, I'm using them, but I don't know if I should use mocks for > > associations, all real fixture data... > > > > This example http://rspec.rubyforge.org/documentation/rails/writing/models.html > > uses both approachs (data generated on setup (but no mocks), and data > > from fixtures). > > > > Please, help me! > > > > Apart from that, I really like this way of testing. I just want to do > > it the right way. > > The "right" way doesn't really exist. It depends largely on the nature > and complexity of your app. That said, my personal preference is to > avoid fixtures and just create what I need in each spec. That's > because I like to see everything I need to understand the context. Out of curiosity, do you create AR records in your setup and save them? I almost always just create an object without saving it and stub any finder methods. I know AR is going to do its job and this lets me hit the DB as little as possible, keeping my specs running really fast. Though sometimes I'm not sure if I'm using mocks and stubs too much...trying to find a sweet spot. I think I might write a tutorial on using RSpec to build Rails apps, and then maybe you and Aslak could pick it apart and make recommendations. I could at least get started producing some practical documentation for Rails though. Pat From dchelimsky at gmail.com Thu Dec 21 13:41:34 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 12:41:34 -0600 Subject: [rspec-users] Advice with Model tests In-Reply-To: <810a540e0612211002i4bb263b6s63b21148afe7795@mail.gmail.com> References: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> <57c63afe0612210750w2bec2a84p4532131790569c15@mail.gmail.com> <810a540e0612211002i4bb263b6s63b21148afe7795@mail.gmail.com> Message-ID: <57c63afe0612211041t5a39996cke05cf268fa049c9a@mail.gmail.com> On 12/21/06, Pat Maddox wrote: > On 12/21/06, David Chelimsky wrote: > > On 12/21/06, Rodrigo Alvarez Fern?ndez wrote: > > > Hi! > > > > > > I'm developing a rails applicaton with specify-before approach, with > > > nice results so far. > > > > > > I use mocks and stubs in both Controller and views tests, but the main > > > issue is with model testing. Since I've seen many examples here and > > > there, I don't know if the right way is to use fixtures or not at all > > > (in model specs). > > > > > > Atm, I'm using them, but I don't know if I should use mocks for > > > associations, all real fixture data... > > > > > > This example http://rspec.rubyforge.org/documentation/rails/writing/models.html > > > uses both approachs (data generated on setup (but no mocks), and data > > > from fixtures). > > > > > > Please, help me! > > > > > > Apart from that, I really like this way of testing. I just want to do > > > it the right way. > > > > The "right" way doesn't really exist. It depends largely on the nature > > and complexity of your app. That said, my personal preference is to > > avoid fixtures and just create what I need in each spec. That's > > because I like to see everything I need to understand the context. > > Out of curiosity, do you create AR records in your setup and save > them? I only save them when saving them is necessary for the behaviour I'm spec'ing. I'll also use fixtures on occasion for model classes that have no interesting behaviour (i.e. validations, relationships, etc). >I almost always just create an object without saving it and > stub any finder methods. If you're talking about non-model specs, I generally stub the finder methods to return mocks (not instances of AR classes) > I know AR is going to do its job and this > lets me hit the DB as little as possible, keeping my specs running > really fast. > > Though sometimes I'm not sure if I'm using mocks and stubs too > much...trying to find a sweet spot. That's the quest. And it's going to vary from app to app depending on where the interesting behaviour exists. Sometimes it's more in the models. Sometimes moreso in the controllers. > > I think I might write a tutorial on using RSpec to build Rails apps, > and then maybe you and Aslak could pick it apart and make > recommendations. I could at least get started producing some > practical documentation for Rails though. That would be great! Thanks Pat. David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nicksieger at gmail.com Thu Dec 21 14:13:29 2006 From: nicksieger at gmail.com (Nick Sieger) Date: Thu, 21 Dec 2006 13:13:29 -0600 Subject: [rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5 In-Reply-To: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> References: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> Message-ID: On 12/21/06, Michael Johnston wrote: > > Has anyone else encountered this problem? > > What I mean is, rspec_autotest runs all specs, then waits. When you > change a spec, it reruns that spec. However, if that spec now passes, > it should run the whole suite again, so you can see the next one to > work on. It no longer does this. This renders it somewhat useless. > > Does anyone have autotest working with rspec 0.7.5, or does anyone > have any idea of what may be causing this issue or how to go about > fixing it? Are you sure this is caused by the 0.7.5 upgrade? I've seen similar behavior but I'm still on 0.7.3. Here's the response comment I posted to yours: I think this is expected behavior for autotest ? I've already noticed this and assumed it was standard behavior. The only time autotest reruns the whole suite is after I've just fixed a failing test or spec. Is it possible that's what you're observing? Feel free to take any further discussion off-list, thanks. /Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061221/3a0f1d68/attachment.html From jaydonnell at yahoo.com Thu Dec 21 13:43:42 2006 From: jaydonnell at yahoo.com (jshen) Date: Thu, 21 Dec 2006 10:43:42 -0800 (PST) Subject: [rspec-users] Advice with Model tests In-Reply-To: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> References: <6d2bdda0612210648n5e15e928i7203982608899101@mail.gmail.com> Message-ID: <8012839.post@talk.nabble.com> "Since I've seen many examples here and there, I don't know if the right way is to use fixtures or not at all (in model specs)." I've personally had a lot of problems with fixtures. One of my current rails apps uses test::unit and fixtures and the fixtures become like spaghetti code very fast. As your tests evolve over time it becomes very hard to manage your fixtures if they aren't super simple. When your writing a new test you don't know if you can add to a certain fixture association or not because it may break some other test in your app. If you delete a test that is no longer necessary you are unsure if you can delete the associated fixture data because some other test may depend on it. I also agree with david in that it's nice to see everything in the context of the test. -- View this message in context: http://www.nabble.com/Advice-with-Model-tests-tf2865964.html#a8012839 Sent from the rspec-users mailing list archive at Nabble.com. From brixen at gmail.com Thu Dec 21 18:06:23 2006 From: brixen at gmail.com (brian ford) Date: Thu, 21 Dec 2006 15:06:23 -0800 Subject: [rspec-users] Stubbing an instance method on a class In-Reply-To: <57c63afe0612210348m4e3e9a15obea2ac59a13885c@mail.gmail.com> References: <8b80ba590612202125w5ff835bflec5ec3af9a60ec9b@mail.gmail.com> <57c63afe0612210348m4e3e9a15obea2ac59a13885c@mail.gmail.com> Message-ID: <8b80ba590612211506r35d75434re394dbced4fd8718@mail.gmail.com> David, Thanks for the response. I'll be sure to check the RFE's first next time. Forgot to do that. :( Brian On 12/21/06, David Chelimsky wrote: > On 12/20/06, brian ford wrote: > > Hi all, > > > > I'm not sure if I've missed it, but I couldn't find any docs for > > stubbing an instance method on a class. For example: > > > > class Foo; end > > > > Foo.stub!(:my_instance_method).and_return(nil) > > Hasn't been implemented yet, but there is an RFE: > > http://rubyforge.org/tracker/index.php?func=detail&aid=6791&group_id=797&atid=3152 > > > > > The reason (I think) I need this is because a certain class > > (Test::Unit::TestCase) expects an argument (name of method) to new and > > throws an exception if that instance method doesn't exist. > > > > Thanks, > > 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 > From dchelimsky at gmail.com Thu Dec 21 18:51:25 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 21 Dec 2006 17:51:25 -0600 Subject: [rspec-users] Stubbing an instance method on a class In-Reply-To: <8b80ba590612211506r35d75434re394dbced4fd8718@mail.gmail.com> References: <8b80ba590612202125w5ff835bflec5ec3af9a60ec9b@mail.gmail.com> <57c63afe0612210348m4e3e9a15obea2ac59a13885c@mail.gmail.com> <8b80ba590612211506r35d75434re394dbced4fd8718@mail.gmail.com> Message-ID: <57c63afe0612211551i590c9ab0jfd1e051be94acc24@mail.gmail.com> On 12/21/06, brian ford wrote: > David, > > Thanks for the response. I'll be sure to check the RFE's first next > time. Forgot to do that. :( No worries. Just because there's an RFE doesn't mean it's going to get implemented anyhow. So if you see something on the list that you care about, let us know. I was just letting you know that it's on the radar. Cheers, David > > Brian > > On 12/21/06, David Chelimsky wrote: > > On 12/20/06, brian ford wrote: > > > Hi all, > > > > > > I'm not sure if I've missed it, but I couldn't find any docs for > > > stubbing an instance method on a class. For example: > > > > > > class Foo; end > > > > > > Foo.stub!(:my_instance_method).and_return(nil) > > > > Hasn't been implemented yet, but there is an RFE: > > > > http://rubyforge.org/tracker/index.php?func=detail&aid=6791&group_id=797&atid=3152 > > > > > > > > The reason (I think) I need this is because a certain class > > > (Test::Unit::TestCase) expects an argument (name of method) to new and > > > throws an exception if that instance method doesn't exist. > > > > > > Thanks, > > > 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From david at davelee.com.au Thu Dec 21 20:14:16 2006 From: david at davelee.com.au (David Lee) Date: Fri, 22 Dec 2006 12:14:16 +1100 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <810a540e0612202020s1ad5662csae0f7a3e18c128ae@mail.gmail.com> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <810a540e0612200832j1fb37949lc261e6889a85c1f0@mail.gmail.com> <810a540e0612200949i51517877l79a61cabdecf1289@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> <0B392E42-5CD0-470B-948D-CB1744931F6D@davelee.com.au> <8b80ba590612201745q3ce6d6a6pfa77041b82371a38@mail.gmail.com> <810a540e0612202020s1ad5662csae0f7a3e18c128ae@mail.gmail.com> Message-ID: <51DB1043-EC45-49DD-92CB-0DF226C1DC96@davelee.com.au> thanks for the advice guys, I've been using test::unit on a frozen rev of edge rails - might consider switching as long as i don't hit any immediate hitches. I do recall starting this project with RSpec and changing to Test::Unit becuase something wasn't working, but I'll try again given you're reporting reasonable success hmm .. is that test::unit to rspec conversion tool still supported? I can't seem to find it locally and it would make evaluating a switch to RSpec a lot easier. I heard mutterings about discontinuing it earlier, but don't recall what happened cheers, David Lee On 21/12/2006, at 3:20 PM, Pat Maddox wrote: > On 12/20/06, brian ford wrote: >> David, >> >> I've been developing on edge rails for months and using rspec plugin >> (latest release, updating as soon as another is released) for at >> least >> one month and rarely have trouble. >> >> If you can, I'd say do it because it may flush out stuff that >> wouldn't >> be seen otherwise. If it really breaks, you can always revert to last >> release (unless you can't live without edge features, which is why I >> use it). >> >> One thing I do, I link to a particular version of edge, not just >> trunk. That way I can update it when convenient. > > I know RSpec may not officially be keeping up with edge rails, but > they do a very good job of it regardless. I use edge everything, so > when something breaks I try to get a patch in as well. > > If you want to use rspec entirely without any hassles, it's probably > best not to use edge. Use the latest rspec, freeze rails to a certain > revision, and develop away. If you don't mind the occasional problem, > use edge everything, because it'll help us make rspec better. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri Dec 22 12:25:21 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 22 Dec 2006 11:25:21 -0600 Subject: [rspec-users] Edge RSpec on Rails...what did I forget? In-Reply-To: <51DB1043-EC45-49DD-92CB-0DF226C1DC96@davelee.com.au> References: <810a540e0612200247x51925ab1v1da77cd8f199c3f7@mail.gmail.com> <57c63afe0612200958h40c19bcby7641df760d294b55@mail.gmail.com> <810a540e0612201030k594fab76y27efd089941c19da@mail.gmail.com> <57c63afe0612201119x141c107bx2eefecceea35daa@mail.gmail.com> <2E6280DF-B849-4ECC-BBD6-D5A800384D97@davelee.com.au> <57c63afe0612201451v7eee28fay8038452561a89d92@mail.gmail.com> <0B392E42-5CD0-470B-948D-CB1744931F6D@davelee.com.au> <8b80ba590612201745q3ce6d6a6pfa77041b82371a38@mail.gmail.com> <810a540e0612202020s1ad5662csae0f7a3e18c128ae@mail.gmail.com> <51DB1043-EC45-49DD-92CB-0DF226C1DC96@davelee.com.au> Message-ID: <8d961d900612220925w118610b5o38856833b8ef3d80@mail.gmail.com> On 12/21/06, David Lee wrote: > thanks for the advice guys, > > I've been using test::unit on a frozen rev of edge rails - might > consider switching as long as i don't hit any immediate hitches. > > I do recall starting this project with RSpec and changing to > Test::Unit becuase something wasn't working, but I'll try again given > you're reporting reasonable success > > hmm .. > > is that test::unit to rspec conversion tool still supported? I can't > seem to find it locally and it would make evaluating a switch to > RSpec a lot easier. > > I heard mutterings about discontinuing it earlier, but don't recall > what happened > It's been decommissioned. It was too much work to maintain. > cheers, > David Lee > > On 21/12/2006, at 3:20 PM, Pat Maddox wrote: > > > On 12/20/06, brian ford wrote: > >> David, > >> > >> I've been developing on edge rails for months and using rspec plugin > >> (latest release, updating as soon as another is released) for at > >> least > >> one month and rarely have trouble. > >> > >> If you can, I'd say do it because it may flush out stuff that > >> wouldn't > >> be seen otherwise. If it really breaks, you can always revert to last > >> release (unless you can't live without edge features, which is why I > >> use it). > >> > >> One thing I do, I link to a particular version of edge, not just > >> trunk. That way I can update it when convenient. > > > > I know RSpec may not officially be keeping up with edge rails, but > > they do a very good job of it regardless. I use edge everything, so > > when something breaks I try to get a patch in as well. > > > > If you want to use rspec entirely without any hassles, it's probably > > best not to use edge. Use the latest rspec, freeze rails to a certain > > revision, and develop away. If you don't mind the occasional problem, > > use edge everything, because it'll help us make rspec better. > > > > 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 > From blissdev at gmail.com Sat Dec 23 17:19:37 2006 From: blissdev at gmail.com (blissdev) Date: Sat, 23 Dec 2006 14:19:37 -0800 (PST) Subject: [rspec-users] Having trouble installing the Rails plugin with Rspec 0.7.5 Message-ID: <8037409.post@talk.nabble.com> Hi, I'm running Rails 1.1.6 and just installed RSpec 0.7.5. When I try to install the appropriate Rails plugin, it just says that "Export Complete". Any ideas? blissdev:~/code/rails/client/wordone > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/vend or/rspec_on_rails/vendor/plugins/rspec_on_rails Export complete. blissdev:~/code/rails/client/wordone > ruby script/generate rspec Couldn't find 'rspec' generator Thanks for your time, Jordan -- View this message in context: http://www.nabble.com/Having-trouble-installing-the-Rails-plugin-with-Rspec-0.7.5-tf2875614.html#a8037409 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/20061223/5bd1e757/attachment.html From blissdev at gmail.com Sat Dec 23 17:19:37 2006 From: blissdev at gmail.com (blissdev) Date: Sat, 23 Dec 2006 14:19:37 -0800 (PST) Subject: [rspec-users] Having trouble installing the Rails plugin with Rspec 0.7.5 Message-ID: <8037409.post@talk.nabble.com> Hi, I'm running Rails 1.1.6 and just installed RSpec 0.7.5. When I try to install the appropriate Rails plugin, it just says that "Export Complete" and doesn't install anything to vendor. I can do it with older version, but then it's not compatible with RSpec. Any ideas? blissdev:~/code/rails/client/wordone > ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/vend or/rspec_on_rails/vendor/plugins/rspec_on_rails Export complete. blissdev:~/code/rails/client/wordone > ruby script/generate rspec Couldn't find 'rspec' generator Thanks for your time, Jordan -- View this message in context: http://www.nabble.com/Having-trouble-installing-the-Rails-plugin-with-Rspec-0.7.5-tf2875614.html#a8037409 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/20061223/5bd1e757/attachment-0001.html From dchelimsky at gmail.com Sat Dec 23 19:52:17 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 23 Dec 2006 18:52:17 -0600 Subject: [rspec-users] Having trouble installing the Rails plugin with Rspec 0.7.5 In-Reply-To: <8037409.post@talk.nabble.com> References: <8037409.post@talk.nabble.com> Message-ID: <57c63afe0612231652tdc1cd5aydcac5c01fc2334a@mail.gmail.com> On 12/23/06, blissdev wrote: > Hi, I'm running Rails 1.1.6 and just installed RSpec 0.7.5. When I try to > install the appropriate Rails plugin, it just says that "Export Complete". > Any ideas? blissdev:~/code/rails/client/wordone > ruby > script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/vend > or/rspec_on_rails/vendor/plugins/rspec_on_rails try this: svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/plugins/rspec_on_rails > Export complete. > blissdev:~/code/rails/client/wordone > ruby script/generate > rspec > Couldn't find 'rspec' generator > > Thanks for your time, Jordan > ________________________________ > View this message in context: Having trouble installing the Rails plugin > with Rspec 0.7.5 > 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 aslak.hellesoy at gmail.com Sat Dec 23 19:57:57 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 23 Dec 2006 18:57:57 -0600 Subject: [rspec-users] Having trouble installing the Rails plugin with Rspec 0.7.5 In-Reply-To: <8037409.post@talk.nabble.com> References: <8037409.post@talk.nabble.com> Message-ID: <8d961d900612231657w18564b6dy2628fe3212edf123@mail.gmail.com> The website has a bad URL. The correct URL is svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/rspec_on_rails/vendor/plugins/rspec_on_rails HTH, Aslak On 12/23/06, blissdev wrote: > Hi, I'm running Rails 1.1.6 and just installed RSpec 0.7.5. When I try to > install the appropriate Rails plugin, it just says that "Export Complete". > Any ideas? blissdev:~/code/rails/client/wordone > ruby > script/plugin install > svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_5/vend > or/rspec_on_rails/vendor/plugins/rspec_on_rails > Export complete. > blissdev:~/code/rails/client/wordone > ruby script/generate > rspec > Couldn't find 'rspec' generator > > Thanks for your time, Jordan > ________________________________ > View this message in context: Having trouble installing the Rails plugin > with Rspec 0.7.5 > 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 Sun Dec 24 15:53:02 2006 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 24 Dec 2006 13:53:02 -0700 Subject: [rspec-users] What do you think of this controller spec? Message-ID: <810a540e0612241253gd5b327ex706cb07e3ccacc6e@mail.gmail.com> Here's a controller spec I wrote, it's for a very simple RESTful controller (well, aren't all RESTful controllers simple? :) I've created a couple spec helper methods to refactor some of the common code...for example, require_login_and_correct_user creates two specifications: one for when the user isn't logged in, and one when the user is logged in but requests someone else's book. do_request automatically calls do_get/post/put/delete depending on what's implemented. Here's all the code: books_controller.rb: http://pastie.caboo.se/29469 books_controller_spec.rb: http://pastie.caboo.se/29470 spec_helper.rb: http://pastie.caboo.se/29471 The specs just feel somewhat unwieldy to me...maybe it's because the controller code is very simple and elegant, and the spec looks big and bloated in comparison. Also, it feels like it's taking me a lot longer to write the controller specs with all these individual verifications. Am I just tripping for no reason, and the specs look fine? What would you change? Also I know that the controller code could be improved by using the finder on the association, this is just how I have it for now. I'm interested in how the specs could be better. I'll be understanding if I don't get a response for a few days :) Merry Christmas everybody! Pat From dchelimsky at gmail.com Mon Dec 25 11:34:12 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Dec 2006 11:34:12 -0500 Subject: [rspec-users] What do you think of this controller spec? In-Reply-To: <810a540e0612241253gd5b327ex706cb07e3ccacc6e@mail.gmail.com> References: <810a540e0612241253gd5b327ex706cb07e3ccacc6e@mail.gmail.com> Message-ID: <57c63afe0612250834nf735f0cge4cb2346a03e1057@mail.gmail.com> On 12/24/06, Pat Maddox wrote: > Here's a controller spec I wrote, it's for a very simple RESTful > controller (well, aren't all RESTful controllers simple? :) > > I've created a couple spec helper methods to refactor some of the > common code...for example, require_login_and_correct_user creates two > specifications: one for when the user isn't logged in, and one when > the user is logged in but requests someone else's book. do_request > automatically calls do_get/post/put/delete depending on what's > implemented. > > Here's all the code: > > books_controller.rb: http://pastie.caboo.se/29469 > books_controller_spec.rb: http://pastie.caboo.se/29470 > spec_helper.rb: http://pastie.caboo.se/29471 > > The specs just feel somewhat unwieldy to me...maybe it's because the > controller code is very simple and elegant, and the spec looks big and > bloated in comparison. Also, it feels like it's taking me a lot > longer to write the controller specs with all these individual > verifications. > > Am I just tripping for no reason, and the specs look fine? What would > you change? Also I know that the controller code could be improved by > using the finder on the association, this is just how I have it for > now. I'm interested in how the specs could be better. > > I'll be understanding if I don't get a response for a few days :) > Merry Christmas everybody! Quick observations: 1. At first glance I like the structure of wrapping specify blocks in methods like this. 2. Instead of having free floating methods I'd wrap them in a module and include the module in the context: module MyHelperMethods def login(user, pw) ... end end context "Given blah...." do include MyHelperMethods setup {..} specify "a logged in user..." do login(@user, @pw) .. end end 3. The extractions are inconsistent. For example: setup do create_user login_as @mock_user end The reference to @mock_user is confusing here. Where does it come from? To make it easier to understand, I might phrase this like this: setup do @mock_user = create_user login_as @mock_user end or, more terse: module MyHelpers def mock_user @mock_user ||= mock("user") end def login_as(user) .. end end context ... setup do login_as mock_user end end Using a mock_user method like that could make the specs look more consistent (i.e. not sometimes referencing @mock_user and sometimes referencing mock_user). 4. The magic involved in having should_find_user call do_get is a bit troubling for me. I appreciate the need to indicate what to call, but I'd do it more explicitly: should_find_user_on :get ... or something like that. Then you can eliminate do_request and the spec becomes a bit more explicit. ==================== Pat, this is great stuff in general. The challenge is to eliminate duplication in such a way that each spec is still completely understandable without having to go read the other helpers, etc. I hope my suggestions here help a bit. I'll give this a more thorough look over later in the week. Cheers, David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Mon Dec 25 15:37:47 2006 From: cwdinfo at gmail.com (s.ross) Date: Mon, 25 Dec 2006 12:37:47 -0800 Subject: [rspec-users] Issues with 0.7.5 Message-ID: <149489D8-0E81-497C-A382-C254F4366D20@gmail.com> I installed 0.7.5 and the corresponding Rails plugin. Now it seems that the rake command is: rake spec:autotest I immediately ran into several problems: 1. rspec_autotest.rb line 30 has curly quotes and makes Ruby choke 2. Same line, rails_spec is spelled solid, when it should have the underscore But fixing these didn't get me back going. Now I have to have a rails_spec_server running in one console window (is this recommended practice?) and rake spec:autotest gives me: (druby://localhost:8989) /opt/local/lib/ruby/gems/1.8/gems/ rspec-0.7.5/lib/spec/runner/command_line.rb:23:in `run': File or directory not found: ?diff (RuntimeError) from (druby://localhost:8989) /opt/local/lib/ruby/gems/1.8/ gems/rspec-0.7.5/lib/spec/runner/command_line.rb:15:in `each' from (druby://localhost:8989) /opt/local/lib/ruby/gems/1.8/ gems/rspec-0.7.5/lib/spec/runner/command_line.rb:15:in `run' from (druby://localhost:8989) script/rails_spec_server:16:in `run' from script/rails_spec:8 The whole setup was working perfectly under 0.7.4 but I can't even get through a single spec pass on 0.7.5. Any hints are appreciated. Thanks, Steve From pergesu at gmail.com Tue Dec 26 12:08:05 2006 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 26 Dec 2006 10:08:05 -0700 Subject: [rspec-users] What do you think of this controller spec? In-Reply-To: <57c63afe0612250834nf735f0cge4cb2346a03e1057@mail.gmail.com> References: <810a540e0612241253gd5b327ex706cb07e3ccacc6e@mail.gmail.com> <57c63afe0612250834nf735f0cge4cb2346a03e1057@mail.gmail.com> Message-ID: <810a540e0612260908k55c67a79wf281c58fa9fb7ce2@mail.gmail.com> On 12/25/06, David Chelimsky wrote: > On 12/24/06, Pat Maddox wrote: > > Here's a controller spec I wrote, it's for a very simple RESTful > > controller (well, aren't all RESTful controllers simple? :) > > > > I've created a couple spec helper methods to refactor some of the > > common code...for example, require_login_and_correct_user creates two > > specifications: one for when the user isn't logged in, and one when > > the user is logged in but requests someone else's book. do_request > > automatically calls do_get/post/put/delete depending on what's > > implemented. > > > > Here's all the code: > > > > books_controller.rb: http://pastie.caboo.se/29469 > > books_controller_spec.rb: http://pastie.caboo.se/29470 > > spec_helper.rb: http://pastie.caboo.se/29471 > > > > The specs just feel somewhat unwieldy to me...maybe it's because the > > controller code is very simple and elegant, and the spec looks big and > > bloated in comparison. Also, it feels like it's taking me a lot > > longer to write the controller specs with all these individual > > verifications. > > > > Am I just tripping for no reason, and the specs look fine? What would > > you change? Also I know that the controller code could be improved by > > using the finder on the association, this is just how I have it for > > now. I'm interested in how the specs could be better. > > > > I'll be understanding if I don't get a response for a few days :) > > Merry Christmas everybody! > > Quick observations: > > 1. At first glance I like the structure of wrapping specify blocks in > methods like this. > > 2. Instead of having free floating methods I'd wrap them in a module > and include the module in the context: > > module MyHelperMethods > def login(user, pw) > ... > end > end > > context "Given blah...." do > include MyHelperMethods > setup {..} > specify "a logged in user..." do > login(@user, @pw) > .. > end > end > > 3. The extractions are inconsistent. For example: > > setup do > create_user > login_as @mock_user > end > > The reference to @mock_user is confusing here. Where does it come from? > > To make it easier to understand, I might phrase this like this: > > setup do > @mock_user = create_user > login_as @mock_user > end > > or, more terse: > > module MyHelpers > def mock_user > @mock_user ||= mock("user") > end > def login_as(user) > .. > end > end > > context ... > setup do > login_as mock_user > end > end > > Using a mock_user method like that could make the specs look more > consistent (i.e. not sometimes referencing @mock_user and sometimes > referencing mock_user). > > 4. The magic involved in having should_find_user call do_get is a bit > troubling for me. I appreciate the need to indicate what to call, but > I'd do it more explicitly: > > should_find_user_on :get > > ... or something like that. Then you can eliminate do_request and the > spec becomes a bit more explicit. > > ==================== > Pat, this is great stuff in general. The challenge is to eliminate > duplication in such a way that each spec is still completely > understandable without having to go read the other helpers, etc. I > hope my suggestions here help a bit. Hey David, Thanks a lot for the suggestions. I agree with all of them, I think they make the code clearer. Things are more explicit and consistent. Here's the code with the incorporated changes: spec_helper.rb: http://pastie.caboo.se/29577 books_controller_spec.rb: http://pastie.caboo.se/29578 Pat From mlangenberg at gmail.com Wed Dec 27 08:04:01 2006 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Wed, 27 Dec 2006 14:04:01 +0100 Subject: [rspec-users] What do you think of this controller spec? In-Reply-To: <810a540e0612260908k55c67a79wf281c58fa9fb7ce2@mail.gmail.com> References: <810a540e0612241253gd5b327ex706cb07e3ccacc6e@mail.gmail.com> <57c63afe0612250834nf735f0cge4cb2346a03e1057@mail.gmail.com> <810a540e0612260908k55c67a79wf281c58fa9fb7ce2@mail.gmail.com> Message-ID: <27c0ac6d0612270504r69edf1ct6aedc2dca9dab13@mail.gmail.com> Thanks for the example controller spec Pat, I'm just starting to play a bit with RSpec and I've got some hard time finding my way in the controller specs. This is just the example I need. On 12/26/06, Pat Maddox wrote: > On 12/25/06, David Chelimsky wrote: > > On 12/24/06, Pat Maddox wrote: > > > Here's a controller spec I wrote, it's for a very simple RESTful > > > controller (well, aren't all RESTful controllers simple? :) > > > > > > I've created a couple spec helper methods to refactor some of the > > > common code...for example, require_login_and_correct_user creates two > > > specifications: one for when the user isn't logged in, and one when > > > the user is logged in but requests someone else's book. do_request > > > automatically calls do_get/post/put/delete depending on what's > > > implemented. > > > > > > Here's all the code: > > > > > > books_controller.rb: http://pastie.caboo.se/29469 > > > books_controller_spec.rb: http://pastie.caboo.se/29470 > > > spec_helper.rb: http://pastie.caboo.se/29471 > > > > > > The specs just feel somewhat unwieldy to me...maybe it's because the > > > controller code is very simple and elegant, and the spec looks big and > > > bloated in comparison. Also, it feels like it's taking me a lot > > > longer to write the controller specs with all these individual > > > verifications. > > > > > > Am I just tripping for no reason, and the specs look fine? What would > > > you change? Also I know that the controller code could be improved by > > > using the finder on the association, this is just how I have it for > > > now. I'm interested in how the specs could be better. > > > > > > I'll be understanding if I don't get a response for a few days :) > > > Merry Christmas everybody! > > > > Quick observations: > > > > 1. At first glance I like the structure of wrapping specify blocks in > > methods like this. > > > > 2. Instead of having free floating methods I'd wrap them in a module > > and include the module in the context: > > > > module MyHelperMethods > > def login(user, pw) > > ... > > end > > end > > > > context "Given blah...." do > > include MyHelperMethods > > setup {..} > > specify "a logged in user..." do > > login(@user, @pw) > > .. > > end > > end > > > > 3. The extractions are inconsistent. For example: > > > > setup do > > create_user > > login_as @mock_user > > end > > > > The reference to @mock_user is confusing here. Where does it come from? > > > > To make it easier to understand, I might phrase this like this: > > > > setup do > > @mock_user = create_user > > login_as @mock_user > > end > > > > or, more terse: > > > > module MyHelpers > > def mock_user > > @mock_user ||= mock("user") > > end > > def login_as(user) > > .. > > end > > end > > > > context ... > > setup do > > login_as mock_user > > end > > end > > > > Using a mock_user method like that could make the specs look more > > consistent (i.e. not sometimes referencing @mock_user and sometimes > > referencing mock_user). > > > > 4. The magic involved in having should_find_user call do_get is a bit > > troubling for me. I appreciate the need to indicate what to call, but > > I'd do it more explicitly: > > > > should_find_user_on :get > > > > ... or something like that. Then you can eliminate do_request and the > > spec becomes a bit more explicit. > > > > ==================== > > Pat, this is great stuff in general. The challenge is to eliminate > > duplication in such a way that each spec is still completely > > understandable without having to go read the other helpers, etc. I > > hope my suggestions here help a bit. > > Hey David, > > Thanks a lot for the suggestions. I agree with all of them, I think > they make the code clearer. Things are more explicit and consistent. > > Here's the code with the incorporated changes: > spec_helper.rb: http://pastie.caboo.se/29577 > books_controller_spec.rb: http://pastie.caboo.se/29578 > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Dec 27 11:21:00 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 27 Dec 2006 11:21:00 -0500 Subject: [rspec-users] What do you think of this controller spec? In-Reply-To: <810a540e0612260908k55c67a79wf281c58fa9fb7ce2@mail.gmail.com> References: <810a540e0612241253gd5b327ex706cb07e3ccacc6e@mail.gmail.com> <57c63afe0612250834nf735f0cge4cb2346a03e1057@mail.gmail.com> <810a540e0612260908k55c67a79wf281c58fa9fb7ce2@mail.gmail.com> Message-ID: <57c63afe0612270821r4735eadcx21bfb4d4118fafdf@mail.gmail.com> On 12/26/06, Pat Maddox wrote: > On 12/25/06, David Chelimsky wrote: > > On 12/24/06, Pat Maddox wrote: > > > Here's a controller spec I wrote, it's for a very simple RESTful > > > controller (well, aren't all RESTful controllers simple? :) > > > > > > I've created a couple spec helper methods to refactor some of the > > > common code...for example, require_login_and_correct_user creates two > > > specifications: one for when the user isn't logged in, and one when > > > the user is logged in but requests someone else's book. do_request > > > automatically calls do_get/post/put/delete depending on what's > > > implemented. > > > > > > Here's all the code: > > > > > > books_controller.rb: http://pastie.caboo.se/29469 > > > books_controller_spec.rb: http://pastie.caboo.se/29470 > > > spec_helper.rb: http://pastie.caboo.se/29471 > > > > > > The specs just feel somewhat unwieldy to me...maybe it's because the > > > controller code is very simple and elegant, and the spec looks big and > > > bloated in comparison. Also, it feels like it's taking me a lot > > > longer to write the controller specs with all these individual > > > verifications. > > > > > > Am I just tripping for no reason, and the specs look fine? What would > > > you change? Also I know that the controller code could be improved by > > > using the finder on the association, this is just how I have it for > > > now. I'm interested in how the specs could be better. > > > > > > I'll be understanding if I don't get a response for a few days :) > > > Merry Christmas everybody! > > > > Quick observations: > > > > 1. At first glance I like the structure of wrapping specify blocks in > > methods like this. > > > > 2. Instead of having free floating methods I'd wrap them in a module > > and include the module in the context: > > > > module MyHelperMethods > > def login(user, pw) > > ... > > end > > end > > > > context "Given blah...." do > > include MyHelperMethods > > setup {..} > > specify "a logged in user..." do > > login(@user, @pw) > > .. > > end > > end > > > > 3. The extractions are inconsistent. For example: > > > > setup do > > create_user > > login_as @mock_user > > end > > > > The reference to @mock_user is confusing here. Where does it come from? > > > > To make it easier to understand, I might phrase this like this: > > > > setup do > > @mock_user = create_user > > login_as @mock_user > > end > > > > or, more terse: > > > > module MyHelpers > > def mock_user > > @mock_user ||= mock("user") > > end > > def login_as(user) > > .. > > end > > end > > > > context ... > > setup do > > login_as mock_user > > end > > end > > > > Using a mock_user method like that could make the specs look more > > consistent (i.e. not sometimes referencing @mock_user and sometimes > > referencing mock_user). > > > > 4. The magic involved in having should_find_user call do_get is a bit > > troubling for me. I appreciate the need to indicate what to call, but > > I'd do it more explicitly: > > > > should_find_user_on :get > > > > ... or something like that. Then you can eliminate do_request and the > > spec becomes a bit more explicit. > > > > ==================== > > Pat, this is great stuff in general. The challenge is to eliminate > > duplication in such a way that each spec is still completely > > understandable without having to go read the other helpers, etc. I > > hope my suggestions here help a bit. > > Hey David, > > Thanks a lot for the suggestions. I agree with all of them, I think > they make the code clearer. Things are more explicit and consistent. > > Here's the code with the incorporated changes: > spec_helper.rb: http://pastie.caboo.se/29577 > books_controller_spec.rb: http://pastie.caboo.se/29578 Cool Pat. I have a couple more observations. These are admittedly REALLY nit-picky, so take them w/ a grain of salt. I'm just sharing how I would approach it from here. 1. There is an imbalance between @mock_book (instance var) and mock_user (method). I'd add a mock_book method like the mock_user method to make the setups feel more consistent. For example: setup do login_as mock_user mock_book.stub!(:mark_as_read) end 2. I'd call the modules something like BookSpecs and UserSpecs. I think that describes better what they represent (specs that later get applied in different contexts). 3. I'm almost tempted to take ALL of the specs and define them in the modules. Then the contexts read like this: context "Given a call to :update using PUT, the BooksController" do include UserSpecHelpers extend BookHelperMethods controller_name :books setup do login_as mock_user mock_book.stub!(:mark_as_read) mock_book.stub!(:to_param).and_return("1") end def do_put(options = {}) put :update, options.merge({ :user_id => "1", :id => "1" }) end should_find_user_on :put should_find_book_on :put should_not_update_the_book_as_read_if_not_specified should_update_the_book_as_read_if_specified should_redirect_to_the_book_just_updated end I have some mixed feelings about that because it pushes more towards the sort of indirection confusion that I so want to avoid in specs. On the other hand, it makes the specs read very consistently. WDYT? David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From listaccount at e-tobi.net Wed Dec 27 13:41:54 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Wed, 27 Dec 2006 19:41:54 +0100 Subject: [rspec-users] DB-less rspec_on_rails Message-ID: <4592BE72.3020000@e-tobi.net> Hi! I'm still struggling with RSpec to get it working with a Rails application, that does not use a database. I removed all the db:* dependencies from the RSpec targets, but it still wants to connect to a database. Any ideas? bye, Tobias ** Execute spec:models /usr/bin/ruby1.8 -I"/var/lib/gems/1.8/gems/rspec-0.7.5/lib" "/var/lib/gems/1.8/gems/rspec-0.7.5/bin/spec" "spec/models/person_spec.rb" F 1) Mysql::Error in 'This sample spec should work without a database' #28000Access denied for user 'root'@'localhost' (using password: NO) Finished in 0.026762 seconds 1 specification, 1 failure rake aborted! Command failed with status (1): [/usr/bin/ruby1.8 -I"/var/lib/gems/1.8/gems...] /usr/lib/ruby/1.8/rake.rb:722:in `sh' /usr/lib/ruby/1.8/rake.rb:729:in `call' /usr/lib/ruby/1.8/rake.rb:729:in `sh' /usr/lib/ruby/1.8/rake.rb:812:in `sh' /usr/lib/ruby/1.8/rake.rb:747:in `ruby' /usr/lib/ruby/1.8/rake.rb:812:in `ruby' /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:131:in `define' /usr/lib/ruby/1.8/rake.rb:831:in `verbose' /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:110:in `define' /usr/lib/ruby/1.8/rake.rb:387:in `call' /usr/lib/ruby/1.8/rake.rb:387:in `execute' /usr/lib/ruby/1.8/rake.rb:387:in `each' /usr/lib/ruby/1.8/rake.rb:387:in `execute' /usr/lib/ruby/1.8/rake.rb:357:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/1.8/rake.rb:350:in `invoke' /usr/lib/ruby/1.8/rake.rb:1906:in `run' /usr/lib/ruby/1.8/rake.rb:1906:in `each' /usr/lib/ruby/1.8/rake.rb:1906:in `run' /usr/bin/rake:4 From aslak.hellesoy at gmail.com Wed Dec 27 17:51:02 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 27 Dec 2006 23:51:02 +0100 Subject: [rspec-users] DB-less rspec_on_rails In-Reply-To: <4592BE72.3020000@e-tobi.net> References: <4592BE72.3020000@e-tobi.net> Message-ID: <8d961d900612271451u4f169f63y19024ce645b28b0a@mail.gmail.com> How do I reproduce this erratic behaviour? Detailed steps please. On 12/27/06, Tobias Grimm wrote: > Hi! > > I'm still struggling with RSpec to get it working with a Rails > application, that does not use a database. I removed all the db:* > dependencies from the RSpec targets, but it still wants to connect to a > database. > > Any ideas? > > bye, > > Tobias > > ** Execute spec:models > /usr/bin/ruby1.8 -I"/var/lib/gems/1.8/gems/rspec-0.7.5/lib" > "/var/lib/gems/1.8/gems/rspec-0.7.5/bin/spec" "spec/models/person_spec.rb" > > F > > 1) > Mysql::Error in 'This sample spec should work without a database' > #28000Access denied for user 'root'@'localhost' (using password: NO) > > > Finished in 0.026762 seconds > > 1 specification, 1 failure > rake aborted! > Command failed with status (1): [/usr/bin/ruby1.8 > -I"/var/lib/gems/1.8/gems...] > /usr/lib/ruby/1.8/rake.rb:722:in `sh' > /usr/lib/ruby/1.8/rake.rb:729:in `call' > /usr/lib/ruby/1.8/rake.rb:729:in `sh' > /usr/lib/ruby/1.8/rake.rb:812:in `sh' > /usr/lib/ruby/1.8/rake.rb:747:in `ruby' > /usr/lib/ruby/1.8/rake.rb:812:in `ruby' > /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:131:in `define' > /usr/lib/ruby/1.8/rake.rb:831:in `verbose' > /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:110:in `define' > /usr/lib/ruby/1.8/rake.rb:387:in `call' > /usr/lib/ruby/1.8/rake.rb:387:in `execute' > /usr/lib/ruby/1.8/rake.rb:387:in `each' > /usr/lib/ruby/1.8/rake.rb:387:in `execute' > /usr/lib/ruby/1.8/rake.rb:357:in `invoke' > /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' > /usr/lib/ruby/1.8/rake.rb:350:in `invoke' > /usr/lib/ruby/1.8/rake.rb:1906:in `run' > /usr/lib/ruby/1.8/rake.rb:1906:in `each' > /usr/lib/ruby/1.8/rake.rb:1906:in `run' > /usr/bin/rake:4 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Dec 27 23:15:17 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 28 Dec 2006 05:15:17 +0100 Subject: [rspec-users] New command line options Message-ID: <8d961d900612272015x17bf0c3ct40180276d355cc9f@mail.gmail.com> I have just committed some changes to the spec command line addressing the following shortcomings: * drb-based spec running (fast-running rails specs) couldn't be used from spec/rails' rake tasks or RSpec.tmbundle * coloured or any other standard spec command line options could not be passed to spec/rails' rake tasks These shortcomings are now history. Options can now be passed to the spec command via the --options switch. The default spec/rails rake tasks now use this, so you can tweak RSpec's behaviour by editing your RSpec-enabled Rails project's spec/spec.opts file. Further, the --drb command line switch makes fast-running specs accessible both from Rake and from the RSpec.tmbundle (TextMate plugin) via the TM_RSPEC_OPTS variable. Most of this is already described in the upcoming website docs. I'm planning to publish some screencasts soon. They will cover both RSpec basics as well as some of the more advanced features that have been added recently. Cheers, Aslak From listaccount at e-tobi.net Fri Dec 29 03:22:22 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Fri, 29 Dec 2006 09:22:22 +0100 Subject: [rspec-users] DB-less rspec_on_rails In-Reply-To: <8d961d900612271451u4f169f63y19024ce645b28b0a@mail.gmail.com> References: <4592BE72.3020000@e-tobi.net> <8d961d900612271451u4f169f63y19024ce645b28b0a@mail.gmail.com> Message-ID: <4594D03E.5040108@e-tobi.net> Hello! aslak hellesoy wrote: > How do I reproduce this erratic behaviour? Detailed steps please. > Ok - I figured out, that I even get this problem without using rake: - Create a new rails app and install the rspec on rails plugin (I used version 0.7.5) - Create a new model test.rb, that not derives from AR: app/models/test.rb: class Test end - Create a spec for this model: spec/models/test_spec.rb: require File.dirname(__FILE__) + '/../spec_helper' context "A simple test" do specify "should not need a database" do 1.should.be == 1 end end Now run `ruby spec/models/test_spec.rb`. At this point I get: Mysql::Error in 'A simple test should not need a database' Access denied for user 'root'@'localhost' (using password: NO) spec/models/test_spec.rb:3: Now go into spec/models and run `ruby test_spec.rb`. This one seems to work, which makes it even more strange: . Finished in 0.001245 seconds 1 specification, 0 failures Test::Unit works fine, after replacing test_helper with: ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'application' require 'test/unit' require 'action_controller/test_process' require 'action_web_service/test_invoke' require 'breakpoint' I tried the same with spec_helper.rb, but it didn't work. What is different between running a spec from the application root and from the spec directory? For the moment I simply use a sqlite3 memory database to get RSpec working with my DB-less application. But I would prefer to not have this additional "build-time" -dependency. bye, Tobias From listaccount at e-tobi.net Fri Dec 29 17:37:27 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Fri, 29 Dec 2006 23:37:27 +0100 Subject: [rspec-users] RSpecOnRails - setup or context_setup? Message-ID: <459598A7.1050603@e-tobi.net> Hi! While working on a controller spec, I got into this situation: The controller uses in it's initialize method some configuration options from a Configuration class (singleton). For testing these options need to be changed, so I started with: context "..." do controller_name "test" setup do Configuration.instance.option = "this should be used in the tests" end specify "..." do ... end end This looks fine, but has one problem: the setup code of the context is executed AFTER the controller has been instantiated, but Configuration.instance.option is needed BEFORE the controllers initialize method is called. One way to work around this, is to move the setup code to context_setup, which apparently gets called BEFORE the controller gets instantiated. In my current situation this works fine, but what if I need to setup something before every specification in a context that needs to be done before the controller is initialized? bye, Tobias From lastobelus at mac.com Sat Dec 30 07:33:26 2006 From: lastobelus at mac.com (Michael Johnston) Date: Sat, 30 Dec 2006 04:33:26 -0800 Subject: [rspec-users] Issues with 0.7.5 In-Reply-To: <149489D8-0E81-497C-A382-C254F4366D20@gmail.com> References: <149489D8-0E81-497C-A382-C254F4366D20@gmail.com> Message-ID: <5C8C67A4-8DE8-461B-A187-B3625F9B88F6@mac.com> You are talking about using rspec_autotest (a separate plugin from rspec_on_rails), yes? Have you installed diff-lcs? (sudo gem install diff-lcs) If you want to use the rspec server, the autotest spec command should be: @spec_command = "script/rails_spec -C --diff unified" if you don't want to use the rspec server, it should be: @spec_command = "spec -C --diff unified" If you don't want to have to remember to start the rspec server, just make a shell function that looks like: function rspec { proc=`ps | grep [r]ails_spec_server |wc -l` if test $proc -lt 1 then script/rails_spec_server & sleep 3 fi rake spec:autotest } (tune the sleep amount for your system, so that the spec server has time to start) Cheers, Michael On 25-Dec-06, at 12:37 PM, s.ross wrote: > I installed 0.7.5 and the corresponding Rails plugin. Now it seems > that the rake command is: > > rake spec:autotest > > I immediately ran into several problems: > > 1. rspec_autotest.rb line 30 has curly quotes and makes Ruby choke > 2. Same line, rails_spec is spelled solid, when it should have the > underscore > > But fixing these didn't get me back going. Now I have to have a > rails_spec_server running in one console window (is this recommended > practice?) and rake spec:autotest gives me: > > (druby://localhost:8989) /opt/local/lib/ruby/gems/1.8/gems/ > rspec-0.7.5/lib/spec/runner/command_line.rb:23:in `run': File or > directory not found: ?diff (RuntimeError) > from (druby://localhost:8989) /opt/local/lib/ruby/gems/1.8/ > gems/rspec-0.7.5/lib/spec/runner/command_line.rb:15:in `each' > from (druby://localhost:8989) /opt/local/lib/ruby/gems/1.8/ > gems/rspec-0.7.5/lib/spec/runner/command_line.rb:15:in `run' > from (druby://localhost:8989) script/rails_spec_server:16:in > `run' > from script/rails_spec:8 > > The whole setup was working perfectly under 0.7.4 but I can't even > get through a single spec pass on 0.7.5. Any hints are appreciated. > > Thanks, > > Steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lastobelus at mac.com Sat Dec 30 07:46:29 2006 From: lastobelus at mac.com (Michael Johnston) Date: Sat, 30 Dec 2006 04:46:29 -0800 Subject: [rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5 In-Reply-To: References: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> Message-ID: <4232AA34-F6EC-42BE-A6D9-044F05D29149@mac.com> That is what I meant. In my setup, it is NOT rerunning the whole suite after I fix a failing spec. After a cursory look at autotest.rb in ZenTest, I haven't figured out why it is broken. But I think I will try to figure that out today, because autotest seems kind of pointless without that behaviour. It probably has nothing to do with rspec or rspec_autotest; I realized that my version of ZenTest is new too, 3.4.3 instead of 3.4.1. Cheers, Michael On 21-Dec-06, at 11:13 AM, Nick Sieger wrote: > On 12/21/06, Michael Johnston wrote: > Has anyone else encountered this problem? > > What I mean is, rspec_autotest runs all specs, then waits. When you > change a spec, it reruns that spec. However, if that spec now passes, > it should run the whole suite again, so you can see the next one to > work on. It no longer does this. This renders it somewhat useless. > > Does anyone have autotest working with rspec 0.7.5, or does anyone > have any idea of what may be causing this issue or how to go about > fixing it? > > Are you sure this is caused by the 0.7.5 upgrade? I've seen > similar behavior but I'm still on 0.7.3. Here's the response > comment I posted to yours: > > I think this is expected behavior for autotest ? I've already > noticed this and assumed it was standard behavior. The only time > autotest reruns the whole suite is after I've just fixed a failing > test or spec. Is it possible that's what you're observing? > > Feel free to take any further discussion off-list, thanks. > > /Nick > _______________________________________________ > 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/20061230/5fe795da/attachment.html From daniel.manges at gmail.com Sat Dec 30 11:26:43 2006 From: daniel.manges at gmail.com (Daniel Manges) Date: Sat, 30 Dec 2006 11:26:43 -0500 Subject: [rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5 In-Reply-To: <4232AA34-F6EC-42BE-A6D9-044F05D29149@mac.com> References: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> <4232AA34-F6EC-42BE-A6D9-044F05D29149@mac.com> Message-ID: In my opinion the rspec_autotest plugin needs quite a bit of work. At a minimum it should be using the Inflector for pluralization. Example from current revision (r47): def tests_for_file(filename) case filename when %r%^spec/fixtures/(.*)s.yml% then ["spec/models/#{$1}_spec.rb", "spec/controllers/#{$1}_controller_spec.rb"] If I have a model City with fixtures cities.yml, rspec_autotest is going to try to run spec/models/citie_spec.rb and spec/controllers/citie_controller_spec.rb Nick, do you have plans on improving this? Thanks, Dan Manges On 12/30/06, Michael Johnston wrote: > > That is what I meant. In my setup, it is NOT rerunning the whole suite > after I fix a failing spec. > > After a cursory look at autotest.rb in ZenTest, I haven't figured out why > it is broken. But I think I will try to figure that out today, because > autotest seems kind of pointless without that behaviour. > > It probably has nothing to do with rspec or rspec_autotest; I realized > that my version of ZenTest is new too, 3.4.3 instead of 3.4.1. > > Cheers, > Michael > On 21-Dec-06, at 11:13 AM, Nick Sieger wrote: > > On 12/21/06, Michael Johnston wrote: > > > > Has anyone else encountered this problem? > > > > What I mean is, rspec_autotest runs all specs, then waits. When you > > change a spec, it reruns that spec. However, if that spec now passes, > > it should run the whole suite again, so you can see the next one to > > work on. It no longer does this. This renders it somewhat useless. > > > > Does anyone have autotest working with rspec 0.7.5, or does anyone > > have any idea of what may be causing this issue or how to go about > > fixing it? > > > Are you sure this is caused by the 0.7.5 upgrade? I've seen similar > behavior but I'm still on 0.7.3. Here's the response comment I posted to > yours: > > I think this is expected behavior for autotest ? I've already noticed this > and assumed it was standard behavior. The only time autotest reruns the > whole suite is after I've just fixed a failing test or spec. Is it possible > that's what you're observing? > > Feel free to take any further discussion off-list, thanks. > > /Nick > _______________________________________________ > 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/20061230/665dd077/attachment.html From nicksieger at gmail.com Sat Dec 30 17:13:31 2006 From: nicksieger at gmail.com (Nick Sieger) Date: Sat, 30 Dec 2006 16:13:31 -0600 Subject: [rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5 In-Reply-To: References: <4FF77DF8-CDB3-466D-AC16-925BB4842491@mac.com> <4232AA34-F6EC-42BE-A6D9-044F05D29149@mac.com> Message-ID: On 12/30/06, Daniel Manges wrote: > > In my opinion the rspec_autotest plugin needs quite a bit of work. At a > minimum it should be using the Inflector for pluralization. > Example from current revision (r47): > > def tests_for_file(filename) > case filename > > when %r%^spec/fixtures/(.*)s.yml% then > ["spec/models/#{$1}_spec.rb", > "spec/controllers/#{$1}_controller_spec.rb"] > > If I have a model City with fixtures cities.yml, rspec_autotest is going > to try to run spec/models/citie_spec.rb and > spec/controllers/citie_controller_spec.rb > > Nick, do you have plans on improving this? Well, it certainly can be done. Any chance you can email me a patch against the latest rev at [1]? [1] http://svn.caldersphere.net/svn/main/rspec_autotest/trunk/lib/rspec_autotest.rb /Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061230/18463bfc/attachment.html From listaccount at e-tobi.net Sat Dec 30 18:00:49 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Sun, 31 Dec 2006 00:00:49 +0100 Subject: [rspec-users] Another RSpec on Rails issue: how to test send_file() Message-ID: <4596EFA1.1070700@e-tobi.net> Hi! Today I needed to implement some controller code, that uses send_file() to send image data. How can this be tested / specified with RSpec? bye, Tobias From court3nay at gmail.com Sat Dec 30 18:55:59 2006 From: court3nay at gmail.com (Courtenay) Date: Sat, 30 Dec 2006 15:55:59 -0800 Subject: [rspec-users] redirect_to(:action => 'foo') and return Message-ID: <4b430c8f0612301555x17331a86l66a79bf2d804927@mail.gmail.com> I'm not sure why this is happening, but if I do this in a controller unless @variation && @variation.quantity > 0 flash[:error] = "Sorry, that product is currently not available." redirect_to(:action => 'error') and return end rspec tells me 2) ActionController::DoubleRenderError in 'The Carts controller with an existing User should add items to the cart' Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and only once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, explicitly, so "render(...) and return false". /disk0s3/rails/store/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/context/controller.rb:82:in `redirect_to' /disk0s3/rails/store/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/context/controller.rb:82:in `redirect_to' /disk0s3/rails/store/trunk/config/../app/controllers/carts_controller.rb:92:in `create' spec/controllers/carts_controller_spec.rb:99: spec/controllers/carts_controller_spec.rb:118: however if I change that to redirect_to(:action => 'error') return it works just fine. All versions of "..and return" seem to fail. courtenay http://blog.caboo.se From cwdinfo at gmail.com Sat Dec 30 19:45:26 2006 From: cwdinfo at gmail.com (s.ross) Date: Sat, 30 Dec 2006 16:45:26 -0800 Subject: [rspec-users] Another RSpec on Rails issue: how to test send_file() In-Reply-To: <4596EFA1.1070700@e-tobi.net> References: <4596EFA1.1070700@e-tobi.net> Message-ID: <07F11DE2-8BBF-4877-B2AD-7050C6EAFF9E@gmail.com> Well, here's one I just dealt with. The spec might not be great, but here it is: # in spec_helper.rb (this code is taken pretty much intact from the Wiki article on testing uploads # get us an object that represents an uploaded file def uploaded_file(path, content_type="application/octet- stream", filename=nil) filename ||= File.basename(path) t = Tempfile.new(filename) FileUtils.copy_file(path, t.path) (class << t; self; end;).class_eval do alias local_path path define_method(:original_filename) { filename } define_method(:content_type) { content_type } end return t end # a JPEG helper def uploaded_jpeg(path, filename=nil) uploaded_file(path, 'image/jpeg', filename) end # a GIF helper def uploaded_gif(path, filename=nil) uploaded_file(path, 'image/gif', filename) end # a CSV helper def uploaded_csv(path, filename=nil) uploaded_file(path, 'text/csv', filename) end # in your spec setup do get_logged_in @upload_file = uploaded_csv("#{File.expand_path(RAILS_ROOT)}/ spec/fixtures/upload_test.csv") @upload_record_count = File.open("#{File.expand_path (RAILS_ROOT)}/spec/fixtures/upload_test.csv").readlines("\r").size - 1 @original_size = Member.count end specify "the upload method should receive a good file" do @upload_file = uploaded_csv("#{File.expand_path(RAILS_ROOT)}/ spec/fixtures/upload_test.csv") post :upload, :member_file => @upload_file response.should_be_success Member.count.should == @original_size + @upload_record_count m = Member.find_by_first_and_last('Blake', 'Park') m.should_not_be_nil m.created_on.year.should_be > 2000 end specify "the upload method should reject bogus data in a file" do @upload_file = uploaded_csv("#{File.expand_path(RAILS_ROOT)}/ spec/fixtures/upload_bogus_test.csv") post :upload, :member_file => @upload_file response.should_be_success response.should_have_tag :p, :content => /upload data error/ end Comments welcomed. Steve On Dec 30, 2006, at 3:00 PM, Tobias Grimm wrote: > Hi! > > Today I needed to implement some controller code, that uses > send_file() > to send image data. How can this be tested / specified with RSpec? > > bye, > > Tobias > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From court3nay at gmail.com Sat Dec 30 20:24:50 2006 From: court3nay at gmail.com (Courtenay) Date: Sat, 30 Dec 2006 17:24:50 -0800 Subject: [rspec-users] what's with the response.should_be_xxxx stacktrace? Message-ID: <4b430c8f0612301724w29fa33b2y5ad34142847daab5@mail.gmail.com> If I do get :index response.should_be_success I get about 20k of marshalled dumpage that starts like #You are being redirected.\", @assigns=[], @redirected_to={:action=>\"show\", :id=>1}, @template=#<#:0x38d5f9c @assigns={\"template_ro and finishes 20 pages later with @headers={"Status"=>"302 Found", "cookie"=>[], "Content-Type"=>"text/html; charset=utf-8", "Cache-Control"=>"no-cache", "location"=>"http://test.host/carts/1"}, @session=#{}, :cart=>{}}>> should be success nil My question is, is this intended, or just a side-effect of using should_be_xxxx? In which case, particularly regarding the "artificial sugar causes cancer", the response should_be really could be more nicely formatted ("response should be success but was 'redirect' to 'http://'") Finally, while I'm assuming that I'm doing it properly, is there a better way to do the response code checking? Thanks, Courtenay http://blog.caboo.se From dchelimsky at gmail.com Sat Dec 30 22:55:01 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 30 Dec 2006 22:55:01 -0500 Subject: [rspec-users] what's with the response.should_be_xxxx stacktrace? In-Reply-To: <4b430c8f0612301724w29fa33b2y5ad34142847daab5@mail.gmail.com> References: <4b430c8f0612301724w29fa33b2y5ad34142847daab5@mail.gmail.com> Message-ID: <57c63afe0612301955n460dd741i679d03af11b0546@mail.gmail.com> On 12/30/06, Courtenay wrote: > If I do > > get :index > response.should_be_success > > I get about 20k of marshalled dumpage that starts like > > #You > are being redirected.\", > @assigns=[], @redirected_to={:action=>\"show\", :id=>1}, > @template=#<#:0x38d5f9c @assigns={\"template_ro > > and finishes 20 pages later with > > @headers={"Status"=>"302 Found", "cookie"=>[], > "Content-Type"=>"text/html; charset=utf-8", > "Cache-Control"=>"no-cache", "location"=>"http://test.host/carts/1"}, > @session=# @attributes={"flash"=>{}, :cart=>{}}>> should be success nil > > My question is, is this intended, or just a side-effect of using > should_be_xxxx? In which case, particularly regarding the "artificial > sugar causes cancer", the response should_be really could be more > nicely formatted ("response should be success but was 'redirect' to > 'http://'") > > Finally, while I'm assuming that I'm doing it properly, is there a > better way to do the response code checking? You're doing the right thing re: response code checking. In the future, please consider raising a bug report for things like this. I took the liberty of doing so: http://rubyforge.org/tracker/index.php?func=detail&aid=7506&group_id=797&atid=3149 raised and fixed Happy New Year, David > > Thanks, > > Courtenay > http://blog.caboo.se > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Dec 30 23:13:04 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 30 Dec 2006 23:13:04 -0500 Subject: [rspec-users] redirect_to(:action => 'foo') and return In-Reply-To: <4b430c8f0612301555x17331a86l66a79bf2d804927@mail.gmail.com> References: <4b430c8f0612301555x17331a86l66a79bf2d804927@mail.gmail.com> Message-ID: <57c63afe0612302013g582767e6q3c3dec23319c89f0@mail.gmail.com> On 12/30/06, Courtenay wrote: > I'm not sure why this is happening, but if I do this in a controller > > unless @variation && @variation.quantity > 0 > flash[:error] = "Sorry, that product is currently not available." > redirect_to(:action => 'error') and return > end > > rspec tells me > > 2) > ActionController::DoubleRenderError in 'The Carts controller with an > existing User should add items to the cart' > Render and/or redirect were called multiple times in this action. > Please note that you may only call render OR redirect, and only once > per action. Also note that neither redirect nor render terminate > execution of the action, so if you want to exit an action after > redirecting, you need to do something like "redirect_to(...) and > return". Finally, note that to cause a before filter to halt execution > of the rest of the filter chain, the filter must return false, > explicitly, so "render(...) and return false". > /disk0s3/rails/store/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/context/controller.rb:82:in > `redirect_to' > /disk0s3/rails/store/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/context/controller.rb:82:in > `redirect_to' > /disk0s3/rails/store/trunk/config/../app/controllers/carts_controller.rb:92:in > `create' > spec/controllers/carts_controller_spec.rb:99: > spec/controllers/carts_controller_spec.rb:118: > > > however if I change that to > > redirect_to(:action => 'error') > return > > it works just fine. All versions of "..and return" seem to fail. Please raise a bug on this. http://rspec.rubyforge.org/contribute.html http://rubyforge.org/tracker/?group_id=797 Thanks, David > > > courtenay > http://blog.caboo.se > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From court3nay at gmail.com Sat Dec 30 23:26:10 2006 From: court3nay at gmail.com (Courtenay) Date: Sat, 30 Dec 2006 20:26:10 -0800 Subject: [rspec-users] what's with the response.should_be_xxxx stacktrace? In-Reply-To: <57c63afe0612301955n460dd741i679d03af11b0546@mail.gmail.com> References: <4b430c8f0612301724w29fa33b2y5ad34142847daab5@mail.gmail.com> <57c63afe0612301955n460dd741i679d03af11b0546@mail.gmail.com> Message-ID: <4b430c8f0612302026t31f6a361s8df5870fcabfa1be@mail.gmail.com> On 12/30/06, David Chelimsky wrote: > On 12/30/06, Courtenay wrote: > > If I do > > > > get :index > > response.should_be_success > > > > I get about 20k of marshalled dumpage that starts like > > > > #You > > are being redirected.\", > > @assigns=[], @redirected_to={:action=>\"show\", :id=>1}, > > @template=#<#:0x38d5f9c @assigns={\"template_ro > > > > and finishes 20 pages later with > > > > @headers={"Status"=>"302 Found", "cookie"=>[], > > "Content-Type"=>"text/html; charset=utf-8", > > "Cache-Control"=>"no-cache", "location"=>"http://test.host/carts/1"}, > > @session=# > @attributes={"flash"=>{}, :cart=>{}}>> should be success nil > > > > My question is, is this intended, or just a side-effect of using > > should_be_xxxx? In which case, particularly regarding the "artificial > > sugar causes cancer", the response should_be really could be more > > nicely formatted ("response should be success but was 'redirect' to > > 'http://'") > > > > Finally, while I'm assuming that I'm doing it properly, is there a > > better way to do the response code checking? > > You're doing the right thing re: response code checking. In the > future, please consider raising a bug report for things like this. I > took the liberty of doing so: > > http://rubyforge.org/tracker/index.php?func=detail&aid=7506&group_id=797&atid=3149 > Awesome..! OK, will do in future. I generally assume that I'm doing it wrong if I get a page o' code.. still fumbling my way around the syntax. Courtenay http://blog.caboo.se From listaccount at e-tobi.net Sun Dec 31 04:58:52 2006 From: listaccount at e-tobi.net (Tobias Grimm) Date: Sun, 31 Dec 2006 10:58:52 +0100 Subject: [rspec-users] Another RSpec on Rails issue: how to test send_file() In-Reply-To: <07F11DE2-8BBF-4877-B2AD-7050C6EAFF9E@gmail.com> References: <4596EFA1.1070700@e-tobi.net> <07F11DE2-8BBF-4877-B2AD-7050C6EAFF9E@gmail.com> Message-ID: <459789DC.7040407@e-tobi.net> s.ross wrote: > Well, here's one I just dealt with. The spec might not be great, but > here it is: > This is kinda different from what I want to do. My controller looks like this: ... def images image_file_name = get_image_file_name_by_id(params[:id]) send_file(image_file_name, :type => 'image/png', :disposition => 'inline') end .. I can test with response.should_be_success that this request works. setup do get(:images, :id => 'test-image') end spec "should be successful" do response.should_be_success end spec "should return mime type image/png' # dont know how to test this end spec "image data should be inline' # dont know how to test this end spec "should return the content of the image file" # test-images simply contains "dummy-data" - but how do I check this? end But I don't know how to check, if the content sent to the client with send_file is correct. During running the spec, the image file is a simple text file - But how do I get access to the content, the mime header and the content disposition field to check if these are correct? Tobias