From address4spams at 21croissants.com Thu May 1 11:00:27 2008 From: address4spams at 21croissants.com (21croissants) Date: Thu, 1 May 2008 08:00:27 -0700 (PDT) Subject: [rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher In-Reply-To: <71E6913D-A330-4FC8-BB81-6F6B310266CC@patchspace.co.uk> References: <16965619.post@talk.nabble.com> <71E6913D-A330-4FC8-BB81-6F6B310266CC@patchspace.co.uk> Message-ID: <16993286.post@talk.nabble.com> thanks for your feedback Ashley. You're right and one of my next action will be to create a gem so it can be use in any ruby project, I will keep the Rails plugin of course. At the moment, you can write : require ... specific your location ... + '/lib/dont_repeat_yourself/reporter' dry_reporter = DontRepeatYourself::Reporter.new dry_reporter.configure_simian_for_ruby_project("/home/jeanmichel/ruby/projects/dry-report/rails_plugin/vendor/plugins/dont_repeat_yourself") dry_reporter.html_rails_report It will generate the report (HTML, Textmate) in a file called DRY_report.html at the root folder of your rails app. I reckon this is not very handy - you need to create a Rails project and install the plugin - but it will soon improve! JM Ashley Moran-4 wrote: > > > Sounds good! Any reason why you wrote it as a Rails plugin though? > This could be used for any ruby project... except mine of course, I > never copy and paste, honest :o) > > Ashley > -- View this message in context: http://www.nabble.com/Sharing%3A-dont_repeat_yourself-plugin%2C-will-report-duplicate-lines-in-your-code%21-tp16965619p16993286.html Sent from the rspec-users mailing list archive at Nabble.com. From ashley.moran at patchspace.co.uk Thu May 1 12:07:40 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 1 May 2008 17:07:40 +0100 Subject: [rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher In-Reply-To: <16993286.post@talk.nabble.com> References: <16965619.post@talk.nabble.com> <71E6913D-A330-4FC8-BB81-6F6B310266CC@patchspace.co.uk> <16993286.post@talk.nabble.com> Message-ID: <8F1B2463-E06D-41B7-973A-AE54FA66BAF5@patchspace.co.uk> On 1 May 2008, at 16:00, 21croissants wrote: > You're right and one of my next action will be to create a gem so it > can be > use in any ruby project, I will keep the Rails plugin of course. Cool, be sure to post here when you've gemified it :) > At the moment, you can write : > > require ... specific your location ... + > '/lib/dont_repeat_yourself/reporter' > > dry_reporter = DontRepeatYourself::Reporter.new > dry_reporter.configure_simian_for_ruby_project("/home/jeanmichel/ > ruby/projects/dry-report/rails_plugin/vendor/plugins/ > dont_repeat_yourself") > dry_reporter.html_rails_report > > It will generate the report (HTML, Textmate) in a file called > DRY_report.html at the root folder of your rails app. > > I reckon this is not very handy - you need to create a Rails project > and > install the plugin - but it will soon improve! As a spoilt Rails developer I demand that everything written in Ruby works magically whatever I am doing :o) This reminds me a bit of a time when I created a Rails project just to use AR migrations. I think I'll wait for now until there is a gem version. Just out of curiosity, have you run your DRY reporter against the Rails code itself? Might be interesting to see the results... Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From tero at tilus.net Fri May 2 01:13:52 2008 From: tero at tilus.net (Tero Tilus) Date: Fri, 2 May 2008 08:13:52 +0300 Subject: [rspec-users] BDD/Rails/Shoulda In-Reply-To: References: <51538E8C-C42A-4AE0-9CE0-25D6560E3CE6@parkerhill.com> <7B749038-B6C8-42EE-8CAB-D92661D3C019@patchspace.co.uk> <04414D52-7044-4CC5-88AB-89F06FF57DE8@gmail.com> Message-ID: <20080502051351.GC18800@uivelo.tilus.net> 2008-04-30 15:51, Ashley Moran: > about a month ago I was working on someone else's code and followed > this process of uncommenting code as I wrote the specs for it (there > were none for that class). I actually *removed* the 'if > this_condition and that_condition' part of a line that follows the > pattern you gave above. Maybe the fact that the code was not yours makes a difference here? Dunnot, but I'd expect it to. > I don't see how you could end up with redundant code following this > process. I can well imagine how you may end up not getting all the advantages of BDD thru uncommenting process when you compare to clean BDD. But uncommenting is definitely better than writing spec on top of existing code, which in turn is _way_ better than not writing spec at all. > Maybe it's because I am blanking out what the code says when I write > the specs? Lucky you if you are able to do that. I've noticed I'm not. -- Tero Tilus ## 050 3635 235 ## http://www.tilus.net/koti/tero/ From ashley.moran at patchspace.co.uk Fri May 2 12:06:34 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 2 May 2008 17:06:34 +0100 Subject: [rspec-users] BDD/Rails/Shoulda In-Reply-To: <20080502051351.GC18800@uivelo.tilus.net> References: <51538E8C-C42A-4AE0-9CE0-25D6560E3CE6@parkerhill.com> <7B749038-B6C8-42EE-8CAB-D92661D3C019@patchspace.co.uk> <04414D52-7044-4CC5-88AB-89F06FF57DE8@gmail.com> <20080502051351.GC18800@uivelo.tilus.net> Message-ID: <1867A8FF-EF69-4017-972D-2F8D69FFD84D@patchspace.co.uk> On 2 May 2008, at 06:13, Tero Tilus wrote: > I can well imagine how you may end up not getting all the advantages > of BDD thru uncommenting process when you compare to clean BDD. But > uncommenting is definitely better than writing spec on top of existing > code, which in turn is _way_ better than not writing spec at all. Perhaps "uncommenting" is a bad description. What I do is write specs for the behaviour I want, and see what bits of the code (if any) do that. (Which will obviously be pretty similar to the what it does anyway.) What I *don't* do is pick a line of code and write a spec for it so I can uncomment it. I guess that's how you would run into trouble. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From rspec-users at kero.tmfweb.nl Fri May 2 15:57:22 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Fri, 2 May 2008 21:57:22 +0200 Subject: [rspec-users] Return code for running stories Message-ID: <20080502195722.GE4320@bumblebee.m38c.nl> Hi all! Just wrote a few stories and committed code to a project of mine, then realized I made a mistake (with the commit, not the code or tests). It would be nice to put the script that runs the stories as a pre-commit hook, preventing the commit from succeeding if the stories fail. For that, I need to set the right exit code. In turn, I need to know he result of the tests. Given the prescription of running stories: with_steps_for :accounts do run 'path/to/file/with/story' end I see neither #with_steps_for, nor #run return anything resembling the result of the tests (which does not really surprise me). So how to get the success/pending/failure of the stories out? Should I write a formatter/listener that exit(1)s on failure? Bye, Kero. PS: I'm back after a few months, and -behold- it looks like I can use rspec for work, too :) From nabble.108 at xoxy.net Fri May 2 17:17:01 2008 From: nabble.108 at xoxy.net (Matt McNeil) Date: Fri, 2 May 2008 14:17:01 -0700 (PDT) Subject: [rspec-users] spec'ing calls to super (or other Ruby keywords) Message-ID: <17027929.post@talk.nabble.com> Hi there, How does one spec an invocation of a Ruby keyword, such as super in this case? class User < ActiveResource::Base # faking the ActiveRecord before/after_save observers def save super UserMailer.deliver_activation(self) if recently_activated? end end Does the solution look anything like the following? describe User do describe '#save' do it "should call save on the parent class" do # something.should_receive(:something) @user.save end end end Any thoughts? Thanks much, Matt -- View this message in context: http://www.nabble.com/spec%27ing-calls-to-super-%28or-other-Ruby-keywords%29-tp17027929p17027929.html Sent from the rspec-users mailing list archive at Nabble.com. From ben at benmabey.com Fri May 2 19:21:32 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 02 May 2008 17:21:32 -0600 Subject: [rspec-users] Return code for running stories In-Reply-To: <20080502195722.GE4320@bumblebee.m38c.nl> References: <20080502195722.GE4320@bumblebee.m38c.nl> Message-ID: <481BA1FC.2080507@benmabey.com> Kero wrote: > Hi all! > > Just wrote a few stories and committed code to a project of mine, > then realized I made a mistake (with the commit, not the code or > tests). It would be nice to put the script > that runs the stories as a pre-commit hook, preventing the commit > from succeeding if the stories fail. > > For that, I need to set the right exit code. > In turn, I need to know he result of the tests. > > Given the prescription of running stories: > with_steps_for :accounts do > run 'path/to/file/with/story' > end > I see neither #with_steps_for, nor #run return anything resembling > the result of the tests (which does not really surprise me). > > So how to get the success/pending/failure of the stories out? > Should I write a formatter/listener that exit(1)s on failure? > > Bye, > Kero. > > PS: I'm back after a few months, and -behold- it looks like I > can use rspec for work, too :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Kero, This does not work in rspec 1.1.3. I submitted a patch to add this functionality and it has already been accepted. So you can upgrade to edge rspec to get this functionality or just apply my patch.: http://rspec.lighthouseapp.com/projects/5645/tickets/228-story-runner-exit-code -Ben From rspec-users at kero.tmfweb.nl Sat May 3 04:34:32 2008 From: rspec-users at kero.tmfweb.nl (Kero) Date: Sat, 3 May 2008 10:34:32 +0200 Subject: [rspec-users] Return code for running stories In-Reply-To: <481BA1FC.2080507@benmabey.com> References: <20080502195722.GE4320@bumblebee.m38c.nl> <481BA1FC.2080507@benmabey.com> Message-ID: <20080503083432.GF4320@bumblebee.m38c.nl> >> I see neither #with_steps_for, nor #run return anything resembling >> the result of the tests (which does not really surprise me). >> >> So how to get the success/pending/failure of the stories out? >> Should I write a formatter/listener that exit(1)s on failure? >> >> PS: I'm back after a few months, and -behold- it looks like I >> can use rspec for work, too :) > > This does not work in rspec 1.1.3. I submitted a patch to add this > functionality and it has already been accepted. So you can upgrade to > edge rspec to get this functionality or just apply my patch.: > http://rspec.lighthouseapp.com/projects/5645/tickets/228-story-runner-exit-code Ironic, this is about the first thing that happened when I stepped off the list ;) Also, I had looked at HEAD svn, but it seems I need a git repo. Good, I like git! OK, seems to work, great! thanks! Bye, Kero. From duelin.markers at gmail.com Sat May 3 10:49:11 2008 From: duelin.markers at gmail.com (John D. Hume) Date: Sat, 3 May 2008 10:49:11 -0400 Subject: [rspec-users] spec'ing calls to super (or other Ruby keywords) In-Reply-To: <17027929.post@talk.nabble.com> References: <17027929.post@talk.nabble.com> Message-ID: I believe calls to super are sufficiently internal to the Ruby interpreter that a mocking framework can't intercept them without doing separate implementations for separate Ruby interpreters (and likely even separate versions). I could be wrong, but even so I'd recommend a different approach. If your need is really as simple as your example, what you have is just a method that has to get two things done: the base save and one additional call. You can write one (or more) example for each of those two things without your spec knowing that one of those things gets done by calling super. (You might object that by spec'ing the base #save behavior you're spec'ing the framework. I'd say you're USING the framework to spec something your code does. To be clear, I'm not suggesting you spec every detail of what save does: just something to make sure the record actually lands in the db.) (Sidebar: Keep in mind the return value if you're really overriding #save like that.) If you're dead set on spec'ing that the super method gets called, there are a couple of hideous ways of doing it that will leak out of your example. Namely, you can (in your spec) redefine the method in the superclass and verify it gets called or (also in your spec, and this one's a little less leaky) have the class under test include a module that defines the same method and verify it gets called. Don't do either of those though (unless it's just to prove to yourself that they're possible). -hume. On Fri, May 2, 2008 at 5:17 PM, Matt McNeil wrote: > > Hi there, > > How does one spec an invocation of a Ruby keyword, such as super in this > case? > > class User < ActiveResource::Base > # faking the ActiveRecord before/after_save observers > def save > super > UserMailer.deliver_activation(self) if recently_activated? > end > end > > Does the solution look anything like the following? > > describe User do > describe '#save' do > it "should call save on the parent class" do > # something.should_receive(:something) > @user.save > end > end > end > > Any thoughts? > > Thanks much, > Matt > > -- > View this message in context: > http://www.nabble.com/spec%27ing-calls-to-super-%28or-other-Ruby-keywords%29-tp17027929p17027929.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From duelin.markers at gmail.com Sat May 3 11:07:21 2008 From: duelin.markers at gmail.com (John D. Hume) Date: Sat, 3 May 2008 11:07:21 -0400 Subject: [rspec-users] BDD/Rails/Shoulda In-Reply-To: <1867A8FF-EF69-4017-972D-2F8D69FFD84D@patchspace.co.uk> References: <51538E8C-C42A-4AE0-9CE0-25D6560E3CE6@parkerhill.com> <7B749038-B6C8-42EE-8CAB-D92661D3C019@patchspace.co.uk> <04414D52-7044-4CC5-88AB-89F06FF57DE8@gmail.com> <20080502051351.GC18800@uivelo.tilus.net> <1867A8FF-EF69-4017-972D-2F8D69FFD84D@patchspace.co.uk> Message-ID: Even when working test/spec-first, when I'm pairing with someone who isn't experienced working that way, I find myself constantly saying "I'm pretty sure we don't need that yet." (I've just written the spec my pair is trying to get passing, so I know how little code we need.) If it happens then, it will certainly happen when that same developer is uncommenting code already written. Out of curiosity, Ashley, what size team are you working with where you don't see this problem? -hume. On Fri, May 2, 2008 at 12:06 PM, Ashley Moran wrote: > > On 2 May 2008, at 06:13, Tero Tilus wrote: > > I can well imagine how you may end up not getting all the advantages >> of BDD thru uncommenting process when you compare to clean BDD. But >> uncommenting is definitely better than writing spec on top of existing >> code, which in turn is _way_ better than not writing spec at all. >> > > Perhaps "uncommenting" is a bad description. What I do is write specs for > the behaviour I want, and see what bits of the code (if any) do that. > (Which will obviously be pretty similar to the what it does anyway.) What > I *don't* do is pick a line of code and write a spec for it so I can > uncomment it. I guess that's how you would run into trouble. > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hotfusionman at yahoo.com Sat May 3 11:09:13 2008 From: hotfusionman at yahoo.com (Al Chou) Date: Sat, 3 May 2008 08:09:13 -0700 (PDT) Subject: [rspec-users] spec'ing calls to super (or other Ruby keywords) Message-ID: <96663.58122.qm@web58707.mail.re1.yahoo.com> In the particular case of super, another approach, though perhaps not using the spec framework, would be to assert (a la Test::Unit) that your class is a subclass of the intended superclass. To be truly anal, also assert that the superclass has a method with the same name as the subclass's method of interest and that the subclass has that method, too. But all this seems deeply into the xUnit world, and far from the BDD way. Al ----- Original Message ---- From: John D. Hume To: rspec-users Sent: Saturday, May 3, 2008 7:49:11 AM Subject: Re: [rspec-users] spec'ing calls to super (or other Ruby keywords) I believe calls to super are sufficiently internal to the Ruby interpreter that a mocking framework can't intercept them without doing separate implementations for separate Ruby interpreters (and likely even separate versions). I could be wrong, but even so I'd recommend a different approach. If your need is really as simple as your example, what you have is just a method that has to get two things done: the base save and one additional call. You can write one (or more) example for each of those two things without your spec knowing that one of those things gets done by calling super. (You might object that by spec'ing the base #save behavior you're spec'ing the framework. I'd say you're USING the framework to spec something your code does. To be clear, I'm not suggesting you spec every detail of what save does: just something to make sure the record actually lands in the db.) (Sidebar: Keep in mind the return value if you're really overriding #save like that.) If you're dead set on spec'ing that the super method gets called, there are a couple of hideous ways of doing it that will leak out of your example. Namely, you can (in your spec) redefine the method in the superclass and verify it gets called or (also in your spec, and this one's a little less leaky) have the class under test include a module that defines the same method and verify it gets called. Don't do either of those though (unless it's just to prove to yourself that they're possible). -hume. On Fri, May 2, 2008 at 5:17 PM, Matt McNeil wrote: Hi there, How does one spec an invocation of a Ruby keyword, such as super in this case? class User < ActiveResource::Base # faking the ActiveRecord before/after_save observers def save super UserMailer.deliver_activation(self) if recently_activated? end end Does the solution look anything like the following? describe User do describe '#save' do it "should call save on the parent class" do # something.should_receive(:something) @user.save end end end Any thoughts? Thanks much, Matt ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at pinkpucker.net Sat May 3 12:17:14 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Sat, 3 May 2008 09:17:14 -0700 Subject: [rspec-users] Date comparisons Message-ID: I occasionally get this error: 1) 'A puzzle once featured, should no longer be nominated' FAILED expected: Sun May 04 09:10:26 -0700 2008, got: Sun May 04 09:10:26 -0700 2008 (using ==) ./spec/models/puzzle_spec.rb:180: So, the dates looks the same to me. Any ideas for how to debug? Joe From steve.downtown at gmail.com Sat May 3 12:37:29 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Sat, 3 May 2008 09:37:29 -0700 Subject: [rspec-users] Date comparisons In-Reply-To: References: Message-ID: <4fff79200805030937n5a65e308mb6854e9a3d8de545@mail.gmail.com> I've seen that one too. Maybe has to do with how equality is defined in the Time or DateTime class. I get around it by comparing the string-ified versions: foo.time.to_s.should == expected_time.to_s On Sat, May 3, 2008 at 9:17 AM, Joe Van Dyk wrote: > I occasionally get this error: > > 1) > 'A puzzle once featured, should no longer be nominated' FAILED > expected: Sun May 04 09:10:26 -0700 2008, > got: Sun May 04 09:10:26 -0700 2008 (using ==) > ./spec/models/puzzle_spec.rb:180: > > > > So, the dates looks the same to me. Any ideas for how to debug? > > Joe > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at schuerig.de Sat May 3 13:06:49 2008 From: michael at schuerig.de (Michael Schuerig) Date: Sat, 3 May 2008 19:06:49 +0200 Subject: [rspec-users] Any news on the rSpec books? Message-ID: <200805031906.49313.michael@schuerig.de> I admit it, when it comes to rSpec, I'm lazy. I've made a few feeble attempts to use it, but for once I'm waiting for a book-length treatment. At least two books were announced, I think. Can anyone in the know please report on their progress? Thanks Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From steve.downtown at gmail.com Sat May 3 13:25:04 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Sat, 3 May 2008 10:25:04 -0700 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: <200805031906.49313.michael@schuerig.de> References: <200805031906.49313.michael@schuerig.de> Message-ID: <4fff79200805031025n24f0f01bqb48272d0e4e667c9@mail.gmail.com> I sent an inquiry to Prag Bookshelf but didn't hear anything -- saw something online that led me to believe they were the publisher. PeepCode has several RSpec screencasts. On Sat, May 3, 2008 at 10:06 AM, Michael Schuerig wrote: > > I admit it, when it comes to rSpec, I'm lazy. I've made a few feeble > attempts to use it, but for once I'm waiting for a book-length > treatment. At least two books were announced, I think. Can anyone in > the know please report on their progress? > > Thanks > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat May 3 13:38:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 May 2008 12:38:02 -0500 Subject: [rspec-users] Any news on the rSpec books? In-Reply-To: <200805031906.49313.michael@schuerig.de> References: <200805031906.49313.michael@schuerig.de> Message-ID: There are three I know about, one of which I'm working on (Prag Bookshelf). I can tell you the one I'm working on will be in beta sometime in the next few months, but I can't really be any more specific than that right now. I can assure you that as things get more specific I'll be blogging about it like crazy. Cheers, David On May 3, 2008, at 12:06 PM, Michael Schuerig wrote: > > I admit it, when it comes to rSpec, I'm lazy. I've made a few feeble > attempts to use it, but for once I'm waiting for a book-length > treatment. At least two books were announced, I think. Can anyone in > the know please report on their progress? > > Thanks > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rick.denatale at gmail.com Sat May 3 13:51:43 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 3 May 2008 13:51:43 -0400 Subject: [rspec-users] Date comparisons In-Reply-To: References: Message-ID: On Sat, May 3, 2008 at 12:17 PM, Joe Van Dyk wrote: > I occasionally get this error: > > 1) > 'A puzzle once featured, should no longer be nominated' FAILED > expected: Sun May 04 09:10:26 -0700 2008, > got: Sun May 04 09:10:26 -0700 2008 (using ==) > ./spec/models/puzzle_spec.rb:180: > > > > So, the dates looks the same to me. Any ideas for how to debug? Just because too objects have the same to_s representation don't mean they are equal: Are these, perhaps times rather than dates? k$ irb irb(main):001:0> Time.now == Time.now => false irb(main):002:0> a, b = Time.now, Time.now => [Sat May 03 12:23:12 -0400 2008, Sat May 03 12:23:12 -0400 2008] irb(main):003:0> a == b => false This is a similar issue to Floats where there's more precision than the exernal representation shows. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From steve.downtown at gmail.com Sat May 3 14:12:16 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Sat, 3 May 2008 11:12:16 -0700 Subject: [rspec-users] Date comparisons In-Reply-To: References: Message-ID: <4fff79200805031112p28571687wcc57919c438aed1f@mail.gmail.com> > > Just because too objects have the same to_s representation don't mean > they are equal: The important equality in this case is what matters to the tester. > > This is a similar issue to Floats where there's more precision than > the exernal representation shows. > Is there more precision than seconds in a Time instance? irb(main):006:0> a,b = Time.now, Time.now => [Sat May 03 11:06:31 -0700 2008, Sat May 03 11:06:31 -0700 2008] irb(main):007:0> puts a.to_i, b.to_i 1209837991 1209837991 => nil -------------- next part -------------- An HTML attachment was scrubbed... URL: From philodespotos at gmail.com Sat May 3 14:16:48 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Sat, 3 May 2008 13:16:48 -0500 Subject: [rspec-users] Date comparisons In-Reply-To: <4fff79200805031112p28571687wcc57919c438aed1f@mail.gmail.com> References: <4fff79200805031112p28571687wcc57919c438aed1f@mail.gmail.com> Message-ID: <60f3810c0805031116g27b49100le3620e48d6c89f13@mail.gmail.com> On Sat, May 3, 2008 at 1:12 PM, Steve Downey wrote: > Is there more precision than seconds in a Time instance? > > irb(main):006:0> a,b = Time.now, Time.now > => [Sat May 03 11:06:31 -0700 2008, Sat May 03 11:06:31 -0700 2008] > irb(main):007:0> puts a.to_i, b.to_i > 1209837991 > 1209837991 > => nil This came up this morning in #rspec; Time tracks microseconds which blows up equality: >> a, b = Time.now, Time.now => [Sat May 03 13:15:31 -0500 2008, Sat May 03 13:15:31 -0500 2008] >> a == b => false >> [a.usec, b.usec] => [93308, 93309] Because of this, I tend to use 'should be_between()' when handling times; someone else suggested the .to_i trick which is probably closer to what is intended, but for some reason I find it confusing. k From omen.king at gmail.com Sat May 3 15:18:55 2008 From: omen.king at gmail.com (Andrew Brown) Date: Sat, 3 May 2008 15:18:55 -0400 Subject: [rspec-users] Everyone Using Rspec Autotest? Message-ID: I haven't been spec'ing lately, but been hopping back on and adding autotest. However I get an error: http://pastie.caboo.se/177538/wrap I also noticed a post by Scott and there was mention of rspec_autotest. Is this is what everyone is using? http://svn.caldersphere.net/svn/main/plugins/rspec_autotest/ From jarkko at jlaine.net Sat May 3 15:21:54 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Sat, 3 May 2008 22:21:54 +0300 Subject: [rspec-users] Everyone Using Rspec Autotest? In-Reply-To: References: Message-ID: <3A19E407-7D71-4359-B252-5AE5F54D30EF@jlaine.net> On 3.5.2008, at 22.18, Andrew Brown wrote: > I haven't been spec'ing lately, but been hopping back on and adding > autotest. > However I get an error: > > http://pastie.caboo.se/177538/wrap > > I also noticed a post by Scott and there was mention of > rspec_autotest. > Is this is what everyone is using? I'm just using the one that comes with ZenTest. No need for anything else, just run 'autotest' in the root of your Rails app. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From omen.king at gmail.com Sat May 3 15:36:58 2008 From: omen.king at gmail.com (Andrew Brown) Date: Sat, 3 May 2008 15:36:58 -0400 Subject: [rspec-users] Everyone Using Rspec Autotest? In-Reply-To: <3A19E407-7D71-4359-B252-5AE5F54D30EF@jlaine.net> References: <3A19E407-7D71-4359-B252-5AE5F54D30EF@jlaine.net> Message-ID: <9D3C4788-594B-404B-9188-82CFEC1E4EE3@gmail.com> I will, once I resolve the error. On 3-May-08, at 3:21 PM, Jarkko Laine wrote: > > On 3.5.2008, at 22.18, Andrew Brown wrote: > >> I haven't been spec'ing lately, but been hopping back on and adding >> autotest. >> However I get an error: >> >> http://pastie.caboo.se/177538/wrap >> >> I also noticed a post by Scott and there was mention of >> rspec_autotest. >> Is this is what everyone is using? > > I'm just using the one that comes with ZenTest. No need for anything > else, just run 'autotest' in the root of your Rails app. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From shingler at gmail.com Sat May 3 16:08:25 2008 From: shingler at gmail.com (steven shingler) Date: Sat, 3 May 2008 21:08:25 +0100 Subject: [rspec-users] silly partial qu Message-ID: hi all, i'm just trying to check a partial has been rendered, by using: response.template.should_receive(:render).with(:partial => "tasks/list") this passes, even if I put something bogus in the partial name, such as: response.template.should_receive(:render).with(:partial => "___tassdfsdfks/list") does anyone know why this doesn't fail? is this the wrong way to simply check a partial is being rendered? am running this as a story step. thanks, steven From mailing_lists at railsnewbie.com Sat May 3 16:44:01 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 3 May 2008 16:44:01 -0400 Subject: [rspec-users] Everyone Using Rspec Autotest? In-Reply-To: References: Message-ID: On May 3, 2008, at 3:18 PM, Andrew Brown wrote: > I haven't been spec'ing lately, but been hopping back on and adding > autotest. > However I get an error: > > http://pastie.caboo.se/177538/wrap > > I also noticed a post by Scott and there was mention of > rspec_autotest. > Is this is what everyone is using? > > http://svn.caldersphere.net/svn/main/plugins/rspec_autotest/ > Update your gems - use Zentest 3.9.2. (3.9.1 might work too, but 3.8.x doesn't) Scott From omen.king at gmail.com Sat May 3 16:49:41 2008 From: omen.king at gmail.com (Andrew Brown) Date: Sat, 3 May 2008 16:49:41 -0400 Subject: [rspec-users] Everyone Using Rspec Autotest? In-Reply-To: References: Message-ID: <72B68BFE-1FBC-4FB1-9D42-D8A419909E0D@gmail.com> Thanks Scott that fixed it. Forgot to do the obvious. On 3-May-08, at 4:44 PM, Scott Taylor wrote: > > On May 3, 2008, at 3:18 PM, Andrew Brown wrote: > >> I haven't been spec'ing lately, but been hopping back on and adding >> autotest. >> However I get an error: >> >> http://pastie.caboo.se/177538/wrap >> >> I also noticed a post by Scott and there was mention of >> rspec_autotest. >> Is this is what everyone is using? >> >> http://svn.caldersphere.net/svn/main/plugins/rspec_autotest/ >> > > Update your gems - use Zentest 3.9.2. (3.9.1 might work too, but > 3.8.x doesn't) > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Sat May 3 16:51:51 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 3 May 2008 16:51:51 -0400 Subject: [rspec-users] spec'ing calls to super (or other Ruby keywords) In-Reply-To: <96663.58122.qm@web58707.mail.re1.yahoo.com> References: <96663.58122.qm@web58707.mail.re1.yahoo.com> Message-ID: <6CEE24A1-451C-422B-BEAF-835AEB8620F9@railsnewbie.com> On May 3, 2008, at 11:09 AM, Al Chou wrote: > In the particular case of super, another approach, though perhaps > not using the spec framework, would be to assert (a la Test::Unit) > that your class is a subclass of the intended superclass. To be > truly anal, also assert that the superclass has a method with the > same name as the subclass's method of interest and that the subclass > has that method, too. But all this seems deeply into the xUnit > world, and far from the BDD way. > > Al The truth is that you shouldn't be spec'ing calls to the super "method", but rather the behaviour of super. One quick way to do this is as so: [BaseClass, Subclass].each { |klass| it "should do whatever super does" do klass.new.foo_bar.should == :baz end end Your original example is a little trickier, because you didn't write the base class, and you probably aren't going to spec it out. There's obviously great complexity in that call to super. Now you know why none of us like writing specs against rails apps. Scott > > > ----- Original Message ---- > From: John D. Hume > To: rspec-users > Sent: Saturday, May 3, 2008 7:49:11 AM > Subject: Re: [rspec-users] spec'ing calls to super (or other Ruby > keywords) > > I believe calls to super are sufficiently internal to the Ruby > interpreter that a mocking framework can't intercept them without > doing separate implementations for separate Ruby interpreters (and > likely even separate versions). I could be wrong, but even so I'd > recommend a different approach. > > If your need is really as simple as your example, what you have is > just a method that has to get two things done: the base save and one > additional call. You can write one (or more) example for each of > those two things without your spec knowing that one of those things > gets done by calling super. (You might object that by spec'ing the > base #save behavior you're spec'ing the framework. I'd say you're > USING the framework to spec something your code does. To be clear, > I'm not suggesting you spec every detail of what save does: just > something to make sure the record actually lands in the db.) > > (Sidebar: Keep in mind the return value if you're really overriding > #save like that.) > > If you're dead set on spec'ing that the super method gets called, > there are a couple of hideous ways of doing it that will leak out of > your example. Namely, you can (in your spec) redefine the method in > the superclass and verify it gets called or (also in your spec, and > this one's a little less leaky) have the class under test include a > module that defines the same method and verify it gets called. > Don't do either of those though (unless it's just to prove to > yourself that they're possible). > > -hume. > > > On Fri, May 2, 2008 at 5:17 PM, Matt McNeil > wrote: > > Hi there, > > How does one spec an invocation of a Ruby keyword, such as super in > this > case? > > class User < ActiveResource::Base > # faking the ActiveRecord before/after_save observers > def save > super > UserMailer.deliver_activation(self) if recently_activated? > end > end > > Does the solution look anything like the following? > > describe User do > describe '#save' do > it "should call save on the parent class" do > # something.should_receive(:something) > @user.save > end > end > end > > Any thoughts? > > Thanks much, > Matt > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. > Try it now._______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing_lists at railsnewbie.com Sat May 3 16:53:42 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 3 May 2008 16:53:42 -0400 Subject: [rspec-users] Date comparisons In-Reply-To: <60f3810c0805031116g27b49100le3620e48d6c89f13@mail.gmail.com> References: <4fff79200805031112p28571687wcc57919c438aed1f@mail.gmail.com> <60f3810c0805031116g27b49100le3620e48d6c89f13@mail.gmail.com> Message-ID: On May 3, 2008, at 2:16 PM, Kyle Hargraves wrote: > On Sat, May 3, 2008 at 1:12 PM, Steve Downey > wrote: >> Is there more precision than seconds in a Time instance? >> >> irb(main):006:0> a,b = Time.now, Time.now >> => [Sat May 03 11:06:31 -0700 2008, Sat May 03 11:06:31 -0700 2008] >> irb(main):007:0> puts a.to_i, b.to_i >> 1209837991 >> 1209837991 >> => nil > > This came up this morning in #rspec; Time tracks microseconds which > blows up equality: > >>> a, b = Time.now, Time.now > => [Sat May 03 13:15:31 -0500 2008, Sat May 03 13:15:31 -0500 2008] >>> a == b > => false >>> [a.usec, b.usec] > => [93308, 93309] > > Because of this, I tend to use 'should be_between()' when handling > times; someone else suggested the .to_i trick which is probably closer > to what is intended, but for some reason I find it confusing. If I'm in a rails project, I like to use to_s(:db) to compare the times - that's how they are stored in the database. Any greater precision (at least in MySQL) gets lost when the datetime is read out of the database. Scott From mailing_lists at railsnewbie.com Sat May 3 17:01:51 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 3 May 2008 17:01:51 -0400 Subject: [rspec-users] BDD/Rails/Shoulda In-Reply-To: References: <51538E8C-C42A-4AE0-9CE0-25D6560E3CE6@parkerhill.com> <7B749038-B6C8-42EE-8CAB-D92661D3C019@patchspace.co.uk> <04414D52-7044-4CC5-88AB-89F06FF57DE8@gmail.com> <20080502051351.GC18800@uivelo.tilus.net> <1867A8FF-EF69-4017-972D-2F8D69FFD84D@patchspace.co.uk> Message-ID: On May 3, 2008, at 11:07 AM, John D. Hume wrote: > Even when working test/spec-first, when I'm pairing with someone who > isn't experienced working that way, I find myself constantly saying > "I'm pretty sure we don't need that yet." (I've just written the > spec my pair is trying to get passing, so I know how little code we > need.) If it happens then, it will certainly happen when that same > developer is uncommenting code already written. > > Out of curiosity, Ashley, what size team are you working with where > you don't see this problem? > -hume. I remember a joke that Aslak mentioned a while back ago on this list: He had a friend (or co-worker) who wanted to write a tool which would delete every line of code which didn't get covered with rcov. I found that remark funny because Aslak didn't know if his co-worker was joking or not. Now that I think about it more, it probably wouldn't be a bad idea to have such a tool like this, even if it was just for didactic purposes. Scott > > > > On Fri, May 2, 2008 at 12:06 PM, Ashley Moran > wrote: > > On 2 May 2008, at 06:13, Tero Tilus wrote: > > I can well imagine how you may end up not getting all the advantages > of BDD thru uncommenting process when you compare to clean BDD. But > uncommenting is definitely better than writing spec on top of existing > code, which in turn is _way_ better than not writing spec at all. > > Perhaps "uncommenting" is a bad description. What I do is write > specs for the behaviour I want, and see what bits of the code (if > any) do that. (Which will obviously be pretty similar to the what > it does anyway.) What I *don't* do is pick a line of code and write > a spec for it so I can uncomment it. I guess that's how you would > run into trouble. > > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > 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: From rick.denatale at gmail.com Sat May 3 18:17:38 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 3 May 2008 18:17:38 -0400 Subject: [rspec-users] silly partial qu In-Reply-To: References: Message-ID: On Sat, May 3, 2008 at 4:08 PM, steven shingler wrote: > hi all, > > i'm just trying to check a partial has been rendered, by using: > response.template.should_receive(:render).with(:partial => "tasks/list") > > this passes, even if I put something bogus in the partial name, such as: > response.template.should_receive(:render).with(:partial => > "___tassdfsdfks/list") > > does anyone know why this doesn't fail? > is this the wrong way to simply check a partial is being rendered? > am running this as a story step. I'm not sure how this is working to begin with. Where is this expectation in the flow of the code? It would seem to need to be before the request since it's a should_receive But then what's response at this point? And what's response.template? It's the controller, not the template which receives the render call. You say that this is in a story step? I've got a hunch that the step is'nt actually matching and therfore not getting run, which would explain why the assertion never fails. If you're doing this as a full stack rails integration story, I don't believe that you've got access to the controller, and this level of specification doesn't belong here but rather in a controller spec, where you might want to use expect_render instead of should_receive(:render) as well. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From hotfusionman at yahoo.com Sat May 3 18:58:04 2008 From: hotfusionman at yahoo.com (Al Chou) Date: Sat, 3 May 2008 15:58:04 -0700 (PDT) Subject: [rspec-users] spec'ing calls to super (or other Ruby keywords) Message-ID: <301749.35445.qm@web58709.mail.re1.yahoo.com> Funny, I mostly like writing RSpec specs for Rails, aside from the fact that it sometimes takes me a while to figure out exactly how and what I need to write to specify what I want to specify. In any case, I agree that the spec should specify what the method achieves, not the fact that the method calls super. Al ----- Original Message ---- From: Scott Taylor To: rspec-users Sent: Saturday, May 3, 2008 1:51:51 PM Subject: Re: [rspec-users] spec'ing calls to super (or other Ruby keywords) On May 3, 2008, at 11:09 AM, Al Chou wrote: In the particular case of super, another approach, though perhaps not using the spec framework, would be to assert (a la Test::Unit) that your class is a subclass of the intended superclass. To be truly anal, also assert that the superclass has a method with the same name as the subclass's method of interest and that the subclass has that method, too. But all this seems deeply into the xUnit world, and far from the BDD way. Al The truth is that you shouldn't be spec'ing calls to the super "method", but rather the behaviour of super. One quick way to do this is as so: [BaseClass, Subclass].each { |klass| it "should do whatever super does" do klass.new.foo_bar.should == :baz end end Your original example is a little trickier, because you didn't write the base class, and you probably aren't going to spec it out. There's obviously great complexity in that call to super. Now you know why none of us like writing specs against rails apps. Scott ----- Original Message ---- From: John D. Hume To: rspec-users Sent: Saturday, May 3, 2008 7:49:11 AM Subject: Re: [rspec-users] spec'ing calls to super (or other Ruby keywords) I believe calls to super are sufficiently internal to the Ruby interpreter that a mocking framework can't intercept them without doing separate implementations for separate Ruby interpreters (and likely even separate versions). I could be wrong, but even so I'd recommend a different approach. If your need is really as simple as your example, what you have is just a method that has to get two things done: the base save and one additional call. You can write one (or more) example for each of those two things without your spec knowing that one of those things gets done by calling super. (You might object that by spec'ing the base #save behavior you're spec'ing the framework. I'd say you're USING the framework to spec something your code does. To be clear, I'm not suggesting you spec every detail of what save does: just something to make sure the record actually lands in the db.) (Sidebar: Keep in mind the return value if you're really overriding #save like that.) If you're dead set on spec'ing that the super method gets called, there are a couple of hideous ways of doing it that will leak out of your example. Namely, you can (in your spec) redefine the method in the superclass and verify it gets called or (also in your spec, and this one's a little less leaky) have the class under test include a module that defines the same method and verify it gets called. Don't do either of those though (unless it's just to prove to yourself that they're possible). -hume. On Fri, May 2, 2008 at 5:17 PM, Matt McNeil wrote: Hi there, How does one spec an invocation of a Ruby keyword, such as super in this case? class User < ActiveResource::Base # faking the ActiveRecord before/after_save observers def save super UserMailer.deliver_activation(self) if recently_activated? end end Does the solution look anything like the following? describe User do describe '#save' do it "should call save on the parent class" do # something.should_receive(:something) @user.save end end end Any thoughts? Thanks much, Matt ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat May 3 23:08:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 3 May 2008 22:08:09 -0500 Subject: [rspec-users] BDD/Rails/Shoulda In-Reply-To: References: <51538E8C-C42A-4AE0-9CE0-25D6560E3CE6@parkerhill.com> <7B749038-B6C8-42EE-8CAB-D92661D3C019@patchspace.co.uk> <04414D52-7044-4CC5-88AB-89F06FF57DE8@gmail.com> <20080502051351.GC18800@uivelo.tilus.net> <1867A8FF-EF69-4017-972D-2F8D69FFD84D@patchspace.co.uk> Message-ID: <5F3F85D8-D2D0-4238-B5B4-B17C2C101587@gmail.com> On May 3, 2008, at 4:01 PM, Scott Taylor wrote: > I remember a joke that Aslak mentioned a while back ago on this > list: He had a friend (or co-worker) who wanted to write a tool > which would delete every line of code which didn't get covered with > rcov. I found that remark funny because Aslak didn't know if his co- > worker was joking or not. I think you've got the story mixed up a bit here. Aslak DID write a tool called Guantanamo that does just what you propose, for java, not Ruby: http://docs.codehaus.org/display/ASH/Guantanamo > > Now that I think about it more, it probably wouldn't be a bad idea > to have such a tool like this, even if it was just for didactic > purposes. > > Scott From shingler at gmail.com Sun May 4 10:16:33 2008 From: shingler at gmail.com (steven shingler) Date: Sun, 4 May 2008 15:16:33 +0100 Subject: [rspec-users] silly partial qu In-Reply-To: References: Message-ID: Hi Rick, Thanks for your reply. You are right that this step is basically testing the basic actions of a controller, and is being run as part of a story_with_steps stack. The step itself is definitely being hit, because I have a: response.should have_tag('li', @title) ...in the same step, and that is working nicely. This step is called right after clicking an Update button, which is a standard rails scaffold and does a: redirect_to(@task) - this causes a partial to be rendered to the screen as part of my default layout, and I was hoping to be able to verify that the partial loaded. What would fit my brain better, would be: response.should render_partial("tasks/list") ...but that isn't available :) I hope that is clearer - I am quite new to the world of rspec. If you can shed any more light that would be really great. Thanks, Steven On Sat, May 3, 2008 at 11:17 PM, Rick DeNatale wrote: > > On Sat, May 3, 2008 at 4:08 PM, steven shingler wrote: > > hi all, > > > > i'm just trying to check a partial has been rendered, by using: > > response.template.should_receive(:render).with(:partial => "tasks/list") > > > > this passes, even if I put something bogus in the partial name, such as: > > response.template.should_receive(:render).with(:partial => > > "___tassdfsdfks/list") > > > > does anyone know why this doesn't fail? > > is this the wrong way to simply check a partial is being rendered? > > am running this as a story step. > > I'm not sure how this is working to begin with. > > Where is this expectation in the flow of the code? It would seem to > need to be before the request since it's a should_receive > But then what's response at this point? > And what's response.template? > > It's the controller, not the template which receives the render call. > > You say that this is in a story step? I've got a hunch that the step > is'nt actually matching and therfore not getting run, which would > explain why the assertion never fails. > > If you're doing this as a full stack rails integration story, I don't > believe that you've got access to the controller, and this level of > specification doesn't belong here but rather in a controller spec, > where you might want to use expect_render instead of > should_receive(:render) as well. > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Sun May 4 10:36:31 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 4 May 2008 10:36:31 -0400 Subject: [rspec-users] silly partial qu In-Reply-To: References: Message-ID: On Sun, May 4, 2008 at 10:16 AM, steven shingler wrote: > Hi Rick, > Thanks for your reply. > You are right that this step is basically testing the basic actions of > a controller, and is being run as part of a story_with_steps stack. > The step itself is definitely being hit, because I have a: > response.should have_tag('li', @title) > ...in the same step, and that is working nicely. > > This step is called right after clicking an Update button, which is a > standard rails scaffold and does a: redirect_to(@task) - this causes a > partial to be rendered to the screen as part of my default layout, and > I was hoping to be able to verify that the partial loaded. > > What would fit my brain better, would be: > response.should render_partial("tasks/list") Except that responses don't render anything, controllers do which result in the body of the response. Also even if this were controller.should render_partial... I can't see how this would work, since it seems to involve backwards time travel. In a controller spec you use controller.expect_render(:partial => ...) BEFORE doing a get/post etc. It works like x.should_receive(:foo) it's something which needs to be set up before something happens. > ...but that isn't available :) > > I hope that is clearer - I am quite new to the world of rspec. > If you can shed any more light that would be really great. Rails integration testing happens in the context of a simulated browser. It's awkward, if indeed it's possible at all, to instrument the mechanisms of controllers and templates here. This is normally done in controller and/or view specs. At the story/integration level, I think you really want to be looking at the result of the http requests, which means you should be setting expectations about what's in the response rather than how the response is going to be constructed. So instead of trying to determine if the tasks_list partial is being rendered, why not do something like having the partial generate evidence that it was invoked in the output, for example it might generate a div or ol or whatever which contains the tasks list which has a particular dom id, and then use response.should have_tag to verify that the task list is in the response? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From shingler at gmail.com Sun May 4 11:32:45 2008 From: shingler at gmail.com (steven shingler) Date: Sun, 4 May 2008 16:32:45 +0100 Subject: [rspec-users] silly partial qu In-Reply-To: References: Message-ID: Hi Rick - Thanks again. Cool - I see what you mean about what the story steps should get involved with, and what should be left to the specs. In that case, my response.should have_tag('li', @title) is a reasonable test, and I'll leave it at that! All the best, Steven On Sun, May 4, 2008 at 3:36 PM, Rick DeNatale wrote: > On Sun, May 4, 2008 at 10:16 AM, steven shingler wrote: > > Hi Rick, > > Thanks for your reply. > > You are right that this step is basically testing the basic actions of > > a controller, and is being run as part of a story_with_steps stack. > > The step itself is definitely being hit, because I have a: > > response.should have_tag('li', @title) > > ...in the same step, and that is working nicely. > > > > This step is called right after clicking an Update button, which is a > > standard rails scaffold and does a: redirect_to(@task) - this causes a > > partial to be rendered to the screen as part of my default layout, and > > I was hoping to be able to verify that the partial loaded. > > > > What would fit my brain better, would be: > > response.should render_partial("tasks/list") > > Except that responses don't render anything, controllers do which > result in the body of the response. > > Also even if this were > > controller.should render_partial... > > I can't see how this would work, since it seems to involve backwards > time travel. In a controller spec you use > > controller.expect_render(:partial => ...) > > BEFORE doing a get/post etc. It works like x.should_receive(:foo) > it's something which needs to be set up before something happens. > > > > ...but that isn't available :) > > > > I hope that is clearer - I am quite new to the world of rspec. > > If you can shed any more light that would be really great. > > Rails integration testing happens in the context of a simulated > browser. It's awkward, if indeed it's possible at all, to instrument > the mechanisms of controllers and templates here. This is normally > done in controller and/or view specs. > > At the story/integration level, I think you really want to be looking > at the result of the http requests, which means you should be setting > expectations about what's in the response rather than how the response > is going to be constructed. > > So instead of trying to determine if the tasks_list partial is being > rendered, why not do something like having the partial generate > evidence that it was invoked in the output, for example it might > generate a div or ol or whatever which contains the tasks list which > has a particular dom id, and then use response.should have_tag to > verify that the task list is in the response? > > -- > > > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattberther.com Sun May 4 12:30:09 2008 From: matt at mattberther.com (Matt Berther) Date: Sun, 4 May 2008 10:30:09 -0600 Subject: [rspec-users] Everyone Using Rspec Autotest? In-Reply-To: <9D3C4788-594B-404B-9188-82CFEC1E4EE3@gmail.com> References: <3A19E407-7D71-4359-B252-5AE5F54D30EF@jlaine.net> <9D3C4788-594B-404B-9188-82CFEC1E4EE3@gmail.com> Message-ID: <6F869410-14D0-48AF-8846-9B01901BC8FE@mattberther.com> Hi Andrew, I've been using rspactor (the command line version) and really prefer it to autotest. If you're using a Mac, you may want to look at this. -- Matt Berther http://www.mattberther.com On May 3, 2008, at 1:36 PM, Andrew Brown wrote: > I will, once I resolve the error. > > > On 3-May-08, at 3:21 PM, Jarkko Laine wrote: > >> >> On 3.5.2008, at 22.18, Andrew Brown wrote: >> >>> I haven't been spec'ing lately, but been hopping back on and >>> adding autotest. >>> However I get an error: >>> >>> http://pastie.caboo.se/177538/wrap >>> >>> I also noticed a post by Scott and there was mention of >>> rspec_autotest. >>> Is this is what everyone is using? >> >> I'm just using the one that comes with ZenTest. No need for >> anything else, just run 'autotest' in the root of your Rails app. >> >> //jarkko >> >> -- >> Jarkko Laine >> http://jlaine.net >> http://dotherightthing.com >> http://www.railsecommerce.com >> http://odesign.fi >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From omen.king at gmail.com Sun May 4 12:40:00 2008 From: omen.king at gmail.com (Andrew Brown) Date: Sun, 4 May 2008 12:40:00 -0400 Subject: [rspec-users] Everyone Using Rspec Autotest? In-Reply-To: <6F869410-14D0-48AF-8846-9B01901BC8FE@mattberther.com> References: <3A19E407-7D71-4359-B252-5AE5F54D30EF@jlaine.net> <9D3C4788-594B-404B-9188-82CFEC1E4EE3@gmail.com> <6F869410-14D0-48AF-8846-9B01901BC8FE@mattberther.com> Message-ID: I am and I will On 4-May-08, at 12:30 PM, Matt Berther wrote: > rspactor From rick.denatale at gmail.com Sun May 4 20:39:28 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 4 May 2008 20:39:28 -0400 Subject: [rspec-users] Do message expectations work in story steps? Message-ID: I've never tried to use them myself, but another list member brought this up in another thread. He was using a message expectation in a story step, and couldn't get it to fail. Looking at what he was doing, it didn't look to me that it would ever succeed, which got me thinking. Message expectations are implemented in rspec by asking the mock framework to verify them after each example by calling verify_mocks_for_rspec. This seems to be the only place where this is called, so I've got my doubts that message expectations ever get verified when a story is run. Now, it's not clear just when in a story a message expectation should be tested, and it's probably the case that they shouldn't be used/supported in stories. If so should this be documented somewhere, or is it already? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From cwdinfo at gmail.com Sun May 4 23:42:15 2008 From: cwdinfo at gmail.com (s.ross) Date: Sun, 4 May 2008 20:42:15 -0700 Subject: [rspec-users] Date comparisons In-Reply-To: References: Message-ID: Hi-- On May 3, 2008, at 9:17 AM, Joe Van Dyk wrote: > I occasionally get this error: > > 1) > 'A puzzle once featured, should no longer be nominated' FAILED > expected: Sun May 04 09:10:26 -0700 2008, > got: Sun May 04 09:10:26 -0700 2008 (using ==) > ./spec/models/puzzle_spec.rb:180: > > > > So, the dates looks the same to me. Any ideas for how to debug? > > Joe I monkeypatched DateTime (aieeeeee!) to get this effect. A custom matcher is probably a better solution. Here's the monkeypatch: require File.dirname(__FILE__) + '/../spec_helper' class DateTime def close?(other_date, difference) (other_date.to_time.to_i - DateTime.now.to_time.to_i).abs < difference end end #Delete this context and add some real ones context "should be able to create a project viewer" do fixtures :project_viewers specify "fixtures should load two ProjectViewers" do pb = ProjectViewer.create(:comments => 'a comment', :last_viewed_at => DateTime.now) pb.last_viewed_at.should_be_close(DateTime.now, 100) end end From aslak.hellesoy at gmail.com Mon May 5 02:07:30 2008 From: aslak.hellesoy at gmail.com (=?UTF-8?Q?Aslak_Helles=C3=B8y?=) Date: Mon, 5 May 2008 08:07:30 +0200 Subject: [rspec-users] Date comparisons In-Reply-To: References: Message-ID: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> If your code uses Date#now, always make sure you stub it in your specs. Always. On 5. mai. 2008, at 05.42, "s.ross" wrote: > Hi-- > > On May 3, 2008, at 9:17 AM, Joe Van Dyk wrote: > >> I occasionally get this error: >> >> 1) >> 'A puzzle once featured, should no longer be nominated' FAILED >> expected: Sun May 04 09:10:26 -0700 2008, >> got: Sun May 04 09:10:26 -0700 2008 (using ==) >> ./spec/models/puzzle_spec.rb:180: >> >> >> >> So, the dates looks the same to me. Any ideas for how to debug? >> >> Joe > > I monkeypatched DateTime (aieeeeee!) to get this effect. A custom > matcher is probably a better solution. Here's the monkeypatch: > > require File.dirname(__FILE__) + '/../spec_helper' > > class DateTime > def close?(other_date, difference) > (other_date.to_time.to_i - DateTime.now.to_time.to_i).abs < > difference > end > end > > #Delete this context and add some real ones > context "should be able to create a project viewer" do > fixtures :project_viewers > > specify "fixtures should load two ProjectViewers" do > pb = ProjectViewer.create(:comments => 'a > comment', :last_viewed_at => DateTime.now) > pb.last_viewed_at.should_be_close(DateTime.now, 100) > end > end > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pergesu at gmail.com Mon May 5 04:02:49 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 5 May 2008 01:02:49 -0700 Subject: [rspec-users] Date comparisons In-Reply-To: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> References: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> Message-ID: <810a540e0805050102m6ee3742k7935987432263e97@mail.gmail.com> Yes, that was my first idea as well. The Time class is a little fucked up in that < a, b = Time.now, Time.now < a == b #=> false So if you're using Time anywhere, you really ought to be stubbing it. "always" :) Pat On Sun, May 4, 2008 at 11:07 PM, Aslak Helles?y wrote: > If your code uses Date#now, always make sure you stub it in your specs. > Always. > > > > On 5. mai. 2008, at 05.42, "s.ross" wrote: > > > > Hi-- > > > > On May 3, 2008, at 9:17 AM, Joe Van Dyk wrote: > > > > > > > I occasionally get this error: > > > > > > 1) > > > 'A puzzle once featured, should no longer be nominated' FAILED > > > expected: Sun May 04 09:10:26 -0700 2008, > > > got: Sun May 04 09:10:26 -0700 2008 (using ==) > > > ./spec/models/puzzle_spec.rb:180: > > > > > > > > > > > > So, the dates looks the same to me. Any ideas for how to debug? > > > > > > Joe > > > > > > > I monkeypatched DateTime (aieeeeee!) to get this effect. A custom matcher > is probably a better solution. Here's the monkeypatch: > > > > require File.dirname(__FILE__) + '/../spec_helper' > > > > class DateTime > > def close?(other_date, difference) > > (other_date.to_time.to_i - DateTime.now.to_time.to_i).abs < > difference > > end > > end > > > > #Delete this context and add some real ones > > context "should be able to create a project viewer" do > > fixtures :project_viewers > > > > specify "fixtures should load two ProjectViewers" do > > pb = ProjectViewer.create(:comments => 'a comment', :last_viewed_at => > DateTime.now) > > pb.last_viewed_at.should_be_close(DateTime.now, 100) > > end > > end > > > > > > _______________________________________________ > > 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 jarkko at jlaine.net Mon May 5 04:12:43 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Mon, 5 May 2008 11:12:43 +0300 Subject: [rspec-users] Date comparisons In-Reply-To: <810a540e0805050102m6ee3742k7935987432263e97@mail.gmail.com> References: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> <810a540e0805050102m6ee3742k7935987432263e97@mail.gmail.com> Message-ID: <4AADED9C-F819-40F4-99E6-DFA7A313F5B0@jlaine.net> On 5.5.2008, at 11.02, Pat Maddox wrote: > Yes, that was my first idea as well. The Time class is a little > fucked up in that > > < a, b = Time.now, Time.now > < a == b #=> false That's definitely a gotcha but I wouldn't necessarily say it's fucked up. It's just that Time#now returns the current (exact) point of time, so running it successively on the same machine will by definition return different values (by a tiny margin but still). The fact that the textual representation of the two look exactly the same certainly makes it confusing the first time get bitten by it, though :-) Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From tastapod at gmail.com Mon May 5 05:28:34 2008 From: tastapod at gmail.com (Dan North) Date: Mon, 5 May 2008 10:28:34 +0100 Subject: [rspec-users] Date comparisons In-Reply-To: <4AADED9C-F819-40F4-99E6-DFA7A313F5B0@jlaine.net> References: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> <810a540e0805050102m6ee3742k7935987432263e97@mail.gmail.com> <4AADED9C-F819-40F4-99E6-DFA7A313F5B0@jlaine.net> Message-ID: The (pretty much universal) problem with dates and times is that people use "date" and "time" to mean different things. There's a java library called joda that provides a really clean vocabulary around this. An *instant* is a point in time. You shouldn't be able to ask for two instants and get the same answer however close together you ask. (There's probably something philosophical in there somewhere.) A *datetime* is a type of instant with millisecond precision that can tell you the time and date it represents, based on a timezone. The Ruby Time class represents an instant but renders itself as a datetime, hence the confusion (it has microsecond precision that you only get to see if you know to ask). A *local date* is a day when something happens, say 4th May 2008. My understanding of 4th May in the UK is bounded by different start and end instants than, say, David's in the US, because of timezones, but we both know what we "mean" by 4th May 2008. A *duration* is a length of time in milliseconds. Given these atoms you can have fairly sensible conversations about times and dates. For instance, in the current example I might do this: Instant = Time # make it clear what I'm using it for ... Instant.new == Instant.new # false, but now I know why Cheers, Dan ps. and as Aslak says, make sure you control "time" in your examples - either by stubbing Time or by injecting your own Clock abstraction. 2008/5/5 Jarkko Laine : > On 5.5.2008, at 11.02, Pat Maddox wrote: > > Yes, that was my first idea as well. The Time class is a little > > fucked up in that > > > > < a, b = Time.now, Time.now > > < a == b #=> false > > > > That's definitely a gotcha but I wouldn't necessarily say it's fucked up. > It's just that Time#now returns the current (exact) point of time, so > running it successively on the same machine will by definition return > different values (by a tiny margin but still). > > The fact that the textual representation of the two look exactly the same > certainly makes it confusing the first time get bitten by it, though :-) > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon May 5 11:42:11 2008 From: lists at ruby-forum.com (Cyril Mougel) Date: Mon, 5 May 2008 17:42:11 +0200 Subject: [rspec-users] Problems with redirect_to In-Reply-To: <57c63afe0802220743q391a76c8g8a94835e0c85fad1@mail.gmail.com> References: <57c63afe0802220600l552a8e67u9c46467dfe612e2b@mail.gmail.com> <57c63afe0802220625s74d7817s10875cd3ae2e6cb5@mail.gmail.com> <57c63afe0802220743q391a76c8g8a94835e0c85fad1@mail.gmail.com> Message-ID: <73b6a648f23b7fff33dbb5c0bee7247a@ruby-forum.com> David Chelimsky wrote: > On Fri, Feb 22, 2008 at 9:20 AM, Maur?cio Linhares > wrote: >> "/pages/test" and sent it two the recognize_path method, but this path >> ActionController::Routing::Routes.recognize_path path, :method => :get >> end >> >> As you can only redirect to GET requests, this should not be a >> problem. Should i file a patch for this? > > > That would be great, thanks! Please do review > http://rspec.lighthouseapp.com/projects/5645/how-to-file-a-ticket > before you do. > This bug are a ticket or not ? Because I have the same problem and I don't find in lighthouse bug tracking. -- Posted via http://www.ruby-forum.com/. From cwdinfo at gmail.com Mon May 5 12:59:21 2008 From: cwdinfo at gmail.com (s.ross) Date: Mon, 5 May 2008 09:59:21 -0700 Subject: [rspec-users] Date comparisons In-Reply-To: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> References: <1EF80BAF-A6A7-4D68-B09E-F412DD0B14D7@gmail.com> Message-ID: <94CAA9CA-0D77-424F-AACE-D984127B8A87@gmail.com> On May 4, 2008, at 11:07 PM, Aslak Helles?y wrote: > If your code uses Date#now, always make sure you stub it in your > specs. Always. Yes, but the OP's question was why do two "same" date objects compare as different. This is a typical problem with floating-point and anything that counts time. I used DateTime.now in my sample code below, but certainly I agree that specifying an exact object either by stubbing or explicit constant specification is a better idea. There will be cases, however, where a strict equality test can't be trusted and one must compare something as being within some "close" tolerance. -s > On 5. mai. 2008, at 05.42, "s.ross" wrote: > >> Hi-- >> >> On May 3, 2008, at 9:17 AM, Joe Van Dyk wrote: >> >>> I occasionally get this error: >>> >>> 1) >>> 'A puzzle once featured, should no longer be nominated' FAILED >>> expected: Sun May 04 09:10:26 -0700 2008, >>> got: Sun May 04 09:10:26 -0700 2008 (using ==) >>> ./spec/models/puzzle_spec.rb:180: >>> >>> >>> >>> So, the dates looks the same to me. Any ideas for how to debug? >>> >>> Joe >> >> I monkeypatched DateTime (aieeeeee!) to get this effect. A custom >> matcher is probably a better solution. Here's the monkeypatch: >> >> require File.dirname(__FILE__) + '/../spec_helper' >> >> class DateTime >> def close?(other_date, difference) >> (other_date.to_time.to_i - DateTime.now.to_time.to_i).abs < >> difference >> end >> end >> >> #Delete this context and add some real ones >> context "should be able to create a project viewer" do >> fixtures :project_viewers >> >> specify "fixtures should load two ProjectViewers" do >> pb = ProjectViewer.create(:comments => 'a >> comment', :last_viewed_at => DateTime.now) >> pb.last_viewed_at.should_be_close(DateTime.now, 100) >> end >> end >> >> >> _______________________________________________ >> 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 nabble.108 at xoxy.net Mon May 5 20:18:02 2008 From: nabble.108 at xoxy.net (Matt McNeil) Date: Mon, 5 May 2008 17:18:02 -0700 (PDT) Subject: [rspec-users] specifying output of render call Message-ID: <17071496.post@talk.nabble.com> Hello again, First of all, thanks much for everyone's input on my question last week about spec'ing an invocation of super. Here's another question that seems resistant to my Google searching: With this helper method (defined in a module and included in Rails controllers): def render_rjs_redirect(url = '/') render :update do |page| page << "location.href='#{url}'" end end Is it possible/advisable to specify either the block passed to render or the output of the helper, something like below? The only way I have been able so far to spec this was to create a FooController with an index action that called the method and then checked the response.body, but that seems like a lot of overhead to test such a simple method. Is there a better or obvious way to do this? Thanks! Matt it "should render javascript to redirect the browser" do self.should_receive(:render).with(:update) { |page| page << "location.href='example.com'"} render_rjs_redirect('example.com') end it "should render javascript to redirect the browser" do render_rjs_redirect('example.com') response.body.should == "location.href='example.com'" end -- View this message in context: http://www.nabble.com/specifying-output-of-render-call-tp17071496p17071496.html Sent from the rspec-users mailing list archive at Nabble.com. From pergesu at gmail.com Mon May 5 22:47:27 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 5 May 2008 19:47:27 -0700 Subject: [rspec-users] specifying output of render call In-Reply-To: <17071496.post@talk.nabble.com> References: <17071496.post@talk.nabble.com> Message-ID: <810a540e0805051947v28f229benc8729e62a22af2ce@mail.gmail.com> Hey Matt, One problem with rjs is that it's very difficult to test. You can't execute it, and executing code is necessary for specification by example. In this case, I would probably not unit test that code, based on the combination of it being simple code but difficult to test. I would probably right a "ping" test though, that just makes the request and asserts an ok response. That at least covers syntax errors or bad method calls. You could write a selenium test if you want I suppose. My current favorite pattern for RJS-type stuff is to push the behavior into the client and have the server just render JSON. This makes it very easy to test the behavior using jspec, and leaves you with a very natural separation of concerns. Pat From jmenoube at gmail.com Tue May 6 00:15:40 2008 From: jmenoube at gmail.com (Eeby) Date: Mon, 5 May 2008 21:15:40 -0700 (PDT) Subject: [rspec-users] "Plugin not found" after RSpec install Message-ID: <815ba561-55a3-45e8-937f-4a0193db1240@b9g2000prh.googlegroups.com> I tried to install the RSpec Rails plugin as described here: http://rspec.info/documentation/rails/install.html After I run this... ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec At the very end after a lot of output I get this error: Plugin not found: ["http://rspec.rubyforge.org/svn/tags/CURRENT/ rspec"] It looks as though it actually was installed because the dir is there and the output reported scores of items being installed. Any idea why I get that error? Thanks, Ethan From jmenoube at gmail.com Tue May 6 00:23:41 2008 From: jmenoube at gmail.com (Eeby) Date: Mon, 5 May 2008 21:23:41 -0700 (PDT) Subject: [rspec-users] "Plugin not found" after RSpec install Message-ID: <0bdba0ac-e9c0-4b04-99ff-db611ed25fb4@d19g2000prm.googlegroups.com> I tried to install the RSpec Rails plugin as described here: http://rspec.info/documentation/rails/install.html After I run this... ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec At the very end after a lot of output I get this error: Plugin not found: ["http://rspec.rubyforge.org/svn/tags/CURRENT/ rspec"] It looks as though it actually was installed because the dir is there and the output reported scores of items being installed. Any idea why I get that error? Thanks, Ethan From hans at degraaff.org Tue May 6 01:03:11 2008 From: hans at degraaff.org (Hans de Graaff) Date: Tue, 06 May 2008 07:03:11 +0200 Subject: [rspec-users] another noob question about stubs In-Reply-To: <6b6419750804300926u6273e793xaf3de1fecbae8fd9@mail.gmail.com> References: <6b6419750804290900j21c97121u639086002b4fb8bc@mail.gmail.com> <6b6419750804292300u53e6396dp4eff40ba838d460@mail.gmail.com> <2F3ECFEF-57DF-4959-B836-F06C9EFEA72B@gmail.com> <6b6419750804300926u6273e793xaf3de1fecbae8fd9@mail.gmail.com> Message-ID: <1210050191.15276.6.camel@ip6-localhost> On Wed, 2008-04-30 at 11:26 -0500, Patrick Aljord wrote: > My spec looks like this: > it "should login with openid and redirect" do > openid_url = "patcito.myopenid.com" > controller.stub!(:using_open_id?).and_return(true) > controller.stub!(:authenticate_with_open_id).and_yield(result,openid_url,registration={"nickname"=>"patcito","email"=>"bob at gmail.com","fullname"=>'bobby > bob'}) > post :create, :openid_url => openid_url > session[:user_id].should_not be(nil) > response.should be_redirect > end result is not defined, so the successful? method isn't known. I'd create a mock for it and stub! that method. result = mock('openid result') result.stub!(:successful?).and_return(true) You can then use result.should_receive(:successful?) in subsequent specs to describe what happens if the result of the call is and isn't successful. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: From dchelimsky at gmail.com Tue May 6 06:30:24 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 May 2008 05:30:24 -0500 Subject: [rspec-users] "Plugin not found" after RSpec install In-Reply-To: <0bdba0ac-e9c0-4b04-99ff-db611ed25fb4@d19g2000prm.googlegroups.com> References: <0bdba0ac-e9c0-4b04-99ff-db611ed25fb4@d19g2000prm.googlegroups.com> Message-ID: On May 5, 2008, at 11:23 PM, Eeby wrote: > > > I tried to install the RSpec Rails plugin as described here: > > http://rspec.info/documentation/rails/install.html > > After I run this... > > ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec > > At the very end after a lot of output I get this error: > > Plugin not found: ["http://rspec.rubyforge.org/svn/tags/CURRENT/ > rspec"] > > It looks as though it actually was installed because the dir is there > and the output reported scores of items being installed. > > Any idea why I get that error? I'm not getting any error. I'm using Rails 2.0.2. You? From jmenoube at gmail.com Tue May 6 12:46:12 2008 From: jmenoube at gmail.com (Eeby) Date: Tue, 6 May 2008 09:46:12 -0700 (PDT) Subject: [rspec-users] "Plugin not found" after RSpec install In-Reply-To: References: <0bdba0ac-e9c0-4b04-99ff-db611ed25fb4@d19g2000prm.googlegroups.com> Message-ID: <2435c63d-e61e-4d22-9be6-eb11d8128158@v26g2000prm.googlegroups.com> > I'm not getting any error. I'm using Rails 2.0.2. You? Same Rails version. OS X. Ruby 1.8.6. I worked with it a little, and the RSpec functionality seems to be working OK as far as I can tell. (I'm just starting to learn how to use RSpec.) Did I install the plugin from the right source? I noticed that there's also an RSpec-rails project on GitHub. Is the svn repository outdated? Ethan From dchelimsky at gmail.com Tue May 6 12:48:57 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 6 May 2008 11:48:57 -0500 Subject: [rspec-users] "Plugin not found" after RSpec install In-Reply-To: <2435c63d-e61e-4d22-9be6-eb11d8128158@v26g2000prm.googlegroups.com> References: <0bdba0ac-e9c0-4b04-99ff-db611ed25fb4@d19g2000prm.googlegroups.com> <2435c63d-e61e-4d22-9be6-eb11d8128158@v26g2000prm.googlegroups.com> Message-ID: <67CCFE08-BE17-4CCA-B411-5EF166891262@gmail.com> On May 6, 2008, at 11:46 AM, Eeby wrote: >> I'm not getting any error. I'm using Rails 2.0.2. You? > > Same Rails version. > > OS X. Ruby 1.8.6. > > I worked with it a little, and the RSpec functionality seems to be > working OK as far as I can tell. (I'm just starting to learn how to > use RSpec.) > > Did I install the plugin from the right source? I noticed that there's > also an RSpec-rails project on GitHub. Is the svn repository outdated? What you're getting from svn is the last release: 1.1.3. If you want the latest you should grab the github repo, but there has not been a release from source at github yet. > > > Ethan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From george at benevolentcode.com Tue May 6 13:11:48 2008 From: george at benevolentcode.com (George Anderson) Date: Tue, 6 May 2008 13:11:48 -0400 Subject: [rspec-users] "Plugin not found" after RSpec install In-Reply-To: <815ba561-55a3-45e8-937f-4a0193db1240@b9g2000prh.googlegroups.com> References: <815ba561-55a3-45e8-937f-4a0193db1240@b9g2000prh.googlegroups.com> Message-ID: <782d66f30805061011o10e3a06fx10279403ac3f757@mail.gmail.com> Can you pastie the full output? /g On Tue, May 6, 2008 at 12:15 AM, Eeby wrote: > I tried to install the RSpec Rails plugin as described here: > > http://rspec.info/documentation/rails/install.html > > After I run this... > > ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec > > At the very end after a lot of output I get this error: > > Plugin not found: ["http://rspec.rubyforge.org/svn/tags/CURRENT/ > rspec"] > > It looks as though it actually was installed because the dir is there > and the output reported scores of items being installed. > > Any idea why I get that error? > > Thanks, > > Ethan > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- George Anderson BenevolentCode LLC O: (410) 461-7553 C: (410) 218-5185 george at benevolentcode.com From erik at snowedin.net Tue May 6 16:03:37 2008 From: erik at snowedin.net (Erik Pukinskis) Date: Tue, 6 May 2008 13:03:37 -0700 Subject: [rspec-users] Can you use RSpec to test initializers? Message-ID: Hi there! I'm trying to spec out some code that will set the smtp_settings in a custom ActiveMailer object. Basically I want to check that if my configuration object has the right smtp_server, that the ActiveMailer object gets set up correctly. So, my spec looks like this: it "uses smtp server if config says so" do GitoriousConfig.should_receive(:[]).with('smtp_settings').and_return({ :address => "smtp.postoffice.net", }) Mailer.smtp_settings[:address].should == "smtp.postoffice.net" end The trouble is, the code that sets the mailer settings is in an initializer (config/initializers/mailer.rb) and it gets run long before my spec gets run, and so it never encounters my mock. Is there any way I can get the initializer code to run inside my spec? I know I could create a separate initialize method on my Mailer object that has the initialization stuff, and call that method from both my test and my initializer, but that seems less ideal than just calling the initializer from the spec. Any advice? I can't find any information at all online about using Rspec with initializers. Thank you! Erik From jmenoube at gmail.com Tue May 6 17:46:21 2008 From: jmenoube at gmail.com (Eeby) Date: Tue, 6 May 2008 14:46:21 -0700 (PDT) Subject: [rspec-users] "Plugin not found" after RSpec install In-Reply-To: <782d66f30805061011o10e3a06fx10279403ac3f757@mail.gmail.com> References: <815ba561-55a3-45e8-937f-4a0193db1240@b9g2000prh.googlegroups.com> <782d66f30805061011o10e3a06fx10279403ac3f757@mail.gmail.com> Message-ID: On May 6, 10:11 am, "George Anderson" wrote: > Can you pastie the full output? > > /g I deleted the plugins from my project to replay the whole scenario so I could copy and paste it. However, this time there was no error. I pasted it anyway: http://pastie.caboo.se/192662 Thanks, Ethan From mailing_lists at railsnewbie.com Tue May 6 21:55:12 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 6 May 2008 21:55:12 -0400 Subject: [rspec-users] Can you use RSpec to test initializers? In-Reply-To: References: Message-ID: <247869AB-C510-4B3B-A361-EAB69D78AF61@railsnewbie.com> On May 6, 2008, at 4:03 PM, Erik Pukinskis wrote: > Hi there! > > I'm trying to spec out some code that will set the smtp_settings in a > custom ActiveMailer object. Basically I want to check that if my > configuration object has the right smtp_server, that the ActiveMailer > object gets set up correctly. So, my spec looks like this: > > it "uses smtp server if config says so" do > GitoriousConfig.should_receive(: > []).with('smtp_settings').and_return({ > :address => "smtp.postoffice.net", > }) > > Mailer.smtp_settings[:address].should == "smtp.postoffice.net" > end > > The trouble is, the code that sets the mailer settings is in an > initializer (config/initializers/mailer.rb) and it gets run long > before my spec gets run, and so it never encounters my mock. Is there > any way I can get the initializer code to run inside my spec? > > I know I could create a separate initialize method on my Mailer object > that has the initialization stuff, and call that method from both my > test and my initializer, but that seems less ideal than just calling > the initializer from the spec. > > Any advice? I can't find any information at all online about using > Rspec with initializers. You could try using Kernel#load to load the file inside the spec, but you might get strange errors on the other side... Let me know how it works out. Scott From zach.dennis at gmail.com Wed May 7 11:09:56 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 7 May 2008 11:09:56 -0400 Subject: [rspec-users] Can you use RSpec to test initializers? In-Reply-To: References: Message-ID: <85d99afe0805070809h4b219fc5ob0a0138b7bfd0a0f@mail.gmail.com> On Tue, May 6, 2008 at 4:03 PM, Erik Pukinskis wrote: > Hi there! > > I'm trying to spec out some code that will set the smtp_settings in a > custom ActiveMailer object. Basically I want to check that if my > configuration object has the right smtp_server, that the ActiveMailer > object gets set up correctly. So, my spec looks like this: > > it "uses smtp server if config says so" do > GitoriousConfig.should_receive(:[]).with('smtp_settings').and_return({ > :address => "smtp.postoffice.net", > }) > > Mailer.smtp_settings[:address].should == "smtp.postoffice.net" > end > > The trouble is, the code that sets the mailer settings is in an > initializer (config/initializers/mailer.rb) and it gets run long > before my spec gets run, and so it never encounters my mock. Is there > any way I can get the initializer code to run inside my spec? > > I know I could create a separate initialize method on my Mailer object > that has the initialization stuff, and call that method from both my > test and my initializer, but that seems less ideal than just calling > the initializer from the spec. > > Any advice? I can't find any information at all online about using > Rspec with initializers. > Erik, I would not test configuration settings this way. Setting up mock expectations helps when you are talking to another object whose implementation you don't have yet, or don't want the test to rely. Since you are testing configuration settings I would vote that you test against the actual configuration settings. A quick sidebar, I don't like setting up SMTP settings in an initializer. I prefer to do it in the correct environment/*.rb file. This is because you often don't want your development or test environments sending out emails (at least not via the same route as production). If you do move the configuration setup from your initializer to an environment file then what you want to test is going to be more difficult since it may be different for each environment. And when you run a spec it's going to be executed in the test environment, which is probably not the SMTP settings you wanted to ensure got setup. You are probably wanting to make sure the production environment runs with specific settings. In the past I've foregone automated testing of my configuration settings. I usually setup my production.rb configuration on the production server, and then every time I deploy I'm symlink that file into RAILS_ROOT/config/environment/. This greatly reduces the risk that the production settings is going to be modified or altered unintentionally. Keeping snapshot backups of your production setup (or even just the configuration files) also helps reduce risk even more. You could put your production files in their own svn or git repository so you can easily revert back when you do make changes to those files. If you really want to test the production settings you could right a test which loaded up the rails application in the production environment, printed out the SMTP settings in YAML, and then your test could read that in using YAML.load and you could ensure the settings are what you expect. IE: settings = YAML.load( `RAILS_ENV=production ruby -r config/environment.rb -e "y ActionMailer::Base.smtp_settings"` ) settings[:domain].should == "smtp.example.com" -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed May 7 19:18:39 2008 From: lists at ruby-forum.com (Oliver Saunders) Date: Thu, 8 May 2008 01:18:39 +0200 Subject: [rspec-users] Hiding the passes Message-ID: <544f078832283730ec567df80a82a84e@ruby-forum.com> How do you hide all the green passing examples from the output? I don't need to know what has passed and it means I have to scroll to see what has failed. -- Posted via http://www.ruby-forum.com/. From steve.downtown at gmail.com Wed May 7 20:14:39 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Wed, 7 May 2008 17:14:39 -0700 Subject: [rspec-users] Hiding the passes In-Reply-To: <544f078832283730ec567df80a82a84e@ruby-forum.com> References: <544f078832283730ec567df80a82a84e@ruby-forum.com> Message-ID: <4fff79200805071714g559b948bq536ce62d1f6f402b@mail.gmail.com> I assume you are running with '-f s' switch? Maybe its in your spec.opts file ... maybe as --format progress? If you change that to '-f p' you only see progress as a single '.' for each passing test with errors at the end of the output. Or maybe I'm not understanding the question. On Wed, May 7, 2008 at 4:18 PM, Oliver Saunders wrote: > How do you hide all the green passing examples from the output? > I don't need to know what has passed and it means I have to scroll to > see what has failed. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Wed May 7 21:01:47 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 May 2008 18:01:47 -0700 Subject: [rspec-users] Hiding the passes In-Reply-To: <544f078832283730ec567df80a82a84e@ruby-forum.com> References: <544f078832283730ec567df80a82a84e@ruby-forum.com> Message-ID: <810a540e0805071801n53b85282m2dc3d7bb39f0eb56@mail.gmail.com> On Wed, May 7, 2008 at 4:18 PM, Oliver Saunders wrote: > How do you hide all the green passing examples from the output? > I don't need to know what has passed and it means I have to scroll to > see what has failed. Hey Oliver, You can write a custom formatter that implements #example_passed as a noop: class HalfEmptyFormatter < Spec::Runner::Formatter::ProgressBarFormatter def example_passed; end end From ben at benmabey.com Wed May 7 21:53:49 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 07 May 2008 19:53:49 -0600 Subject: [rspec-users] Hiding the passes In-Reply-To: <4fff79200805071714g559b948bq536ce62d1f6f402b@mail.gmail.com> References: <544f078832283730ec567df80a82a84e@ruby-forum.com> <4fff79200805071714g559b948bq536ce62d1f6f402b@mail.gmail.com> Message-ID: <48225D2D.60903@benmabey.com> Steve Downey wrote: > I assume you are running with '-f s' switch? Maybe its in your > spec.opts file ... maybe as --format progress? > > If you change that to '-f p' you only see progress as a single '.' for > each passing test with errors at the end of the output. > > Or maybe I'm not understanding the question. > > On Wed, May 7, 2008 at 4:18 PM, Oliver Saunders > wrote: > > How do you hide all the green passing examples from the output? > I don't need to know what has passed and it means I have to scroll to > see what has failed. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users I wrote some JS that would hide the passing specs on the HTML formatted version and would allow you to expand it later. I might be able to dig it up if your interested... -Ben From lists at ruby-forum.com Thu May 8 08:22:37 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Thu, 8 May 2008 14:22:37 +0200 Subject: [rspec-users] Rspec Stories / Selenium Nightmare Message-ID: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> I have been using Rspec stories with Webrat feeling very productive and happy. Then I needed to do something with Selenium (Webrat could have done what I needed but it does not yet have the functionality). Selenium-core as part of a rails plugin looked nice but did not seem to fit with rspec stories. So I went the Selenium-rc route. Since Selenium uses a separate instance of rails (http://www.nabble.com/stories-with-selenium-and-the-db-td16190686.html) I had to turn off the ActiveRecordSafetyListener used in rspec to make sure the db writes committed. Which in turn left me having to manually cleanup my selenium stories :( So that required writing a new, rather gritty scenario listener which dealt with the cleaning operation. It has to do lots of horrible things like remove all listeners for a selenium story and then re-add them all for the others stories. *Code Extract* def story_ended(title, narrative) case title when 'Edit a page' #We have finished the selenium story $selenium_driver.stop #Do we need to re-add some listeners if !@listener_reloaded Spec::Story::Runner.scenario_runner.add_listener(ActiveRecordSafetyListener.instance) @listener_reloaded=true end end end I had to duplicate a lot of the story steps since now any previous post/gets did not work since they post to the test instance and not the selenium rails instance. I also needed to invoke against the selenium driver so even when the steps would work I had to duplicate them with $selenium_driver.do_something() This nice Given: Given('log in as a admin user') post '/admin/sessions/create', :login => @user.login, :password => @user.password end Being duplicated with this Given('log in as a admin user') $selenium_driver.open '/admin/login' $selenium_driver.type 'login', 'developer' $selenium_driver.type 'password', 'test' $selenium_driver.click 'commit' end After some very painful testing and a lot of time I got my Selenium-rc and Webrat stories working. This experience really opened my eyes to the big void introduced by Selenium-rc running outside of the test instance. This has made me wonder whether I should have rspec stories stepping outside of the test rails instance to drive Selenium tests. Has anyone managed to make this process easier? I'm hoping I'm doing something silly which is making it all harder! Is it feasible to bring selenium into the test rails instances? Is it just always going to be painful? I was skipping along having a lot of fun with stories and Webrat, now I'm face down in a puddle of mud, dreading that Selenium moment. -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu May 8 11:10:30 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 8 May 2008 11:10:30 -0400 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> Message-ID: <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> I've had really iffy luck with Selenium plugins in the past (selenium-on-rails, seleniumfu_rc, selenium_rc, etc.) so I've started to write a RailsSeleniumStory. I also had to remove the ActiveRecordSafetyListener in my efforts. The RailsSeleniumStory is a part of the mhs_testing plugin [0] and it provides higher level helpers. For example I love how form-test-helper is used to select and submit forms: # option 1 form = select_form 'expense_form' form.expense.amount = 12.99 form.submit # option 2 submit_form 'expense_form' do |form| form.expense.amount = 12.99 form.expense.category_id = 2 form.expense.comments = "map for trip" end You can use this same syntax within RailsSeleniumStories. Right now you can also use "have_tag" and "with_tag" matchers with Selenium. It supports basic matching (I wouldn't get to crazy with nesting or lots of assert-select/have-tag options), but it will be supporting more options shortly. So your login example could just look like: Given('log in as a admin user') open "/admin/login" submit_form "login_form" do |form| form.login = 'developer' form.password = 'test' end end Which IMO I really like because if you need variations of that you can pull out a helper method like: def submit_login_form(user, password='test') submit_form "login_form" do |form| form.login = user.login form.password = passsword end end And you could push your open into a helper as well: def go_to_login_page open "/admin/login" end And now your Given could look like: Given('log in as a admin user') go_to_login_page submit_login_form @user, 'test' end Now granted submit_form and select_form both take a form's id, so each of your forms need to have one. If you are interested and have the time please check it out. Granted it's in its infancy and there's not a whole lot of docs right now (there is a README.Selenium for instructions on how-to setup in your project), but you can find me on GTalk or in irc.freenode.net (zdennis) and of course right here on the rspec ML. I am have 33 scenarios using the RailsSeleniumStory, ttyl, Zach 0 - http://github.com/mvanholstyn/mhs_testing/tree/master On Thu, May 8, 2008 at 8:22 AM, Joseph Wilk wrote: > I have been using Rspec stories with Webrat feeling very productive and > happy. > > Then I needed to do something with Selenium (Webrat could have done what > I needed but it does not yet have the functionality). > > Selenium-core as part of a rails plugin looked nice but did not seem to > fit with rspec stories. So I went the Selenium-rc route. > > Since Selenium uses a separate instance of rails > (http://www.nabble.com/stories-with-selenium-and-the-db-td16190686.html) > I had to turn off the ActiveRecordSafetyListener used in rspec to make > sure the db writes committed. > > Which in turn left me having to manually cleanup my selenium stories :( > > So that required writing a new, rather gritty scenario listener which > dealt with the cleaning operation. It has to do lots of horrible things > like remove all listeners for a selenium story and then re-add them all > for the others stories. > > *Code Extract* > > def story_ended(title, narrative) > case title > when 'Edit a page' > > #We have finished the selenium story > $selenium_driver.stop > > #Do we need to re-add some listeners > if !@listener_reloaded > > Spec::Story::Runner.scenario_runner.add_listener(ActiveRecordSafetyListener.instance) > @listener_reloaded=true > end > end > end > > > I had to duplicate a lot of the story steps since now any previous > post/gets did not work since they post to the test instance and not the > selenium rails instance. > > I also needed to invoke against the selenium driver so even when the > steps would work I had to duplicate them with > $selenium_driver.do_something() > > > This nice Given: > > Given('log in as a admin user') > post '/admin/sessions/create', :login => @user.login, :password => > @user.password > end > > Being duplicated with this > > Given('log in as a admin user') > $selenium_driver.open '/admin/login' > $selenium_driver.type 'login', 'developer' > $selenium_driver.type 'password', 'test' > $selenium_driver.click 'commit' > end > > After some very painful testing and a lot of time I got my Selenium-rc > and Webrat stories working. This experience really opened my eyes to the > big void introduced by Selenium-rc running outside of the test instance. > > This has made me wonder whether I should have rspec stories stepping > outside of the test rails instance to drive Selenium tests. > > Has anyone managed to make this process easier? > > I'm hoping I'm doing something silly which is making it all harder! > > Is it feasible to bring selenium into the test rails instances? > > Is it just always going to be painful? > > I was skipping along having a lot of fun with stories and Webrat, now > I'm face down in a puddle of mud, dreading that Selenium moment. > > -- > Joseph Wilk > http://www.joesniff.co.uk > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu May 8 11:15:28 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 May 2008 10:15:28 -0500 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> Message-ID: <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> Just an FYI - spec-ui, an rspec extension that supports integration with selenium and watir, has been under some discussion lately and should see some new life soon. On May 8, 2008, at 10:10 AM, Zach Dennis wrote: > I've had really iffy luck with Selenium plugins in the past > (selenium-on-rails, seleniumfu_rc, selenium_rc, etc.) so I've > started to write a RailsSeleniumStory. I also had to remove the > ActiveRecordSafetyListener in my efforts. > > The RailsSeleniumStory is a part of the mhs_testing plugin [0] and > it provides higher level helpers. For example I love how form-test- > helper is used to select and submit forms: > > # option 1 > form = select_form 'expense_form' > form.expense.amount = 12.99 > form.submit > > # option 2 > submit_form 'expense_form' do |form| > form.expense.amount = 12.99 > form.expense.category_id = 2 > form.expense.comments = "map for trip" > end > > You can use this same syntax within RailsSeleniumStories. Right now > you can also use "have_tag" and "with_tag" matchers with Selenium. > It supports basic matching (I wouldn't get to crazy with nesting or > lots of assert-select/have-tag options), but it will be supporting > more options shortly. > > So your login example could just look like: > > Given('log in as a admin user') > open "/admin/login" > submit_form "login_form" do |form| > form.login = 'developer' > form.password = 'test' > end > end > > Which IMO I really like because if you need variations of that you > can pull out a helper method like: > > def submit_login_form(user, password='test') > submit_form "login_form" do |form| > form.login = user.login > form.password = passsword > end > end > > And you could push your open into a helper as well: > def go_to_login_page > open "/admin/login" > end > > And now your Given could look like: > Given('log in as a admin user') > go_to_login_page > submit_login_form @user, 'test' > end > > Now granted submit_form and select_form both take a form's id, so > each of your forms need to have one. > > If you are interested and have the time please check it out. Granted > it's in its infancy and there's not a whole lot of docs right now > (there is a README.Selenium for instructions on how-to setup in your > project), but you can find me on GTalk or in irc.freenode.net > (zdennis) and of course right here on the rspec ML. I am have 33 > scenarios using the RailsSeleniumStory, > > ttyl, > > Zach > > 0 - http://github.com/mvanholstyn/mhs_testing/tree/master > > > > On Thu, May 8, 2008 at 8:22 AM, Joseph Wilk > wrote: > I have been using Rspec stories with Webrat feeling very productive > and > happy. > > Then I needed to do something with Selenium (Webrat could have done > what > I needed but it does not yet have the functionality). > > Selenium-core as part of a rails plugin looked nice but did not seem > to > fit with rspec stories. So I went the Selenium-rc route. > > Since Selenium uses a separate instance of rails > (http://www.nabble.com/stories-with-selenium-and-the-db-td16190686.html > ) > I had to turn off the ActiveRecordSafetyListener used in rspec to make > sure the db writes committed. > > Which in turn left me having to manually cleanup my selenium > stories :( > > So that required writing a new, rather gritty scenario listener which > dealt with the cleaning operation. It has to do lots of horrible > things > like remove all listeners for a selenium story and then re-add them > all > for the others stories. > > *Code Extract* > > def story_ended(title, narrative) > case title > when 'Edit a page' > > #We have finished the selenium story > $selenium_driver.stop > > #Do we need to re-add some listeners > if !@listener_reloaded > > Spec > ::Story > ::Runner > .scenario_runner.add_listener(ActiveRecordSafetyListener.instance) > @listener_reloaded=true > end > end > end > > > I had to duplicate a lot of the story steps since now any previous > post/gets did not work since they post to the test instance and not > the > selenium rails instance. > > I also needed to invoke against the selenium driver so even when the > steps would work I had to duplicate them with > $selenium_driver.do_something() > > > This nice Given: > > Given('log in as a admin user') > post '/admin/sessions/create', :login => @user.login, :password > => > @user.password > end > > Being duplicated with this > > Given('log in as a admin user') > $selenium_driver.open '/admin/login' > $selenium_driver.type 'login', 'developer' > $selenium_driver.type 'password', 'test' > $selenium_driver.click 'commit' > end > > After some very painful testing and a lot of time I got my Selenium-rc > and Webrat stories working. This experience really opened my eyes to > the > big void introduced by Selenium-rc running outside of the test > instance. > > This has made me wonder whether I should have rspec stories stepping > outside of the test rails instance to drive Selenium tests. > > Has anyone managed to make this process easier? > > I'm hoping I'm doing something silly which is making it all harder! > > Is it feasible to bring selenium into the test rails instances? > > Is it just always going to be painful? > > I was skipping along having a lot of fun with stories and Webrat, now > I'm face down in a puddle of mud, dreading that Selenium moment. > > -- > Joseph Wilk > http://www.joesniff.co.uk > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu May 8 14:40:51 2008 From: lists at ruby-forum.com (Oliver Saunders) Date: Thu, 8 May 2008 20:40:51 +0200 Subject: [rspec-users] Hiding the passes In-Reply-To: <48225D2D.60903@benmabey.com> References: <544f078832283730ec567df80a82a84e@ruby-forum.com> <4fff79200805071714g559b948bq536ce62d1f6f402b@mail.gmail.com> <48225D2D.60903@benmabey.com> Message-ID: <03cfaa2b93c716efbedf02bd8af7c197@ruby-forum.com> I should explain I'm running the tests from textmate. So for those interested in doing the same I changed the "Run Examples" command in the RSpec bundle to: #!/usr/bin/env ruby require ENV['TM_BUNDLE_SUPPORT'] + "/lib/spec/mate" require 'spec/runner/formatter/html_formatter' module Spec::Runner::Formatter class TextMateFormatter < HtmlFormatter # hide passes def example_passed(*args); end end end Spec::Mate::Runner.new.run_file STDOUT -- Posted via http://www.ruby-forum.com/. From steve.downtown at gmail.com Thu May 8 16:05:18 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Thu, 8 May 2008 13:05:18 -0700 Subject: [rspec-users] Fixtures not clearing tables? Message-ID: <4fff79200805081305m1d13fe92k30e2b25a09645d5f@mail.gmail.com> I have a case where I'm loading fixtures and a row added to a table in a spec is around at the start of all subsequent specs. When I set config.use_transactional_fixtures = false the fixtures load/clear as expected. Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Thu May 8 18:24:25 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 8 May 2008 18:24:25 -0400 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> Message-ID: <85d99afe0805081524l44318a69y67cd479d872ddb51@mail.gmail.com> David, Can you provide any more info? Is it just being talked about or are people actively working on it now? I would be interested in assisting. I've done a lot with Selenium and the ruby driver and would be interested in providing beautiful high level helpers that allow people switch from non-Selenium based specs to Selenium-based specs with more ease. I know this can be a barrier for people. Zach On Thu, May 8, 2008 at 11:15 AM, David Chelimsky wrote: > Just an FYI - spec-ui, an rspec extension that supports integration with > selenium and watir, has been under some discussion lately and should see > some new life soon. > > On May 8, 2008, at 10:10 AM, Zach Dennis wrote: > > I've had really iffy luck with Selenium plugins in the past > (selenium-on-rails, seleniumfu_rc, selenium_rc, etc.) so I've started to > write a RailsSeleniumStory. I also had to remove the > ActiveRecordSafetyListener in my efforts. > > The RailsSeleniumStory is a part of the mhs_testing plugin [0] and it > provides higher level helpers. For example I love how form-test-helper is > used to select and submit forms: > > # option 1 > form = select_form 'expense_form' > form.expense.amount = 12.99 > form.submit > > # option 2 > submit_form 'expense_form' do |form| > form.expense.amount = 12.99 > form.expense.category_id = 2 > form.expense.comments = "map for trip" > end > > You can use this same syntax within RailsSeleniumStories. Right now you can > also use "have_tag" and "with_tag" matchers with Selenium. It supports basic > matching (I wouldn't get to crazy with nesting or lots of > assert-select/have-tag options), but it will be supporting more options > shortly. > > So your login example could just look like: > > Given('log in as a admin user') > open "/admin/login" > submit_form "login_form" do |form| > form.login = 'developer' > form.password = 'test' > end > end > > Which IMO I really like because if you need variations of that you can pull > out a helper method like: > > def submit_login_form(user, password='test') > submit_form "login_form" do |form| > form.login = user.login > form.password = passsword > end > end > > And you could push your open into a helper as well: > def go_to_login_page > open "/admin/login" > end > > And now your Given could look like: > Given('log in as a admin user') > go_to_login_page > submit_login_form @user, 'test' > end > > Now granted submit_form and select_form both take a form's id, so each of > your forms need to have one. > > If you are interested and have the time please check it out. Granted it's > in its infancy and there's not a whole lot of docs right now (there is a > README.Selenium for instructions on how-to setup in your project), but you > can find me on GTalk or in irc.freenode.net (zdennis) and of course right > here on the rspec ML. I am have 33 scenarios using the RailsSeleniumStory, > > ttyl, > > Zach > > 0 - http://github.com/mvanholstyn/mhs_testing/tree/master > > > > On Thu, May 8, 2008 at 8:22 AM, Joseph Wilk wrote: > >> I have been using Rspec stories with Webrat feeling very productive and >> happy. >> >> Then I needed to do something with Selenium (Webrat could have done what >> I needed but it does not yet have the functionality). >> >> Selenium-core as part of a rails plugin looked nice but did not seem to >> fit with rspec stories. So I went the Selenium-rc route. >> >> Since Selenium uses a separate instance of rails >> (http://www.nabble.com/stories-with-selenium-and-the-db-td16190686.html) >> I had to turn off the ActiveRecordSafetyListener used in rspec to make >> sure the db writes committed. >> >> Which in turn left me having to manually cleanup my selenium stories :( >> >> So that required writing a new, rather gritty scenario listener which >> dealt with the cleaning operation. It has to do lots of horrible things >> like remove all listeners for a selenium story and then re-add them all >> for the others stories. >> >> *Code Extract* >> >> def story_ended(title, narrative) >> case title >> when 'Edit a page' >> >> #We have finished the selenium story >> $selenium_driver.stop >> >> #Do we need to re-add some listeners >> if !@listener_reloaded >> >> Spec::Story::Runner.scenario_runner.add_listener(ActiveRecordSafetyListener.instance) >> @listener_reloaded=true >> end >> end >> end >> >> >> I had to duplicate a lot of the story steps since now any previous >> post/gets did not work since they post to the test instance and not the >> selenium rails instance. >> >> I also needed to invoke against the selenium driver so even when the >> steps would work I had to duplicate them with >> $selenium_driver.do_something() >> >> >> This nice Given: >> >> Given('log in as a admin user') >> post '/admin/sessions/create', :login => @user.login, :password => >> @user.password >> end >> >> Being duplicated with this >> >> Given('log in as a admin user') >> $selenium_driver.open '/admin/login' >> $selenium_driver.type 'login', 'developer' >> $selenium_driver.type 'password', 'test' >> $selenium_driver.click 'commit' >> end >> >> After some very painful testing and a lot of time I got my Selenium-rc >> and Webrat stories working. This experience really opened my eyes to the >> big void introduced by Selenium-rc running outside of the test instance. >> >> This has made me wonder whether I should have rspec stories stepping >> outside of the test rails instance to drive Selenium tests. >> >> Has anyone managed to make this process easier? >> >> I'm hoping I'm doing something silly which is making it all harder! >> >> Is it feasible to bring selenium into the test rails instances? >> >> Is it just always going to be painful? >> >> I was skipping along having a lot of fun with stories and Webrat, now >> I'm face down in a puddle of mud, dreading that Selenium moment. >> >> -- >> Joseph Wilk >> http://www.joesniff.co.uk >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com_______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwilden at twistage.com Thu May 8 18:26:52 2008 From: mwilden at twistage.com (Mark Wilden) Date: Thu, 8 May 2008 15:26:52 -0700 Subject: [rspec-users] Testing render :text without has_text References: <123D6B60-6C94-4EC5-90E8-D781B2ED8EBE@mwilden.com> Message-ID: <3DAFEE82-FD6B-4049-8B50-9379AD41D20F@twistage.com> A controller I'm trying to test simply delivers a text string to the client, which then demarshalls it to retrieve some objects. I want to test that the returned string is correct. I don't want to compare the string character-by-character with response.has_text because that ties me to the implementation of the Marshall class. Instead, I just want to demarshall the string and compare that with the expected objects. To do this, I need RSpec to give me the complete text string that's rendered by the controller. Here's the controller: class StatsController < ApplicationController layout nil def query reports = StatisticsReporter.query params[:query_params] render :text => Marshal.dump(reports) end end And here's the test: describe StatsController do before :each do @query_params = { :foo => :bar } end it "should return a demarshallable string of the reports" do reports = [ StatisticsReport.new(:date => nil), StatisticsReport.new(:bytes_transferred => 0) ] StatisticsReporter.should_receive(:query).and_return reports get :query, :query_params => @query_params # PROBLEM CODE (the equality test needs tweaking, but you get the idea) Marshal.load(response.what_goes_here?).should == reports end end (This code may look familiar to one member of this list...:) Can this be done? adthanksvance, ///ark From dchelimsky at gmail.com Thu May 8 18:36:33 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 May 2008 17:36:33 -0500 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: <85d99afe0805081524l44318a69y67cd479d872ddb51@mail.gmail.com> References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> <85d99afe0805081524l44318a69y67cd479d872ddb51@mail.gmail.com> Message-ID: <909F712C-8080-49CB-9717-72705CF7BF24@gmail.com> On May 8, 2008, at 5:24 PM, Zach Dennis wrote: > David, > > Can you provide any more info? Is it just being talked about or are > people actively working on it now? I would be interested in > assisting. I've done a lot with Selenium and the ruby driver and > would be interested in providing beautiful high level helpers that > allow people switch from non-Selenium based specs to Selenium-based > specs with more ease. I know this can be a barrier for people. The short term plan is that Aslak will set up a spec-ui project up at github, at which point you, Ian Dees (who ha also expressed an interested in working on this), and anyone else who wishes can set up clones. It might take a while before there is a formal release (gem published to rubyforge), but at least this positions us to move forward with your assistance. I don't want to commit to a time frame, but my suspicion is that we should have git repo up within the next week or two. Cheers, David > Zach > > On Thu, May 8, 2008 at 11:15 AM, David Chelimsky > wrote: > Just an FYI - spec-ui, an rspec extension that supports integration > with selenium and watir, has been under some discussion lately and > should see some new life soon. > > On May 8, 2008, at 10:10 AM, Zach Dennis wrote: >> I've had really iffy luck with Selenium plugins in the past >> (selenium-on-rails, seleniumfu_rc, selenium_rc, etc.) so I've >> started to write a RailsSeleniumStory. I also had to remove the >> ActiveRecordSafetyListener in my efforts. >> >> The RailsSeleniumStory is a part of the mhs_testing plugin [0] and >> it provides higher level helpers. For example I love how form-test- >> helper is used to select and submit forms: >> >> # option 1 >> form = select_form 'expense_form' >> form.expense.amount = 12.99 >> form.submit >> >> # option 2 >> submit_form 'expense_form' do |form| >> form.expense.amount = 12.99 >> form.expense.category_id = 2 >> form.expense.comments = "map for trip" >> end >> >> You can use this same syntax within RailsSeleniumStories. Right now >> you can also use "have_tag" and "with_tag" matchers with Selenium. >> It supports basic matching (I wouldn't get to crazy with nesting or >> lots of assert-select/have-tag options), but it will be supporting >> more options shortly. >> >> So your login example could just look like: >> >> Given('log in as a admin user') >> open "/admin/login" >> submit_form "login_form" do |form| >> form.login = 'developer' >> form.password = 'test' >> end >> end >> >> Which IMO I really like because if you need variations of that you >> can pull out a helper method like: >> >> def submit_login_form(user, password='test') >> submit_form "login_form" do |form| >> form.login = user.login >> form.password = passsword >> end >> end >> >> And you could push your open into a helper as well: >> def go_to_login_page >> open "/admin/login" >> end >> >> And now your Given could look like: >> Given('log in as a admin user') >> go_to_login_page >> submit_login_form @user, 'test' >> end >> >> Now granted submit_form and select_form both take a form's id, so >> each of your forms need to have one. >> >> If you are interested and have the time please check it out. >> Granted it's in its infancy and there's not a whole lot of docs >> right now (there is a README.Selenium for instructions on how-to >> setup in your project), but you can find me on GTalk or in >> irc.freenode.net (zdennis) and of course right here on the rspec >> ML. I am have 33 scenarios using the RailsSeleniumStory, >> >> ttyl, >> >> Zach >> >> 0 - http://github.com/mvanholstyn/mhs_testing/tree/master >> >> >> >> On Thu, May 8, 2008 at 8:22 AM, Joseph Wilk >> wrote: >> I have been using Rspec stories with Webrat feeling very productive >> and >> happy. >> >> Then I needed to do something with Selenium (Webrat could have done >> what >> I needed but it does not yet have the functionality). >> >> Selenium-core as part of a rails plugin looked nice but did not >> seem to >> fit with rspec stories. So I went the Selenium-rc route. >> >> Since Selenium uses a separate instance of rails >> (http://www.nabble.com/stories-with-selenium-and-the-db-td16190686.html >> ) >> I had to turn off the ActiveRecordSafetyListener used in rspec to >> make >> sure the db writes committed. >> >> Which in turn left me having to manually cleanup my selenium >> stories :( >> >> So that required writing a new, rather gritty scenario listener which >> dealt with the cleaning operation. It has to do lots of horrible >> things >> like remove all listeners for a selenium story and then re-add them >> all >> for the others stories. >> >> *Code Extract* >> >> def story_ended(title, narrative) >> case title >> when 'Edit a page' >> >> #We have finished the selenium story >> $selenium_driver.stop >> >> #Do we need to re-add some listeners >> if !@listener_reloaded >> >> Spec >> ::Story >> ::Runner >> .scenario_runner.add_listener(ActiveRecordSafetyListener.instance) >> @listener_reloaded=true >> end >> end >> end >> >> >> I had to duplicate a lot of the story steps since now any previous >> post/gets did not work since they post to the test instance and not >> the >> selenium rails instance. >> >> I also needed to invoke against the selenium driver so even when the >> steps would work I had to duplicate them with >> $selenium_driver.do_something() >> >> >> This nice Given: >> >> Given('log in as a admin user') >> post '/admin/sessions/create', :login => >> @user.login, :password => >> @user.password >> end >> >> Being duplicated with this >> >> Given('log in as a admin user') >> $selenium_driver.open '/admin/login' >> $selenium_driver.type 'login', 'developer' >> $selenium_driver.type 'password', 'test' >> $selenium_driver.click 'commit' >> end >> >> After some very painful testing and a lot of time I got my Selenium- >> rc >> and Webrat stories working. This experience really opened my eyes >> to the >> big void introduced by Selenium-rc running outside of the test >> instance. >> >> This has made me wonder whether I should have rspec stories stepping >> outside of the test rails instance to drive Selenium tests. >> >> Has anyone managed to make this process easier? >> >> I'm hoping I'm doing something silly which is making it all harder! >> >> Is it feasible to bring selenium into the test rails instances? >> >> Is it just always going to be painful? >> >> I was skipping along having a lot of fun with stories and Webrat, now >> I'm face down in a puddle of mud, dreading that Selenium moment. >> >> -- >> Joseph Wilk >> http://www.joesniff.co.uk >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> Zach Dennis >> http://www.continuousthinking.com >> _______________________________________________ >> >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu May 8 18:38:22 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 8 May 2008 17:38:22 -0500 Subject: [rspec-users] Testing render :text without has_text In-Reply-To: <3DAFEE82-FD6B-4049-8B50-9379AD41D20F@twistage.com> References: <123D6B60-6C94-4EC5-90E8-D781B2ED8EBE@mwilden.com> <3DAFEE82-FD6B-4049-8B50-9379AD41D20F@twistage.com> Message-ID: <53ACAF91-DDCE-4044-A730-1359110C90E6@gmail.com> On May 8, 2008, at 5:26 PM, Mark Wilden wrote: > A controller I'm trying to test simply delivers a text string to the > client, which then demarshalls it to retrieve some objects. I want > to test that the returned string is correct. > > I don't want to compare the string character-by-character with > response.has_text because that ties me to the implementation of the > Marshall class. Instead, I just want to demarshall the string and > compare that with the expected objects. To do this, I need RSpec to > give me the complete text string that's rendered by the controller. > > Here's the controller: > > class StatsController < ApplicationController > layout nil > > def query > reports = StatisticsReporter.query params[:query_params] > render :text => Marshal.dump(reports) > end > end > > And here's the test: > > describe StatsController do > before :each do > @query_params = { :foo => :bar } > end > > it "should return a demarshallable string of the reports" do > reports = [ > StatisticsReport.new(:date => nil), > StatisticsReport.new(:bytes_transferred => 0) > ] > StatisticsReporter.should_receive(:query).and_return reports > > get :query, :query_params => @query_params > > # PROBLEM CODE (the equality test needs tweaking, but you get the > idea) > Marshal.load(response.what_goes_here?).should == reports Try this: Marshal.load(response.body).should == reports > > end > end > > (This code may look familiar to one member of this list...:) > > Can this be done? > > adthanksvance, > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mwilden at twistage.com Thu May 8 19:43:11 2008 From: mwilden at twistage.com (Mark Wilden) Date: Thu, 8 May 2008 16:43:11 -0700 Subject: [rspec-users] Testing render :text without has_text In-Reply-To: <53ACAF91-DDCE-4044-A730-1359110C90E6@gmail.com> References: <123D6B60-6C94-4EC5-90E8-D781B2ED8EBE@mwilden.com> <3DAFEE82-FD6B-4049-8B50-9379AD41D20F@twistage.com> <53ACAF91-DDCE-4044-A730-1359110C90E6@gmail.com> Message-ID: <63F2B579-7209-4EFB-948B-354DF93DC890@twistage.com> On May 8, 2008, at 3:38 PM, David Chelimsky wrote: >> I need RSpec to give me the complete text string that's rendered by >> the controller. >> >> Try this: > > Marshal.load(response.body).should == reports Dang! I dumped response.methods and tried everything that looked likely, but I guess I missed that one. Thanks! Just to preserve my sanity in the future, is there a place where this is documented? ///ark From mhw+rspec at kremvax.net Fri May 9 07:43:01 2008 From: mhw+rspec at kremvax.net (Mark H. Wilkinson) Date: Fri, 09 May 2008 12:43:01 +0100 Subject: [rspec-users] rspec version to use with git Message-ID: <1210333381.7292.34.camel@sputnik> I want to start using RSpec in an existing project that uses git for SCM, and I was planning on using git submodules to pull in known-stable releases of the rspec and rspec_on_rails plugins. The current repositories on github don't seem to be set up to help with this at the moment though, so I'm looking for some advice. Here're the issues, I think: * The last stable release is 1.1.3, but there's no tag in the git repository to indicate the revision that makes that release. I think the equivalent commit is 11d7cc9d9a45c957f7a9215b41aa0b9c3d5c236b but... * The rspec.git repository for the last stable revision actually includes rspec (and rspec_on_rails) as subdirectories, so if you check them out as submodules in vendor/plugins the plugins themselves aren't in the right place (they finish up in vendor/plugins/rspec/rspec and ?vendor/plugins/rspec/rspec_on_rails). I can see that both of these issues will disappear when the first real release from git happens, but in the meantime I feel a bit stuck. Is there a specific revision of rspec.git (and rspec_on_rails.git) that is actually pretty stable, or is master pretty stable and I could just pick any revision and find it works fine? Cheers, -Mark. From lists at ruby-forum.com Fri May 9 08:17:36 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Fri, 9 May 2008 14:17:36 +0200 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: <909F712C-8080-49CB-9717-72705CF7BF24@gmail.com> References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> <85d99afe0805081524l44318a69y67cd479d872ddb51@mail.gmail.com> <909F712C-8080-49CB-9717-72705CF7BF24@gmail.com> Message-ID: I would be happy to get involved with this project. I'll be spending most of this year writing Rspec stories and anything that makes browser testing easier will be easy to justify to my work colleagues. David Chelimsky wrote: > On May 8, 2008, at 5:24 PM, Zach Dennis wrote: > >> David, >> >> Can you provide any more info? Is it just being talked about or are >> people actively working on it now? I would be interested in >> assisting. I've done a lot with Selenium and the ruby driver and >> would be interested in providing beautiful high level helpers that >> allow people switch from non-Selenium based specs to Selenium-based >> specs with more ease. I know this can be a barrier for people. > > The short term plan is that Aslak will set up a spec-ui project up at > github, at which point you, Ian Dees (who ha also expressed an > interested in working on this), and anyone else who wishes can set up > clones. It might take a while before there is a formal release (gem > published to rubyforge), but at least this positions us to move > forward with your assistance. > > I don't want to commit to a time frame, but my suspicion is that we > should have git repo up within the next week or two. > > Cheers, > David -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 9 08:38:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 9 May 2008 07:38:53 -0500 Subject: [rspec-users] rspec version to use with git In-Reply-To: <1210333381.7292.34.camel@sputnik> References: <1210333381.7292.34.camel@sputnik> Message-ID: <178BF75D-3160-492F-9A2D-B52284E68A3F@gmail.com> On May 9, 2008, at 6:43 AM, Mark H. Wilkinson wrote: > I want to start using RSpec in an existing project that uses git for > SCM, and I was planning on using git submodules to pull in known- > stable > releases of the rspec and rspec_on_rails plugins. The current > repositories on github don't seem to be set up to help with this at > the > moment though, so I'm looking for some advice. Here're the issues, I > think: > * The last stable release is 1.1.3, but there's no tag in the git > repository to indicate the revision that makes that release. I > think the equivalent commit is > 11d7cc9d9a45c957f7a9215b41aa0b9c3d5c236b but... > * The rspec.git repository for the last stable revision actually > includes rspec (and rspec_on_rails) as subdirectories, so if > you > check them out as submodules in vendor/plugins the plugins > themselves aren't in the right place (they finish up in > vendor/plugins/rspec/rspec > and vendor/plugins/rspec/rspec_on_rails). > > I can see that both of these issues will disappear when the first real > release from git happens, but in the meantime I feel a bit stuck. Is > there a specific revision of rspec.git (and rspec_on_rails.git) that > is > actually pretty stable, or is master pretty stable and I could just > pick > any revision and find it works fine? Unfortunately you *are* stuck for the moment. We broke up the repositories as we did because git doesn't support partial clones (i.e. you can't just clone one subdirectory of a repo) the way you can checkout subdirectories of a subversion repository. There's no way for us to go back and tag the correct commit without you grabbing the full repository at that time. I can tell you that I use the current master with no issues, BUT, there have been some changes to internals that might break your monkey patches (if you have any). I don't have time to doc them right now (part of why there has been no release), but if I were in your shoes I'd grab the latest and see what happens. It's an inexpensive experiment. David > > > Cheers, > > -Mark. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri May 9 14:26:14 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 9 May 2008 20:26:14 +0200 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> <85d99afe0805081524l44318a69y67cd479d872ddb51@mail.gmail.com> <909F712C-8080-49CB-9717-72705CF7BF24@gmail.com> Message-ID: <8d961d900805091126s393509b4j1538557dc43b0f39@mail.gmail.com> I have just git-svn'ed the code that was formerly in http://rubyforge.org/projects/rspec-ext to GitHub: http://github.com/aslakhellesoy (rspec-distributed and rspec-ui) I haven't maintained these in a while, so they might be a little broken. Hopefully someone will clone and improve them. FYI: The rspec-ui code was written prior to the story framework. Now that the story framework exists, UI extensions should IMO be against the story framework - not the RSpec example framework (describe/it). You'll also see that I'm working on an experimental reimplementation of the story framework, based on the excellent Treetop parser generator. The goal of this framework is: * Stories that are easier to run (separate command line - no need to write all.rb files) * Rake task * Ability to run just one story (a --line switch) * Before and After blocks * i18n * Nice backtraces that go all the way back to the plain text .story files * Less code to maintain * Easier to hook into for customisations (such as Rails/Webrat/UI/Watir/Selenium/Celerity/FunFX/screenshot/etc extensions) Plus some other cool things I'll save for laters. A lot of the stuff above is already implemented. Not a lot of specs for the code itself - I've been driving it mostly by running sample stories. Don't shoot me. Cheers, Aslak On Fri, May 9, 2008 at 2:17 PM, Joseph Wilk wrote: > I would be happy to get involved with this project. > I'll be spending most of this year writing Rspec stories and anything > that makes browser testing easier will be easy to justify to my work > colleagues. > > David Chelimsky wrote: >> On May 8, 2008, at 5:24 PM, Zach Dennis wrote: >> >>> David, >>> >>> Can you provide any more info? Is it just being talked about or are >>> people actively working on it now? I would be interested in >>> assisting. I've done a lot with Selenium and the ruby driver and >>> would be interested in providing beautiful high level helpers that >>> allow people switch from non-Selenium based specs to Selenium-based >>> specs with more ease. I know this can be a barrier for people. >> >> The short term plan is that Aslak will set up a spec-ui project up at >> github, at which point you, Ian Dees (who ha also expressed an >> interested in working on this), and anyone else who wishes can set up >> clones. It might take a while before there is a formal release (gem >> published to rubyforge), but at least this positions us to move >> forward with your assistance. >> >> I don't want to commit to a time frame, but my suspicion is that we >> should have git repo up within the next week or two. >> >> Cheers, >> David > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri May 9 23:44:13 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 09 May 2008 21:44:13 -0600 Subject: [rspec-users] Rspec Stories / Selenium Nightmare In-Reply-To: <8d961d900805091126s393509b4j1538557dc43b0f39@mail.gmail.com> References: <4014db023e946c1e69d59f04ea87989c@ruby-forum.com> <85d99afe0805080810l2a2ffd5dwd7f653f00110bf92@mail.gmail.com> <05627E77-E4B0-4100-AEBA-430A18510EC3@gmail.com> <85d99afe0805081524l44318a69y67cd479d872ddb51@mail.gmail.com> <909F712C-8080-49CB-9717-72705CF7BF24@gmail.com> <8d961d900805091126s393509b4j1538557dc43b0f39@mail.gmail.com> Message-ID: <48251A0D.7060604@benmabey.com> aslak hellesoy wrote: > I have just git-svn'ed the code that was formerly in > http://rubyforge.org/projects/rspec-ext to GitHub: > > http://github.com/aslakhellesoy > > (rspec-distributed and rspec-ui) > > I haven't maintained these in a while, so they might be a little > broken. Hopefully someone will clone and improve them. > > The DeepTest project has added rspec support and distributed processing across multiple machines so rspec-distributed may not need the love: http://github.com/qxjit/deep-test/tree/master -Ben From mailing_lists at railsnewbie.com Sat May 10 07:25:17 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 10 May 2008 07:25:17 -0400 Subject: [rspec-users] rspec version to use with git In-Reply-To: <178BF75D-3160-492F-9A2D-B52284E68A3F@gmail.com> References: <1210333381.7292.34.camel@sputnik> <178BF75D-3160-492F-9A2D-B52284E68A3F@gmail.com> Message-ID: On May 9, 2008, at 8:38 AM, David Chelimsky wrote: > On May 9, 2008, at 6:43 AM, Mark H. Wilkinson wrote: > >> I want to start using RSpec in an existing project that uses git for >> SCM, and I was planning on using git submodules to pull in known- >> stable >> releases of the rspec and rspec_on_rails plugins. The current >> repositories on github don't seem to be set up to help with this at >> the >> moment though, so I'm looking for some advice. Here're the issues, I >> think: >> * The last stable release is 1.1.3, but there's no tag in the git >> repository to indicate the revision that makes that release. I >> think the equivalent commit is >> 11d7cc9d9a45c957f7a9215b41aa0b9c3d5c236b but... >> * The rspec.git repository for the last stable revision actually >> includes rspec (and rspec_on_rails) as subdirectories, so if >> you >> check them out as submodules in vendor/plugins the plugins >> themselves aren't in the right place (they finish up in >> vendor/plugins/rspec/rspec >> and vendor/plugins/rspec/rspec_on_rails). >> >> I can see that both of these issues will disappear when the first >> real >> release from git happens, but in the meantime I feel a bit stuck. Is >> there a specific revision of rspec.git (and rspec_on_rails.git) >> that is >> actually pretty stable, or is master pretty stable and I could just >> pick >> any revision and find it works fine? > > Unfortunately you *are* stuck for the moment. We broke up the > repositories as we did because git doesn't support partial clones > (i.e. you can't just clone one subdirectory of a repo) the way you > can checkout subdirectories of a subversion repository. There's no > way for us to go back and tag the correct commit without you > grabbing the full repository at that time. > > I can tell you that I use the current master with no issues, BUT, > there have been some changes to internals that might break your > monkey patches (if you have any). I don't have time to doc them > right now (part of why there has been no release), but if I were in > your shoes I'd grab the latest and see what happens. It's an > inexpensive experiment. > > David David, Didn't you do git-svn import? Shouldn't the full repository history be there? I would imagine that you could create a branch for the last stable release, and revert backwards to the revision (in svn) in which the last release was tagged. As for (git) tags - I see no way to use submodules with tags - Or am I missing something very obvious? Scott From carmine.moleti at gmail.com Sat May 10 08:23:54 2008 From: carmine.moleti at gmail.com (CarmineM) Date: Sat, 10 May 2008 05:23:54 -0700 (PDT) Subject: [rspec-users] Newbie: lambda do...end.should change(Model, :count).by(1). Doesn't work Message-ID: Hi to everyone, I'm an RSpec, and BDD in general, newbie so in order to learn I have chosen to use my personal website as a tesbed. I'm having difficulties juggling with mocks, and in particula with the following code. Here's the controller action: def create @album = Album.new(params[:album]) if @album.save flash[:notice] = "album saved" else flash[:notice] = "could not save album" end redirect_to albums_path end And here an excerpt of the spec I'm fighting with: describe "create" do before(:each) do login_as(:admin) @album = mock_model(Album, :save => true) Album.stub!(:new).and_return(@album) @params = { :title => 'a new title', :description => 'a new description', :category => 'a new category' } end def do_verb(params = @params) post :create, :album => params end it "should change the Albums count by 1 after POST" do lambda do @album.should_receive(:save).and_return(true) do_verb end.should change(Album, :count).by(1) end end When I run the spec (in TextMate) I get the following error: count should have been changed by 1, but was changed by 0 And the row with "lambda do" highlighted. Where am I doing wrong? Thanks in advance for your help. Regards, Carmine P.S.: I already have bought Peepcode's screencast on RSpec, but they've left me only with a partial picture. Is there anything else I can use to learn? From dchelimsky at gmail.com Sat May 10 08:54:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 10 May 2008 07:54:52 -0500 Subject: [rspec-users] rspec version to use with git In-Reply-To: References: <1210333381.7292.34.camel@sputnik> <178BF75D-3160-492F-9A2D-B52284E68A3F@gmail.com> Message-ID: <17C1A332-4729-4260-9218-FAE83326B9F3@gmail.com> On May 10, 2008, at 6:25 AM, Scott Taylor wrote: > On May 9, 2008, at 8:38 AM, David Chelimsky wrote: >> On May 9, 2008, at 6:43 AM, Mark H. Wilkinson wrote: >> >>> I want to start using RSpec in an existing project that uses git for >>> SCM, and I was planning on using git submodules to pull in known- >>> stable >>> releases of the rspec and rspec_on_rails plugins. The current >>> repositories on github don't seem to be set up to help with this >>> at the >>> moment though, so I'm looking for some advice. Here're the issues, I >>> think: >>> * The last stable release is 1.1.3, but there's no tag in the git >>> repository to indicate the revision that makes that release. I >>> think the equivalent commit is >>> 11d7cc9d9a45c957f7a9215b41aa0b9c3d5c236b but... >>> * The rspec.git repository for the last stable revision actually >>> includes rspec (and rspec_on_rails) as subdirectories, so if >>> you >>> check them out as submodules in vendor/plugins the plugins >>> themselves aren't in the right place (they finish up in >>> vendor/plugins/rspec/rspec >>> and vendor/plugins/rspec/rspec_on_rails). >>> >>> I can see that both of these issues will disappear when the first >>> real >>> release from git happens, but in the meantime I feel a bit stuck. Is >>> there a specific revision of rspec.git (and rspec_on_rails.git) >>> that is >>> actually pretty stable, or is master pretty stable and I could >>> just pick >>> any revision and find it works fine? >> >> Unfortunately you *are* stuck for the moment. We broke up the >> repositories as we did because git doesn't support partial clones >> (i.e. you can't just clone one subdirectory of a repo) the way you >> can checkout subdirectories of a subversion repository. There's no >> way for us to go back and tag the correct commit without you >> grabbing the full repository at that time. >> >> I can tell you that I use the current master with no issues, BUT, >> there have been some changes to internals that might break your >> monkey patches (if you have any). I don't have time to doc them >> right now (part of why there has been no release), but if I were in >> your shoes I'd grab the latest and see what happens. It's an >> inexpensive experiment. >> >> David > > > David, > > Didn't you do git-svn import? Shouldn't the full repository history > be there? I would imagine that you could create a branch for the > last stable release, and revert backwards to the revision (in svn) > in which the last release was tagged. We can do that, but at that revision you get the whole repo - so it would be up to you to then copy the different subdirectories to the right places. > > > As for (git) tags - I see no way to use submodules with tags - Or am > I missing something very obvious? > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From edvard at majakari.net Sat May 10 09:34:15 2008 From: edvard at majakari.net (Edvard Majakari) Date: Sat, 10 May 2008 16:34:15 +0300 Subject: [rspec-users] Newbie: lambda do...end.should change(Model, :count).by(1). Doesn't work In-Reply-To: References: Message-ID: Hi, > def do_verb(params = @params) > post :create, :album => params > end > > it "should change the Albums count by 1 after POST" do > lambda do > @album.should_receive(:save).and_return(true) > do_verb > end.should change(Album, :count).by(1) > end You expect the database count to change, but because you mock away the method :save, the object won't get saved. You don't need to test for Album#count to increase; if the 'save' method is called for the object, you can rest assured there's one more object in the db. And if save doesn't work as it should, the problem isn't in your code but in the ActiveRecord instead. I'm not sure, but I guess that people who make this kind of mistake think that mocking/stubbing a method doesn't prevent the calling of the original method, but it does. The whole idea in mocking is to specify _expectations related to behaviour_. The following (simplified) rule could be stated as follows: if you use mocks, you don't need to (nor should) use state-based assertions, as lambda {...}.should change(Model, :method) does. And vice versa; if you use state to test stuff, you don't use mocks. But as I said, it is an oversimplification. For example, usually you don't want to mock or stub methods to unit/thingy under the test, but you _should_ probably mock/stub methods related to associated classes. That said, some people consider use of mocks dangerous and brittle to changes. I don't - if you have a language terse enough (like Ruby) and an advanced speccing framework (like RSpec), changing your tests to reflect intended changes to code is not a chore too tedious for me. Besides, to ensure at least mediocre test/spec coverage you should automate your integration tests as well, where you don't use mock/stub objects at all (with the exception of very expensive/non-deterministic resources such as say, network and random number generators). As for the other question, I learned BDD by reading the well-documented RSpec site itself and random blog entries related to BDD and Rails. But to really learn BDD well, I'd recommend any newcomer to get acquaintanted with core concepts of BDD first, like unit testing and mocks/stubs. For the former I recommend books related to Test-Driven Development like those by David Astel and Kent Beck, and for the latter articles related to mocking: Fowler's Mocks Aren't Stubs (http://martinfowler.com/articles/mocksArentStubs.html) is an excellent explanation (or a viewpoint; some people don't make such difference between the two) for both mocks and stubs, and the article "Mock Roles, not Objects" (http://www.jmock.org/oopsla2004.pdf) is an invaluable gem in itself -- for me it took two reads to really understand (I hope!) it, though, with more than one year in between (the catch is that the paper appears to be simple; it doesn't contain cryptic formulas or ingenious mathematical proofs, however, I believe it may take a while before the reader really, really understands the subject of the article). -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From cdemyanovich at gmail.com Sat May 10 09:40:16 2008 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Sat, 10 May 2008 09:40:16 -0400 Subject: [rspec-users] Newbie: lambda do...end.should change(Model, :count).by(1). Doesn't work In-Reply-To: References: Message-ID: <61c885db0805100640u139fbb29x835c32cb78953aee@mail.gmail.com> A syntax note from the RSpec docs: "blocks passed to should change and should_not change must use the {} form (do/end is not supported)." http://rspec.info/rdoc/classes/Spec/Matchers.html#M000386 Regards, Craig From rick.denatale at gmail.com Sat May 10 10:28:55 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 10 May 2008 10:28:55 -0400 Subject: [rspec-users] Newbie: lambda do...end.should change(Model, :count).by(1). Doesn't work In-Reply-To: <61c885db0805100640u139fbb29x835c32cb78953aee@mail.gmail.com> References: <61c885db0805100640u139fbb29x835c32cb78953aee@mail.gmail.com> Message-ID: On Sat, May 10, 2008 at 9:40 AM, Craig Demyanovich wrote: > A syntax note from the RSpec docs: "blocks passed to should change and > should_not change must use the {} form (do/end is not supported)." > > http://rspec.info/rdoc/classes/Spec/Matchers.html#M000386 But, I'm pretty sure that this is talking about a block which is passed as an argument to should_change/should_not_change as in this example from the docs: string = "string" lambda { string.reverse }.should change { string }.from("string").to("gnirts") as opposed to: string = "string" lambda { string.reverse }.should change do string end.from("string").to("gnirts") This is because do/end binds less tightly than {} so that in the first (working case) the block is passed to the change method, while in the second one it gets passed to the should method instead. On the other hand: string = "string" lambda do string.reverse end.should change { string }.from("string").to("gnirts") should work, although I prefer the {} syntax in this case. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From lists at ruby-forum.com Sat May 10 11:30:13 2008 From: lists at ruby-forum.com (Wayne Molina) Date: Sat, 10 May 2008 17:30:13 +0200 Subject: [rspec-users] Problems running RSpec from w/in TextMate Message-ID: Hello everyone, I'm new to RSpec, and pretty much Ruby in general. I am trying to run RSpec from within TextMate to get the nice-looking GUI that lists my specs and whatnot. It runs fine from the command line, but when I run it from TextMate, I get the following error (I am working with a Rails application): RubyMate r8136 running Ruby r1.8.6 (/usr/local/bin/ruby) >>> event_spec.rb /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/runner/options.rb:195:in `files_to_load': File or directory not found: [, (RuntimeError) from /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/runner/options.rb:187:in `each' from /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/runner/options.rb:187:in `files_to_load' from /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/runner/options.rb:85:in `run_examples' from /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec.rb:20:in `run' from /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/runner.rb:192:in `register_at_exit_hook' from /Users/waynemolina/work/liberty_truth/spec/models/event_spec.rb:75 RuntimeError: File or directory not found: [, I don't know how to fix this.. I have tried to search Google but I can't find anything that deals with it or how to fix it. I am using RSpec 1.1.3 - this is confirmed via gem list rspec. I've also installed the latest RSpec tmbundle, just to be on the safe side. It's not a big deal, since as I said it works from the command line, but I would rather not switch out of TextMate so I'm really hoping that someone can give me some pointers on how to fix this error, since my own searches are turning up empty. Thanks to anyone who can offer some advice! -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sat May 10 11:41:07 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 10 May 2008 10:41:07 -0500 Subject: [rspec-users] Problems running RSpec from w/in TextMate In-Reply-To: References: Message-ID: <16917D80-9744-4092-9305-20C2F9E192D1@gmail.com> On May 10, 2008, at 10:30 AM, Wayne Molina wrote: > Hello everyone, I'm new to RSpec, and pretty much Ruby in general. > I am > trying to run RSpec from within TextMate to get the nice-looking GUI > that lists my specs and whatnot. It runs fine from the command line, > but when I run it from TextMate, I get the following error (I am > working > with a Rails application): > > > RubyMate r8136 running Ruby r1.8.6 (/usr/local/bin/ruby) >>>> event_spec.rb > > /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/ > runner/options.rb:195:in > `files_to_load': File or directory not found: [, (RuntimeError) > from > /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/ > runner/options.rb:187:in > `each' > from > /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/ > runner/options.rb:187:in > `files_to_load' > from > /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/ > runner/options.rb:85:in > `run_examples' > from > /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/ > spec.rb:20:in > `run' > from > /Users/waynemolina/work/liberty_truth/vendor/plugins/rspec/lib/spec/ > runner.rb:192:in > `register_at_exit_hook' > from > /Users/waynemolina/work/liberty_truth/spec/models/event_spec.rb:75 > > RuntimeError: File or directory not found: [, > > I don't know how to fix this.. I have tried to search Google but I > can't > find anything that deals with it or how to fix it. I am using RSpec > 1.1.3 - this is confirmed via gem list rspec. I've also installed the > latest RSpec tmbundle, just to be on the safe side. Actually, that is on the dangerous side. If you are using rspec 1.1.3, you should use the TextMate bundle from the same release. Try grabbing that and see if it works. http://rspec.rubyforge.org/svn/tags/REL_1_1_3/RSpec.tmbundle/ Cheers, David > > > It's not a big deal, since as I said it works from the command line, > but > I would rather not switch out of TextMate so I'm really hoping that > someone can give me some pointers on how to fix this error, since my > own > searches are turning up empty. > > Thanks to anyone who can offer some advice! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From davids at tower-mt.com Sat May 10 12:59:24 2008 From: davids at tower-mt.com (David Schmidt) Date: Sat, 10 May 2008 09:59:24 -0700 Subject: [rspec-users] Problems running RSpec from w/in TextMate In-Reply-To: References: Message-ID: <60DC8353-7B5C-4A6D-B493-9265C62A11D8@tower-mt.com> I also had problems with running RSpec from within TextMate where sometimes it would work and sometimes it would fail repeatedly and finally found my problem. At the bottom of the TextMate window look at the status line in the second box to see what type of file TextMate has the file set as. If it's not "RSpec" then click on it and change it to "RSpec" and try running the test again. If it's not set to RSpec then it may be trying to just run the file as a Ruby script, which doesn't work from within TextMate. When using the RSpec TextMate bundle the window that opens when you run Command-R should be titled "Run Examples". If it just says "Run" then the file type probably isn't set to RSpec. Hope that helps! David Schmidt On May 10, 2008, at 8:30 AM, Wayne Molina wrote: > Hello everyone, I'm new to RSpec, and pretty much Ruby in general. > I am > trying to run RSpec from within TextMate to get the nice-looking GUI > that lists my specs and whatnot. It runs fine from the command line, > but when I run it from TextMate, I get the following error (I am > working > with a Rails application): > > [...] > > I don't know how to fix this.. I have tried to search Google but I > can't > find anything that deals with it or how to fix it. I am using RSpec > 1.1.3 - this is confirmed via gem list rspec. I've also installed the > latest RSpec tmbundle, just to be on the safe side. > > It's not a big deal, since as I said it works from the command line, > but > I would rather not switch out of TextMate so I'm really hoping that > someone can give me some pointers on how to fix this error, since my > own > searches are turning up empty. > > Thanks to anyone who can offer some advice! From lists at ruby-forum.com Sat May 10 14:03:39 2008 From: lists at ruby-forum.com (Wayne Molina) Date: Sat, 10 May 2008 20:03:39 +0200 Subject: [rspec-users] Problems running RSpec from w/in TextMate In-Reply-To: References: Message-ID: <93794b0de2ad306615ae9d6bce8acd93@ruby-forum.com> Okay the issue seems to have been that it wasn't set to RSpec but Ruby on Rails. Changing it to RSpec seems to fix it... silly me, I guess :) -- Posted via http://www.ruby-forum.com/. From carmine.moleti at gmail.com Sun May 11 11:16:49 2008 From: carmine.moleti at gmail.com (CarmineM) Date: Sun, 11 May 2008 08:16:49 -0700 (PDT) Subject: [rspec-users] Newbie: lambda do...end.should change(Model, :count).by(1). Doesn't work In-Reply-To: References: Message-ID: <3463c6c1-8b37-44cd-9731-843f0715a74f@c65g2000hsa.googlegroups.com> First off, thanks for your help and time and hints! [...snipped some code...] > You expect the database count to change, but because you mock away the > method :save, > the object won't get saved. You don't need to test for Album#count to > increase; if the 'save' method is called > for the object, you can rest assured there's one more object in the > db. And if save doesn't work as it should, the problem > isn't in your code but in the ActiveRecord instead. > I'm not sure, but I guess that people who make this kind of mistake > think that mocking/stubbing a method doesn't > prevent the calling of the original method, but it does. My fault, the code posted was my last (desperate I dare to say) attempt to get the whole thing work. In the first "version", it doesn't have a stub/mock on "save" method, still it didn't worked the way I expected. (Put aside the fact that I shouldn't be testing the ActiveRecord's code, which is a profound truth :) ). In my case I've been fooled by the "should_receive" thing. Being that an expectation, to me, only meant that the system was being checked about that particular event (the call to save) to occur. I didn't pay much attention to the fact that "should_receive(:save).and_..." wasn't only about expectation. I thought that after the expectation being met, the regular "save" method was to be called. That's why I choosed "mock_model" over the regular (and more generic) "mock". > The whole idea in mocking is to specify _expectations related to > behaviour_. The following (simplified) rule could > be stated as follows: if you use mocks, you don't need to (nor should) > use state-based assertions, as > lambda {...}.should change(Model, :method) does. And vice versa; if > you use state to test stuff, you don't use mocks. But as > I said, it is an oversimplification. For example, usually you don't > want to mock or stub methods to unit/thingy under the test, but > you _should_ probably mock/stub methods related to associated classes. > > That said, some people consider use of mocks dangerous and brittle to > changes. I don't - if you have a language terse > enough (like Ruby) and an advanced speccing framework (like RSpec), > changing your tests to reflect intended changes to code > is not a chore too tedious for me. Besides, to ensure at least > mediocre test/spec coverage you should automate your integration tests > as well, where you don't use mock/stub objects at all (with the > exception of very expensive/non-deterministic resources such as say, > network and random number generators). > [...snipped tips on how to learn BDD...] Thanks for the pointers and tips. I will read first Fowler's article and the other you mentioned, then I'll try to see if things get better. BDD is something I can't "afford" to use at work, and so I'm trying at home during "spare time", using my website as a testbed before attempting writing a "real" application. Again, thanks for your help! Regards, Carmine From ben at benmabey.com Sun May 11 17:01:17 2008 From: ben at benmabey.com (Ben Mabey) Date: Sun, 11 May 2008 15:01:17 -0600 Subject: [rspec-users] Are you writing "imperative" or "declarative" scenarios in your stories? Message-ID: <48275E9D.30001@benmabey.com> Hey all, I just found Bryan Helmkamp's (of webrat fame) slides on a presentation he did at GoRuCo 2008: http://www.brynary.com/2008/4/26/story-driven-development-slides-posted On slides 21-24 he talks about writing good stories and shows gives two examples.. the way not to do it and the way to do it. You can also see the video of the presentation at confreaks (http://goruco2008.confreaks.com/01_helmkamp.html -- jump to 13:24 to see where he talks about the two examples.) The first is what he calls an imperative example: ---------------------------------------------------------------------------- Scenario: Reject duplicate names Given I am on the Developers page When I click the Add Developer button Then I should see the Add Developer page When I enter the first name Zed And I enter the last name Shaw And I click the Create Developer button Then I should see the message "Zed was created" And the Developers list should contain Zed Shaw When I enter the first name Zed And I enter the last name Shaw And I click the Create Developer button Then I should see an error "There can be only one Zed Shaw" ---------------------------------------------------------------------------- The second is a declarative example and the same scenario reads like: ---------------------------------------------------------------------------- Scenario: Reject duplicate names Given there is a developer Zed Shaw When I try to add a developer named Zed Shaw Then I should see an error "There can be only one Zed Shaw" ---------------------------------------------------------------------------- Bryan argues that the imperative version is a poor choice because it is too coupled to the implementation; keeping a scenario up to date with future maintenance changes may be a pain when you have to add or remove fields. Additionally, the declarative version removes all of the noise so that the most important features of that story stand out. The imperative version looks like the "detailed scenarios" that David talked about at his ETEC slides (http://blog.davidchelimsky.net/articles/2008/04/01/etec-slides.) On slide #75 David gives a good overview of the pros and cons of this style. The pros mentioned are that they are easier to write and easier to change. While my stories may not read quite as bad as the example presented by Bryan I have been going down more of the imperative/detailed scenario route the majority of the time. I have done this due to the high reuse of steps that it enables. I haven't ran into maintenance issues with them yet but I can understand that point. The more and more I think about it the more I agree with Bryan though. The declarative version does feel a lot better and seems to keep the salient points more prominent. Keeping the stories small, I think, is also more in line with the typical user stories in XP and other agile methodologies. (I would like to see someone stick the first example on a 3x5 card :). ) I did Use Cases (Alistair Cockburn style) on a project several years ago and I remember that revealing anything about the interface or implementation was a big no no. I realize that user stories != use cases so I'm trying to find a balance between UI based stories and more declarative stories that don't reveal the implementation. The funny thing is that I started out doing more declarative stories but my current customer kept wanting to write stories dealing with how the forms worked. It seemed silly to fight the customer on this since the app will always be a web app.. so maybe it is just a balancing act we have to play on a case by case basis? I'm curious what everyone else on this list has been doing in this regard. Are you writing declarative scenarios all the time? Or are you reusing a lot of your steps with detailed scenarios? A little bit of both maybe? If so, how do you decide which type of scenario to use in a given case? Any other thoughts on this matter? Thanks, Ben From philodespotos at gmail.com Sun May 11 18:05:04 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Sun, 11 May 2008 17:05:04 -0500 Subject: [rspec-users] Are you writing "imperative" or "declarative" scenarios in your stories? In-Reply-To: <48275E9D.30001@benmabey.com> References: <48275E9D.30001@benmabey.com> Message-ID: <60f3810c0805111505p6aa0bd47n736cb539bde67530@mail.gmail.com> On Sun, May 11, 2008 at 4:01 PM, Ben Mabey wrote: > I'm curious what everyone else on this list has been doing in this regard. > Are you writing declarative scenarios all the time? Or are you reusing a > lot of your steps with detailed scenarios? A little bit of both maybe? If > so, how do you decide which type of scenario to use in a given case? Any > other thoughts on this matter? When I first started writing stories for rails apps, I primarily used the declarative form, just because they were easier to implement and reusing steps was generally difficult anyhow. It was just the natural style that I'd hit upon when writing them for small projects I used to play with rbehave / the story runner. Once webrat came about, I moved toward the imperative form, with a lot of steps that were just english forms of the webrat helpers ("When I click the link ...", "When I select Foo from the Bar menu", etc). This was really nice, since I was able to write a number of scenarios almost entirely without implementing any steps. Mix in some GivenScenario and you could get fairly detailed paths through the application with minimal effort. But then, I'd come back to a story and have to, god forbid, think about what the meaning was. The story description and scenario name will hint at it, but the meat was tough to pick out of the steps. Too many times, I'd had to sit down with a coworker while we figured out, "why did we write this?" So for the past few months I've come full circle, and I prefer short, high-level scenarios that describe the *feature*, not the particular way it might be performed within the current interface. I don't get to reuse steps as often, but with a few helper methods mixed into Spec::Story::World, it hasn't been an issue. The scenarios themselves are terse and get right to the point. It has made a *big* difference in how useful my stories are as documentation, and maintenance is significantly easier when the UI is tweaked. It hasn't really affected my level of confidence in them serving as tests -- it either fails or it doesn't -- but the other wins have been worth it. That said, some of my scenarios, especially when first tinkering on a new feature, still read like a howto manual for a web browser. "Click this button", "Type XYZ in this field", etc. One or two of those don't bother me, but I move on to more abstract language -- Bryan's "When I add Zed Shaw" -- once it's solid enough to elide the details. Sometimes I go back and edit the initial scenarios, sometimes I don't. Kyle From dchelimsky at gmail.com Sun May 11 18:05:41 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 11 May 2008 17:05:41 -0500 Subject: [rspec-users] Are you writing "imperative" or "declarative" scenarios in your stories? In-Reply-To: <48275E9D.30001@benmabey.com> References: <48275E9D.30001@benmabey.com> Message-ID: On May 11, 2008, at 4:01 PM, Ben Mabey wrote: > Hey all, > I just found Bryan Helmkamp's (of webrat fame) slides on a > presentation he did at GoRuCo 2008: > > http://www.brynary.com/2008/4/26/story-driven-development-slides- > posted > > On slides 21-24 he talks about writing good stories and shows gives > two examples.. the way not to do it and the way to do it. You can > also see the video of the presentation at confreaks (http://goruco2008.confreaks.com/01_helmkamp.html > -- jump to 13:24 to see where he talks about the two examples.) > The first is what he calls an imperative example: > ---------------------------------------------------------------------------- > Scenario: Reject duplicate names > > Given I am on the Developers page > > When I click the Add Developer button > > Then I should see the Add Developer page > > When I enter the first name Zed > And I enter the last name Shaw > And I click the Create Developer button > > Then I should see the message "Zed was created" > And the Developers list should contain Zed Shaw > > When I enter the first name Zed > > And I enter the last name Shaw > And I click the Create Developer button > > Then I should see an error "There can be only one Zed Shaw" > ---------------------------------------------------------------------------- > > The second is a declarative example and the same scenario reads like: > > ---------------------------------------------------------------------------- > Scenario: Reject duplicate names > > Given there is a developer Zed Shaw > > When I try to add a developer named Zed Shaw > > Then I should see an error "There can be only one Zed Shaw" > ---------------------------------------------------------------------------- > Bryan argues that the imperative version is a poor choice because it > is too coupled to the implementation; keeping a scenario up to date > with future maintenance changes may be a pain when you have to add > or remove fields. Additionally, the declarative version removes all > of the noise so that the most important features of that story stand > out. > The imperative version looks like the "detailed scenarios" that > David talked about at his ETEC slides (http://blog.davidchelimsky.net/articles/2008/04/01/etec-slides. > ) On slide #75 David gives a good overview of the pros and cons of > this style. The pros mentioned are that they are easier to write > and easier to change. To be clear - I mean that the step definitions themselves are easier to write and change - not the supported scenarios. In general, I think the overall maintenance cost is higher with this approach. But I don't agree that it is a definitively poor choice. There's another factor to consider here - the human factor. Scenarios have an audience with whom they are trying to communicate something. The appropriate level of granularity is going to be driven in part by the communication needs of the audience. Working with FitNesse, I've encountered some stakeholders who really need to see every field represented and others who are perfectly happy with a more abstract representation. This needs to be accounted for when choosing the appropriate level of granularity. Also, I find that even when there is a need for high levels of granularity in some cases, this doesn't need to happen throughout a suite of scenarios. For example, let's say that I've got an app that has to run in a browser, on the desktop and through a command line interface. I might have three separate scenarios to describe the login process. I might have one scenario that is high level enough that I can let it drive three different sets of step definitions. Regardless, this would only be required for the login scenario. Any other scenario that requires that the user is logged in can simply say something like "Given that I am logged in as Joe Smith" or "Given that I am logged in with the 'administrator' role", etc. > While my stories may not read quite as bad as the example presented > by Bryan I have been going down more of the imperative/detailed > scenario route the majority of the time. I have done this due to > the high reuse of steps that it enables. I haven't ran into > maintenance issues with them yet but I can understand that point. > The more and more I think about it the more I agree with Bryan > though. The declarative version does feel a lot better and seems to > keep the salient points more prominent. Keeping the stories small, > I think, is also more in line with the typical user stories in XP > and other agile methodologies. (I would like to see someone stick > the first example on a 3x5 card :). ) It is not necessary to include the scenarios on the card. What goes on the card is the narrative. > I did Use Cases (Alistair Cockburn style) on a project several years > ago and I remember that revealing anything about the interface or > implementation was a big no no. I realize that user stories != use > cases so I'm trying to find a balance between UI based stories and > more declarative stories that don't reveal the implementation. The > funny thing is that I started out doing more declarative stories but > my current customer kept wanting to write stories dealing with how > the forms worked. Exactly!!!!!! > It seemed silly to fight the customer on this since the app will > always be a web app.. so maybe it is just a balancing act we have to > play on a case by case basis? Exactly!!!!!! > I'm curious what everyone else on this list has been doing in this > regard. Are you writing declarative scenarios all the time? Or are > you reusing a lot of your steps with detailed scenarios? A little > bit of both maybe? If so, how do you decide which type of scenario > to use in a given case? Any other thoughts on this matter? Definitely a little of both. As with all things, there are always pros and cons to be weighed and the key to the craft is having a number of tools at your disposal and the wisdom to understand which tool to pull out when. Cheers, David > Thanks, > Ben From zach.dennis at gmail.com Sun May 11 19:49:31 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 11 May 2008 19:49:31 -0400 Subject: [rspec-users] Are you writing "imperative" or "declarative" scenarios in your stories? In-Reply-To: <48275E9D.30001@benmabey.com> References: <48275E9D.30001@benmabey.com> Message-ID: <85d99afe0805111649p66a638fan90f97c085d5dc60e@mail.gmail.com> On Sun, May 11, 2008 at 5:01 PM, Ben Mabey wrote: > Hey all, > I just found Bryan Helmkamp's (of webrat fame) slides on a presentation he > did at GoRuCo 2008: > > http://www.brynary.com/2008/4/26/story-driven-development-slides-posted > > On slides 21-24 he talks about writing good stories and shows gives two > examples.. the way not to do it and the way to do it. You can also see the > video of the presentation at confreaks ( > http://goruco2008.confreaks.com/01_helmkamp.html -- jump to 13:24 to see > where he talks about the two examples.) The first is what he calls an > imperative example: > > ---------------------------------------------------------------------------- > Scenario: Reject duplicate names > > Given I am on the Developers page > > When I click the Add Developer button > > Then I should see the Add Developer page > > When I enter the first name Zed > And I enter the last name Shaw > And I click the Create Developer button > > Then I should see the message "Zed was created" > And the Developers list should contain Zed Shaw > > When I enter the first name Zed > > And I enter the last name Shaw > And I click the Create Developer button > > Then I should see an error "There can be only one Zed Shaw" > > ---------------------------------------------------------------------------- > > The second is a declarative example and the same scenario reads like: > > > ---------------------------------------------------------------------------- > Scenario: Reject duplicate names > > Given there is a developer Zed Shaw > > When I try to add a developer named Zed Shaw > > Then I should see an error "There can be only one Zed Shaw" > > ---------------------------------------------------------------------------- > > Bryan argues that the imperative version is a poor choice because it is > too coupled to the implementation; keeping a scenario up to date with > future maintenance changes may be a pain when you have to add or remove > fields. Additionally, the declarative version removes all of the noise so > that the most important features of that story stand out. > The imperative version looks like the "detailed scenarios" that David > talked about at his ETEC slides ( > http://blog.davidchelimsky.net/articles/2008/04/01/etec-slides.) On slide > #75 David gives a good overview of the pros and cons of this style. The > pros mentioned are that they are easier to write and easier to change. > > While my stories may not read quite as bad as the example presented by > Bryan I have been going down more of the imperative/detailed scenario route > the majority of the time. I have done this due to the high reuse of steps > that it enables. I haven't ran into maintenance issues with them yet but I > can understand that point. The more and more I think about it the more I > agree with Bryan though. The declarative version does feel a lot better and > seems to keep the salient points more prominent. Keeping the stories small, > I think, is also more in line with the typical user stories in XP and other > agile methodologies. (I would like to see someone stick the first example > on a 3x5 card :). ) > I did Use Cases (Alistair Cockburn style) on a project several years ago > and I remember that revealing anything about the interface or implementation > was a big no no. I realize that user stories != use cases so I'm trying to > find a balance between UI based stories and more declarative stories that > don't reveal the implementation. The funny thing is that I started out > doing more declarative stories but my current customer kept wanting to write > stories dealing with how the forms worked. It seemed silly to fight the > customer on this since the app will always be a web app.. so maybe it is > just a balancing act we have to play on a case by case basis? > > I'm curious what everyone else on this list has been doing in this regard. > Are you writing declarative scenarios all the time? Or are you reusing a > lot of your steps with detailed scenarios? A little bit of both maybe? If > so, how do you decide which type of scenario to use in a given case? Any > other thoughts on this matter? > I've been doing both with more scenarios leaning towards imperative than declarative. I find that my stories tend to be more of a mixture of the imperative/declarative styles mentioned. For example I would have probably written: ---------------------------------------------------------------------------- Scenario: Reject duplicate names Given there is a developer named Zed Shaw in the system And a user at the add a developer page When they enter the first name Zed And they enter the last name Shaw And they click the Create Developer button Then they should see an error "There can be only one Zed Shaw" ------------------------------------------------------------------------------------- I think there are other benefits of going the declarative route as well, such as creating a nicer set of re-usable helper methods sooner. When you have more granular steps it seems there is less pain and discomfort upfront associated with writing less re-usable pieces of code. When you go the declarative route all of your code is pushed together without the granular step boundaries, forcing you to face up and extract out methods which reveal the intent of the step. -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Mon May 12 18:56:10 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 May 2008 16:56:10 -0600 Subject: [rspec-users] Are you writing "imperative" or "declarative" scenarios in your stories? In-Reply-To: References: <48275E9D.30001@benmabey.com> Message-ID: <4828CB0A.5010106@benmabey.com> David Chelimsky wrote: > On May 11, 2008, at 4:01 PM, Ben Mabey wrote: > >> Hey all, >> I just found Bryan Helmkamp's (of webrat fame) slides on a >> presentation he did at GoRuCo 2008: >> >> http://www.brynary.com/2008/4/26/story-driven-development-slides-posted >> >> On slides 21-24 he talks about writing good stories and shows gives >> two examples.. the way not to do it and the way to do it. You can >> also see the video of the presentation at confreaks >> (http://goruco2008.confreaks.com/01_helmkamp.html -- jump to 13:24 to >> see where he talks about the two examples.) The first is what he >> calls an imperative example: >> ---------------------------------------------------------------------------- >> >> Scenario: Reject duplicate names >> >> Given I am on the Developers page >> >> When I click the Add Developer button >> >> Then I should see the Add Developer page >> >> When I enter the first name Zed >> And I enter the last name Shaw >> And I click the Create Developer button >> >> Then I should see the message "Zed was created" >> And the Developers list should contain Zed Shaw >> >> When I enter the first name Zed >> >> And I enter the last name Shaw >> And I click the Create Developer button >> >> Then I should see an error "There can be only one Zed Shaw" >> ---------------------------------------------------------------------------- >> >> >> The second is a declarative example and the same scenario reads like: >> >> ---------------------------------------------------------------------------- >> >> Scenario: Reject duplicate names >> >> Given there is a developer Zed Shaw >> >> When I try to add a developer named Zed Shaw >> >> Then I should see an error "There can be only one Zed Shaw" >> ---------------------------------------------------------------------------- >> >> Bryan argues that the imperative version is a poor choice because it >> is too coupled to the implementation; keeping a scenario up to date >> with future maintenance changes may be a pain when you have to add or >> remove fields. Additionally, the declarative version removes all of >> the noise so that the most important features of that story stand out. >> The imperative version looks like the "detailed scenarios" that David >> talked about at his ETEC slides >> (http://blog.davidchelimsky.net/articles/2008/04/01/etec-slides.) On >> slide #75 David gives a good overview of the pros and cons of this >> style. The pros mentioned are that they are easier to write and >> easier to change. > > To be clear - I mean that the step definitions themselves are easier > to write and change - not the supported scenarios. In general, I think > the overall maintenance cost is higher with this approach. But I don't > agree that it is a definitively poor choice. > > There's another factor to consider here - the human factor. Scenarios > have an audience with whom they are trying to communicate something. > The appropriate level of granularity is going to be driven in part by > the communication needs of the audience. Working with FitNesse, I've > encountered some stakeholders who really need to see every field > represented and others who are perfectly happy with a more abstract > representation. This needs to be accounted for when choosing the > appropriate level of granularity. Great point. Lower level specs (unit tests) are meant for developer use only and I think that is the mentality that I was getting trapped in for the scenarios as well. Instead of considering just our confidence and yearning for a better design the confidence of the customer also needs to be addressed and accounted for. > > Also, I find that even when there is a need for high levels of > granularity in some cases, this doesn't need to happen throughout a > suite of scenarios. For example, let's say that I've got an app that > has to run in a browser, on the desktop and through a command line > interface. I might have three separate scenarios to describe the login > process. I might have one scenario that is high level enough that I > can let it drive three different sets of step definitions. Regardless, > this would only be required for the login scenario. Any other scenario > that requires that the user is logged in can simply say something like > "Given that I am logged in as Joe Smith" or "Given that I am logged in > with the 'administrator' role", etc. > >> While my stories may not read quite as bad as the example presented >> by Bryan I have been going down more of the imperative/detailed >> scenario route the majority of the time. I have done this due to the >> high reuse of steps that it enables. I haven't ran into maintenance >> issues with them yet but I can understand that point. The more and >> more I think about it the more I agree with Bryan though. The >> declarative version does feel a lot better and seems to keep the >> salient points more prominent. Keeping the stories small, I think, >> is also more in line with the typical user stories in XP and other >> agile methodologies. (I would like to see someone stick the first >> example on a 3x5 card :). ) > > It is not necessary to include the scenarios on the card. What goes on > the card is the narrative. Ahh, yes. Thanks for setting me straight on that. > >> I did Use Cases (Alistair Cockburn style) on a project several years >> ago and I remember that revealing anything about the interface or >> implementation was a big no no. I realize that user stories != use >> cases so I'm trying to find a balance between UI based stories and >> more declarative stories that don't reveal the implementation. The >> funny thing is that I started out doing more declarative stories but >> my current customer kept wanting to write stories dealing with how >> the forms worked. > > Exactly!!!!!! > >> It seemed silly to fight the customer on this since the app will >> always be a web app.. so maybe it is just a balancing act we have to >> play on a case by case basis? > > > Exactly!!!!!! > >> I'm curious what everyone else on this list has been doing in this >> regard. Are you writing declarative scenarios all the time? Or are >> you reusing a lot of your steps with detailed scenarios? A little >> bit of both maybe? If so, how do you decide which type of scenario >> to use in a given case? Any other thoughts on this matter? > > Definitely a little of both. As with all things, there are always pros > and cons to be weighed and the key to the craft is having a number of > tools at your disposal and the wisdom to understand which tool to pull > out when. > > Cheers, > David Thanks for your thoughts. This helped me clear things up and confirmed what I was thinking. -Ben From ben at benmabey.com Mon May 12 19:06:21 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 12 May 2008 17:06:21 -0600 Subject: [rspec-users] Are you writing "imperative" or "declarative" scenarios in your stories? In-Reply-To: <60f3810c0805111505p6aa0bd47n736cb539bde67530@mail.gmail.com> References: <48275E9D.30001@benmabey.com> <60f3810c0805111505p6aa0bd47n736cb539bde67530@mail.gmail.com> Message-ID: <4828CD6D.1060604@benmabey.com> Kyle Hargraves wrote: > On Sun, May 11, 2008 at 4:01 PM, Ben Mabey wrote: > >> I'm curious what everyone else on this list has been doing in this regard. >> Are you writing declarative scenarios all the time? Or are you reusing a >> lot of your steps with detailed scenarios? A little bit of both maybe? If >> so, how do you decide which type of scenario to use in a given case? Any >> other thoughts on this matter? >> > > When I first started writing stories for rails apps, I primarily used > the declarative form, just because they were easier to implement and > reusing steps was generally difficult anyhow. It was just the natural > style that I'd hit upon when writing them for small projects I used to > play with rbehave / the story runner. > > Once webrat came about, I moved toward the imperative form, with a lot > of steps that were just english forms of the webrat helpers ("When I > click the link ...", "When I select Foo from the Bar menu", etc). This > was really nice, since I was able to write a number of scenarios > almost entirely without implementing any steps. Mix in some > GivenScenario and you could get fairly detailed paths through the > application with minimal effort. > > But then, I'd come back to a story and have to, god forbid, think > about what the meaning was. The story description and scenario name > will hint at it, but the meat was tough to pick out of the steps. Too > many times, I'd had to sit down with a coworker while we figured out, > "why did we write this?" > > So for the past few months I've come full circle, and I prefer short, > high-level scenarios that describe the *feature*, not the particular > way it might be performed within the current interface. I don't get to > reuse steps as often, but with a few helper methods mixed into > Spec::Story::World, it hasn't been an issue. The scenarios themselves > are terse and get right to the point. > Good point. So, do you just define all your helpers in your helper.rb file or do you monkey patch it in each of the step files? > It has made a *big* difference in how useful my stories are as > documentation, and maintenance is significantly easier when the UI is > tweaked. It hasn't really affected my level of confidence in them > serving as tests -- it either fails or it doesn't -- but the other > wins have been worth it. > > That said, some of my scenarios, especially when first tinkering on a > new feature, still read like a howto manual for a web browser. "Click > this button", "Type XYZ in this field", etc. One or two of those don't > bother me, but I move on to more abstract language -- Bryan's "When I > add Zed Shaw" -- once it's solid enough to elide the details. > Sometimes I go back and edit the initial scenarios, sometimes I don't. > > Kyle > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Thanks for sharing your experience. In your case have you had a customer help writing the scenarios or are you creating them yourself? -Ben From steve.downtown at gmail.com Mon May 12 20:34:30 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Mon, 12 May 2008 17:34:30 -0700 Subject: [rspec-users] Problems running RSpec from w/in TextMate In-Reply-To: <93794b0de2ad306615ae9d6bce8acd93@ruby-forum.com> References: <93794b0de2ad306615ae9d6bce8acd93@ruby-forum.com> Message-ID: <4fff79200805121734r1ff9a54bx209a10fc6e17757@mail.gmail.com> On Sat, May 10, 2008 at 11:03 AM, Wayne Molina wrote: > Okay the issue seems to have been that it wasn't set to RSpec but Ruby > on Rails. Changing it to RSpec seems to fix it... silly me, I guess :) > Same problem (and solution) for me, but ... when I'm in a spec file and switch to RSpec then switch to a non-spec .rb file it says "Ruby". When I switch it to "Ruby on Rails" and then go back to a spec file it says "Ruby on Rails" instead of RSpec. So is there some trick to getting *_spec.rb files to be RSpec and other *.rb files to be Ruby on Rails? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rspec.user at gmail.com Tue May 13 13:24:00 2008 From: rspec.user at gmail.com (sinclair bain) Date: Tue, 13 May 2008 13:24:00 -0400 Subject: [rspec-users] Rspec 1.1.3 +ZenTest 3.9.1= rspec tests not found In-Reply-To: <527fd94446466712fc4136d0cfa1b8c8@ruby-forum.com> References: <527fd94446466712fc4136d0cfa1b8c8@ruby-forum.com> Message-ID: <2ca660dd0805131024j1cc4e879u8beba1758388956d@mail.gmail.com> Hi, I have just been having the same problem on windows using autotest and/or rspec_autotest I have successfully moved to rspec and rspec on rails 1.1.3 ZenTest 3.9.2 So if you were on windows the fix in case you still may need it is here http://rspec.lighthouseapp.com/projects/5645/tickets/80-15670-win32-autotest-colour-script-rspec-win32console-no-output > gem update win32console add a require 'win32console' to the .autotest in your rails app root and you can (re-)enable --colour in your spec/spec.opts file (the cause of the problem) I was having a similar problem on mac leopard but this was using rspec_autotest but i just ditched it and moved to autotest (and today rspactor ). hth sinclair On Fri, Feb 8, 2008 at 6:46 PM, Terry Shuttleworth wrote: > Hi there > > Have upgraded to Rspec 1.1.3 and ZenTest 3.9.1 and have --force > re-installed rspec plugin in the relevant place, but am getting the > following when I run rake spec:autotest > > spec --diff unified test/test_helper.rb > > and not > > spec --diff unified > > Have tried looking in the plugin codes and in the ZenTest gem code, but > I can't find what I need to change to get it to look for my rspec tests > rather than look at test/test_helper.rb > > Have spent the past couple of hours googling around to find an answer, > but to no avail. > > Can anyone please point me in the right direction ? > > Thanks in advance ! > > Terry > > (I know about the "script/spec" edit that I have to make so that the > "spec --diff unified" command works. Have reinstalled rspec this so many > times tonight that I can't remember if I did it in the last > incarnation!) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Cheers! sinclair -------------- next part -------------- An HTML attachment was scrubbed... URL: From helder at gmail.com Tue May 13 18:39:11 2008 From: helder at gmail.com (Helder Ribeiro) Date: Tue, 13 May 2008 19:39:11 -0300 Subject: [rspec-users] Testing that named_scope is defined Message-ID: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> Hi guys, I'm just beginning to use RSpec and I ran into the issue of testing a named_scope. I'm not actually trying to test its behavior, as it's not my code, but I wanted to test at least that it's defined. I tried doing this: describe Post, ".most_recent" do it "should be defined" do Post.method_defined?(:most_recent).should be_true end end But it always fails, even though it *is* defined. Any idea on how to test this? Thanks a lot! Cheers, -- Helder Ribeiro ProFUSION Embedded Systems http://profusion.mobi "If I have not seen as far as others, it is because giants were standing on my shoulders" -- Jeff Goll From jonathan at parkerhill.com Tue May 13 18:53:06 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 13 May 2008 18:53:06 -0400 Subject: [rspec-users] Testing that named_scope is defined In-Reply-To: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> References: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> Message-ID: On May 13, 2008, at 6:39 PM, Helder Ribeiro wrote: > I'm not actually trying to test its behavior, quick! Duck! INCOMING...!!!!! From lists at ruby-forum.com Tue May 13 19:02:17 2008 From: lists at ruby-forum.com (Alf Mikula) Date: Wed, 14 May 2008 01:02:17 +0200 Subject: [rspec-users] rake spec:rcov failing In-Reply-To: <4fff79200804301602g316fdd54o32131db1ec9d8f86@mail.gmail.com> References: <4fff79200804301602g316fdd54o32131db1ec9d8f86@mail.gmail.com> Message-ID: <87abf32c84ad76b263411a3bdd54b8fb@ruby-forum.com> Steve, Did you have any luck with this? I ran into this problem today, with Rcov 0.8.1.2.0, RSpec 1.1.3, and REXML 3.1.7.3. -Alf -- Posted via http://www.ruby-forum.com/. From rick.lee-morlang at justleapin.com Tue May 13 19:48:07 2008 From: rick.lee-morlang at justleapin.com (Rick Lee-Morlang) Date: Tue, 13 May 2008 16:48:07 -0700 Subject: [rspec-users] user stories for load testing? Message-ID: <482A28B7.6040402@justleapin.com> Hi all, We've recently been kicking around different ideas for simulating user behaviour for the purposes of load testing our backend. We hit on the idea of having user stories do double duty for both verifying behaviour and (if selected stories were driven en-masse by a distributed network of clients) for application load testing. I googled around a bit and didn't find anything relevant. Anyone have any thoughts/pointers as to the usefulness and feasibility of this approach, or does anyone have any pointers to complementary tools/plugins? I was imagining something like webrat-over-HTTP and a drb wrapper. Thanks, Rick From steve.downtown at gmail.com Tue May 13 19:53:06 2008 From: steve.downtown at gmail.com (Steve Downey) Date: Tue, 13 May 2008 16:53:06 -0700 Subject: [rspec-users] rake spec:rcov failing In-Reply-To: <87abf32c84ad76b263411a3bdd54b8fb@ruby-forum.com> References: <4fff79200804301602g316fdd54o32131db1ec9d8f86@mail.gmail.com> <87abf32c84ad76b263411a3bdd54b8fb@ruby-forum.com> Message-ID: <4fff79200805131653j13b06bcn5105bae4dc56aab8@mail.gmail.com> I havne't take a look yet, but a couple of points: - I was mistaken in my OP; I'm running REXML 3.1.7.3 - I saw a different post on a related topic that seemed to blame REXML I'd been meaning to go back to an earlier version of REXML and see if that fixed it since I had rcov working on this project a while back and I did upgrade my REXML version at some point. On Tue, May 13, 2008 at 4:02 PM, Alf Mikula wrote: > Steve, > > Did you have any luck with this? I ran into this problem today, with > Rcov 0.8.1.2.0, RSpec 1.1.3, and REXML 3.1.7.3. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Tue May 13 20:20:18 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 13 May 2008 17:20:18 -0700 Subject: [rspec-users] Testing that named_scope is defined In-Reply-To: References: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> Message-ID: <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> On 5/13/08, Jonathan Linowes wrote: > > On May 13, 2008, at 6:39 PM, Helder Ribeiro wrote: > > > I'm not actually trying to test its behavior, > > > quick! Duck! INCOMING...!!!!! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I wonder why OP doesn't create two records, call #most_recent, and verify that the record returned is the one with the larger timestamp. If the code is "not yours" (and I think you ought to clarify what you mean by that), then you should be testing it at a higher level instead of directly. Pat From pergesu at gmail.com Tue May 13 20:25:54 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 13 May 2008 17:25:54 -0700 Subject: [rspec-users] Testing that named_scope is defined In-Reply-To: <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> References: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> Message-ID: <810a540e0805131725yfddfdadk7ab516e50b648381@mail.gmail.com> On 5/13/08, Pat Maddox wrote: > On 5/13/08, Jonathan Linowes wrote: > > > > On May 13, 2008, at 6:39 PM, Helder Ribeiro wrote: > > > > > I'm not actually trying to test its behavior, > > > > > > quick! Duck! INCOMING...!!!!! > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > I wonder why OP doesn't create two records, call #most_recent, and > verify that the record returned is the one with the larger timestamp. > > If the code is "not yours" (and I think you ought to clarify what you > mean by that), then you should be testing it at a higher level instead > of directly. > > Pat > The other answer to your question is that #method_defined looks at the instance methods. To do what you want, you should do Foo.singleton_methods.should include("most_recent") Pat From lists at ruby-forum.com Tue May 13 20:41:06 2008 From: lists at ruby-forum.com (Alf Mikula) Date: Wed, 14 May 2008 02:41:06 +0200 Subject: [rspec-users] rake spec:rcov failing In-Reply-To: <4fff79200805131653j13b06bcn5105bae4dc56aab8@mail.gmail.com> References: <4fff79200804301602g316fdd54o32131db1ec9d8f86@mail.gmail.com> <87abf32c84ad76b263411a3bdd54b8fb@ruby-forum.com> <4fff79200805131653j13b06bcn5105bae4dc56aab8@mail.gmail.com> Message-ID: Wow, ok...I have had other trouble with REXML 3.1.7.3 being too finicky...a few weeks back I found it enforcing declaration of XML namespaces even though it doesn't seem to be actually doing anything with namespaces except refusing to parse if they weren't properly declared. So, I did suspect the REXML version until I saw you were running 3.1.6. :-) I downgraded to 3.1.7 and it's working now! Don't know if it's REXML being buggy or just finicky, but I'm glad to have something working. :-) Thanks, -Alf -- Posted via http://www.ruby-forum.com/. From helder at gmail.com Tue May 13 22:14:00 2008 From: helder at gmail.com (Helder Ribeiro) Date: Tue, 13 May 2008 23:14:00 -0300 Subject: [rspec-users] Testing that named_scope is defined In-Reply-To: <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> References: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> Message-ID: <9bb72e130805131914odb14e9em1be207f57576beeb@mail.gmail.com> On Tue, May 13, 2008 at 9:20 PM, Pat Maddox wrote: > > > I wonder why OP doesn't create two records, call #most_recent, and > verify that the record returned is the one with the larger timestamp. I'm sorry about the confusion here. Your idea sounds indeed better (I'll explain below). > > If the code is "not yours" (and I think you ought to clarify what you > mean by that), then you should be testing it at a higher level instead > of directly. As I said, I'm not very familiar with specs and stuff, and I've read repeatedly on this list and other places that one should only test one's own code. That is, if you declare a has_many association, you shouldn't test that the methods actually return the proper model objects, etc., because that would be testing ActiveRecord. In that same spirit, I thought I shouldn't test that a named_scope does what it's supposed to, only that it is declared (because that one line is all I wrote myself). But I guess I got a bit carried away, as in that declaration there is stuff besides the declaration itself, namely, the bit specifying the order. So it would be better to test for that, rather than just testing if it was declared or not. Thanks a lot for your help :) > > Pat > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Helder Ribeiro ProFUSION Embedded Systems http://profusion.mobi "If I have not seen as far as others, it is because giants were standing on my shoulders" -- Jeff Goll From dchelimsky at gmail.com Tue May 13 22:50:58 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 May 2008 21:50:58 -0500 Subject: [rspec-users] Testing that named_scope is defined In-Reply-To: <9bb72e130805131914odb14e9em1be207f57576beeb@mail.gmail.com> References: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> <9bb72e130805131914odb14e9em1be207f57576beeb@mail.gmail.com> Message-ID: <5966D47A-AB61-4839-AFEF-75B47A3F3243@gmail.com> Oi Helder, On May 13, 2008, at 9:14 PM, Helder Ribeiro wrote: > On Tue, May 13, 2008 at 9:20 PM, Pat Maddox wrote: >> >> >> I wonder why OP doesn't create two records, call #most_recent, and >> verify that the record returned is the one with the larger timestamp. > > I'm sorry about the confusion here. Your idea sounds indeed better > (I'll explain below). > >> >> If the code is "not yours" (and I think you ought to clarify what you >> mean by that), then you should be testing it at a higher level >> instead >> of directly. > > As I said, I'm not very familiar with specs and stuff, and I've read > repeatedly on this list and other places that one should only test > one's own code. That is, if you declare a has_many association, you > shouldn't test that the methods actually return the proper model > objects, etc., because that would be testing ActiveRecord. In that > same spirit, I thought I shouldn't test that a named_scope does what > it's supposed to, only that it is declared (because that one line is > all I wrote myself). You're thinking of this backwards. You are trying to test that you're using a specific method rather than expecting a behaviour. Specs are about behaviour. You're trying to backfill them against implementation. The behaviour you expect is to find the most recent posts, so that's what the example should expect. The fact that you're implementing that (which should happen after you write the example, not before) with named_scope instead of defining a method is an implementation detail. If you decide later that, for whatever reason, you want to change the implementation to a defined method, this example will still pass - or fail if you do the wrong thing. That's the whole point for executable examples. They encourage you to write the code you need and only the code you need, and then later they let you know whether changes you make to implementation preserve the behaviour that you are expecting. That all make sense? Tchau, David ps - eu acho que voc? ? brasileiro ou portugu?s por causa do seu nome - n?? > But I guess I got a bit carried away, as in that declaration there is > stuff besides the declaration itself, namely, the bit specifying the > order. So it would be better to test for that, rather than just > testing if it was declared or not. > > Thanks a lot for your help :) > > >> >> Pat >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Helder Ribeiro > > ProFUSION > Embedded Systems > http://profusion.mobi > > "If I have not seen as far as others, it is because giants were > standing on my shoulders" -- Jeff Goll > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ericw at xmtp.net Wed May 14 02:17:22 2008 From: ericw at xmtp.net (EAW) Date: Wed, 14 May 2008 00:17:22 -0600 Subject: [rspec-users] description method and test failures Message-ID: <4141D304-E34D-47E2-A444-CD486B13CC41@xmtp.net> Hi all, Hoping you can help. I have a project using rspec 1.1.3 and rails 2.0.2. I've run into a small problem. Said project has a method in application_helper.rb named "description". Whenever a spec test fails, I see a message like so: *snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in `description': wrong number of arguments (0 for 2) (ArgumentError) It just so happens that my description method takes 2 arguments. It seems that this method is clashing with one of the methods in rspec. Is there a workaround for this situation? It's a pain to have to rename my method everytime I want to see a proper failure message from rspec. I'm attaching a full backtrace run with --trace. Thanks, e. -- ericw at xmtp.net "If the answer isn't violence, neither is your silence!" -- Pop Will Eat Itself, "Ich Bin Ein Auslander" -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: failure.txt URL: -------------- next part -------------- From dchelimsky at gmail.com Wed May 14 08:44:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 May 2008 07:44:09 -0500 Subject: [rspec-users] description method and test failures In-Reply-To: <4141D304-E34D-47E2-A444-CD486B13CC41@xmtp.net> References: <4141D304-E34D-47E2-A444-CD486B13CC41@xmtp.net> Message-ID: <57c63afe0805140544p501bc18cg2af9b7fd09b1d8fe@mail.gmail.com> On Wed, May 14, 2008 at 1:17 AM, EAW wrote: > Hi all, > > Hoping you can help. I have a project using rspec 1.1.3 and rails 2.0.2. > I've run into a small problem. Said project has a method in > application_helper.rb named "description". Whenever a spec test fails, I > see a message like so: > > *snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in > `description': wrong number of arguments (0 for 2) (ArgumentError) > > It just so happens that my description method takes 2 arguments. It seems > that this method is clashing with one of the methods in rspec. Is there a > workaround for this situation? It's a pain to have to rename my method > everytime I want to see a proper failure message from rspec. > > I'm attaching a full backtrace run with --trace. If the first argument to describe() is a module it gets included in the resulting example group. To avoid this, just make it a String: describe 'MyHelperModule' do ... end In the next release there is a helper object you can use in your helper examples: describe HelperModule do it "should describe something by default" do helper.description.should == "something" end end In some future release, that is the only way it will work as we will no longer include the module in the example group. That might be a way off though. Cheers, David > > Thanks, > > e. > -- > ericw at xmtp.net > > "If the answer isn't violence, neither is your silence!" > -- Pop Will Eat Itself, "Ich Bin Ein Auslander" > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From duelin.markers at gmail.com Wed May 14 09:09:32 2008 From: duelin.markers at gmail.com (John D. Hume) Date: Wed, 14 May 2008 09:09:32 -0400 Subject: [rspec-users] description method and test failures In-Reply-To: <4141D304-E34D-47E2-A444-CD486B13CC41@xmtp.net> References: <4141D304-E34D-47E2-A444-CD486B13CC41@xmtp.net> Message-ID: On Wed, May 14, 2008 at 2:17 AM, EAW wrote: > It seems that this method is clashing with one of the methods in rspec. Is > there a workaround for this situation? It's a pain to have to rename my > method everytime I want to see a proper failure message from rspec. Not to be glib, but you could just rename it one time. :) Seriously though, 'description' is an awfully generically named method to have exposed to every view in your app. Is that the best name for it? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan at brynary.com Wed May 14 13:42:19 2008 From: bryan at brynary.com (Bryan Helmkamp) Date: Wed, 14 May 2008 13:42:19 -0400 Subject: [rspec-users] user stories for load testing? In-Reply-To: <482A28B7.6040402@justleapin.com> References: <482A28B7.6040402@justleapin.com> Message-ID: Hi Rick, We're very interested in doing this at weplay (where I work). I've started refactoring webrat to support pluggable adapters, which I see being Rails, Merb (coming soon), and (most relevant to this) WWW::Mechanize. So far I just have it able to make HTTP requests, but there seem to be some issues. You can see what I've got at: http://github.com/brynary/webrat Would be interested if others are interested in exploring this, what their ideal usage might be, etc. Cheers, -Bryan On Tue, May 13, 2008 at 7:48 PM, Rick Lee-Morlang wrote: > Hi all, > > We've recently been kicking around different ideas for simulating user > behaviour for the purposes of load testing our backend. We hit on the idea > of having user stories do double duty for both verifying behaviour and (if > selected stories were driven en-masse by a distributed network of clients) > for application load testing. > > I googled around a bit and didn't find anything relevant. Anyone have any > thoughts/pointers as to the usefulness and feasibility of this approach, or > does anyone have any pointers to complementary tools/plugins? I was > imagining something like webrat-over-HTTP and a drb wrapper. > > Thanks, > Rick > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Bryan Helmkamp http://brynary.com -- My blog From lists at brynary.com Wed May 14 13:45:04 2008 From: lists at brynary.com (Bryan Helmkamp) Date: Wed, 14 May 2008 13:45:04 -0400 Subject: [rspec-users] Reuse steps like a method call Message-ID: If I have a step matcher defined as so: Given "a user named $username" do |username| .... end Is there a way to call it from another step? For example: Given "a user named $username with a blog post |username| given_a_user_named(username) # calls existing step code # create a blog post end Cheers, -- Bryan Helmkamp http://brynary.com -- My blog From ben at benmabey.com Wed May 14 13:53:29 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 14 May 2008 11:53:29 -0600 Subject: [rspec-users] Reuse steps like a method call In-Reply-To: References: Message-ID: <482B2719.6030000@benmabey.com> Bryan Helmkamp wrote: > If I have a step matcher defined as so: > > Given "a user named $username" do |username| > .... > end > > Is there a way to call it from another step? For example: > > Given "a user named $username with a blog post |username| > given_a_user_named(username) # calls existing step code > # create a blog post > end > > Cheers, > > I'm not sure if you can call a step directly... I would be very interested in that if you can.. But AFAIK the only option is to extract it into a helper method an place it in Spec::Story::World. So you would have: Given "a user named $username" do |username| create_user_with_name(user_name) end Given "a user named $username with a blog post |username| create_user_with_name(user_name) # create a blog post end I typically do things with instance variables though. So the "Given a user named $username" step would set an instance variable named @username. Then I would have a step that reads "$username has a blog post" that would get the instance variable name and it would build a post off of that user. The story would the read like: Given a user named Joey And Joey has a blog post -Ben From dchelimsky at gmail.com Wed May 14 14:24:41 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 May 2008 13:24:41 -0500 Subject: [rspec-users] Reuse steps like a method call In-Reply-To: References: Message-ID: On May 14, 2008, at 12:45 PM, Bryan Helmkamp wrote: > If I have a step matcher defined as so: > > Given "a user named $username" do |username| > .... > end > > Is there a way to call it from another step? For example: > > Given "a user named $username with a blog post |username| > given_a_user_named(username) # calls existing step code > # create a blog post > end I'm pretty sure you can do this: Given "a user named $username with a blog post |username| Given "a user named #{username}" # create a blog post end Cheers, David > > > Cheers, > > -- > Bryan Helmkamp > http://brynary.com -- My blog > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From helder at gmail.com Wed May 14 14:32:37 2008 From: helder at gmail.com (Helder Ribeiro) Date: Wed, 14 May 2008 15:32:37 -0300 Subject: [rspec-users] Testing that named_scope is defined In-Reply-To: <5966D47A-AB61-4839-AFEF-75B47A3F3243@gmail.com> References: <9bb72e130805131539j2603c406o1bd9f1e70e4bddf5@mail.gmail.com> <810a540e0805131720i16e20c1fh700e04547ff7c263@mail.gmail.com> <9bb72e130805131914odb14e9em1be207f57576beeb@mail.gmail.com> <5966D47A-AB61-4839-AFEF-75B47A3F3243@gmail.com> Message-ID: <9bb72e130805141132i1ad461e1ved1cfceacd2db882@mail.gmail.com> On Tue, May 13, 2008 at 11:50 PM, David Chelimsky wrote: > Oi Helder, Opa, beleza? :) > > On May 13, 2008, at 9:14 PM, Helder Ribeiro wrote: > >> On Tue, May 13, 2008 at 9:20 PM, Pat Maddox wrote: >>> >>> >>> I wonder why OP doesn't create two records, call #most_recent, and >>> verify that the record returned is the one with the larger timestamp. >> >> I'm sorry about the confusion here. Your idea sounds indeed better >> (I'll explain below). >> >>> >>> If the code is "not yours" (and I think you ought to clarify what you >>> mean by that), then you should be testing it at a higher level instead >>> of directly. >> >> As I said, I'm not very familiar with specs and stuff, and I've read >> repeatedly on this list and other places that one should only test >> one's own code. That is, if you declare a has_many association, you >> shouldn't test that the methods actually return the proper model >> objects, etc., because that would be testing ActiveRecord. In that >> same spirit, I thought I shouldn't test that a named_scope does what >> it's supposed to, only that it is declared (because that one line is >> all I wrote myself). > > You're thinking of this backwards. You are trying to test that you're using > a specific method rather than expecting a behaviour. Specs are about > behaviour. You're trying to backfill them against implementation. > > The behaviour you expect is to find the most recent posts, so that's what > the example should expect. The fact that you're implementing that (which > should happen after you write the example, not before) with named_scope > instead of defining a method is an implementation detail. If you decide > later that, for whatever reason, you want to change the implementation to a > defined method, this example will still pass - or fail if you do the wrong > thing. That's the whole point for executable examples. They encourage you to > write the code you need and only the code you need, and then later they let > you know whether changes you make to implementation preserve the behaviour > that you are expecting. > > That all make sense? Ok, that made a lot of sense, and for my particular case seems to be the sensible approach. But where do you draw the line? Take the ActiveRecord example. By the same logic you could argue that whatever code you have that uses ActiveRecord should be spec'ed according to its (your code's) expected behavior, regardless of it using ActiveRecord or not under the hood. But then couldn't you end up describing a lot of ActiveRecord's behavior along the way, which would be kinda wasteful, since ActiveRecord is itself pretty well-tested already? > > Tchau, > David > > ps - eu acho que voc? ? brasileiro ou portugu?s por causa do seu nome - n?? > > >> But I guess I got a bit carried away, as in that declaration there is >> stuff besides the declaration itself, namely, the bit specifying the >> order. So it would be better to test for that, rather than just >> testing if it was declared or not. >> >> Thanks a lot for your help :) >> >> >>> >>> Pat >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> Helder Ribeiro >> >> ProFUSION >> Embedded Systems >> http://profusion.mobi >> >> "If I have not seen as far as others, it is because giants were >> standing on my shoulders" -- Jeff Goll >> _______________________________________________ >> 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 > -- Helder Ribeiro ProFUSION Embedded Systems http://profusion.mobi "If I have not seen as far as others, it is because giants were standing on my shoulders" -- Jeff Goll From zach.dennis at gmail.com Wed May 14 16:07:09 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 14 May 2008 16:07:09 -0400 Subject: [rspec-users] Reuse steps like a method call In-Reply-To: References: Message-ID: <85d99afe0805141307j306a1235id7bba28319a703f8@mail.gmail.com> On Wed, May 14, 2008 at 2:24 PM, David Chelimsky wrote: > On May 14, 2008, at 12:45 PM, Bryan Helmkamp wrote: > > If I have a step matcher defined as so: >> >> Given "a user named $username" do |username| >> .... >> end >> >> Is there a way to call it from another step? For example: >> >> Given "a user named $username with a blog post |username| >> given_a_user_named(username) # calls existing step code >> # create a blog post >> end >> > > I'm pretty sure you can do this: > > Given "a user named $username with a blog post |username| > Given "a user named #{username}" > # create a blog post > end > Is this by intention or just a side effect of the current implementation? -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed May 14 16:17:41 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 14 May 2008 15:17:41 -0500 Subject: [rspec-users] Reuse steps like a method call In-Reply-To: <85d99afe0805141307j306a1235id7bba28319a703f8@mail.gmail.com> References: <85d99afe0805141307j306a1235id7bba28319a703f8@mail.gmail.com> Message-ID: <55FDB92E-DD32-4436-BD70-E0A217C75B6C@gmail.com> On May 14, 2008, at 3:07 PM, Zach Dennis wrote: > On Wed, May 14, 2008 at 2:24 PM, David Chelimsky > wrote: > On May 14, 2008, at 12:45 PM, Bryan Helmkamp wrote: > > If I have a step matcher defined as so: > > Given "a user named $username" do |username| > .... > end > > Is there a way to call it from another step? For example: > > Given "a user named $username with a blog post |username| > given_a_user_named(username) # calls existing step code > # create a blog post > end > > I'm pretty sure you can do this: > > > Given "a user named $username with a blog post |username| > Given "a user named #{username}" > # create a blog post > end > > Is this by intention or just a side effect of the current > implementation? You'll have to ask Dan - Dan? > > -- > Zach Dennis > http://www.continuousthinking.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From ericw at xmtp.net Wed May 14 18:06:58 2008 From: ericw at xmtp.net (EAW) Date: Wed, 14 May 2008 16:06:58 -0600 Subject: [rspec-users] description method and test failures In-Reply-To: <57c63afe0805140544p501bc18cg2af9b7fd09b1d8fe@mail.gmail.com> References: <4141D304-E34D-47E2-A444-CD486B13CC41@xmtp.net> <57c63afe0805140544p501bc18cg2af9b7fd09b1d8fe@mail.gmail.com> Message-ID: I followed your advice, with one slight addition. Inside of my describe block I included the ApplicationHelper manually, so that I could call the methods in it. Everything is working fine now. Thanks for your help. e. On May 14, 2008, at 6:44 AM, David Chelimsky wrote: > On Wed, May 14, 2008 at 1:17 AM, EAW wrote: >> Hi all, >> >> Hoping you can help. I have a project using rspec 1.1.3 and rails >> 2.0.2. >> I've run into a small problem. Said project has a method in >> application_helper.rb named "description". Whenever a spec test >> fails, I >> see a message like so: >> >> *snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in >> `description': wrong number of arguments (0 for 2) (ArgumentError) >> >> It just so happens that my description method takes 2 arguments. >> It seems >> that this method is clashing with one of the methods in rspec. Is >> there a >> workaround for this situation? It's a pain to have to rename my >> method >> everytime I want to see a proper failure message from rspec. >> >> I'm attaching a full backtrace run with --trace. > > If the first argument to describe() is a module it gets included in > the resulting example group. To avoid this, just make it a String: > > describe 'MyHelperModule' do > ... > end > > In the next release there is a helper object you can use in your > helper examples: > > describe HelperModule do > it "should describe something by default" do > helper.description.should == "something" > end > end > > In some future release, that is the only way it will work as we will > no longer include the module in the example group. That might be a way > off though. > > Cheers, > David > >> >> Thanks, >> >> e. >> -- >> ericw at xmtp.net >> >> "If the answer isn't violence, neither is your silence!" >> -- Pop Will Eat Itself, "Ich Bin Ein Auslander" >> >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- ericw at xmtp.net "If the answer isn't violence, neither is your silence!" -- Pop Will Eat Itself, "Ich Bin Ein Auslander" From rick.denatale at gmail.com Fri May 16 11:41:54 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 16 May 2008 11:41:54 -0400 Subject: [rspec-users] Which rspec for rails 2.1RC1? Message-ID: I'm working on porting our app. Do I need to upgrade rspec from 1.1.3? If so which version. BTW the installation doc at http://rspec.info/documentation/rails/install.html seems to be stuck in the pre-git days. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From aslak.hellesoy at gmail.com Fri May 16 16:19:26 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 16 May 2008 22:19:26 +0200 Subject: [rspec-users] Which rspec for rails 2.1RC1? In-Reply-To: References: Message-ID: <8d961d900805161319u129dd884j7a99e406b72d18d4@mail.gmail.com> On Fri, May 16, 2008 at 5:41 PM, Rick DeNatale wrote: > I'm working on porting our app. Do I need to upgrade rspec from 1.1.3? > If so which version. > 1.1.3 might work - we're not systematically testing old version against newer versions of Rails. If it doesn't work, try the latest code in Git. > BTW the installation doc at > http://rspec.info/documentation/rails/install.html seems to be stuck > in the pre-git days. > That's because there hasn't been a release since we were on subversion. > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Fri May 16 18:21:29 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 16 May 2008 18:21:29 -0400 Subject: [rspec-users] Which rspec for rails 2.1RC1? In-Reply-To: <8d961d900805161319u129dd884j7a99e406b72d18d4@mail.gmail.com> References: <8d961d900805161319u129dd884j7a99e406b72d18d4@mail.gmail.com> Message-ID: On Fri, May 16, 2008 at 4:19 PM, aslak hellesoy wrote: > On Fri, May 16, 2008 at 5:41 PM, Rick DeNatale wrote: >> BTW the installation doc at >> http://rspec.info/documentation/rails/install.html seems to be stuck >> in the pre-git days. >> > > That's because there hasn't been a release since we were on subversion. True enough, but it talks about getting the edge version as well as releases. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From dchelimsky at gmail.com Fri May 16 21:28:27 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 16 May 2008 21:28:27 -0400 Subject: [rspec-users] Which rspec for rails 2.1RC1? In-Reply-To: References: <8d961d900805161319u129dd884j7a99e406b72d18d4@mail.gmail.com> Message-ID: <98B4B65C-9D6C-453D-926F-8AFE2E949C20@gmail.com> On May 16, 2008, at 6:21 PM, "Rick DeNatale" wrote: > On Fri, May 16, 2008 at 4:19 PM, aslak hellesoy > wrote: >> On Fri, May 16, 2008 at 5:41 PM, Rick DeNatale > > wrote: > >>> BTW the installation doc at >>> http://rspec.info/documentation/rails/install.html seems to be stuck >>> in the pre-git days. >>> >> >> That's because there hasn't been a release since we were on >> subversion. > > True enough, but it talks about getting the edge version as well as > releases. We maintain the website with source, so when we release 1.1.4 we'll update the website. > > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jonathan at parkerhill.com Fri May 16 23:29:03 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Fri, 16 May 2008 23:29:03 -0400 Subject: [rspec-users] test log Message-ID: Is there an easy way to inject each example text into test.log so I can isolate the log output per example? From ben at benmabey.com Sat May 17 01:08:36 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 16 May 2008 23:08:36 -0600 Subject: [rspec-users] test log In-Reply-To: References: Message-ID: <482E6854.2030202@benmabey.com> Jonathan Linowes wrote: > Is there an easy way to inject each example text into test.log so I > can isolate the log output per example? > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users You could create a custom formatter that does that.. although, that probably isn't the answer you wanted to hear. :) Maybe you could try redirecting/appending the regular output to the log file. From lists at carroll.de Sat May 17 13:34:14 2008 From: lists at carroll.de (Jens Carroll) Date: Sat, 17 May 2008 19:34:14 +0200 Subject: [rspec-users] Help needed Message-ID: <482F1716.3020003@carroll.de> Hi All, I am new to rspec and it seems that I don't understand some basics. I need to have a XML import which should parse through XML data and saves all that in various mysql tables. The XML part works just fine and I can test this with rspec. However when I try to execute it "should find country object for DE" do I get an error. @user.country is a one-to-many relation in the user table. It seems easy but I don't get it (hmmmm feels like I am still a newbie). The error I get is: 'XmlImport should find country object for DE' FAILED expected #, got nil (using .equal?) Any help very appreciated. Thanks Jens --- model --- require 'hpricot' class XmlImport #< ActiveRecord::Base attr_reader :doc, :user def parse_xml(file) @doc = Hpricot.XML(open(file)) (@doc/:member).each do |data| retrieve_and_save_user(data) end end def retrieve_and_save_user(data) # email address must be unique for members @user = User.find_or_initialize_by_email(email) # save user if not existing if @user.new_record? @user.country = Country.find_by_short((data/:countryShort).inner_html) end end end ---- spec ------- module XmlImportSpecHelper def mock_xml_import xml_file = RAILS_ROOT + "/spec/fixtures/import-member.xml" xml = File.read(xml_file) @xml_import = XmlImport.new @xml_import.should_receive(:open).exactly(1).times. with("any-file-name.xml"). and_return(xml) end end describe XmlImport do include XmlImportSpecHelper before(:each) do mock_xml_import @xml_import.parse_xml("any-file-name.xml") @country = mock_model(Country) Country.stub!(:find_by_short).and_return(@country) end it "should find country object for DE" do Country.should_receive(:find_by_short).with("DE").and_return(@country) @xml_import.user.country.should equal(@country) end end From jarkko at jlaine.net Sat May 17 14:21:39 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Sat, 17 May 2008 21:21:39 +0300 Subject: [rspec-users] Help needed In-Reply-To: <482F1716.3020003@carroll.de> References: <482F1716.3020003@carroll.de> Message-ID: <1A2A330F-C5A1-47D0-899C-94A4E2579EA3@jlaine.net> Hi Jens, On 17.5.2008, at 20.34, Jens Carroll wrote: > Hi All, > > I am new to rspec and it seems that I don't understand some basics. > I need to have a XML import which should parse through XML data > and saves all that in various mysql tables. The XML part works just > fine and I can test this with rspec. However when I try to execute > > it "should find country object for DE" do > > I get an error. @user.country is a one-to-many relation in the user > table. It seems easy but I don't get it (hmmmm feels like I am still > a newbie). > > The error I get is: > > 'XmlImport should find country object for DE' FAILED > expected #, got nil > (using .equal?) > > > Any help very appreciated. > Thanks > Jens > > --- model --- > > require 'hpricot' > class XmlImport #< ActiveRecord::Base > > attr_reader :doc, :user > > def parse_xml(file) > @doc = Hpricot.XML(open(file)) > > (@doc/:member).each do |data| > retrieve_and_save_user(data) > end > end > > def retrieve_and_save_user(data) > # email address must be unique for members > @user = User.find_or_initialize_by_email(email) > > # save user if not existing > if @user.new_record? > @user.country = > Country.find_by_short((data/:countryShort).inner_html) > end > end > end > > > ---- spec ------- > > module XmlImportSpecHelper > > def mock_xml_import > xml_file = RAILS_ROOT + "/spec/fixtures/import-member.xml" > xml = File.read(xml_file) > > @xml_import = XmlImport.new > @xml_import.should_receive(:open).exactly(1).times. > with("any-file-name.xml"). > and_return(xml) > end > > end > > describe XmlImport do > > include XmlImportSpecHelper > > before(:each) do > mock_xml_import > @xml_import.parse_xml("any-file-name.xml") > > @country = mock_model(Country) > Country.stub!(:find_by_short).and_return(@country) In order to have the above stubbing and mocking work, it must be done *before* you use them in the actual code. It seems to me that parse_xml is where you want to use them. > > end > > it "should find country object for DE" do > > Country.should_receive(:find_by_short).with("DE").and_return(@country) Same here. should_receive must always be defined before you run the code that is expected to do something. In this case, parse_xml and thus Country.find_by_short is run without any stubbing so it will go to the database and probably find nothing. > > @xml_import.user.country.should equal(@country) > end > end > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From ashley.moran at patchspace.co.uk Sun May 18 04:40:23 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 18 May 2008 09:40:23 +0100 Subject: [rspec-users] Help needed In-Reply-To: <482F1716.3020003@carroll.de> References: <482F1716.3020003@carroll.de> Message-ID: On 17 May 2008, at 18:34, Jens Carroll wrote: > Hi All, > > I am new to rspec and it seems that I don't understand some basics. Hi Jens, Jarkko answered your real question but there are other things worth pointing out, more about style than actually making the specs work. > ---- spec ------- > > module XmlImportSpecHelper > > def mock_xml_import > xml_file = RAILS_ROOT + "/spec/fixtures/import-member.xml" > xml = File.read(xml_file) > > @xml_import = XmlImport.new > @xml_import.should_receive(:open).exactly(1).times. > with("any-file-name.xml"). > and_return(xml) > end > > end You shouldn't have (hoho) a should_receive here. You're using the mock_xml_import in the before step, which is intended to set up mocks and stubs shared across the examples ("it" blocks). The code "@xml_import.should_receive(:open)..." should have its own example. Also, since you're creating a *real* XmlImport, it doesn't make sense to call it "mock_xml_import", maybe "new_xml_import" would be clearer. > describe XmlImport do > > include XmlImportSpecHelper > > before(:each) do > mock_xml_import > @xml_import.parse_xml("any-file-name.xml") > > @country = mock_model(Country) > Country.stub!(:find_by_short).and_return(@country) > end > > it "should find country object for DE" do > > Country.should_receive(:find_by_short).with("DE").and_return(@country) > @xml_import.user.country.should equal(@country) > end > end Be clear what you are specifying here. Your call to #parse_xml is in the before block, which means you can't set expectations on it. I like to nest my methods in their own inner describe blocks, eg: describe XmlImport do before(:each) do @xml_import = XmlImport.new end describe "#parse_xml" do it "should open the XML file" do # ... end it "should find country object for DE" do # ... end end end Be aware also that while "xml_import.should_receive(:open)" may work, it's a bit of a quirk of Ruby. The real method is define on the Kernel module, which is included into Object (so you get access to it everywhere). Since you know you're dealing with files, I'd use File.open, and specify that File.should_receive(:open) instead. Otherwise you may start thinking it's ok to specify interpendencies between methods in the class being specified. Finally, this line: > @xml_import.user.country.should equal(@country) is known as a trainwreck- that is, multiple method calls strung together. It's usually a sign that something is modelled wrong. In this case, it's because your XmlParser class is doing too much. This section > (@doc/:member).each do |data| > retrieve_and_save_user(data) > end Is the culprit. The XmlParser should parse XML, not retrieve and save user data (I know this, because it's called XmlParser, not UserDataRetrieverAndSaver, basically.) A more OO approach would be to make User responsible for this: (@doc/:member).each do |data| User.update_from_xml(data) end That way, the spec for User#update_from_xml would have one less level of indirection, ie just @user.country.should equal(@country) Hope this is useful, Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Sun May 18 05:13:03 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 18 May 2008 10:13:03 +0100 Subject: [rspec-users] Using Hash to mock classes that respond to :[] Message-ID: <66828B9F-1739-4057-A15D-FFC5CCDFC88D@patchspace.co.uk> Hi I've been doing this a while now. If I have a class that responds to : [], and all I'm interested in stubbing is that method, then instead of using a mock I just create a hash. (Similarly, you could create an array when you are testing an Enumerable object.) Example from code I just worked on, where uses MigrationGraph#[] looks up graph vertices by name: @migration_graph = { # "name" => vertex "changeset 1 migration 1" => @migration_a, "changeset 1 migration 2" => @migration_b, "changeset 2 migration 1" => @migration_c, "changeset 2 migration 2" => @migration_d } What I'm really interested in is what happens to (some of) the four migrations, not the migration graph itself. I just wondered if anyone else did this. Generally doing unusual things is a sign something is amiss. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at carroll.de Sun May 18 13:28:25 2008 From: lists at carroll.de (Jens Carroll) Date: Sun, 18 May 2008 19:28:25 +0200 Subject: [rspec-users] Help needed In-Reply-To: References: <482F1716.3020003@carroll.de> Message-ID: <48306739.3020509@carroll.de> Ashley Moran schrieb: > On 17 May 2008, at 18:34, Jens Carroll wrote: >> Hi All, >> >> I am new to rspec and it seems that I don't understand some basics. > > Hi Jens, > > Jarkko answered your real question but there are other things worth > pointing out, more about style than actually making the specs work. > > >> ---- spec ------- >> >> module XmlImportSpecHelper >> >> def mock_xml_import >> xml_file = RAILS_ROOT + "/spec/fixtures/import-member.xml" >> xml = File.read(xml_file) >> >> @xml_import = XmlImport.new >> @xml_import.should_receive(:open).exactly(1).times. >> with("any-file-name.xml"). >> and_return(xml) >> end >> >> end > > You shouldn't have (hoho) a should_receive here. You're using the > mock_xml_import in the before step, which is intended to set up mocks > and stubs shared across the examples ("it" blocks). The code > "@xml_import.should_receive(:open)..." should have its own example. > > Also, since you're creating a *real* XmlImport, it doesn't make sense > to call it "mock_xml_import", maybe "new_xml_import" would be clearer. > > >> describe XmlImport do >> >> include XmlImportSpecHelper >> >> before(:each) do >> mock_xml_import >> @xml_import.parse_xml("any-file-name.xml") >> >> @country = mock_model(Country) >> Country.stub!(:find_by_short).and_return(@country) >> end >> >> it "should find country object for DE" do >> >> Country.should_receive(:find_by_short).with("DE").and_return(@country) >> @xml_import.user.country.should equal(@country) >> end >> end > > Be clear what you are specifying here. Your call to #parse_xml is in > the before block, which means you can't set expectations on it. I > like to nest my methods in their own inner describe blocks, eg: > > describe XmlImport do > before(:each) do > @xml_import = XmlImport.new > end > > describe "#parse_xml" do > it "should open the XML file" do > # ... > end > > it "should find country object for DE" do > # ... > end > end > end > > Be aware also that while "xml_import.should_receive(:open)" may work, > it's a bit of a quirk of Ruby. The real method is define on the > Kernel module, which is included into Object (so you get access to it > everywhere). Since you know you're dealing with files, I'd use > File.open, and specify that File.should_receive(:open) instead. > Otherwise you may start thinking it's ok to specify interpendencies > between methods in the class being specified. > > Finally, this line: > >> @xml_import.user.country.should equal(@country) > > > is known as a trainwreck- that is, multiple method calls strung > together. It's usually a sign that something is modelled wrong. In > this case, it's because your XmlParser class is doing too much. > > This section > >> (@doc/:member).each do |data| >> retrieve_and_save_user(data) >> end > > > Is the culprit. The XmlParser should parse XML, not retrieve and save > user data (I know this, because it's called XmlParser, not > UserDataRetrieverAndSaver, basically.) A more OO approach would be to > make User responsible for this: > > (@doc/:member).each do |data| > User.update_from_xml(data) > end > > That way, the spec for User#update_from_xml would have one less level > of indirection, ie just > > @user.country.should equal(@country) > > Hope this is useful, > Ashley > > Hi Ashley, Your hints are most appreciated. Wow looks like I have to change quite a bit. I was not aware that "@xml_import.user.country.should equal(@country)" is already a trainwreck. I think I have even longer ones - refactoring might be the magic word for my code now. Every hint was really useful for me. Thanks a million for taking the time to analyze my code. Have a nice day Jens From lists at carroll.de Sun May 18 13:29:12 2008 From: lists at carroll.de (Jens Carroll) Date: Sun, 18 May 2008 19:29:12 +0200 Subject: [rspec-users] Help needed In-Reply-To: <1A2A330F-C5A1-47D0-899C-94A4E2579EA3@jlaine.net> References: <482F1716.3020003@carroll.de> <1A2A330F-C5A1-47D0-899C-94A4E2579EA3@jlaine.net> Message-ID: <48306768.6000802@carroll.de> Jarkko Laine schrieb: > Hi Jens, > > On 17.5.2008, at 20.34, Jens Carroll wrote: > >> Hi All, >> >> I am new to rspec and it seems that I don't understand some basics. >> I need to have a XML import which should parse through XML data >> and saves all that in various mysql tables. The XML part works just >> fine and I can test this with rspec. However when I try to execute >> >> it "should find country object for DE" do >> >> I get an error. @user.country is a one-to-many relation in the user >> table. It seems easy but I don't get it (hmmmm feels like I am still >> a newbie). >> >> The error I get is: >> >> 'XmlImport should find country object for DE' FAILED >> expected #, got nil >> (using .equal?) >> >> >> Any help very appreciated. >> Thanks >> Jens >> >> --- model --- >> >> require 'hpricot' >> class XmlImport #< ActiveRecord::Base >> >> attr_reader :doc, :user >> >> def parse_xml(file) >> @doc = Hpricot.XML(open(file)) >> >> (@doc/:member).each do |data| >> retrieve_and_save_user(data) >> end >> end >> >> def retrieve_and_save_user(data) >> # email address must be unique for members >> @user = User.find_or_initialize_by_email(email) >> >> # save user if not existing >> if @user.new_record? >> @user.country = >> Country.find_by_short((data/:countryShort).inner_html) >> end >> end >> end >> >> >> ---- spec ------- >> >> module XmlImportSpecHelper >> >> def mock_xml_import >> xml_file = RAILS_ROOT + "/spec/fixtures/import-member.xml" >> xml = File.read(xml_file) >> >> @xml_import = XmlImport.new >> @xml_import.should_receive(:open).exactly(1).times. >> with("any-file-name.xml"). >> and_return(xml) >> end >> >> end >> >> describe XmlImport do >> >> include XmlImportSpecHelper >> >> before(:each) do >> mock_xml_import >> @xml_import.parse_xml("any-file-name.xml") >> >> @country = mock_model(Country) >> Country.stub!(:find_by_short).and_return(@country) > > In order to have the above stubbing and mocking work, it must be done > *before* you use them in the actual code. It seems to me that > parse_xml is where you want to use them. > >> >> end >> >> it "should find country object for DE" do >> >> Country.should_receive(:find_by_short).with("DE").and_return(@country) > > Same here. should_receive must always be defined before you run the > code that is expected to do something. In this case, parse_xml and > thus Country.find_by_short is run without any stubbing so it will go > to the database and probably find nothing. > >> >> @xml_import.user.country.should equal(@country) >> end >> end >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hi Jarkko, Thanks a lot. The next time when I get a nil object I'd better ask myself if the mocking and stubbing has been before the actual code. The real problem was that my whole rspec test got quite big. I need to break it down in smaller pieces not to lose the overview. Have a nice day Jens From ashley.moran at patchspace.co.uk Sun May 18 14:23:14 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 18 May 2008 19:23:14 +0100 Subject: [rspec-users] Help needed In-Reply-To: <48306739.3020509@carroll.de> References: <482F1716.3020003@carroll.de> <48306739.3020509@carroll.de> Message-ID: <7C73B79C-BD5E-4D43-932C-16D29F71DFD8@patchspace.co.uk> On 18 May 2008, at 18:28, Jens Carroll wrote: > I was not aware that "@xml_import.user.country.should > equal(@country)" is already > a trainwreck. I think I have even longer ones - refactoring might be > the magic > word for my code now. Well I guess it's more the wrong sort of leaves on the line :) It's not so much the length of the line that's the problem, that's just a code smell. The real issue is that it makes more sense for the user (domain model) to update itself off the XML, rather than have an XML parser (utility class) go poking around inside the user. Having had a second look at it, I'd be inclined to say that XmlImport#parse_xml should really be a class method of User (something like User.import_all_from_xml). The only bit of this method that isn't domain logic is the line @doc = Hpricot.XML(open(file)) which should probably be in the controller, or wherever this code gets called. You don't want the domain logic depending on filesystem technicalities and more than the utility code fiddling with the model. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Sun May 18 14:47:43 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 18 May 2008 19:47:43 +0100 Subject: [rspec-users] Spec a before_destroy callback in Sequel Message-ID: Hi I'm struggling to find a neat way to spec this. The Sequel ORM doesn't support automatically destroying dependent models. It's easy enough to do in a callback though: class Changeset < Sequel::Model has_many :migrations, :class => DataModel::Migration before_destroy do migrations.each { |m| m.destroy } end # ... end The problem is isolating it from the database to test. I want to know that when I send Changeset#destroy that each migration is destroyed. The implementation of Sequel::Model#destroy (from the RDoc) is this: # File sequel/lib/sequel_model/record.rb, line 325 325: def destroy 326: db.transaction do 327: before_destroy 328: delete 329: after_destroy 330: end 331: self 332: end Now, if a database isn't wired up, Sequel complains if you do anything database related, and that includes using associations. So the best I have so far is this: describe "#destroy" do before(:each) do # ... @changeset = DataModel::Changeset.new end it "should fire a before_destroy hook to destroy all Migrations" do class << @changeset def destroy before_destroy end end @changeset.stub!(:migrations).and_return( [@migration_1, @migration_2]) @migration_1.should_receive(:destroy) @migration_2.should_receive(:destroy) @changeset.destroy end end So I've committed these sins: * redefined someone else's code, when I depend on the real version at runtime * included an assumption about the external code in my stub * stubbed out a method on the object under test In sort, it's suckitude of the highest order. But I don't know how to do this without resorting to an in-memory SQLite database or something. Any help much appreciated. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From duelin.markers at gmail.com Mon May 19 12:57:53 2008 From: duelin.markers at gmail.com (John D. Hume) Date: Mon, 19 May 2008 12:57:53 -0400 Subject: [rspec-users] Using Hash to mock classes that respond to :[] In-Reply-To: <66828B9F-1739-4057-A15D-FFC5CCDFC88D@patchspace.co.uk> References: <66828B9F-1739-4057-A15D-FFC5CCDFC88D@patchspace.co.uk> Message-ID: I do that sort of thing pretty often. I would just point out that you should avoid calling that mocking, since there are no expectations in place and therefore no verification of the specific way the code being specified interacts with the MigrationGraph. According to the definitions in http://martinfowler.com/articles/mocksArentStubs.html (which are apparently from http://xunitpatterns.com/ but I haven't read it), your hash is a 'fake' MigrationGraph. -hume. On Sun, May 18, 2008 at 5:13 AM, Ashley Moran wrote: > Hi > > I've been doing this a while now. If I have a class that responds to :[], > and all I'm interested in stubbing is that method, then instead of using a > mock I just create a hash. (Similarly, you could create an array when you > are testing an Enumerable object.) > > Example from code I just worked on, where uses MigrationGraph#[] looks up > graph vertices by name: > > @migration_graph = { > # "name" => vertex > "changeset 1 migration 1" => @migration_a, > "changeset 1 migration 2" => @migration_b, > "changeset 2 migration 1" => @migration_c, > "changeset 2 migration 2" => @migration_d > } > > What I'm really interested in is what happens to (some of) the four > migrations, not the migration graph itself. > > I just wondered if anyone else did this. Generally doing unusual things is > a sign something is amiss. > > Ashley > > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From address4spams at 21croissants.com Mon May 19 13:21:16 2008 From: address4spams at 21croissants.com (21croissants) Date: Mon, 19 May 2008 10:21:16 -0700 (PDT) Subject: [rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher In-Reply-To: <8F1B2463-E06D-41B7-973A-AE54FA66BAF5@patchspace.co.uk> References: <16965619.post@talk.nabble.com> <71E6913D-A330-4FC8-BB81-6F6B310266CC@patchspace.co.uk> <16993286.post@talk.nabble.com> <8F1B2463-E06D-41B7-973A-AE54FA66BAF5@patchspace.co.uk> Message-ID: <17323753.post@talk.nabble.com> Ashley, I ran the DRY reporter on Rails 2.0.2 and you'll find the results on http://www.21croissants.com/files/rails_2_0_2_DRY_report.html I have done a lot of refactoring lately (but did not changed the external API) and will commit my code soon ... Ashley Moran-4 wrote: > > > > Just out of curiosity, have you run your DRY reporter against the > Rails code itself? Might be interesting to see the results... > > Ashley > > -- View this message in context: http://www.nabble.com/Sharing%3A-dont_repeat_yourself-plugin%2C-will-report-duplicate-lines-in-your-code%21-tp16965619p17323753.html Sent from the rspec-users mailing list archive at Nabble.com. From ashley.moran at patchspace.co.uk Mon May 19 15:50:59 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Mon, 19 May 2008 20:50:59 +0100 Subject: [rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher In-Reply-To: <17323753.post@talk.nabble.com> References: <16965619.post@talk.nabble.com> <71E6913D-A330-4FC8-BB81-6F6B310266CC@patchspace.co.uk> <16993286.post@talk.nabble.com> <8F1B2463-E06D-41B7-973A-AE54FA66BAF5@patchspace.co.uk> <17323753.post@talk.nabble.com> Message-ID: <00C2FD98-E0A7-426E-98E8-B405103C5AF9@patchspace.co.uk> On 19 May 2008, at 18:21, 21croissants wrote: > Ashley, I ran the DRY reporter on Rails 2.0.2 and you'll find the > results on > http://www.21croissants.com/files/rails_2_0_2_DRY_report.html Wow, that's really interesting. Some things are trivial mini-methods, eg "def to_param; to_s; end". But there are some huge chunks of complex logic in there! I wonder how so much duplication got in there, and if some of it is justified? > I have done a lot of refactoring lately (but did not changed the > external > API) and will commit my code soon ... Cool. Is it still a Rails plugin or can you run it on standalone code? It'd make a great gem with a binary. Be sure to post when you commit! Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Mon May 19 17:01:08 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Mon, 19 May 2008 22:01:08 +0100 Subject: [rspec-users] Using Hash to mock classes that respond to :[] In-Reply-To: References: <66828B9F-1739-4057-A15D-FFC5CCDFC88D@patchspace.co.uk> Message-ID: <6689D59A-C136-4A56-AB64-9E763F3E3A66@patchspace.co.uk> On 19 May 2008, at 17:57, John D. Hume wrote: > I do that sort of thing pretty often. > > I would just point out that you should avoid calling that mocking, > since there are no expectations in place and therefore no > verification of the specific way the code being specified interacts > with the MigrationGraph. According to the definitions in http://martinfowler.com/articles/mocksArentStubs.html(which > are apparently from http://xunitpatterns.com/ but I haven't read > it), your hash is a 'fake' MigrationGraph. I hope you will forgive my sloppy use of TDD terms :) Actually I've never liked the use of the word "mock" to mean "verified stub" or something similar, as "mock" and "fake" are synonyms in everyday English. Maybe that's because in RSpec you can create expectations on any object (blank mocks or arbitrary other objects). After all consider these two snippets (which is condensed from how you would write real code): @store = mock("store") @store.stub!(:[]).and_return(1, 2) # implies you know the order of calls @store.should_receive(:[]).with("a").and_return(1) @store.should_receive(:[]).with("b").and_return(2) @store = { "a" => 1, "b" => 2 } @store.should_receive(:[]).with("a").and_return(1) @store.should_receive(:[]).with("b").and_return(2) Only one is a mock by definition, but most sane code (and specs) would behave the same with either. Surely since they both quack, they are both ducks? As for the terms in the Fowler article, this is how I feel: * Dummy - I'm ok with this, I use symbols as dummies all the time * Fake - an "in-memory database" isn't fake, it's just an implementation that satisfies the needs of the code at hand (ie the spec). You could say a single-server database is fake, if a load- balanced cluster is needed to satisfy availability requirements. * Stubs - I think of a stub as a message-level concept, not an object- level one. To me, an object with stubs could be called a "fake" since it could never be used for a real purpose, no matter how simple the real task. * Mocks - in RSpec these are just objects that complain if sent an unexpected message. They become fake (my sense of the word) objects when you stub responses on them, although I prefer to call them mocks. Alternative words that might make more sense in a duck-typed language are "substitute" instead of "fake" (that's what the use of a Hash about would be) and "mock" instead of "stub". I don't know what you'd call a Fowler mock in that case - maybe the idea doesn't make sense when any object can have expectations. I also don't know what you'd call a partial mock - an aberration, perhaps? :) I'm sure this is all nit-picking, but it's taken me two years to learn the "official" words and they still feel unnatural (which is why I always fall back to my own version). End rant! Ashley PS I think my use of a substitute Hash above is actually a symptom of violation Tell Don't Ask, I should probably pass the names of the migrations to the MigrationGraph and have *it* unapply them all. That would also clean up some other really hideous code in the Apply class where #run goes poking around deleting stuff inside the graph (it's a did-I-really-write that moment). I wish I had the foresight to do things right in the first place! -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From rspec at kluger.com Mon May 19 20:01:35 2008 From: rspec at kluger.com (Larry Kluger) Date: Mon, 19 May 2008 17:01:35 -0700 (PDT) Subject: [rspec-users] rspec fails at first run -- no such file to load -- spec/rails Message-ID: <264250.90873.qm@web30802.mail.mud.yahoo.com> Hi, I newly downloaded rspec, rspec_on_rails and ran the command ruby script/generate rspec from the instructions http://rspec.info/documentation/rails/install.html I then created the directories in spec: controllers, fixtures, helpers, models, views I then created the file spec/models/user_spec.rb as a spec for my model User. (Is the convention to name the model's spec user.rb ?? ) The docs give both examples on different pages of the wiki. Anyhow, my problem: I run rake spec and get /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- spec/rails (MissingSourceFile) The file /spec/spec_helper.rb contains the line require 'spec/rails' Using the response to a similar q/a I found on the net, I also tried ruby script/spec spec Same result. Pointers would be most appreciated. Thanks, Larry ps. I URGE the powers-that-be to update the installation instructions. This type of problem dramatically slows down adoption of an otherwise great projec -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon May 19 20:11:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 19 May 2008 19:11:18 -0500 Subject: [rspec-users] rspec fails at first run -- no such file to load -- spec/rails In-Reply-To: <264250.90873.qm@web30802.mail.mud.yahoo.com> References: <264250.90873.qm@web30802.mail.mud.yahoo.com> Message-ID: <8436CB86-364A-4F25-9010-90CC2CF01992@gmail.com> On May 19, 2008, at 7:01 PM, Larry Kluger wrote: > Hi, > > I newly downloaded rspec, rspec_on_rails and ran the command > ruby script/generate rspec > from the instructions http://rspec.info/documentation/rails/install.html > > I then created the directories in spec: > controllers, fixtures, helpers, models, views > > I then created the file spec/models/user_spec.rb as a spec for my > model User. > (Is the convention to name the model's spec user.rb ?? ) The > docs give both examples on different pages of the wiki. > > Anyhow, my problem: > I run rake spec > and get > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- spec/rails > (MissingSourceFile) > > The file /spec/spec_helper.rb contains the line > require 'spec/rails' > > Using the response to a similar q/a I found on the net, I also tried > ruby script/spec spec > Same result. What version of rails are you using? > > > Pointers would be most appreciated. > > Thanks, > > Larry > > ps. I URGE the powers-that-be to update the installation > instructions. This type of problem dramatically slows down adoption > of an otherwise great projec > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From rspec at kluger.com Mon May 19 21:44:22 2008 From: rspec at kluger.com (Larry Kluger) Date: Mon, 19 May 2008 18:44:22 -0700 (PDT) Subject: [rspec-users] rspec fails at first run -- no such file to load -- spec/rails Message-ID: <227807.25041.qm@web30804.mail.mud.yahoo.com> Re: What version of rails are you using? Rails 1.2.3 (I'm using an intermediate version of Hobo which is not ready for 2.0) Regards, Larry -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue May 20 06:50:41 2008 From: lists at ruby-forum.com (Doug Livesey) Date: Tue, 20 May 2008 12:50:41 +0200 Subject: [rspec-users] mock_model not stubbing model attribtues in view spec Message-ID: <7a84a8c278979ca37a54d6f29056718b@ruby-forum.com> Hi -- I am just getting to grips w/ view specs, and am having an issue with mock_model not stubbing the mocked model's attributes. For instance, I have the following: before do @input_timesheet = mock_model( InputTimesheet ) assigns[:input_timesheet] = @input_timesheet end it "should display a table element" do render '/input_timesheets/edit.rhtml_spec.rb' response.should have_tag( 'table' ) end Obviously, the view calls for a number of attributes from the @input_timesheet, but unless I explicitly define these in the mock_model method, I get the following kind of error: ActionView::TemplateError in '/input_timesheets/edit.rhtml should display expected InputTimesheet details' Mock 'InputTimesheet_1000' received unexpected message :comments with (no args) Can anyone offer any advice as to why this should be? (Maybe it's supposed to be like this for views?) Cheers, Doug. -- Posted via http://www.ruby-forum.com/. From ashley.moran at patchspace.co.uk Tue May 20 07:26:00 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 20 May 2008 12:26:00 +0100 Subject: [rspec-users] mock_model not stubbing model attribtues in view spec In-Reply-To: <7a84a8c278979ca37a54d6f29056718b@ruby-forum.com> References: <7a84a8c278979ca37a54d6f29056718b@ruby-forum.com> Message-ID: <857286BD-1613-4837-BD80-D0698787FF49@patchspace.co.uk> On 20 May 2008, at 11:50, Doug Livesey wrote: > Obviously, the view calls for a number of attributes from the > @input_timesheet, but unless I explicitly define these in the > mock_model > method, I get the following kind of error: I'm puzzled, I thought you always had to stub methods on a mock from mock_model? I don't remember the default behaviour ever being to ignore unknown messages? Sorry, guess this is not a helpful post, I just wanted to know how it behaves for you normally. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From jarkko at jlaine.net Tue May 20 07:32:54 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 20 May 2008 14:32:54 +0300 Subject: [rspec-users] mock_model not stubbing model attribtues in view spec In-Reply-To: <857286BD-1613-4837-BD80-D0698787FF49@patchspace.co.uk> References: <7a84a8c278979ca37a54d6f29056718b@ruby-forum.com> <857286BD-1613-4837-BD80-D0698787FF49@patchspace.co.uk> Message-ID: On 20.5.2008, at 14.26, Ashley Moran wrote: > > On 20 May 2008, at 11:50, Doug Livesey wrote: > >> Obviously, the view calls for a number of attributes from the >> @input_timesheet, but unless I explicitly define these in the >> mock_model >> method, I get the following kind of error: > > > I'm puzzled, I thought you always had to stub methods on a mock from > mock_model? I don't remember the default behaviour ever being to > ignore unknown messages? > > Sorry, guess this is not a helpful post, I just wanted to know how > it behaves for you normally. mock_model doesn't stub any methods automatically, and it doesn't matter whether you're in view, model or controller specs. If you need the attributes and don't want to specify anything by hand, stub_model might work for you. It basically creates a real AR object, with its db connections cut. //jarkko > > > Ashley > > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From dchelimsky at gmail.com Tue May 20 07:35:44 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 May 2008 06:35:44 -0500 Subject: [rspec-users] mock_model not stubbing model attribtues in view spec In-Reply-To: References: <7a84a8c278979ca37a54d6f29056718b@ruby-forum.com> <857286BD-1613-4837-BD80-D0698787FF49@patchspace.co.uk> Message-ID: On May 20, 2008, at 6:32 AM, Jarkko Laine wrote: > > On 20.5.2008, at 14.26, Ashley Moran wrote: > >> >> On 20 May 2008, at 11:50, Doug Livesey wrote: >> >>> Obviously, the view calls for a number of attributes from the >>> @input_timesheet, but unless I explicitly define these in the >>> mock_model >>> method, I get the following kind of error: >> >> >> I'm puzzled, I thought you always had to stub methods on a mock >> from mock_model? I don't remember the default behaviour ever being >> to ignore unknown messages? >> >> Sorry, guess this is not a helpful post, I just wanted to know how >> it behaves for you normally. > > mock_model doesn't stub any methods automatically, and it doesn't > matter whether you're in view, model or controller specs. If you > need the attributes and don't want to specify anything by hand, > stub_model might work for you. It basically creates a real AR > object, with its db connections cut. FYI - this is only in git right now: http://github.com/dchelimsky/rspec http://github.com/dchelimsky/rspec-rails git://github.com/dchelimsky/rspec.git git://github.com/dchelimsky/rspec-rails.git Cheers, David > > > //jarkko > >> >> >> Ashley >> >> >> -- >> http://www.patchspace.co.uk/ >> http://aviewfromafar.net/ >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue May 20 09:17:43 2008 From: lists at ruby-forum.com (Doug Livesey) Date: Tue, 20 May 2008 15:17:43 +0200 Subject: [rspec-users] mock_model not stubbing model attribtues in view spec In-Reply-To: References: <7a84a8c278979ca37a54d6f29056718b@ruby-forum.com> <857286BD-1613-4837-BD80-D0698787FF49@patchspace.co.uk> Message-ID: Wow, did I ever have *that* wrong, then! Thanks for all those replies -- stub_model looks like the ticket I was after, in that case. Cheers again, Doug. -- Posted via http://www.ruby-forum.com/. From tek.katu at gmail.com Tue May 20 19:59:18 2008 From: tek.katu at gmail.com (T K) Date: Wed, 21 May 2008 08:59:18 +0900 Subject: [rspec-users] How to write a test for validates_uniqueness_of Message-ID: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> Hi, I have a spec it "should have a unique username " I have a code: validates_uniqueness_of :user_name Now, I don't know how to test this code. In order to test this, do I need to run `save`? For example, @user = User.create(:username => "mike") @another = User.create(:username => "mike") @another.save.should be_false This messes up test database. Is there any better way? -T From philodespotos at gmail.com Tue May 20 20:23:18 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Tue, 20 May 2008 19:23:18 -0500 Subject: [rspec-users] How to write a test for validates_uniqueness_of In-Reply-To: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> References: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> Message-ID: <60f3810c0805201723s228860f2na380a628873299de@mail.gmail.com> On Tue, May 20, 2008 at 6:59 PM, T K wrote: > Hi, > > I have a spec > > it "should have a unique username " > > I have a code: > > validates_uniqueness_of :user_name > > > Now, I don't know how to test this code. In order to test this, do I > need to run `save`? > > For example, > > @user = User.create(:username => "mike") > @another = User.create(:username => "mike") > @another.save.should be_false > > This messes up test database. Is there any better way? I'm not sure what you mean when you say it messes up the test database, but you can either call :create! for the second creation and expect an exception: lambda { User.create!(:username => 'mike') }.should raise_error(ActiveRecord::RecordInvalid, /already taken/) Or you can just call :new and test if it's valid: another = User.new(:username => 'mike') another.should_not be_valid another.should have_at_least(1).errors_on(:username) # or similar I tend to go with the second option, but see the first used pretty often as well. k From dchelimsky at gmail.com Tue May 20 20:25:14 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 20 May 2008 19:25:14 -0500 Subject: [rspec-users] How to write a test for validates_uniqueness_of In-Reply-To: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> References: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> Message-ID: On May 20, 2008, at 6:59 PM, T K wrote: > Hi, > > I have a spec > > it "should have a unique username " > > I have a code: > > validates_uniqueness_of :user_name > > > Now, I don't know how to test this code. In order to test this, do I > need to run `save`? > > For example, > > @user = User.create(:username => "mike") > @another = User.create(:username => "mike") > @another.save.should be_false > > This messes up test database. Is there any better way? Are you running with transactional_fixtures = true? If not, I'd strongly recommend that you do. Even if you're not using fixtures, that setting causes all of your examples to be run in transactions that get rolled back after each example. That way, your examples can make db changes, expect the right thing, and then the db is restored to its previous state. HTH, David > > > -T > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mauricio.linhares at gmail.com Tue May 20 20:29:12 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Tue, 20 May 2008 21:29:12 -0300 Subject: [rspec-users] How to write a test for validates_uniqueness_of In-Reply-To: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> References: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> Message-ID: This plugin does it -> http://code.google.com/p/rspec-on-rails-matchers/ But it's throwing a "forbidden" error right now. On Tue, May 20, 2008 at 8:59 PM, T K wrote: > Hi, > > I have a spec > > it "should have a unique username " > > I have a code: > > validates_uniqueness_of :user_name > > > Now, I don't know how to test this code. In order to test this, do I > need to run `save`? > > For example, > > @user = User.create(:username => "mike") > @another = User.create(:username => "mike") > @another.save.should be_false > > This messes up test database. Is there any better way? > > -T > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://codeshooter.wordpress.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 From ben at benmabey.com Tue May 20 20:40:03 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 20 May 2008 18:40:03 -0600 Subject: [rspec-users] How to write a test for validates_uniqueness_of In-Reply-To: References: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> Message-ID: <48336F63.8020709@benmabey.com> Try this: http://github.com/joshknowles/rspec-on-rails-matchers/tree/master Maur?cio Linhares wrote: > This plugin does it -> http://code.google.com/p/rspec-on-rails-matchers/ > > But it's throwing a "forbidden" error right now. > > On Tue, May 20, 2008 at 8:59 PM, T K wrote: > >> Hi, >> >> I have a spec >> >> it "should have a unique username " >> >> I have a code: >> >> validates_uniqueness_of :user_name >> >> >> Now, I don't know how to test this code. In order to test this, do I >> need to run `save`? >> >> For example, >> >> @user = User.create(:username => "mike") >> @another = User.create(:username => "mike") >> @another.save.should be_false >> >> This messes up test database. Is there any better way? >> >> -T >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > From joshknowles at gmail.com Tue May 20 23:32:43 2008 From: joshknowles at gmail.com (Josh Knowles) Date: Tue, 20 May 2008 23:32:43 -0400 Subject: [rspec-users] How to write a test for validates_uniqueness_of In-Reply-To: References: <5c17ebdc0805201659u505d4be3y6b9c316f5b3d3bf3@mail.gmail.com> Message-ID: On 5/20/08, Maur?cio Linhares wrote: > This plugin does it -> http://code.google.com/p/rspec-on-rails-matchers/ > > But it's throwing a "forbidden" error right now. Sorry, moved the plugin over to GitHub (http://github.com/joshknowles/rspec-on-rails-matchers/tree/master). Finally finding some time to integrate the many wonderful patches from folks over the last month or so. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From rspec at kluger.com Wed May 21 00:26:30 2008 From: rspec at kluger.com (Larry Kluger) Date: Tue, 20 May 2008 21:26:30 -0700 (PDT) Subject: [rspec-users] running rspec on 1.2.3 ?? Message-ID: <502517.53435.qm@web30807.mail.mud.yahoo.com> Hi, Anyone know how to run rspec on 1.2.3? It fails out of the box.... I newly downloaded rspec, rspec_on_rails and ran the command ruby script/generate rspec ==>>> Does this script work right? from the instructions http://rspec.info/documentation/rails/install.html I then created the directories in spec: controllers, fixtures, helpers, models, views I then created the file spec/models/user_spec.rb as a spec for my model User. Anyhow, my problem: I run rake spec and get /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- spec/rails (MissingSourceFile) The file /spec/spec_helper.rb contains the line require 'spec/rails' I noticed that the load path does not include vendor/plugins/rspec_on_rails/lib ....?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed May 21 09:38:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 21 May 2008 08:38:02 -0500 Subject: [rspec-users] running rspec on 1.2.3 ?? In-Reply-To: <502517.53435.qm@web30807.mail.mud.yahoo.com> References: <502517.53435.qm@web30807.mail.mud.yahoo.com> Message-ID: <096BFB3E-D41A-49E6-BEEB-582C22D73804@gmail.com> On May 20, 2008, at 11:26 PM, Larry Kluger wrote: > Hi, > > Anyone know how to run rspec on 1.2.3? > > It fails out of the box.... > > I newly downloaded rspec, rspec_on_rails and ran the command > ruby script/generate rspec ==>>> Does this script work right? > from the instructions http://rspec.info/documentation/rails/install.html > > I then created the directories in spec: > controllers, fixtures, helpers, models, views > > I then created the file spec/models/user_spec.rb as a spec for my > model User. Did you run 'script/generate rspec'? > Anyhow, my problem: > I run rake spec > and get > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- spec/rails > (MissingSourceFile) > > The file /spec/spec_helper.rb contains the line > require 'spec/rails' > > I noticed that the load path does not include vendor/plugins/ > rspec_on_rails/lib That's weird. The load path should include the lib directory of every plugin. What version of rails are you running? David -------------- next part -------------- An HTML attachment was scrubbed... URL: From somanyfishes at gmail.com Wed May 21 09:55:48 2008 From: somanyfishes at gmail.com (SoManyFishes) Date: Wed, 21 May 2008 09:55:48 -0400 Subject: [rspec-users] TextMate bundle not using environment variable to find Ruby library Message-ID: <483429E4.7010709@gmail.com> > Something is going on in my TextMate bundle--it's calling the wrong lib > for Ruby. I have the environment variables set like this: > > > > TM_RSPEC_HOME /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.3 > > TM_RUBY /usr/local/bin/ruby > > How can I get TextMate to use the library in usr/local/bin/ruby instead > of looking in usr/local/bin/ruby? I finally found the answer to this and wanted to post it in case anyone else is searching for help on this in the Archives. I found instructions on this blog: http://blog.dnite.org/2007/8/28/textmate-and-your-environment-variables/comments/7006#comment-7006 It shows how to set up a new environment.plist file here '~/.MacOSX/environment.plist' with the correct PATH definition: > > "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> > > > PATH > > /usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin > > Don't forget to log out & in for it to take effect. Worked for me! Lisa From rspec at kluger.com Wed May 21 11:01:16 2008 From: rspec at kluger.com (Larry Kluger) Date: Wed, 21 May 2008 08:01:16 -0700 (PDT) Subject: [rspec-users] running rspec on 1.2.3 ?? Message-ID: <77920.61511.qm@web30807.mail.mud.yahoo.com> Hi David, Thank you for your response. Got it working: The rspec_on_rails was not being loaded because it appeared in the line config.plugins -= %W( query_trace ... } # plugins that should NOT be loaded in the file config/environments/test.rb Fix: check that both rspec and rspec_on_rails plugins are being loaded in test.rb environment file. Some details: A confusing bit is that it appears that the rspec load path is being added by the rspec runner. So even though the rspec plugin was ALSO NOT being initialized by RoR, the problem was occurring with rspec_on_rails. Regards, Larry ----- Original Message ---- From: David Chelimsky To: rspec-users Sent: Wednesday, May 21, 2008 9:38:02 AM Subject: Re: [rspec-users] running rspec on 1.2.3 ?? On May 20, 2008, at 11:26 PM, Larry Kluger wrote: Hi, Anyone know how to run rspec on 1.2.3? It fails out of the box.... I newly downloaded rspec, rspec_on_rails and ran the command ruby script/generate rspec ==>>> Does this script work right? from the instructions http://rspec.info/documentation/rails/install.html I then created the directories in spec: controllers, fixtures, helpers, models, views I then created the file spec/models/user_spec.rb as a spec for my model User. Did you run 'script/generate rspec'?[yes, see my statement to that effect above.] Anyhow, my problem: I run rake spec and get /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- spec/rails (MissingSourceFile) The file /spec/spec_helper.rb contains the line require 'spec/rails' I noticed that the load path does not include vendor/plugins/rspec_on_rails/lib That's weird. The load path should include the lib directory of every plugin. What version of rails are you running? [v 1.2.3, as stated above :-) ] David -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik at ruby-lang.nl Wed May 21 16:37:17 2008 From: erik at ruby-lang.nl (Erik Terpstra) Date: Wed, 21 May 2008 22:37:17 +0200 Subject: [rspec-users] Testing REST webservices? (Not Rails) Message-ID: <483487FD.7080202@ruby-lang.nl> Hi, I am new to RSpec and BDD. I was wondering if RSpec specifications are a good solution for testing REST webservices (not implemented in Rails). If so, what would be a good way to test something like the API described below? =========== GET http://localhost/workflow text/xml Result: 200 OK flow1 flow2 flow3 POST http://localhost/workflow?name=flow4 text/xml Data: Result: 201 Created GET http://localhost/workflow text/xml Result: 200 OK flow1 flow2 flow3 flow4 GET http://localhost/workflow/flow4 text/xml Result: 200 OK DELETE http://localhost/workflow/flow3 Result: 204 No Content GET http://localhost/workflow text/xml Result: 200 OK flow1 flow2 flow4 ===== TIA, Erik. From erik at ruby-lang.nl Wed May 21 16:32:08 2008 From: erik at ruby-lang.nl (Erik Terpstra) Date: Wed, 21 May 2008 22:32:08 +0200 Subject: [rspec-users] RSpec for testing REST webservices? (Not Rails) Message-ID: <483486C8.80702@ruby-lang.nl> Hi, I am new to RSpec and BDD. I was wondering if RSpec specifications are a good solution for testing REST webservices (not implemented in Rails). If so, what would be a good way to test something like the API described below? =========== GET http://localhost/workflow text/xml Result: 200 OK flow1 flow2 flow3 POST http://localhost/workflow?name=flow4 text/xml Data: Result: 201 Created GET http://localhost/workflow text/xml Result: 200 OK flow1 flow2 flow3 flow4 GET http://localhost/workflow/flow4 text/xml Result: 200 OK DELETE http://localhost/workflow/flow3 Result: 204 No Content GET http://localhost/workflow text/xml Result: 200 OK flow1 flow2 flow4 ===== TIA, Erik. From aselder at mac.com Wed May 21 22:49:57 2008 From: aselder at mac.com (Andrew Selder) Date: Wed, 21 May 2008 22:49:57 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? Message-ID: Is it possible to specify that certain tables not be cleared on each example. I've inherited a project where a good amount of enumerated data is stored in the database (US States, statuses, about 15-20 tables worth. Over all, it's a reasonable decision that leads to solid production code (acts_as_enumerated is good). This data is read-only and relatively static; any changes to these tables are done via migrations. The problem comes when I'm writing my tests. Obviously all these tables get wiped with each example. Yes, I could specify these as fixtures, but I really don't want to have to specify 15-20 fixtures on every example. Yes, I could mock/stub all the values, except that I use many of these values at class definition time, which means that errors are thrown before I can even mock/stub. For instance, I have a statement like this. named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New Incubating Client UAG}.collect{|x| LeadStatus[x].id}] Which loads the named_scope using the string version of the enumeration for clarity's sake. It works great, except for testing. Does anybody see anyway around this other than creating a fixture file for each of these tables and loading all the fixtures on each describe block. Not only does this make for ugly code, but I'm sure it takes a good chunk of time to setup and teardown each of the tables each example. It would be wonderful if there was some option to specify tables that behave like this, that should be loaded at the beginning of the test run, and (optionally) trashed at the end of the run. Or even better, specify that the test script shouldn't touch (build or teardown) these tables at all, and let their migrated state remain. Thanks, Andrew From mailing_lists at railsnewbie.com Thu May 22 00:57:43 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 22 May 2008 00:57:43 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: <69406B99-E19D-493E-A458-47F23A7B7E6F@railsnewbie.com> On May 21, 2008, at 10:49 PM, Andrew Selder wrote: > Is it possible to specify that certain tables not be cleared on each > example. > > I've inherited a project where a good amount of enumerated data is > stored in the database (US States, statuses, about 15-20 tables > worth. Over all, it's a reasonable decision that leads to solid > production code (acts_as_enumerated is good). This data is read-only > and relatively static; any changes to these tables are done via > migrations. > > The problem comes when I'm writing my tests. Obviously all these > tables get wiped with each example. Yes, I could specify these as > fixtures, but I really don't want to have to specify 15-20 fixtures > on every example. Yes, I could mock/stub all the values, except that > I use many of these values at class definition time, which means > that errors are thrown before I can even mock/stub. > > For instance, I have a statement like this. > > named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New > Incubating Client UAG}.collect{|x| LeadStatus[x].id}] > > Which loads the named_scope using the string version of the > enumeration for clarity's sake. It works great, except for testing. > > Does anybody see anyway around this other than creating a fixture > file for each of these tables and loading all the fixtures on each > describe block. Not only does this make for ugly code, but I'm sure > it takes a good chunk of time to setup and teardown each of the > tables each example. > > It would be wonderful if there was some option to specify tables > that behave like this, that should be loaded at the beginning of the > test run, and (optionally) trashed at the end of the run. Or even > better, specify that the test script shouldn't touch (build or > teardown) these tables at all, and let their migrated state remain. > AFAIK, any data that goes into the test database *after* the db:test:prepare rake task, but *before* the spec rake task will not get wiped out with every test case. Rails' Fixtures do not get reloaded every test case, but every test case will get loaded into a transaction, so any data which is modified in those test cases should get rolled back. I don't see any reason why you couldn't have a factory method which would set up that data, make a rake task out of it, and set it the dependency for the spec task: task :spec => :setup_test_data One problem with this solution is that it precludes any ability to run with a single test with script/spec or with autotest. Another option (although, I'm sure that it will be quite slow) is to define a global before(:each) in spec/spec_helper.rb: Spec::Runner.configure do |config| config.use_transactional_fixtures = true config.use_instantiated_fixtures = false before(:each) do # setup_test_data... end end Scott From ashley.moran at patchspace.co.uk Thu May 22 06:46:27 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 22 May 2008 11:46:27 +0100 Subject: [rspec-users] Testing REST webservices? (Not Rails) In-Reply-To: <483487FD.7080202@ruby-lang.nl> References: <483487FD.7080202@ruby-lang.nl> Message-ID: On 21 May 2008, at 21:37, Erik Terpstra wrote: > I am new to RSpec and BDD. > I was wondering if RSpec specifications are a good solution for > testing REST webservices (not implemented in Rails). > If so, what would be a good way to test something like the API > described below? Hi Erik RSpec would be fine to test that, it's just a web app returning XML instead of HTML. You don't say what you are building the web service in. If you want acceptance/integration-style specs that are implementation-independent, you could use the story runner with steps to make HTTP requests. And look at Kyle's rspec_hpricot_matchers for a way of specifying XML output. You will also want unit specs for your models, controllers etc which will be more framework-dependent. That's all I can offer based on your description. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Thu May 22 07:07:28 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 22 May 2008 12:07:28 +0100 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: On 22 May 2008, at 03:49, Andrew Selder wrote: > It would be wonderful if there was some option to specify tables > that behave like this, that should be loaded at the beginning of the > test run, and (optionally) trashed at the end of the run. Or even > better, specify that the test script shouldn't touch (build or > teardown) these tables at all, and let their migrated state remain. Like Scott said, this shouldn't be a problem. Are you creating your test DB like this? rake db:test:clone If so, try this: rake db:migrate RAILS_ENV=test It will create a test database that is identical to a new production database, instead of an approximation. I have no idea why the Rails team decided would be better to test against an incomplete database, but I always use migrate now, instead of clone. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at ruby-forum.com Thu May 22 08:16:46 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Thu, 22 May 2008 14:16:46 +0200 Subject: [rspec-users] Story / Redirection to static html within public Message-ID: With a rails application I'm trying to access the public/ folder from within a rspec story. I have a controller which redirects to: /public/static_html_page.html I have a story written using webat. This story uses the above controller and it expects the redirection. This story always fails as within the story it cannot follow the redirection (Always gives a 500 error). It does not seem to be able to access any public/ content within the story. Within step file of a story this always fails: 'get /index.html' OR visits '/index.html' I looked back at ActionController::IntegrationTest which seems to be where RailsStory gets all its magic from. That lead me to believe that perhaps this was a rails issue? So I'm unsure if: 1. Accessing public/ within a story is just not supposed to be possible. 2. Accessing public/ within ActionController::IntegrationTest is not suppose to be possible. 2. Rspec has a bug 3. Rails has a bug Any ideas? This is down on Rails 2.0.2. Rspec GIT trunk Thanks, -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. From aselder at mac.com Thu May 22 09:27:34 2008 From: aselder at mac.com (Andrew Selder) Date: Thu, 22 May 2008 09:27:34 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: Ashley, I am using rake db:migrate RAILS_ENV=test. The values I'm inserting into the tables using migrations are gone by the time the tests run. Andrew On May 22, 2008, at 7:07 AM, Ashley Moran wrote: > > On 22 May 2008, at 03:49, Andrew Selder wrote: > >> It would be wonderful if there was some option to specify tables >> that behave like this, that should be loaded at the beginning of >> the test run, and (optionally) trashed at the end of the run. Or >> even better, specify that the test script shouldn't touch (build or >> teardown) these tables at all, and let their migrated state remain. > > > Like Scott said, this shouldn't be a problem. Are you creating your > test DB like this? > rake db:test:clone > > If so, try this: > rake db:migrate RAILS_ENV=test > > It will create a test database that is identical to a new production > database, instead of an approximation. I have no idea why the Rails > team decided would be better to test against an incomplete database, > but I always use migrate now, instead of clone. > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu May 22 09:32:06 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 May 2008 08:32:06 -0500 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: On May 21, 2008, at 9:49 PM, Andrew Selder wrote: > Is it possible to specify that certain tables not be cleared on each > example. > > I've inherited a project where a good amount of enumerated data is > stored in the database (US States, statuses, about 15-20 tables > worth. Over all, it's a reasonable decision that leads to solid > production code (acts_as_enumerated is good). This data is read-only > and relatively static; any changes to these tables are done via > migrations. > > The problem comes when I'm writing my tests. Obviously all these > tables get wiped with each example. This should not be the case. Transactions get rolled back, but tables do not just get wiped clean. If this static data is being generated in migrations, then you should be OK. Is it? > Yes, I could specify these as fixtures, but I really don't want to > have to specify 15-20 fixtures on every example. Yes, I could mock/ > stub all the values, except that I use many of these values at class > definition time, which means that errors are thrown before I can > even mock/stub. > > For instance, I have a statement like this. > > named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New > Incubating Client UAG}.collect{|x| LeadStatus[x].id}] > > Which loads the named_scope using the string version of the > enumeration for clarity's sake. It works great, except for testing. > > Does anybody see anyway around this other than creating a fixture > file for each of these tables and loading all the fixtures on each > describe block. Not only does this make for ugly code, but I'm sure > it takes a good chunk of time to setup and teardown each of the > tables each example. > > It would be wonderful if there was some option to specify tables > that behave like this, that should be loaded at the beginning of the > test run, and (optionally) trashed at the end of the run. Or even > better, specify that the test script shouldn't touch (build or > teardown) these tables at all, and let their migrated state remain. > > Thanks, > > Andrew > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aselder at mac.com Thu May 22 09:55:28 2008 From: aselder at mac.com (Andrew Selder) Date: Thu, 22 May 2008 09:55:28 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: David, The static data generated in the migrations in being wiped away. I did a rake db:test:purge followed by rake db:migrate RAILS_ENV=test and then looked in my database to verify that the data was there and it was. And then when I run rake spec, the test blow up and I looks at the DB and all the static tables are empty. Looking at the rspec.rake file in the rspec_on_rails plugin, the spec task calls the spec_prereq task. This task does a db:test:prepare, which looking at the source for that in the rails gem only copies the schema from the development db. I'm using Rails 2.1 RC1, and the tagged CURRENT version of both plugins. Thanks, Andrew On May 22, 2008, at 9:32 AM, David Chelimsky wrote: > On May 21, 2008, at 9:49 PM, Andrew Selder wrote: > >> Is it possible to specify that certain tables not be cleared on >> each example. >> >> I've inherited a project where a good amount of enumerated data is >> stored in the database (US States, statuses, about 15-20 tables >> worth. Over all, it's a reasonable decision that leads to solid >> production code (acts_as_enumerated is good). This data is read- >> only and relatively static; any changes to these tables are done >> via migrations. >> >> The problem comes when I'm writing my tests. Obviously all these >> tables get wiped with each example. > > This should not be the case. Transactions get rolled back, but > tables do not just get wiped clean. > > If this static data is being generated in migrations, then you > should be OK. Is it? > >> Yes, I could specify these as fixtures, but I really don't want to >> have to specify 15-20 fixtures on every example. Yes, I could mock/ >> stub all the values, except that I use many of these values at >> class definition time, which means that errors are thrown before I >> can even mock/stub. >> >> For instance, I have a statement like this. >> >> named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New >> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >> >> Which loads the named_scope using the string version of the >> enumeration for clarity's sake. It works great, except for testing. >> >> Does anybody see anyway around this other than creating a fixture >> file for each of these tables and loading all the fixtures on each >> describe block. Not only does this make for ugly code, but I'm sure >> it takes a good chunk of time to setup and teardown each of the >> tables each example. >> >> It would be wonderful if there was some option to specify tables >> that behave like this, that should be loaded at the beginning of >> the test run, and (optionally) trashed at the end of the run. Or >> even better, specify that the test script shouldn't touch (build or >> teardown) these tables at all, and let their migrated state remain. >> >> Thanks, >> >> Andrew >> >> >> >> _______________________________________________ >> 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 May 22 09:58:14 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 May 2008 08:58:14 -0500 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> On Thu, May 22, 2008 at 8:55 AM, Andrew Selder wrote: > David, > > The static data generated in the migrations in being wiped away. > > I did a > rake db:test:purge > > followed by > > rake db:migrate RAILS_ENV=test > > and then looked in my database to verify that the data was there and it was. > > And then when I run rake spec, the test blow up and I looks at the DB and > all the static tables are empty. > > Looking at the rspec.rake file in the rspec_on_rails plugin, the spec task > calls the spec_prereq task. This task does a db:test:prepare, which looking > at the source for that in the rails gem only copies the schema from the > development db. > > I'm using Rails 2.1 RC1, and the tagged CURRENT version of both plugins. AHA! CURRENT means the latest release, which is 1.1.3, which was released months ago, before Rails 2.1 RC1. Try the latest from github: script/plugin install git://github.com/dchelimsky/rspec.git script/plugin install git://github.com/dchelimsky/rspec-rails.git script/generate rspec See if that makes any difference. Cheers, David > > Thanks, > > Andrew > > On May 22, 2008, at 9:32 AM, David Chelimsky wrote: > >> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >> >>> Is it possible to specify that certain tables not be cleared on each >>> example. >>> >>> I've inherited a project where a good amount of enumerated data is stored >>> in the database (US States, statuses, about 15-20 tables worth. Over all, >>> it's a reasonable decision that leads to solid production code >>> (acts_as_enumerated is good). This data is read-only and relatively static; >>> any changes to these tables are done via migrations. >>> >>> The problem comes when I'm writing my tests. Obviously all these tables >>> get wiped with each example. >> >> This should not be the case. Transactions get rolled back, but tables do >> not just get wiped clean. >> >> If this static data is being generated in migrations, then you should be >> OK. Is it? >> >>> Yes, I could specify these as fixtures, but I really don't want to have >>> to specify 15-20 fixtures on every example. Yes, I could mock/stub all the >>> values, except that I use many of these values at class definition time, >>> which means that errors are thrown before I can even mock/stub. >>> >>> For instance, I have a statement like this. >>> >>> named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New >>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>> >>> Which loads the named_scope using the string version of the enumeration >>> for clarity's sake. It works great, except for testing. >>> >>> Does anybody see anyway around this other than creating a fixture file >>> for each of these tables and loading all the fixtures on each describe >>> block. Not only does this make for ugly code, but I'm sure it takes a good >>> chunk of time to setup and teardown each of the tables each example. >>> >>> It would be wonderful if there was some option to specify tables that >>> behave like this, that should be loaded at the beginning of the test run, >>> and (optionally) trashed at the end of the run. Or even better, specify that >>> the test script shouldn't touch (build or teardown) these tables at all, and >>> let their migrated state remain. >>> >>> Thanks, >>> >>> Andrew >>> >>> >>> >>> _______________________________________________ >>> 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 aselder at mac.com Thu May 22 10:12:30 2008 From: aselder at mac.com (Andrew Selder) Date: Thu, 22 May 2008 10:12:30 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> Message-ID: <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> Downloaded the latest plugins from Github and got the same results. The spec rake task still ends up calling db:test:prepare which blows away the database and reloads only the schema. Thanks, Andrew On May 22, 2008, at 9:58 AM, David Chelimsky wrote: > On Thu, May 22, 2008 at 8:55 AM, Andrew Selder > wrote: >> David, >> >> The static data generated in the migrations in being wiped away. >> >> I did a >> rake db:test:purge >> >> followed by >> >> rake db:migrate RAILS_ENV=test >> >> and then looked in my database to verify that the data was there >> and it was. >> >> And then when I run rake spec, the test blow up and I looks at the >> DB and >> all the static tables are empty. >> >> Looking at the rspec.rake file in the rspec_on_rails plugin, the >> spec task >> calls the spec_prereq task. This task does a db:test:prepare, which >> looking >> at the source for that in the rails gem only copies the schema from >> the >> development db. >> >> I'm using Rails 2.1 RC1, and the tagged CURRENT version of both >> plugins. > > AHA! > > CURRENT means the latest release, which is 1.1.3, which was released > months ago, before Rails 2.1 RC1. > > Try the latest from github: > > script/plugin install git://github.com/dchelimsky/rspec.git > script/plugin install git://github.com/dchelimsky/rspec-rails.git > script/generate rspec > > See if that makes any difference. > > Cheers, > David > >> >> Thanks, >> >> Andrew >> >> On May 22, 2008, at 9:32 AM, David Chelimsky wrote: >> >>> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >>> >>>> Is it possible to specify that certain tables not be cleared on >>>> each >>>> example. >>>> >>>> I've inherited a project where a good amount of enumerated data >>>> is stored >>>> in the database (US States, statuses, about 15-20 tables worth. >>>> Over all, >>>> it's a reasonable decision that leads to solid production code >>>> (acts_as_enumerated is good). This data is read-only and >>>> relatively static; >>>> any changes to these tables are done via migrations. >>>> >>>> The problem comes when I'm writing my tests. Obviously all these >>>> tables >>>> get wiped with each example. >>> >>> This should not be the case. Transactions get rolled back, but >>> tables do >>> not just get wiped clean. >>> >>> If this static data is being generated in migrations, then you >>> should be >>> OK. Is it? >>> >>>> Yes, I could specify these as fixtures, but I really don't want >>>> to have >>>> to specify 15-20 fixtures on every example. Yes, I could mock/ >>>> stub all the >>>> values, except that I use many of these values at class >>>> definition time, >>>> which means that errors are thrown before I can even mock/stub. >>>> >>>> For instance, I have a statement like this. >>>> >>>> named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New >>>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>>> >>>> Which loads the named_scope using the string version of the >>>> enumeration >>>> for clarity's sake. It works great, except for testing. >>>> >>>> Does anybody see anyway around this other than creating a fixture >>>> file >>>> for each of these tables and loading all the fixtures on each >>>> describe >>>> block. Not only does this make for ugly code, but I'm sure it >>>> takes a good >>>> chunk of time to setup and teardown each of the tables each >>>> example. >>>> >>>> It would be wonderful if there was some option to specify tables >>>> that >>>> behave like this, that should be loaded at the beginning of the >>>> test run, >>>> and (optionally) trashed at the end of the run. Or even better, >>>> specify that >>>> the test script shouldn't touch (build or teardown) these tables >>>> at all, and >>>> let their migrated state remain. >>>> >>>> Thanks, >>>> >>>> Andrew >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 pergesu at gmail.com Thu May 22 10:20:43 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 22 May 2008 07:20:43 -0700 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> Message-ID: <810a540e0805220720j15de96c5h7f44b09b8d7886a0@mail.gmail.com> Have you tried making it not call db:test:prepare? On Thu, May 22, 2008 at 7:12 AM, Andrew Selder wrote: > Downloaded the latest plugins from Github and got the same results. > > The spec rake task still ends up calling db:test:prepare which blows away > the database and reloads only the schema. > > Thanks, > > Andrew > > On May 22, 2008, at 9:58 AM, David Chelimsky wrote: > >> On Thu, May 22, 2008 at 8:55 AM, Andrew Selder wrote: >>> >>> David, >>> >>> The static data generated in the migrations in being wiped away. >>> >>> I did a >>> rake db:test:purge >>> >>> followed by >>> >>> rake db:migrate RAILS_ENV=test >>> >>> and then looked in my database to verify that the data was there and it >>> was. >>> >>> And then when I run rake spec, the test blow up and I looks at the DB and >>> all the static tables are empty. >>> >>> Looking at the rspec.rake file in the rspec_on_rails plugin, the spec >>> task >>> calls the spec_prereq task. This task does a db:test:prepare, which >>> looking >>> at the source for that in the rails gem only copies the schema from the >>> development db. >>> >>> I'm using Rails 2.1 RC1, and the tagged CURRENT version of both plugins. >> >> AHA! >> >> CURRENT means the latest release, which is 1.1.3, which was released >> months ago, before Rails 2.1 RC1. >> >> Try the latest from github: >> >> script/plugin install git://github.com/dchelimsky/rspec.git >> script/plugin install git://github.com/dchelimsky/rspec-rails.git >> script/generate rspec >> >> See if that makes any difference. >> >> Cheers, >> David >> >>> >>> Thanks, >>> >>> Andrew >>> >>> On May 22, 2008, at 9:32 AM, David Chelimsky wrote: >>> >>>> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >>>> >>>>> Is it possible to specify that certain tables not be cleared on each >>>>> example. >>>>> >>>>> I've inherited a project where a good amount of enumerated data is >>>>> stored >>>>> in the database (US States, statuses, about 15-20 tables worth. Over >>>>> all, >>>>> it's a reasonable decision that leads to solid production code >>>>> (acts_as_enumerated is good). This data is read-only and relatively >>>>> static; >>>>> any changes to these tables are done via migrations. >>>>> >>>>> The problem comes when I'm writing my tests. Obviously all these tables >>>>> get wiped with each example. >>>> >>>> This should not be the case. Transactions get rolled back, but tables do >>>> not just get wiped clean. >>>> >>>> If this static data is being generated in migrations, then you should be >>>> OK. Is it? >>>> >>>>> Yes, I could specify these as fixtures, but I really don't want to have >>>>> to specify 15-20 fixtures on every example. Yes, I could mock/stub all >>>>> the >>>>> values, except that I use many of these values at class definition >>>>> time, >>>>> which means that errors are thrown before I can even mock/stub. >>>>> >>>>> For instance, I have a statement like this. >>>>> >>>>> named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New >>>>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>>>> >>>>> Which loads the named_scope using the string version of the enumeration >>>>> for clarity's sake. It works great, except for testing. >>>>> >>>>> Does anybody see anyway around this other than creating a fixture file >>>>> for each of these tables and loading all the fixtures on each describe >>>>> block. Not only does this make for ugly code, but I'm sure it takes a >>>>> good >>>>> chunk of time to setup and teardown each of the tables each example. >>>>> >>>>> It would be wonderful if there was some option to specify tables that >>>>> behave like this, that should be loaded at the beginning of the test >>>>> run, >>>>> and (optionally) trashed at the end of the run. Or even better, specify >>>>> that >>>>> the test script shouldn't touch (build or teardown) these tables at >>>>> all, and >>>>> let their migrated state remain. >>>>> >>>>> Thanks, >>>>> >>>>> Andrew >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 Thu May 22 10:25:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 May 2008 09:25:40 -0500 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> Message-ID: <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> On Thu, May 22, 2008 at 9:12 AM, Andrew Selder wrote: > Downloaded the latest plugins from Github and got the same results. > > The spec rake task still ends up calling db:test:prepare which blows away > the database and reloads only the schema. Well, thanks for trying. You can't be the first person to run up against this problem. I've run into it before but not in any rails apps I've worked on. Sounds like the solution would be something like what Scott and Ashley are talking about - introducing rake db:migrate or a custom data setup task after or instead of db:test:prepare. > > Thanks, > > Andrew > > On May 22, 2008, at 9:58 AM, David Chelimsky wrote: > >> On Thu, May 22, 2008 at 8:55 AM, Andrew Selder wrote: >>> >>> David, >>> >>> The static data generated in the migrations in being wiped away. >>> >>> I did a >>> rake db:test:purge >>> >>> followed by >>> >>> rake db:migrate RAILS_ENV=test >>> >>> and then looked in my database to verify that the data was there and it >>> was. >>> >>> And then when I run rake spec, the test blow up and I looks at the DB and >>> all the static tables are empty. >>> >>> Looking at the rspec.rake file in the rspec_on_rails plugin, the spec >>> task >>> calls the spec_prereq task. This task does a db:test:prepare, which >>> looking >>> at the source for that in the rails gem only copies the schema from the >>> development db. >>> >>> I'm using Rails 2.1 RC1, and the tagged CURRENT version of both plugins. >> >> AHA! >> >> CURRENT means the latest release, which is 1.1.3, which was released >> months ago, before Rails 2.1 RC1. >> >> Try the latest from github: >> >> script/plugin install git://github.com/dchelimsky/rspec.git >> script/plugin install git://github.com/dchelimsky/rspec-rails.git >> script/generate rspec >> >> See if that makes any difference. >> >> Cheers, >> David >> >>> >>> Thanks, >>> >>> Andrew >>> >>> On May 22, 2008, at 9:32 AM, David Chelimsky wrote: >>> >>>> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >>>> >>>>> Is it possible to specify that certain tables not be cleared on each >>>>> example. >>>>> >>>>> I've inherited a project where a good amount of enumerated data is >>>>> stored >>>>> in the database (US States, statuses, about 15-20 tables worth. Over >>>>> all, >>>>> it's a reasonable decision that leads to solid production code >>>>> (acts_as_enumerated is good). This data is read-only and relatively >>>>> static; >>>>> any changes to these tables are done via migrations. >>>>> >>>>> The problem comes when I'm writing my tests. Obviously all these tables >>>>> get wiped with each example. >>>> >>>> This should not be the case. Transactions get rolled back, but tables do >>>> not just get wiped clean. >>>> >>>> If this static data is being generated in migrations, then you should be >>>> OK. Is it? >>>> >>>>> Yes, I could specify these as fixtures, but I really don't want to have >>>>> to specify 15-20 fixtures on every example. Yes, I could mock/stub all >>>>> the >>>>> values, except that I use many of these values at class definition >>>>> time, >>>>> which means that errors are thrown before I can even mock/stub. >>>>> >>>>> For instance, I have a statement like this. >>>>> >>>>> named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New >>>>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>>>> >>>>> Which loads the named_scope using the string version of the enumeration >>>>> for clarity's sake. It works great, except for testing. >>>>> >>>>> Does anybody see anyway around this other than creating a fixture file >>>>> for each of these tables and loading all the fixtures on each describe >>>>> block. Not only does this make for ugly code, but I'm sure it takes a >>>>> good >>>>> chunk of time to setup and teardown each of the tables each example. >>>>> >>>>> It would be wonderful if there was some option to specify tables that >>>>> behave like this, that should be loaded at the beginning of the test >>>>> run, >>>>> and (optionally) trashed at the end of the run. Or even better, specify >>>>> that >>>>> the test script shouldn't touch (build or teardown) these tables at >>>>> all, and >>>>> let their migrated state remain. >>>>> >>>>> Thanks, >>>>> >>>>> Andrew From joshknowles at gmail.com Thu May 22 10:31:25 2008 From: joshknowles at gmail.com (Josh Knowles) Date: Thu, 22 May 2008 10:31:25 -0400 Subject: [rspec-users] Story / Redirection to static html within public In-Reply-To: References: Message-ID: On 5/22/08, Joseph Wilk wrote: > With a rails application I'm trying to access the public/ folder from > within a rspec story. > > I have a controller which redirects to: > > /public/static_html_page.html I assume you mean /static_html_page.html? Your document_root in your webserver should be set to /public thus you should never see /public in your URLs, > > I have a story written using webat. > This story uses the above controller and it expects the redirection. > > This story always fails as within the story it cannot follow the > redirection (Always gives a 500 error). It does not seem to be able to > access any public/ content within the story. Rails Integration tests talk directly to controllers, since there is no controller in front of static files there is no way to access them as far as I've seen. > > Within step file of a story this always fails: > 'get /index.html' > OR > visits '/index.html' > > I looked back at ActionController::IntegrationTest which seems to be > where RailsStory gets all its magic from. That lead me to believe that > perhaps this was a rails issue? > > So I'm unsure if: > > 1. Accessing public/ within a story is just not supposed to be possible. Correct > 2. Accessing public/ within ActionController::IntegrationTest is not > suppose to be possible. Correct. > > 2. Rspec has a bug > 3. Rails has a bug > > Any ideas? We can look at getting webrat to recognize the redirect to file outside the scope of the rails environment. Patches always welcome of course. - Josh -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From ashley.moran at patchspace.co.uk Thu May 22 11:10:23 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 22 May 2008 16:10:23 +0100 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> Message-ID: On 22 May 2008, at 15:25, David Chelimsky wrote: > Sounds like the solution would be something like what Scott and Ashley > are talking about - introducing rake db:migrate or a custom data setup > task after or instead of db:test:prepare. It just occurred to me that I never ran any rake tasks to run the specs- I always used autotest. If the rake task behaviour is a "bug" then running autotest won't fix that, but it might get around the issue of your database being cleared out. Andrew - do you use autotest in general? If so do you see the same behaviour with it? Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From aselder at mac.com Thu May 22 11:13:41 2008 From: aselder at mac.com (Andrew Selder) Date: Thu, 22 May 2008 11:13:41 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> Message-ID: <777169B3-5B04-4A37-A469-415E8645FA1B@mac.com> I tried modifying rspec.rake to read spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? [:testing, "db:test:purge", "db:migrate"] : :noop task :noop do end task :testing do RAILS_ENV = ENV['RAILS_ENV'] = 'test' end which should do what I want, I think. However the db:migrate task blows up with a message: rake aborted! Mysql::Error: No database selected: SHOW TABLES /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/connection_adapters/abstract_adapter.rb:151:in `log' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/connection_adapters/mysql_adapter.rb:299:in `execute' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/connection_adapters/mysql_adapter.rb:403:in `tables' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/connection_adapters/abstract/schema_statements.rb:313:in `initialize_schema_migrations_table' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/migration.rb:388:in `initialize' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/migration.rb:357:in `new' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/migration.rb:357:in `up' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.991/lib/ active_record/migration.rb:340:in `migrate' /opt/local/lib/ruby/gems/1.8/gems/rails-2.0.991/lib/tasks/ databases.rake:99 I examined the connection item and it is pointing to the right DB. It's strange since the db:migrate task work in isolation. Anyway, for now I'll manually setup my db for test. Thanks all, Andrew On May 22, 2008, at 10:25 AM, David Chelimsky wrote: > On Thu, May 22, 2008 at 9:12 AM, Andrew Selder > wrote: >> Downloaded the latest plugins from Github and got the same results. >> >> The spec rake task still ends up calling db:test:prepare which >> blows away >> the database and reloads only the schema. > > Well, thanks for trying. > > You can't be the first person to run up against this problem. I've run > into it before but not in any rails apps I've worked on. > > Sounds like the solution would be something like what Scott and Ashley > are talking about - introducing rake db:migrate or a custom data setup > task after or instead of db:test:prepare. > >> >> Thanks, >> >> Andrew >> >> On May 22, 2008, at 9:58 AM, David Chelimsky wrote: >> >>> On Thu, May 22, 2008 at 8:55 AM, Andrew Selder >>> wrote: >>>> >>>> David, >>>> >>>> The static data generated in the migrations in being wiped away. >>>> >>>> I did a >>>> rake db:test:purge >>>> >>>> followed by >>>> >>>> rake db:migrate RAILS_ENV=test >>>> >>>> and then looked in my database to verify that the data was there >>>> and it >>>> was. >>>> >>>> And then when I run rake spec, the test blow up and I looks at >>>> the DB and >>>> all the static tables are empty. >>>> >>>> Looking at the rspec.rake file in the rspec_on_rails plugin, the >>>> spec >>>> task >>>> calls the spec_prereq task. This task does a db:test:prepare, which >>>> looking >>>> at the source for that in the rails gem only copies the schema >>>> from the >>>> development db. >>>> >>>> I'm using Rails 2.1 RC1, and the tagged CURRENT version of both >>>> plugins. >>> >>> AHA! >>> >>> CURRENT means the latest release, which is 1.1.3, which was released >>> months ago, before Rails 2.1 RC1. >>> >>> Try the latest from github: >>> >>> script/plugin install git://github.com/dchelimsky/rspec.git >>> script/plugin install git://github.com/dchelimsky/rspec-rails.git >>> script/generate rspec >>> >>> See if that makes any difference. >>> >>> Cheers, >>> David >>> >>>> >>>> Thanks, >>>> >>>> Andrew >>>> >>>> On May 22, 2008, at 9:32 AM, David Chelimsky wrote: >>>> >>>>> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >>>>> >>>>>> Is it possible to specify that certain tables not be cleared on >>>>>> each >>>>>> example. >>>>>> >>>>>> I've inherited a project where a good amount of enumerated data >>>>>> is >>>>>> stored >>>>>> in the database (US States, statuses, about 15-20 tables worth. >>>>>> Over >>>>>> all, >>>>>> it's a reasonable decision that leads to solid production code >>>>>> (acts_as_enumerated is good). This data is read-only and >>>>>> relatively >>>>>> static; >>>>>> any changes to these tables are done via migrations. >>>>>> >>>>>> The problem comes when I'm writing my tests. Obviously all >>>>>> these tables >>>>>> get wiped with each example. >>>>> >>>>> This should not be the case. Transactions get rolled back, but >>>>> tables do >>>>> not just get wiped clean. >>>>> >>>>> If this static data is being generated in migrations, then you >>>>> should be >>>>> OK. Is it? >>>>> >>>>>> Yes, I could specify these as fixtures, but I really don't want >>>>>> to have >>>>>> to specify 15-20 fixtures on every example. Yes, I could mock/ >>>>>> stub all >>>>>> the >>>>>> values, except that I use many of these values at class >>>>>> definition >>>>>> time, >>>>>> which means that errors are thrown before I can even mock/stub. >>>>>> >>>>>> For instance, I have a statement like this. >>>>>> >>>>>> named_scope :open, :conditions => ["lead_status_id IN (?)", >>>>>> %w{New >>>>>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>>>>> >>>>>> Which loads the named_scope using the string version of the >>>>>> enumeration >>>>>> for clarity's sake. It works great, except for testing. >>>>>> >>>>>> Does anybody see anyway around this other than creating a >>>>>> fixture file >>>>>> for each of these tables and loading all the fixtures on each >>>>>> describe >>>>>> block. Not only does this make for ugly code, but I'm sure it >>>>>> takes a >>>>>> good >>>>>> chunk of time to setup and teardown each of the tables each >>>>>> example. >>>>>> >>>>>> It would be wonderful if there was some option to specify >>>>>> tables that >>>>>> behave like this, that should be loaded at the beginning of the >>>>>> test >>>>>> run, >>>>>> and (optionally) trashed at the end of the run. Or even better, >>>>>> specify >>>>>> that >>>>>> the test script shouldn't touch (build or teardown) these >>>>>> tables at >>>>>> all, and >>>>>> let their migrated state remain. >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Andrew > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aselder at mac.com Thu May 22 11:19:27 2008 From: aselder at mac.com (Andrew Selder) Date: Thu, 22 May 2008 11:19:27 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> Message-ID: <2C896CB4-1314-4F98-A54F-F495F261F966@mac.com> YEAH!!!!!!! I've got it. I changed my rspec.rake to: spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? ["db:test:purge", :testing, "db:migrate"] : :noop task :noop do end task :testing => :environment do RAILS_ENV = ENV['RAILS_ENV'] = 'test' ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) end task :default => :spec task :stats => "spec:statsetup" desc "Run all specs in spec directory (excluding plugin specs)" Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['spec/**/*_spec.rb'] end Thanks for all the assistance from everyone. Thanks, Andrew On May 22, 2008, at 10:25 AM, David Chelimsky wrote: > On Thu, May 22, 2008 at 9:12 AM, Andrew Selder > wrote: >> Downloaded the latest plugins from Github and got the same results. >> >> The spec rake task still ends up calling db:test:prepare which >> blows away >> the database and reloads only the schema. > > Well, thanks for trying. > > You can't be the first person to run up against this problem. I've run > into it before but not in any rails apps I've worked on. > > Sounds like the solution would be something like what Scott and Ashley > are talking about - introducing rake db:migrate or a custom data setup > task after or instead of db:test:prepare. > >> >> Thanks, >> >> Andrew >> >> On May 22, 2008, at 9:58 AM, David Chelimsky wrote: >> >>> On Thu, May 22, 2008 at 8:55 AM, Andrew Selder >>> wrote: >>>> >>>> David, >>>> >>>> The static data generated in the migrations in being wiped away. >>>> >>>> I did a >>>> rake db:test:purge >>>> >>>> followed by >>>> >>>> rake db:migrate RAILS_ENV=test >>>> >>>> and then looked in my database to verify that the data was there >>>> and it >>>> was. >>>> >>>> And then when I run rake spec, the test blow up and I looks at >>>> the DB and >>>> all the static tables are empty. >>>> >>>> Looking at the rspec.rake file in the rspec_on_rails plugin, the >>>> spec >>>> task >>>> calls the spec_prereq task. This task does a db:test:prepare, which >>>> looking >>>> at the source for that in the rails gem only copies the schema >>>> from the >>>> development db. >>>> >>>> I'm using Rails 2.1 RC1, and the tagged CURRENT version of both >>>> plugins. >>> >>> AHA! >>> >>> CURRENT means the latest release, which is 1.1.3, which was released >>> months ago, before Rails 2.1 RC1. >>> >>> Try the latest from github: >>> >>> script/plugin install git://github.com/dchelimsky/rspec.git >>> script/plugin install git://github.com/dchelimsky/rspec-rails.git >>> script/generate rspec >>> >>> See if that makes any difference. >>> >>> Cheers, >>> David >>> >>>> >>>> Thanks, >>>> >>>> Andrew >>>> >>>> On May 22, 2008, at 9:32 AM, David Chelimsky wrote: >>>> >>>>> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >>>>> >>>>>> Is it possible to specify that certain tables not be cleared on >>>>>> each >>>>>> example. >>>>>> >>>>>> I've inherited a project where a good amount of enumerated data >>>>>> is >>>>>> stored >>>>>> in the database (US States, statuses, about 15-20 tables worth. >>>>>> Over >>>>>> all, >>>>>> it's a reasonable decision that leads to solid production code >>>>>> (acts_as_enumerated is good). This data is read-only and >>>>>> relatively >>>>>> static; >>>>>> any changes to these tables are done via migrations. >>>>>> >>>>>> The problem comes when I'm writing my tests. Obviously all >>>>>> these tables >>>>>> get wiped with each example. >>>>> >>>>> This should not be the case. Transactions get rolled back, but >>>>> tables do >>>>> not just get wiped clean. >>>>> >>>>> If this static data is being generated in migrations, then you >>>>> should be >>>>> OK. Is it? >>>>> >>>>>> Yes, I could specify these as fixtures, but I really don't want >>>>>> to have >>>>>> to specify 15-20 fixtures on every example. Yes, I could mock/ >>>>>> stub all >>>>>> the >>>>>> values, except that I use many of these values at class >>>>>> definition >>>>>> time, >>>>>> which means that errors are thrown before I can even mock/stub. >>>>>> >>>>>> For instance, I have a statement like this. >>>>>> >>>>>> named_scope :open, :conditions => ["lead_status_id IN (?)", >>>>>> %w{New >>>>>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>>>>> >>>>>> Which loads the named_scope using the string version of the >>>>>> enumeration >>>>>> for clarity's sake. It works great, except for testing. >>>>>> >>>>>> Does anybody see anyway around this other than creating a >>>>>> fixture file >>>>>> for each of these tables and loading all the fixtures on each >>>>>> describe >>>>>> block. Not only does this make for ugly code, but I'm sure it >>>>>> takes a >>>>>> good >>>>>> chunk of time to setup and teardown each of the tables each >>>>>> example. >>>>>> >>>>>> It would be wonderful if there was some option to specify >>>>>> tables that >>>>>> behave like this, that should be loaded at the beginning of the >>>>>> test >>>>>> run, >>>>>> and (optionally) trashed at the end of the run. Or even better, >>>>>> specify >>>>>> that >>>>>> the test script shouldn't touch (build or teardown) these >>>>>> tables at >>>>>> all, and >>>>>> let their migrated state remain. >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Andrew > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu May 22 11:34:22 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 22 May 2008 10:34:22 -0500 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: <2C896CB4-1314-4F98-A54F-F495F261F966@mac.com> References: <57c63afe0805220658i223d44ddne8ef11e39546797f@mail.gmail.com> <328FBAF5-C6D2-4E11-B21D-21D9301122A3@mac.com> <57c63afe0805220725j1cffa059te514a76a6616c56c@mail.gmail.com> <2C896CB4-1314-4F98-A54F-F495F261F966@mac.com> Message-ID: On May 22, 2008, at 10:19 AM, Andrew Selder wrote: > YEAH!!!!!!! I've got it. > > I changed my rspec.rake to: > > spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', > 'database.yml')) ? ["db:test:purge", :testing, "db:migrate"] : :noop > task :noop do > end > > task :testing => :environment do > RAILS_ENV = ENV['RAILS_ENV'] = 'test' > ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) > end > > task :default => :spec > task :stats => "spec:statsetup" > > desc "Run all specs in spec directory (excluding plugin specs)" > Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['spec/**/*_spec.rb'] > end > > Thanks for all the assistance from everyone. This is great stuff Andrew - do you have a blog? If so, please consider blogging this. Cheers, David > > > Thanks, > > Andrew > > On May 22, 2008, at 10:25 AM, David Chelimsky wrote: > >> On Thu, May 22, 2008 at 9:12 AM, Andrew Selder >> wrote: >>> Downloaded the latest plugins from Github and got the same results. >>> >>> The spec rake task still ends up calling db:test:prepare which >>> blows away >>> the database and reloads only the schema. >> >> Well, thanks for trying. >> >> You can't be the first person to run up against this problem. I've >> run >> into it before but not in any rails apps I've worked on. >> >> Sounds like the solution would be something like what Scott and >> Ashley >> are talking about - introducing rake db:migrate or a custom data >> setup >> task after or instead of db:test:prepare. >> >>> >>> Thanks, >>> >>> Andrew >>> >>> On May 22, 2008, at 9:58 AM, David Chelimsky wrote: >>> >>>> On Thu, May 22, 2008 at 8:55 AM, Andrew Selder >>>> wrote: >>>>> >>>>> David, >>>>> >>>>> The static data generated in the migrations in being wiped away. >>>>> >>>>> I did a >>>>> rake db:test:purge >>>>> >>>>> followed by >>>>> >>>>> rake db:migrate RAILS_ENV=test >>>>> >>>>> and then looked in my database to verify that the data was there >>>>> and it >>>>> was. >>>>> >>>>> And then when I run rake spec, the test blow up and I looks at >>>>> the DB and >>>>> all the static tables are empty. >>>>> >>>>> Looking at the rspec.rake file in the rspec_on_rails plugin, the >>>>> spec >>>>> task >>>>> calls the spec_prereq task. This task does a db:test:prepare, >>>>> which >>>>> looking >>>>> at the source for that in the rails gem only copies the schema >>>>> from the >>>>> development db. >>>>> >>>>> I'm using Rails 2.1 RC1, and the tagged CURRENT version of both >>>>> plugins. >>>> >>>> AHA! >>>> >>>> CURRENT means the latest release, which is 1.1.3, which was >>>> released >>>> months ago, before Rails 2.1 RC1. >>>> >>>> Try the latest from github: >>>> >>>> script/plugin install git://github.com/dchelimsky/rspec.git >>>> script/plugin install git://github.com/dchelimsky/rspec-rails.git >>>> script/generate rspec >>>> >>>> See if that makes any difference. >>>> >>>> Cheers, >>>> David >>>> >>>>> >>>>> Thanks, >>>>> >>>>> Andrew >>>>> >>>>> On May 22, 2008, at 9:32 AM, David Chelimsky wrote: >>>>> >>>>>> On May 21, 2008, at 9:49 PM, Andrew Selder wrote: >>>>>> >>>>>>> Is it possible to specify that certain tables not be cleared >>>>>>> on each >>>>>>> example. >>>>>>> >>>>>>> I've inherited a project where a good amount of enumerated >>>>>>> data is >>>>>>> stored >>>>>>> in the database (US States, statuses, about 15-20 tables >>>>>>> worth. Over >>>>>>> all, >>>>>>> it's a reasonable decision that leads to solid production code >>>>>>> (acts_as_enumerated is good). This data is read-only and >>>>>>> relatively >>>>>>> static; >>>>>>> any changes to these tables are done via migrations. >>>>>>> >>>>>>> The problem comes when I'm writing my tests. Obviously all >>>>>>> these tables >>>>>>> get wiped with each example. >>>>>> >>>>>> This should not be the case. Transactions get rolled back, but >>>>>> tables do >>>>>> not just get wiped clean. >>>>>> >>>>>> If this static data is being generated in migrations, then you >>>>>> should be >>>>>> OK. Is it? >>>>>> >>>>>>> Yes, I could specify these as fixtures, but I really don't >>>>>>> want to have >>>>>>> to specify 15-20 fixtures on every example. Yes, I could mock/ >>>>>>> stub all >>>>>>> the >>>>>>> values, except that I use many of these values at class >>>>>>> definition >>>>>>> time, >>>>>>> which means that errors are thrown before I can even mock/stub. >>>>>>> >>>>>>> For instance, I have a statement like this. >>>>>>> >>>>>>> named_scope :open, :conditions => ["lead_status_id IN (?)", >>>>>>> %w{New >>>>>>> Incubating Client UAG}.collect{|x| LeadStatus[x].id}] >>>>>>> >>>>>>> Which loads the named_scope using the string version of the >>>>>>> enumeration >>>>>>> for clarity's sake. It works great, except for testing. >>>>>>> >>>>>>> Does anybody see anyway around this other than creating a >>>>>>> fixture file >>>>>>> for each of these tables and loading all the fixtures on each >>>>>>> describe >>>>>>> block. Not only does this make for ugly code, but I'm sure it >>>>>>> takes a >>>>>>> good >>>>>>> chunk of time to setup and teardown each of the tables each >>>>>>> example. >>>>>>> >>>>>>> It would be wonderful if there was some option to specify >>>>>>> tables that >>>>>>> behave like this, that should be loaded at the beginning of >>>>>>> the test >>>>>>> run, >>>>>>> and (optionally) trashed at the end of the run. Or even >>>>>>> better, specify >>>>>>> that >>>>>>> the test script shouldn't touch (build or teardown) these >>>>>>> tables at >>>>>>> all, and >>>>>>> let their migrated state remain. >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Andrew >> _______________________________________________ >> 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 zach.dennis at gmail.com Thu May 22 12:31:23 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 22 May 2008 12:31:23 -0400 Subject: [rspec-users] Specifying certain tables NOT to be cleared each example? In-Reply-To: References: Message-ID: <85d99afe0805220931q13b2b0efqfe328d49aa35a533@mail.gmail.com> I know the problem has been solved but you can supply global fixtures in your spec_helper.rb file. This avoids having to repeat them for every describe block. Spec::Runner.configure do |config| config.global_fixtures = :table_a, :table_b end Zach On Wed, May 21, 2008 at 10:49 PM, Andrew Selder wrote: > Is it possible to specify that certain tables not be cleared on each > example. > > I've inherited a project where a good amount of enumerated data is stored > in the database (US States, statuses, about 15-20 tables worth. Over all, > it's a reasonable decision that leads to solid production code > (acts_as_enumerated is good). This data is read-only and relatively static; > any changes to these tables are done via migrations. > > The problem comes when I'm writing my tests. Obviously all these tables get > wiped with each example. Yes, I could specify these as fixtures, but I > really don't want to have to specify 15-20 fixtures on every example. Yes, I > could mock/stub all the values, except that I use many of these values at > class definition time, which means that errors are thrown before I can even > mock/stub. > > For instance, I have a statement like this. > > named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New > Incubating Client UAG}.collect{|x| LeadStatus[x].id}] > > Which loads the named_scope using the string version of the enumeration for > clarity's sake. It works great, except for testing. > > Does anybody see anyway around this other than creating a fixture file for > each of these tables and loading all the fixtures on each describe block. > Not only does this make for ugly code, but I'm sure it takes a good chunk of > time to setup and teardown each of the tables each example. > > It would be wonderful if there was some option to specify tables that > behave like this, that should be loaded at the beginning of the test run, > and (optionally) trashed at the end of the run. Or even better, specify that > the test script shouldn't touch (build or teardown) these tables at all, and > let their migrated state remain. > > Thanks, > > Andrew > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri May 23 05:56:11 2008 From: lists at ruby-forum.com (Doug Livesey) Date: Fri, 23 May 2008 11:56:11 +0200 Subject: [rspec-users] Is there an equivalent to anything() for Hash parameters? Message-ID: <4beaa0e7094845590a199896a6520df9@ruby-forum.com> Hi -- is there an equivalent to the anything() method to use with Hash parameters? So that the following call: Model.find( :all, :conditions => "name LIKE '%rt%'", :order => 'name' ) Could have the two following successful examples: Model.should_receive( :find ).with( :all, { :conditions => "name LIKE '%rt%", anything } ) Model.should_receive( :find ).with( :all, { anything, :order => 'name' } ) If anyone knew a way of generating that sort of behaviour, I'd be *very* grateful! Cheers, Doug. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 23 06:00:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 May 2008 05:00:52 -0500 Subject: [rspec-users] Is there an equivalent to anything() for Hash parameters? In-Reply-To: <4beaa0e7094845590a199896a6520df9@ruby-forum.com> References: <4beaa0e7094845590a199896a6520df9@ruby-forum.com> Message-ID: <3DDF7926-01E2-4344-B43A-0F2A9031BD16@gmail.com> On May 23, 2008, at 4:56 AM, Doug Livesey wrote: > Hi -- is there an equivalent to the anything() method to use with Hash > parameters? > So that the following call: > Model.find( :all, :conditions => "name LIKE '%rt%'", :order => 'name' > ) > > Could have the two following successful examples: > Model.should_receive( :find ).with( :all, { :conditions => "name LIKE > '%rt%", anything } ) > Model.should_receive( :find ).with( :all, { anything, :order => > 'name' > } ) If you're using the latest from github: Model.should_receive(:find).with(:all, hash_including(:order => 'name')) This only verifies the specified key/value pairs and ignores everything else. Cheers, David > > > If anyone knew a way of generating that sort of behaviour, I'd be > *very* > grateful! > Cheers, > Doug. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tom at experthuman.com Fri May 23 06:06:12 2008 From: tom at experthuman.com (Tom Stuart) Date: Fri, 23 May 2008 11:06:12 +0100 Subject: [rspec-users] Is there an equivalent to anything() for Hash parameters? In-Reply-To: <4beaa0e7094845590a199896a6520df9@ruby-forum.com> References: <4beaa0e7094845590a199896a6520df9@ruby-forum.com> Message-ID: <937AC3C5-E675-498D-A404-F99F36212207@experthuman.com> On 23 May 2008, at 10:56, Doug Livesey wrote: > Hi -- is there an equivalent to the anything() method to use with Hash > parameters? FYI this was discussed in March, so you might be able to find something useful in the list archive if you'd rather roll your own parameter matcher than switch to bleeding-edge RSpec: http://rubyforge.org/pipermail/rspec-users/2008-March/006137.html http://rubyforge.org/pipermail/rspec-users/2008-March/006139.html Cheers, -Tom From lists at ruby-forum.com Fri May 23 06:17:12 2008 From: lists at ruby-forum.com (Doug Livesey) Date: Fri, 23 May 2008 12:17:12 +0200 Subject: [rspec-users] Error when trying to get the install RSpec from Github Message-ID: <7d5a585783b2dc9c53b8e8b5e3362038@ruby-forum.com> Hi -- I've tried to get the latest RSpec by following the instructions at: http://github.com/dchelimsky/rspec/wikis/home I clone the repository just fine, but then, when I 'rake gem', I get the following errors: svn: '..' is not a working copy svn: Can't open file '../.svn/entries': No such file or directory tar: rspec-rails-1.1.3: Cannot stat: No such file or directory tar: Error exit delayed from previous errors svn: '..' is not a working copy svn: Can't open file '../.svn/entries': No such file or directory tar: RSpec.tmbundle: Cannot stat: No such file or directory tar: Error exit delayed from previous errors Can anyone advise me on how to get around this? Cheers, Doug. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 23 06:20:50 2008 From: lists at ruby-forum.com (Doug Livesey) Date: Fri, 23 May 2008 12:20:50 +0200 Subject: [rspec-users] Is there an equivalent to anything() for Hash parameters In-Reply-To: <937AC3C5-E675-498D-A404-F99F36212207@experthuman.com> References: <4beaa0e7094845590a199896a6520df9@ruby-forum.com> <937AC3C5-E675-498D-A404-F99F36212207@experthuman.com> Message-ID: <26f77c8109402f61789e30179eb25e32@ruby-forum.com> Cheers for both of those responses! I think I might try to get onto the bleeding edge of RSpec, although I am currently having some issues doing so. If I don't get that fixed in the next half hour or so, I reckon I'll go w/ the custom matcher -- it's probably about time I refreshed my memory on matchers, anyway! Thanks again for the help, there. Doug. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 23 06:44:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 May 2008 05:44:40 -0500 Subject: [rspec-users] Error when trying to get the install RSpec from Github In-Reply-To: <7d5a585783b2dc9c53b8e8b5e3362038@ruby-forum.com> References: <7d5a585783b2dc9c53b8e8b5e3362038@ruby-forum.com> Message-ID: <89995E1B-7C77-4839-83FA-6070B15560B1@gmail.com> On May 23, 2008, at 5:17 AM, Doug Livesey wrote: > Hi -- I've tried to get the latest RSpec by following the instructions > at: > http://github.com/dchelimsky/rspec/wikis/home > > I clone the repository just fine, but then, when I 'rake gem', I get > the > following errors: > > > > svn: '..' is not a working copy > svn: Can't open file '../.svn/entries': No such file or directory > tar: rspec-rails-1.1.3: Cannot stat: No such file or directory > tar: Error exit delayed from previous errors > svn: '..' is not a working copy > svn: Can't open file '../.svn/entries': No such file or directory > tar: RSpec.tmbundle: Cannot stat: No such file or directory > tar: Error exit delayed from previous errors > > > > Can anyone advise me on how to get around this? That's a bug - please file a ticket at http://rspec.lighthouseapp.com. If you're using this for a rails app, you're better off following the directions at http://github.com/dchelimsky/rspec-rails/wikis/home Cheers, David > > Cheers, > Doug. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri May 23 09:02:47 2008 From: lists at ruby-forum.com (Doug Livesey) Date: Fri, 23 May 2008 15:02:47 +0200 Subject: [rspec-users] Error when trying to get the install RSpec from Github In-Reply-To: <89995E1B-7C77-4839-83FA-6070B15560B1@gmail.com> References: <7d5a585783b2dc9c53b8e8b5e3362038@ruby-forum.com> <89995E1B-7C77-4839-83FA-6070B15560B1@gmail.com> Message-ID: <81944c677bc20cdf3053fb5ba98c684b@ruby-forum.com> Ticket files -- #407. & cheers for the link, man -- I'll check that now. Doug. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 23 14:20:22 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Fri, 23 May 2008 20:20:22 +0200 Subject: [rspec-users] View Specs vs. Stories Message-ID: Do RSpec stories make view specs redundant? Does anybody spec their views *and* use stories, and if so how? Any views (no pun intended) appreciated. ~ Thanks Mark -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri May 23 14:20:58 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Fri, 23 May 2008 20:20:58 +0200 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: Message-ID: Mark Dodwell wrote: > Do RSpec stories make view specs redundant? Sorry I should clarify that I'm talking about Rails view specs specifically here. -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Fri May 23 14:27:57 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 23 May 2008 11:27:57 -0700 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: Message-ID: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> On 5/23/08, Mark Dodwell wrote: > Do RSpec stories make view specs redundant? Does anybody spec their > views *and* use stories, and if so how? > > Any views (no pun intended) appreciated. > > ~ Thanks > > Mark > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Not necessarily. You might test one or two paths through stories, and unit test remaining branches in your views. Pat From hayafirst at gmail.com Fri May 23 14:53:43 2008 From: hayafirst at gmail.com (Yi Wen) Date: Fri, 23 May 2008 13:53:43 -0500 Subject: [rspec-users] RailsExampleGroup Message-ID: So I have a describe which is a subclass of RailsExampleGroup. I inserted some data into my database, and reconnect! my connection. Before reconnect, finding the data I just created is fine. The data cannot be found, after reconnection, the data is gone. It's not in the database. It looks to me the data is not actually inserted into the DB at all, just somehow buffered somewhere. Would anybody know why? thanks. Now the workaround is to have a separate class doing all DB operations, but I am still curious why RSpec does this, for speed reason? Yi -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashley.moran at patchspace.co.uk Fri May 23 15:20:59 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 23 May 2008 20:20:59 +0100 Subject: [rspec-users] RailsExampleGroup In-Reply-To: References: Message-ID: <011B2AED-C10B-4530-8C5E-1408E28A88D8@patchspace.co.uk> On 23 May 2008, at 19:53, Yi Wen wrote: > It's not in the database. It looks to me the data is not actually > inserted into the DB at all, just somehow buffered somewhere. It's stored in a transaction, so the only place you can see the data is from the same connection. Make another connection (by reconnecting) and you are protected from seeing that data. Why do you want to see this intermediate state of the database from another connection anyway? It's an unusual thing to want to do. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Fri May 23 15:25:02 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 23 May 2008 20:25:02 +0100 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> Message-ID: <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> On 23 May 2008, at 19:27, Pat Maddox wrote: > Not necessarily. You might test one or two paths through stories, and > unit test remaining branches in your views. I'll go with this. I stopped writing view specs but I can see you could get in a situation where you have more permutations in a view than you want to test through the stories. However, I'd want to establish that that wasn't just a sign of un-refactored code. Right now I'm leaning towards stories only unless I come up with a pressing need for specs. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at ruby-forum.com Fri May 23 15:34:37 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Fri, 23 May 2008 21:34:37 +0200 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> Message-ID: Thanks for the comments. This might be more obvious, but what about rails integration tests -- presumably RSpec stories make these redundant for sure? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri May 23 15:48:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 May 2008 14:48:18 -0500 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> Message-ID: On May 23, 2008, at 2:34 PM, Mark Dodwell wrote: > Thanks for the comments. > > This might be more obvious, but what about rails integration tests -- > presumably RSpec stories make these redundant for sure? RailsStory (in RSpec) wraps rails integration tests. So not only redundant, but the same thing and repetitive all at the same deja-vu- all-over-again moment! From pergesu at gmail.com Fri May 23 15:54:56 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 23 May 2008 12:54:56 -0700 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> Message-ID: <810a540e0805231254w539de88fia2c10579222aa89e@mail.gmail.com> On Fri, May 23, 2008 at 12:34 PM, Mark Dodwell wrote: > Thanks for the comments. > > This might be more obvious, but what about rails integration tests -- > presumably RSpec stories make these redundant for sure? Yeah, stories can serve the same role as integration tests. Pat From dchelimsky at gmail.com Fri May 23 15:58:35 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 May 2008 14:58:35 -0500 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: <810a540e0805231254w539de88fia2c10579222aa89e@mail.gmail.com> References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> <810a540e0805231254w539de88fia2c10579222aa89e@mail.gmail.com> Message-ID: On May 23, 2008, at 2:54 PM, Pat Maddox wrote: > On Fri, May 23, 2008 at 12:34 PM, Mark Dodwell forum.com> wrote: >> Thanks for the comments. >> >> This might be more obvious, but what about rails integration tests -- >> presumably RSpec stories make these redundant for sure? > > Yeah, stories can serve the same role as integration tests. Funny - I always looked at it the other way around - treating rails integration tests as something close to stories. > > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From hayafirst at gmail.com Fri May 23 16:35:40 2008 From: hayafirst at gmail.com (Yi Wen) Date: Fri, 23 May 2008 15:35:40 -0500 Subject: [rspec-users] RailsExampleGroup Message-ID: Well, I use this for driving selenium RC. So the approach I am using is to setup some data, and then invoke selenium to interact with a test server. Apparently the test server uses another connection. Would you suggest a better way to handle this? It will be the same for doing functional testing on web services. What's the "standard way" of doing it? Yi On 23 May 2008, at 19:53, Yi Wen wrote: > It's not in the database. It looks to me the data is not actually > inserted into the DB at all, just somehow buffered somewhere. It's stored in a transaction, so the only place you can see the data is from the same connection. Make another connection (by reconnecting) and you are protected from seeing that data. Why do you want to see this intermediate state of the database from another connection anyway? It's an unusual thing to want to do. Ashley From ashley.moran at patchspace.co.uk Fri May 23 16:54:17 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 23 May 2008 21:54:17 +0100 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> Message-ID: On 23 May 2008, at 20:48, David Chelimsky wrote: > RailsStory (in RSpec) wraps rails integration tests. So not only > redundant, but the same thing and repetitive all at the same deja-vu- > all-over-again moment! Is there a Don't Deja-vu Yourself principle we should be following? :) -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From pergesu at gmail.com Fri May 23 17:17:53 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 23 May 2008 14:17:53 -0700 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: <810a540e0805231127n6f45613ar2256ac0f9712c595@mail.gmail.com> <69E568FD-6064-4D62-8940-1F826213BF8E@patchspace.co.uk> <810a540e0805231254w539de88fia2c10579222aa89e@mail.gmail.com> Message-ID: <810a540e0805231417n45e822c7mbb481c77391ea33f@mail.gmail.com> On Fri, May 23, 2008 at 12:58 PM, David Chelimsky wrote: > On May 23, 2008, at 2:54 PM, Pat Maddox wrote: > >> On Fri, May 23, 2008 at 12:34 PM, Mark Dodwell >> wrote: >>> >>> Thanks for the comments. >>> >>> This might be more obvious, but what about rails integration tests -- >>> presumably RSpec stories make these redundant for sure? >> >> Yeah, stories can serve the same role as integration tests. > > Funny - I always looked at it the other way around - treating rails > integration tests as something close to stories. > >> >> >> 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 > I think that Rails integration tests are very effective integration tests. Although you can make them quite expressive, I still wouldn't show them to a customer. User stories *can* serve that same role, though doing so misses the key benefits. Pat From ashley.moran at patchspace.co.uk Fri May 23 17:12:56 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 23 May 2008 22:12:56 +0100 Subject: [rspec-users] RailsExampleGroup In-Reply-To: References: Message-ID: <2C33058F-DF02-49CE-BACF-8B27C74FACAA@patchspace.co.uk> On 23 May 2008, at 21:35, Yi Wen wrote: > Well, I use this for driving selenium RC. So the approach I am using > is to setup some data, and then invoke selenium to interact with a > test server. Apparently the test server uses another connection. Would > you suggest a better way to handle this? It will be the same for doing > functional testing on web services. What's the "standard way" of doing > it? Ah ok, I get you now. I did the same thing and it stumped me too, I was completely baffled for a whole day. What you've got with selenium- rc is not this: +--ruby-process--+ | | | rails | | ^ | | | |----->(database) | rspec | | | +----------------+ but this: +--ruby-process--+ | | | rails |-------- | | \ +----------------+ | ^ | | | +--native-proc---+ | | | | | browser | | | | | +----------------+ V ^ (database) | ^ +--java-process--+ | | | | | selenium-rc | | | | | +----------------+ | ^ | | | +--ruby-process--+ | | | | | rspec |--------/ | | +----------------+ Nothing like a bit of ascii art to liven up a mailing list :) My solution was to create a custom story listener, which is a class that looks like this (copied from a post I made in April): class MyStoryListener def run_started(number_of_scenarios); end def story_started(story, narrative); end def story_ended(story, narrative); end def scenario_started(story, scenario); end def scenario_succeeded(story, scenario); end def scenario_pending(story, scenario, error); end def scenario_failed(story, scenario, error); end def run_ended; end # method_missing allows you to remove hooks you don't need def method_missing(*args); end end Spec::Story::Runner.register_listener(MyStoryListener.new) What I did was to have the run_started hook delete all non-static data out of the database. There's other things you can do to make the process more useful for development. I've wanted for ages to package some code for this together. I've got a Merb app I want to start soon, and this will be an essential pre-requisite. So hopefully I'll get that done soon and I'll post back here. (However my pet projects usually get sidetracked...) Hope this helps for now anyway. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From loriolson at mac.com Fri May 23 17:35:21 2008 From: loriolson at mac.com (Lori M Olson) Date: Fri, 23 May 2008 15:35:21 -0600 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 Message-ID: Can anyone (David?) shed some light on what exactly this warning is complaining about? I started seeing it when I upgraded to Rails 2.1 RC1 and the latest RSpec from git. I'm getting it in some helper specs that I'm writing. And yes, I am including a module there, to reuse some utility methods I originally wrote for my controller tests (I'm switching to specs as fast as I can, but I don't have time to re-jigger all my tests over to specs yet). Regards, Lori From joshknowles at gmail.com Fri May 23 18:00:54 2008 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 23 May 2008 18:00:54 -0400 Subject: [rspec-users] View Specs vs. Stories In-Reply-To: References: Message-ID: On 5/23/08, Mark Dodwell wrote: > Do RSpec stories make view specs redundant? Does anybody spec their > views *and* use stories, and if so how? > > Any views (no pun intended) appreciated. Our team has been talking a lot about this subject recently as we made a decision at the beginning of the project to skip view specs in favor of stories which has left us with a suite of stories which is now taking roughly 5 minutes to run. Upon investigation I've noticed that many of our stories are things that a simple view-spec would cover, and am now starting to move logic back into view specs. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From pergesu at gmail.com Fri May 23 18:21:08 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 23 May 2008 15:21:08 -0700 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: References: Message-ID: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> It appears when you write a spec like describe FooModule do ... Pat On 5/23/08, Lori M Olson wrote: > Can anyone (David?) shed some light on what exactly this warning is > complaining about? I started seeing it when I upgraded to Rails 2.1 > RC1 and the latest RSpec from git. > > I'm getting it in some helper specs that I'm writing. And yes, I am > including a module there, to reuse some utility methods I originally > wrote for my controller tests (I'm switching to specs as fast as I > can, but I don't have time to re-jigger all my tests over to specs yet). > > Regards, Lori > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Fri May 23 18:23:33 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 23 May 2008 15:23:33 -0700 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> Message-ID: <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> RSpec currently includes the described module so that you can call methods directly. It will no longerdo that automatically, so you'll have to manually include the module if you want these direct calls. Rails helpers are defined in modules, so that's why this is showing up. Pat On 5/23/08, Pat Maddox wrote: > It appears when you write a spec like > > describe FooModule do ... > > Pat > > > On 5/23/08, Lori M Olson wrote: >> Can anyone (David?) shed some light on what exactly this warning is >> complaining about? I started seeing it when I upgraded to Rails 2.1 >> RC1 and the latest RSpec from git. >> >> I'm getting it in some helper specs that I'm writing. And yes, I am >> including a module there, to reuse some utility methods I originally >> wrote for my controller tests (I'm switching to specs as fast as I >> can, but I don't have time to re-jigger all my tests over to specs yet). >> >> Regards, Lori >> >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From dchelimsky at gmail.com Fri May 23 18:48:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 23 May 2008 17:48:56 -0500 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: References: Message-ID: <0765337C-DE49-4067-80B6-25C3835EB792@gmail.com> On May 23, 2008, at 4:35 PM, Lori M Olson wrote: > Can anyone (David?) shed some light on what exactly this warning is > complaining about? I started seeing it when I upgraded to Rails 2.1 > RC1 and the latest RSpec from git. > > I'm getting it in some helper specs that I'm writing. And yes, I am > including a module there, to reuse some utility methods I originally > wrote for my controller tests (I'm switching to specs as fast as I > can, but I don't have time to re-jigger all my tests over to specs > yet). Helper example groups (in git) now have a helper object that you can (and should) use. So instead of this: describe SomeHelper do it "should be helpful" do some_helpful_method.should == "this result" end end You do this: describe SomeHelper do it "should be helpful" do helper.some_helpful_method.should == "this result" end end That will make the warning go away. The reason we did this is that somebody had a describe method in a helper and it created a conflict :) We realized then that including the module implicitly was asking for trouble. HTH, David From loriolson at mac.com Fri May 23 19:10:33 2008 From: loriolson at mac.com (Lori M Olson) Date: Fri, 23 May 2008 17:10:33 -0600 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> Message-ID: <67C7B894-06CC-49F7-85BA-ABE2B064C0F7@mac.com> So, for helper specs, one must now do something like: describe SomeHelper do include SomeHelper before(:each) do ... end it "should do something" end That seems redundant, but I suppose there's a good reason for it. Thanks for the help, Pat! Regards, Lori On 23-May-08, at 4:23 PM, Pat Maddox wrote: > RSpec currently includes the described module so that you can call > methods directly. It will no longerdo that automatically, so you'll > have to manually include the module if you want these direct calls. > > Rails helpers are defined in modules, so that's why this is showing > up. > > Pat > On 5/23/08, Pat Maddox wrote: >> It appears when you write a spec like >> >> describe FooModule do ... >> >> Pat >> >> >> On 5/23/08, Lori M Olson wrote: >>> Can anyone (David?) shed some light on what exactly this warning is >>> complaining about? I started seeing it when I upgraded to Rails 2.1 >>> RC1 and the latest RSpec from git. >>> >>> I'm getting it in some helper specs that I'm writing. And yes, I am >>> including a module there, to reuse some utility methods I originally >>> wrote for my controller tests (I'm switching to specs as fast as I >>> can, but I don't have time to re-jigger all my tests over to specs >>> yet). >>> >>> Regards, Lori >>> >>> >>> >>> >>> _______________________________________________ >>> 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 loriolson at mac.com Fri May 23 20:59:06 2008 From: loriolson at mac.com (Lori M Olson) Date: Fri, 23 May 2008 18:59:06 -0600 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: <0765337C-DE49-4067-80B6-25C3835EB792@gmail.com> References: <0765337C-DE49-4067-80B6-25C3835EB792@gmail.com> Message-ID: On 23-May-08, at 4:48 PM, David Chelimsky wrote: > On May 23, 2008, at 4:35 PM, Lori M Olson wrote: > >> Can anyone (David?) shed some light on what exactly this warning is >> complaining about? I started seeing it when I upgraded to Rails >> 2.1 RC1 and the latest RSpec from git. >> >> I'm getting it in some helper specs that I'm writing. And yes, I >> am including a module there, to reuse some utility methods I >> originally wrote for my controller tests (I'm switching to specs as >> fast as I can, but I don't have time to re-jigger all my tests over >> to specs yet). > > Helper example groups (in git) now have a helper object that you can > (and should) use. So instead of this: > > describe SomeHelper do > it "should be helpful" do > some_helpful_method.should == "this result" > end > end > > You do this: > > describe SomeHelper do > it "should be helpful" do > helper.some_helpful_method.should == "this result" > end > end > > That will make the warning go away. > > The reason we did this is that somebody had a describe method in a > helper and it created a conflict :) We realized then that including > the module implicitly was asking for trouble. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Thanks, David. That makes a lot more sense. Regards, Lori From lists at ruby-forum.com Mon May 26 15:52:43 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Mon, 26 May 2008 21:52:43 +0200 Subject: [rspec-users] Mocking Models in Controller Specs... Message-ID: I find myself doing this kind of thing a lot in Controller Specs: @vacancy = mock_model(Vacancy) @vacancy.stub!(:reference) @vacancy.stub!(:title) @vacancy.stub!(:created_at) @vacancy.stub!(:updated_at) @vacancy.stub!(:body) @vacancy.stub!(:contract) @vacancy.stub!(:location) @vacancy.stub!(:salary) @vacancy.stub!(:benefits) @vacancy.stub!(:start_date) @vacancy.stub!(:duration) I have to stub each of these methods so that the form renders correctly (as I am using integrate_views). This just feels *way* too much code and effort to do this. I have a spec for one controller (which just does plain old CRUD) that is over 300 LOC -- this seems a bit nuts to me when the controller is only 50 LOC. Does anybody have any suggestions on how to avoid this or perhaps I am doing something wrong!? I make use of a Factory pattern to create instances for my model unit tests -- could I use a similar pattern for a 'mock factory'? Is anybody doing anything similar? ~ Mark -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon May 26 16:05:48 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 26 May 2008 15:05:48 -0500 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: References: Message-ID: <54A3B5BE-131C-4B6E-8CFF-567171CDB5BA@gmail.com> On May 26, 2008, at 2:52 PM, Mark Dodwell wrote: > I find myself doing this kind of thing a lot in Controller Specs: > > @vacancy = mock_model(Vacancy) > @vacancy.stub!(:reference) > @vacancy.stub!(:title) > @vacancy.stub!(:created_at) > @vacancy.stub!(:updated_at) > @vacancy.stub!(:body) > @vacancy.stub!(:contract) > @vacancy.stub!(:location) > @vacancy.stub!(:salary) > @vacancy.stub!(:benefits) > @vacancy.stub!(:start_date) > @vacancy.stub!(:duration) > > I have to stub each of these methods so that the form renders > correctly > (as I am using integrate_views). This just feels *way* too much code > and > effort to do this. I have a spec for one controller (which just does > plain old CRUD) that is over 300 LOC -- this seems a bit nuts to me > when > the controller is only 50 LOC. > > Does anybody have any suggestions on how to avoid this or perhaps I am > doing something wrong!? Use stub_model instead (if you're using source from github - if not the 1.4 release is coming soon). > > > I make use of a Factory pattern to create instances for my model unit > tests -- could I use a similar pattern for a 'mock factory'? Is > anybody > doing anything similar? > > ~ Mark > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Mon May 26 16:29:56 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Mon, 26 May 2008 16:29:56 -0400 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: References: Message-ID: On May 26, 2008, at 3:52 PM, Mark Dodwell wrote: > I find myself doing this kind of thing a lot in Controller Specs: > > @vacancy = mock_model(Vacancy) > @vacancy.stub!(:reference) > @vacancy.stub!(:title) > @vacancy.stub!(:created_at) > @vacancy.stub!(:updated_at) > @vacancy.stub!(:body) > @vacancy.stub!(:contract) > @vacancy.stub!(:location) > @vacancy.stub!(:salary) > @vacancy.stub!(:benefits) > @vacancy.stub!(:start_date) > @vacancy.stub!(:duration) > > I have to stub each of these methods so that the form renders > correctly > (as I am using integrate_views). This just feels *way* too much code > and > effort to do this. I have a spec for one controller (which just does > plain old CRUD) that is over 300 LOC -- this seems a bit nuts to me > when > the controller is only 50 LOC. > > Does anybody have any suggestions on how to avoid this or perhaps I am > doing something wrong!? I would highly suggest using :null_object => true in view specs (or controller specs with integrate_views): mock_model(MyARModel, :null_object => true, :to_s => "foobar") stubbing :to_s is also important in view specs. If you don't stub to_s, to_s will be called on the mock object, and you'll get invalid XHTML (see this ticket: http://rspec.lighthouseapp.com/projects/5645/tickets/230-mock-null_object-true-doesn-t-play-nice-with-html) Scott From dchelimsky at gmail.com Mon May 26 17:52:31 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 26 May 2008 16:52:31 -0500 Subject: [rspec-users] [ANN] RSpec-1.1.4 Message-ID: The RSpec Development Team is happy to announce the release of RSpec-1.1.4. See http://rspec.info/changes.html for details of what changed in this release. For Rails developers: * This release of RSpec supports Rails-2.1.0-RC1, 2.0.2, 1.2.6 More info at http://rspec.info. Cheers, David From tim at pivotib.com Mon May 26 19:54:09 2008 From: tim at pivotib.com (Tim Glen) Date: Mon, 26 May 2008 19:54:09 -0400 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> Message-ID: On 23-May-08, at 6:23 PM, Pat Maddox wrote: > RSpec currently includes the described module so that you can call > methods directly. It will no longerdo that automatically, so you'll > have to manually include the module if you want these direct calls. > > Rails helpers are defined in modules, so that's why this is showing > up. So I find myself wondering - is this the case for just helper modules or all modules? For instance, I have a module which gets included into some controllers, but I'd like to spec against it directly so I don't have in those other controllers... I'm not sure how to set this up. What's the best practice? I'm on Rails 2.0.2 and just updated to the fresh Rspec 1.1.4 thanks, tim From dchelimsky at gmail.com Mon May 26 20:05:24 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 26 May 2008 19:05:24 -0500 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> Message-ID: On May 26, 2008, at 6:54 PM, Tim Glen wrote: > On 23-May-08, at 6:23 PM, Pat Maddox wrote: > >> RSpec currently includes the described module so that you can call >> methods directly. It will no longerdo that automatically, so you'll >> have to manually include the module if you want these direct calls. >> >> Rails helpers are defined in modules, so that's why this is showing >> up. > > So I find myself wondering - is this the case for just helper > modules or all modules? For instance, I have a module which gets > included into some controllers, but I'd like to spec against it > directly so I don't have in those other controllers... I'm not sure > how to set this up. What's the best practice? First of all, don't ever believe anybody when they tell you something is a best practice. That said - here's what I *usually* do: describe WhizBangModule do it "should do something" do whiz_banger = Object.new whiz_banger.extend WhizBangModule whiz_banger.whiz.should == "bang" end end or something like that. Make sense? > > > I'm on Rails 2.0.2 and just updated to the fresh Rspec 1.1.4 > > thanks, > tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tim at pivotib.com Mon May 26 20:22:22 2008 From: tim at pivotib.com (Tim Glen) Date: Mon, 26 May 2008 20:22:22 -0400 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> Message-ID: <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> >> So I find myself wondering - is this the case for just helper >> modules or all modules? For instance, I have a module which gets >> included into some controllers, but I'd like to spec against it >> directly so I don't have in those other controllers... I'm not sure >> how to set this up. What's the best practice? > > First of all, don't ever believe anybody when they tell you > something is a best practice. > > That said - here's what I *usually* do: > > describe WhizBangModule do > it "should do something" do > whiz_banger = Object.new > whiz_banger.extend WhizBangModule > whiz_banger.whiz.should == "bang" > end > end > > or something like that. Make sense? Yes, that makes sense. I like that as far as it goes, but I'm wondering if there's a way to take it one step further and actually have it extend the typical controller functionality - some of my methods make use of the session, or set some assigns, for instance. I'd love to be able to test it as if it were in a controller already, with all the spec goodness that comes along with that. I can set up what you've done here to answer _like_ a controller, but that seems silly given that the same functionality is potentially already available. I could also spec it in the context of one of the controllers that includes it already, but that seems too specific. thanks, tim From tom at experthuman.com Tue May 27 03:01:11 2008 From: tom at experthuman.com (Tom Stuart) Date: Tue, 27 May 2008 08:01:11 +0100 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> Message-ID: On 27 May 2008, at 01:22, Tim Glen wrote: >> whiz_banger = Object.new >> whiz_banger.extend WhizBangModule > I like that as far as it goes, but I'm wondering if there's a way to > take it one step further and actually have it extend the typical > controller functionality - some of my methods make use of the > session, or set some assigns, for instance. I'd love to be able to > test it as if it were in a controller already I suspect that the conventional answer is to mock the pieces of "typical controller functionality" you're relying on, so that 1. you're speccing your module in isolation from any other code, instead of trying to exercise two things at once, and 2. you're explicitly specifying (and exercising) the interface between your module and its host class instead of making a whole bunch of invisible assumptions. Cheers, -Tom From loop at superinfinite.com Tue May 27 03:16:13 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Tue, 27 May 2008 09:16:13 +0200 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: References: Message-ID: On 26-mei-2008, at 21:52, Mark Dodwell wrote: > I find myself doing this kind of thing a lot in Controller Specs: > > @vacancy = mock_model(Vacancy) > @vacancy.stub!(:reference) > @vacancy.stub!(:title) > @vacancy.stub!(:created_at) > @vacancy.stub!(:updated_at) > @vacancy.stub!(:body) > @vacancy.stub!(:contract) > @vacancy.stub!(:location) > @vacancy.stub!(:salary) > @vacancy.stub!(:benefits) > @vacancy.stub!(:start_date) > @vacancy.stub!(:duration) > > I have to stub each of these methods so that the form renders > correctly > (as I am using integrate_views). This just feels *way* too much > code and > effort to do this. I have a spec for one controller (which just does > plain old CRUD) that is over 300 LOC -- this seems a bit nuts to me > when > the controller is only 50 LOC. Or, consider moving code into the model, and test it there. See http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model gr, bartz From jarmo.p at gmail.com Tue May 27 03:35:14 2008 From: jarmo.p at gmail.com (kasutaja) Date: Tue, 27 May 2008 00:35:14 -0700 (PDT) Subject: [rspec-users] new --pattern option Message-ID: <17484038.post@talk.nabble.com> Hello. You're saying that: To get rspec to behave as it did before this change, use this: --pattern "**/*.rb" I tried like this (rspec 1.03) and it wasn't same as before (rspec 1.08). Now it also loads all other files in current directory and in all subdirectories and not only from directory and subdirectories given to spec as a parameter. So, for example, I have something like this: .\some_file.rb (which I don't want to load) .\some_dir\some_other_dir\some_other_files.rb (I don't want to load these also) .\my_test_dir (has many subdirs and rb files in it - I want to load all .rb files from THIS dir) now, I execute rspec like this: spec -p **/*.rb my_test_dir (and having working directory . of course). Now I get some errors and things (some of them need input parameters and so on) from the files I did not want to include and they weren't included with previous versions. For example, it is going to load all rb files from "." and from "some_dir" and subdirectories. What's wrong and how can I avoid that? I made simple test, created files called "main_spec.rb" to follow your naming convention. It had only one line in it: puts "spec: " + File.dirname(__FILE__) Now, I executed spec without -p (--pattern) switch to have it to use default option (which is **/*_spec.rb). Everything worked as with version 1.08. But NOW, if I executed spec with -p **/*_spec.rb (which is SAME as default option!) it loaded ALL *_spec.rb files from working directory and from every subdirectories (as supposed to all *_spec.rb files from directories and subdirectories given to spec as input parameter). It seems to be some bug. Any ideas? One way is to change working directory to "my_test_dir" prior executing rspec but it's not comfortable also. Other way would be to rename all my tests to _spec.rb, which wouldn't be also too big of a job. But the question still remains. Jarmo. David Chelimsky-2 wrote: > > Hello all, > > Just a heads up that I made a change (in svn trunk - not yet released) > that may change what files get loaded when you run the rake or spec > commands. Not a big deal if you've been following convention, but for > those who haven't you may need to make a minor adjustment to your rake > file or spec.opts. > > http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/new---pattern-option-tp14983923p17484038.html Sent from the rspec-users mailing list archive at Nabble.com. From lists at ruby-forum.com Tue May 27 03:48:23 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Tue, 27 May 2008 09:48:23 +0200 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: <54A3B5BE-131C-4B6E-8CFF-567171CDB5BA@gmail.com> References: <54A3B5BE-131C-4B6E-8CFF-567171CDB5BA@gmail.com> Message-ID: Many thanks for your replies. David Chelimsky wrote: > Use stub_model instead (if you're using source from github - if not > the 1.4 release is coming soon). Thanks - that helps a great deal. Scott Taylor wrote: > I would highly suggest using :null_object => true in view specs (or > controller specs with integrate_views): Thanks, that's interesting, I didn't know about that option... Are there any advantages of using this approach over #stub_model? Bart Zonneveld (bartz) wrote: > Or, consider moving code into the model, and test it there. See > http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model I agree, but in this case the controller really only does CRUD, and it couldn't really be any skinnier or it might die! Also, I don't think that it is the main source of the problem here, rather the fact that I am using integrate_views which means I have to have a reasonably full mock of any models wherever I have a form for that model. ~ Mark -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue May 27 03:52:23 2008 From: lists at ruby-forum.com (Mark Dodwell) Date: Tue, 27 May 2008 09:52:23 +0200 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: References: <54A3B5BE-131C-4B6E-8CFF-567171CDB5BA@gmail.com> Message-ID: Also, any opinions on using a Factory pattern for instantiating mocks of models? I like the idea of maintaining mocks in one place as I frequently use them across several specs for models that have associations. Do you think it would create dependency issues between the specs using that Factory? ~ Mark -- Posted via http://www.ruby-forum.com/. From jarkko at jlaine.net Tue May 27 05:37:17 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Tue, 27 May 2008 12:37:17 +0300 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: References: <54A3B5BE-131C-4B6E-8CFF-567171CDB5BA@gmail.com> Message-ID: On 27.5.2008, at 10.52, Mark Dodwell wrote: > Also, any opinions on using a Factory pattern for instantiating > mocks of > models? I like the idea of maintaining mocks in one place as I > frequently use them across several specs for models that have > associations. Do you think it would create dependency issues between > the > specs using that Factory? I have built my own "factory" by creating methods such as mock_user in the spec helper. That method will then fill in some reasonable values and stub all the needed methods. Granted, the need for that is less now with stub_model, but sometimes you also want to stub some associations. That has certainly reduced the amount of repetition in my specs. //jarkko > > > ~ Mark > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From rick.denatale at gmail.com Tue May 27 07:06:40 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 27 May 2008 07:06:40 -0400 Subject: [rspec-users] [ANN] RSpec-1.1.4 In-Reply-To: References: Message-ID: On Mon, May 26, 2008 at 5:52 PM, David Chelimsky wrote: > The RSpec Development Team is happy to announce the release of RSpec-1.1.4. > > See http://rspec.info/changes.html for details of what changed in this > release. > > For Rails developers: > > * This release of RSpec supports Rails-2.1.0-RC1, 2.0.2, 1.2.6 > > More info at http://rspec.info. > David, I thought that my hash_including patch was slated to go into this release. I don't see it listed in the changes. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From dchelimsky at gmail.com Tue May 27 07:14:46 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 May 2008 06:14:46 -0500 Subject: [rspec-users] [ANN] RSpec-1.1.4 In-Reply-To: References: Message-ID: On May 27, 2008, at 6:06 AM, Rick DeNatale wrote: > On Mon, May 26, 2008 at 5:52 PM, David Chelimsky > wrote: >> The RSpec Development Team is happy to announce the release of >> RSpec-1.1.4. >> >> See http://rspec.info/changes.html for details of what changed in >> this >> release. >> >> For Rails developers: >> >> * This release of RSpec supports Rails-2.1.0-RC1, 2.0.2, 1.2.6 >> >> More info at http://rspec.info. >> > > David, > > I thought that my hash_including patch was slated to go into this > release. I don't see it listed in the changes. It's in there: http://blog.davidchelimsky.net/articles/2008/05/27/rspec-1-1-4 http://rspec.info/rdoc/classes/Spec/Mocks/ArgumentConstraintMatchers.html#M000039 Just missed the changes file. I'll add it. Cheers, David > > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue May 27 07:37:47 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 May 2008 06:37:47 -0500 Subject: [rspec-users] new --pattern option In-Reply-To: <17484038.post@talk.nabble.com> References: <17484038.post@talk.nabble.com> Message-ID: <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> On May 27, 2008, at 2:35 AM, kasutaja wrote: > > Hello. > > You're saying that: > To get rspec to behave as it did before this change, use this: > > --pattern "**/*.rb" That was an error. Use this instead: --pattern "spec/**/*.rb" or this if you want to avoid loading files other than spec files: --pattern "spec/**/*_spec.rb" This one is actually the default, so if that's what you want you don't need to use the option. I updated my blog post to reflect this: http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option Cheers, David > I tried like this (rspec 1.03) and it wasn't same as before (rspec > 1.08). > Now it also loads all other files in current directory and in all > subdirectories and not only from directory and subdirectories given > to spec > as a parameter. > > So, for example, I have something like this: > .\some_file.rb (which I don't want to load) > .\some_dir\some_other_dir\some_other_files.rb (I don't want to load > these > also) > .\my_test_dir (has many subdirs and rb files in it - I want to load > all .rb > files from THIS dir) > > now, I execute rspec like this: spec -p **/*.rb my_test_dir (and > having > working directory . of course). > > Now I get some errors and things (some of them need input parameters > and so > on) from the files I did not want to include and they weren't > included with > previous versions. For example, it is going to load all rb files > from "." > and from "some_dir" and subdirectories. What's wrong and how can I > avoid > that? > > I made simple test, created files called "main_spec.rb" to follow your > naming convention. It had only one line in it: > puts "spec: " + File.dirname(__FILE__) > > Now, I executed spec without -p (--pattern) switch to have it to use > default > option (which is **/*_spec.rb). Everything worked as with version > 1.08. But > NOW, if I executed spec with -p **/*_spec.rb (which is SAME as default > option!) it loaded ALL *_spec.rb files from working directory and > from every > subdirectories (as supposed to all *_spec.rb files from directories > and > subdirectories given to spec as input parameter). It seems to be > some bug. > Any ideas? > > One way is to change working directory to "my_test_dir" prior > executing > rspec but it's not comfortable also. Other way would be to rename > all my > tests to _spec.rb, which wouldn't be also too big of a job. But the > question > still remains. > > Jarmo. > > > David Chelimsky-2 wrote: >> >> Hello all, >> >> Just a heads up that I made a change (in svn trunk - not yet >> released) >> that may change what files get loaded when you run the rake or spec >> commands. Not a big deal if you've been following convention, but for >> those who haven't you may need to make a minor adjustment to your >> rake >> file or spec.opts. >> >> http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option >> >> Cheers, >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > -- > View this message in context: http://www.nabble.com/new---pattern-option-tp14983923p17484038.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From andypearson at criticalwebdesign.co.uk Tue May 27 07:44:18 2008 From: andypearson at criticalwebdesign.co.uk (andypearson) Date: Tue, 27 May 2008 04:44:18 -0700 (PDT) Subject: [rspec-users] Help with Writing Meaningful Specs Message-ID: <17488575.post@talk.nabble.com> Hello all, In yet another attempt to learn Ruby on Rails and Rspec I have started writing a simple life streaming app with will aggregate feeds from several places and save them in a database for later use. An internet search eventually led me to the following method for looping through the feeds in the database, getting the contents of the URL and then passing this into another model to prepare and save it. def self.cache_all feeds = self.find(:all) for feed in feeds xml = REXML::Document.new Net::HTTP.get(URI.parse(feed.url)) xml.elements.each '//item' do |item| Item.prepare_and_save(feed, item) end end end Problems are now beginning to arise when trying to write the specs for this method. I started from scratch slowly building up the specs but it has led to an awful amount of mocks and stubs, and I am not even sure whether they are asking the correct things of the method. Can anyone give me some pointers on how to write useful, meaningful specs for this method? The other thing I have found is that I seem to have incorrectly stubbed xml.elements.each meaning that the contents of the block are never called, how should I be specifying this behavior? I have pastied the complete code for the Feed model, the spec and a little helper at: http://pastie.caboo.se/203941 Thanks in advance, Andy -- View this message in context: http://www.nabble.com/Help-with-Writing-Meaningful-Specs-tp17488575p17488575.html Sent from the rspec-users mailing list archive at Nabble.com. From tom at experthuman.com Tue May 27 08:04:23 2008 From: tom at experthuman.com (Tom Stuart) Date: Tue, 27 May 2008 13:04:23 +0100 Subject: [rspec-users] Help with Writing Meaningful Specs In-Reply-To: <17488575.post@talk.nabble.com> References: <17488575.post@talk.nabble.com> Message-ID: On 27 May 2008, at 12:44, andypearson wrote: > xml = REXML::Document.new Net::HTTP.get(URI.parse(feed.url)) It won't make the problem go away, but you can certainly reduce the blizzard of intermediate stubs by pulling this chain out into its own method (e.g. fetch_xml_from_url) and stubbing that method once in your cache_all spec. > it has led to an awful amount of mocks and stubs, and I am not even > sure whether they > are asking the correct things of the method. > Can anyone give me some pointers on how to write useful, meaningful > specs > for this method? What part of its behaviour do you care about? (Refactoring into more fine-grained methods might help again here.) It seems as though all you're interested in is that 1. the feed URLs get fetched from the database, 2. the feed contents get fetched from the URLs, and 3. Item.prepare_and_save gets called for each item in each feed. So, ideally, that's what your specs for this method should be saying. > The other thing I have found is that I seem to have incorrectly > stubbed > xml.elements.each meaning that the contents of the block are never > called, > how should I be specifying this behavior? Use #and_yield, not #and_return. (And you might as well use an actual mock, rather than [@element], since you're stubbing the only method you plan to call on it.) Cheers, -Tom From michael at schuerig.de Tue May 27 08:04:47 2008 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 27 May 2008 14:04:47 +0200 Subject: [rspec-users] Testing rails plugins standalone Message-ID: <200805271404.47492.michael@schuerig.de> I'd like to finally get started with RSpec, however, not on a complete (rails or whatever) application, but only on a single rails plugin. In particular, I want to test the plugin without the context of a specific rails app. The only parts of rails that I need are ActiveRecord and ActiveSupport. It would be very helpful to have an existing plugin that's tested like this as a guideline. Any suggestions? Thanks, Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From ashley.moran at patchspace.co.uk Tue May 27 08:26:30 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 27 May 2008 13:26:30 +0100 Subject: [rspec-users] Help with Writing Meaningful Specs In-Reply-To: <17488575.post@talk.nabble.com> References: <17488575.post@talk.nabble.com> Message-ID: <81FC80EB-E3E2-440C-9601-A3A662C946C4@patchspace.co.uk> On 27 May 2008, at 12:44, andypearson wrote: > def self.cache_all > feeds = self.find(:all) > > for feed in feeds > xml = REXML::Document.new Net::HTTP.get(URI.parse(feed.url)) > xml.elements.each '//item' do |item| > Item.prepare_and_save(feed, item) > end > end > end > > Problems are now beginning to arise when trying to write the specs > for this > method. I started from scratch slowly building up the specs but it > has led > to an awful amount of mocks and stubs, and I am not even sure > whether they > are asking the correct things of the method. > > Can anyone give me some pointers on how to write useful, meaningful > specs > for this method? Hi Andy I think the problem comes from two things - trying to specify the details of an algorithm instead of checking it transforms the data correctly, and having too much logic in a class method. To take some Feed-specific logic out, try making an accessor method, such as Feed#uri (I can't think of a good name for it), then you could replace one line with this: xml = REXML::Document.new = Net::HTTP.get(feed.uri) Alternatively, go one step further and have a method in Feed that does the Net::HTTP.get, so you could write this: xml = feed.xml_source Obviously you will still need the corresponding specs in the Feed instance methods, but at least you've encapsulated the logic related to fetching the URI/XML. The other thing is the "item" elements. I don't know what xml.elements.each yields, but I'm guessing it's either plain text (XML) or some REXML object. If it's plain XML fine, but if it's an REXML object, you don't want your code depending on that (you're tying yourself down to a specific library). Instead, consider parsing the XML in Feed.cache_all. I'm imagining something like this: feed.prepare_and_save_item(:item_attr_1 => "foo", :item_attr_2 => "bar", ...) > The other thing I have found is that I seem to have incorrectly > stubbed > xml.elements.each meaning that the contents of the block are never > called, > how should I be specifying this behavior? Just noticed that Tom replied and pointed out the issue. But if you refactor the code like I describe above, you can avoid the issue. Just stub feed.xml_source (or whatever) to return some sample valid feed XML, and check that Feed.cache_all correctly extracts the item data. I can't say that my way is better or worse than the way you are going about it. But I (where possible) I always test the output of third- party libraries rather than my use of them. It avoids loads of stubs that don't, in any case, prove you're using the library correctly so you can see immediately if your code is likely to work in the wild. Hope this helps Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Tue May 27 08:41:40 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 27 May 2008 13:41:40 +0100 Subject: [rspec-users] new --pattern option In-Reply-To: <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> Message-ID: On 27 May 2008, at 12:37, David Chelimsky wrote: > I updated my blog post to reflect this: http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option Just out of curiosity, how come multiple patterns are specified comma- separated? It means I have to go and rename all the files I saved with extension ".rb," ;) Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From dchelimsky at gmail.com Tue May 27 08:45:24 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 May 2008 07:45:24 -0500 Subject: [rspec-users] new --pattern option In-Reply-To: References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> Message-ID: <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> On May 27, 2008, at 7:41 AM, Ashley Moran wrote: > > On 27 May 2008, at 12:37, David Chelimsky wrote: > >> I updated my blog post to reflect this: http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option > > Just out of curiosity, how come multiple patterns are specified > comma-separated? It means I have to go and rename all the files I > saved with extension ".rb," ;) How would you do it? From dchelimsky at gmail.com Tue May 27 08:46:49 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 May 2008 07:46:49 -0500 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> Message-ID: On May 26, 2008, at 7:22 PM, Tim Glen wrote: >>> So I find myself wondering - is this the case for just helper >>> modules or all modules? For instance, I have a module which gets >>> included into some controllers, but I'd like to spec against it >>> directly so I don't have in those other controllers... I'm not >>> sure how to set this up. What's the best practice? >> >> First of all, don't ever believe anybody when they tell you >> something is a best practice. >> >> That said - here's what I *usually* do: >> >> describe WhizBangModule do >> it "should do something" do >> whiz_banger = Object.new >> whiz_banger.extend WhizBangModule >> whiz_banger.whiz.should == "bang" >> end >> end >> >> or something like that. Make sense? > > > Yes, that makes sense. > > I like that as far as it goes, but I'm wondering if there's a way to > take it one step further and actually have it extend the typical > controller functionality - some of my methods make use of the > session, or set some assigns, for instance. I'd love to be able to > test it as if it were in a controller already, with all the spec > goodness that comes along with that. > > I can set up what you've done here to answer _like_ a controller, > but that seems silly given that the same functionality is > potentially already available. I could also spec it in the context > of one of the controllers that includes it already, but that seems > too specific. class WhizBangController < ActionController::Base include WhizBangModule end describe WhizBangController, "including WhizBangModule", :type => :controller do it "should do something" do controller.whiz.should == "bang" end end From ashley.moran at patchspace.co.uk Tue May 27 08:59:04 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 27 May 2008 13:59:04 +0100 Subject: [rspec-users] new --pattern option In-Reply-To: <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> Message-ID: On 27 May 2008, at 13:45, David Chelimsky wrote: > How would you do it? Everywhere I've seen something similar, it's just been space- delimited, no punctuation. For example, this from the rsync man page: rsync -av host:'dir1/file1 dir2/file2' /dest Not quite the same thing but it's the closest I can think of off the top of my head. It doesn't affect me really, I just noticed the syntax and thought it looked odd. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From dchelimsky at gmail.com Tue May 27 09:06:43 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 May 2008 08:06:43 -0500 Subject: [rspec-users] new --pattern option In-Reply-To: References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> Message-ID: <1E6D2D25-1139-4B17-B747-9F5E53711525@gmail.com> On May 27, 2008, at 7:59 AM, Ashley Moran wrote: > > On 27 May 2008, at 13:45, David Chelimsky wrote: > >> How would you do it? > > > Everywhere I've seen something similar, it's just been space- > delimited, no punctuation. For example, this from the rsync man > page: > rsync -av host:'dir1/file1 dir2/file2' /dest I was thinking more of ant patternsets (from my java days). I think they support comma or space separated, but all the examples I ever saw (or wrote) used commas. You said something about having to rename files - not sure I get it. > Not quite the same thing but it's the closest I can think of off the > top of my head. > > It doesn't affect me really, I just noticed the syntax and thought > it looked odd. > > Ashley > > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ashley.moran at patchspace.co.uk Tue May 27 10:12:06 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 27 May 2008 15:12:06 +0100 Subject: [rspec-users] new --pattern option In-Reply-To: <1E6D2D25-1139-4B17-B747-9F5E53711525@gmail.com> References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> <1E6D2D25-1139-4B17-B747-9F5E53711525@gmail.com> Message-ID: <49554266-AEB7-480F-B4EB-2C8BCF5BA018@patchspace.co.uk> On 27 May 2008, at 14:06, David Chelimsky wrote: > I was thinking more of ant patternsets (from my java days). I think > they support comma or space separated, but all the examples I ever > saw (or wrote) used commas. Ah ok, I guess it depends on your heritage. I'm lucky to have not had to build any serious Java projects. I did a lot with NAnt once upon a time, but I've successfully blocked that out of my mind. The therapy must have worked... > You said something about having to rename files - not sure I get it. Ignore me, I was just being stupid :) I don't really put commas at the end of my filenames. I'm sure I've seen something that does though, but I can't remember what. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From avdi at avdi.org Tue May 27 10:15:38 2008 From: avdi at avdi.org (Avdi Grimm) Date: Tue, 27 May 2008 10:15:38 -0400 Subject: [rspec-users] new --pattern option In-Reply-To: <49554266-AEB7-480F-B4EB-2C8BCF5BA018@patchspace.co.uk> References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> <1E6D2D25-1139-4B17-B747-9F5E53711525@gmail.com> <49554266-AEB7-480F-B4EB-2C8BCF5BA018@patchspace.co.uk> Message-ID: On Tue, May 27, 2008 at 10:12 AM, Ashley Moran wrote: > Ignore me, I was just being stupid :) I don't really put commas at the end > of my filenames. I'm sure I've seen something that does though, but I can't > remember what. RCS? -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From ashley.moran at patchspace.co.uk Tue May 27 10:19:36 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 27 May 2008 15:19:36 +0100 Subject: [rspec-users] new --pattern option In-Reply-To: References: <17484038.post@talk.nabble.com> <7FCC0357-16D3-4CA5-835D-53AF9019DBB4@gmail.com> <4CA714B3-8BF8-49C4-A701-E6CDD9B9FE39@gmail.com> <1E6D2D25-1139-4B17-B747-9F5E53711525@gmail.com> <49554266-AEB7-480F-B4EB-2C8BCF5BA018@patchspace.co.uk> Message-ID: <40CB1EC1-062D-40D0-A3FC-88F7DDA5DEE2@patchspace.co.uk> On 27 May 2008, at 15:15, Avdi Grimm wrote: > RCS? Yes! Something else I've never had the pleasure of using. I doubt any rspec users use RCS, but you never know. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From mailing_lists at railsnewbie.com Tue May 27 10:20:27 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Tue, 27 May 2008 10:20:27 -0400 Subject: [rspec-users] Testing rails plugins standalone In-Reply-To: <200805271404.47492.michael@schuerig.de> References: <200805271404.47492.michael@schuerig.de> Message-ID: On May 27, 2008, at 8:04 AM, Michael Schuerig wrote: > > I'd like to finally get started with RSpec, however, not on a complete > (rails or whatever) application, but only on a single rails plugin. In > particular, I want to test the plugin without the context of a > specific > rails app. The only parts of rails that I need are ActiveRecord and > ActiveSupport. > > It would be very helpful to have an existing plugin that's tested like > this as a guideline. Any suggestions? My FixtureReplacement plugin tests against ActiveRecord models - You might want to check that out. (Many thanks to Wincent, I believe, who set it all up for me). Also, Webrat is quite popular - I'd bet that has some good specs. Scott From rick.denatale at gmail.com Tue May 27 10:35:59 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 27 May 2008 10:35:59 -0400 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> Message-ID: On Tue, May 27, 2008 at 8:46 AM, David Chelimsky wrote: > > On May 26, 2008, at 7:22 PM, Tim Glen wrote: > >>>> So I find myself wondering - is this the case for just helper modules or >>>> all modules? For instance, I have a module which gets included into some >>>> controllers, but I'd like to spec against it directly so I don't have in >>>> those other controllers... I'm not sure how to set this up. What's the best >>>> practice? >>> >>> First of all, don't ever believe anybody when they tell you something is >>> a best practice. >>> >>> That said - here's what I *usually* do: >>> >>> describe WhizBangModule do >>> it "should do something" do >>> whiz_banger = Object.new >>> whiz_banger.extend WhizBangModule >>> whiz_banger.whiz.should == "bang" >>> end >>> end >>> >>> or something like that. Make sense? >> >> >> Yes, that makes sense. >> >> I like that as far as it goes, but I'm wondering if there's a way to take >> it one step further and actually have it extend the typical controller >> functionality - some of my methods make use of the session, or set some >> assigns, for instance. I'd love to be able to test it as if it were in a >> controller already, with all the spec goodness that comes along with that. >> >> I can set up what you've done here to answer _like_ a controller, but that >> seems silly given that the same functionality is potentially already >> available. I could also spec it in the context of one of the controllers >> that includes it already, but that seems too specific. > > class WhizBangController < ActionController::Base > include WhizBangModule > end > > describe WhizBangController, "including WhizBangModule", :type => > :controller do > it "should do something" do > controller.whiz.should == "bang" > end > end Is this change something which should be highlighted for those who don't follow the mailing list? It doesn't seem to be mentioned in the changes list http://rspec.info/changes.html -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From dchelimsky at gmail.com Tue May 27 10:58:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 27 May 2008 09:58:09 -0500 Subject: [rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4 In-Reply-To: References: <810a540e0805231521l3f75fd62n91243a7da9bfafcc@mail.gmail.com> <810a540e0805231523i1130c26ej46437d3dc99051e@mail.gmail.com> <5FF14847-F7E2-4283-85F1-E12FC662AB1F@pivotib.com> Message-ID: On May 27, 2008, at 9:35 AM, Rick DeNatale wrote: > On Tue, May 27, 2008 at 8:46 AM, David Chelimsky > wrote: >> >> On May 26, 2008, at 7:22 PM, Tim Glen wrote: >> >>>>> So I find myself wondering - is this the case for just helper >>>>> modules or >>>>> all modules? For instance, I have a module which gets included >>>>> into some >>>>> controllers, but I'd like to spec against it directly so I don't >>>>> have in >>>>> those other controllers... I'm not sure how to set this up. >>>>> What's the best >>>>> practice? >>>> >>>> First of all, don't ever believe anybody when they tell you >>>> something is >>>> a best practice. >>>> >>>> That said - here's what I *usually* do: >>>> >>>> describe WhizBangModule do >>>> it "should do something" do >>>> whiz_banger = Object.new >>>> whiz_banger.extend WhizBangModule >>>> whiz_banger.whiz.should == "bang" >>>> end >>>> end >>>> >>>> or something like that. Make sense? >>> >>> >>> Yes, that makes sense. >>> >>> I like that as far as it goes, but I'm wondering if there's a way >>> to take >>> it one step further and actually have it extend the typical >>> controller >>> functionality - some of my methods make use of the session, or set >>> some >>> assigns, for instance. I'd love to be able to test it as if it >>> were in a >>> controller already, with all the spec goodness that comes along >>> with that. >>> >>> I can set up what you've done here to answer _like_ a controller, >>> but that >>> seems silly given that the same functionality is potentially already >>> available. I could also spec it in the context of one of the >>> controllers >>> that includes it already, but that seems too specific. >> >> class WhizBangController < ActionController::Base >> include WhizBangModule >> end >> >> describe WhizBangController, "including WhizBangModule", :type => >> :controller do >> it "should do something" do >> controller.whiz.should == "bang" >> end >> end > > Is this change something which should be highlighted for those who > don't follow the mailing list? > > It doesn't seem to be mentioned in the changes list > http://rspec.info/changes.html It's there: Deprecation warnings for specs that assume auto-inclusion of modules. Just not highlighted. I'll add something. > > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From sean at seanmiller.ca Tue May 27 11:41:43 2008 From: sean at seanmiller.ca (Sean Miller) Date: Tue, 27 May 2008 8:41:43 -0700 Subject: [rspec-users] =?utf-8?q?Failing_rspec_story_not_causing_a_CruiseC?= =?utf-8?q?ontrol=2Erb_build_to_fail=3F?= Message-ID: <9a3e7de504667d2beefade62eea54445@mail.kattare.com> We've just added rspec stories to our CruiseControl.rb build. When there's a failing scenario we see the failure in the log output, but it doesn't cause the CruiseControl build to fail. We've also just upgraded to the latest rspec version, 1.1.4, which fixes rspec bug 228, but the CC.rb build is still passing. Has anyone got failing rspec stories making CruiseControl.rb fail? Thanks, Sean Miller. From pergesu at gmail.com Tue May 27 12:14:15 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 27 May 2008 09:14:15 -0700 Subject: [rspec-users] Failing rspec story not causing a CruiseControl.rb build to fail? In-Reply-To: <9a3e7de504667d2beefade62eea54445@mail.kattare.com> References: <9a3e7de504667d2beefade62eea54445@mail.kattare.com> Message-ID: <810a540e0805270914n7dad7e58q75184f9365d96c83@mail.gmail.com> On Tue, May 27, 2008 at 8:41 AM, Sean Miller wrote: > We've just added rspec stories to our CruiseControl.rb build. When there's a failing scenario we see the failure in the log output, but it doesn't cause the CruiseControl build to fail. We've also just upgraded to the latest rspec version, 1.1.4, which fixes rspec bug 228, but the CC.rb build is still passing. > > Has anyone got failing rspec stories making CruiseControl.rb fail? > > Thanks, > Sean Miller. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I wasn't aware that CC.rb integrated with story runner yet. Are you sure it does? Pat From ben at benmabey.com Tue May 27 13:07:23 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 27 May 2008 11:07:23 -0600 Subject: [rspec-users] Failing rspec story not causing a CruiseControl.rb build to fail? In-Reply-To: <810a540e0805270914n7dad7e58q75184f9365d96c83@mail.gmail.com> References: <9a3e7de504667d2beefade62eea54445@mail.kattare.com> <810a540e0805270914n7dad7e58q75184f9365d96c83@mail.gmail.com> Message-ID: <483C3FCB.9090303@benmabey.com> Pat Maddox wrote: > On Tue, May 27, 2008 at 8:41 AM, Sean Miller wrote: > >> We've just added rspec stories to our CruiseControl.rb build. When there's a failing scenario we see the failure in the log output, but it doesn't cause the CruiseControl build to fail. We've also just upgraded to the latest rspec version, 1.1.4, which fixes rspec bug 228, but the CC.rb build is still passing. >> >> Has anyone got failing rspec stories making CruiseControl.rb fail? >> >> Thanks, >> Sean Miller. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > I wasn't aware that CC.rb integrated with story runner yet. Are you > sure it does? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > To integrate with CC.rb all is that required is that your build task/process exits with the appropriate code (0 or non-zero for failing.) I originally made the patch so that we could integrate it with CC.rb... Sean, if you run the stories from the command line and it fails what is the exit code? (run the stories and type 'echo $?' to find out.) If you can verify that the exit code is correct then the problem might be with your cc.rb rake task. Maybe you could post it? Also, what version of ruby are you using? I have heard that a recent version of ruby had an at_exit bug, so try it on different versions of ruby to see if it is environment specific. -Ben From sean at seanmiller.ca Tue May 27 16:12:19 2008 From: sean at seanmiller.ca (Sean Miller) Date: Tue, 27 May 2008 13:12:19 -0700 Subject: [rspec-users] =?utf-8?q?Failing_rspec_story_not_causing_a_CruiseC?= =?utf-8?q?ontrol=2Erb_build_to_fail=3F?= In-Reply-To: <483C3FCB.9090303@benmabey.com> References: <483C3FCB.9090303@benmabey.com> Message-ID: Thanks! The problem seems to be that the rake spec task is messing up the exit code of the story spec, but I still can't see how. When I run the failing story spec outside of a rake task (ruby stories/all.rb), I get the correct exit code of 1. When I run it in rake spec:stories, I get the incorrect exit code of 0. namespace :spec do desc "run spec user stories" Spec::Rake::SpecTask.new('stories') do |t| t.spec_files = FileList['stories/**/*_stories.rb'] t.rcov = true output_root = ENV["CC_BUILD_ARTIFACTS"] || "spec" t.rcov_dir = "#{output_root}/user_stories_coverage" t.rcov_opts = RCOV_OPTIONS end But when I make one of the non-story specs fail, I get the exit code of 1 both running the spec outside of rake and as part of "rake spec:coverage", and the rake SpecTask is defined the same way: desc "Run all examples with RCov" Spec::Rake::SpecTask.new('coverage') do |t| t.spec_files = full_spec_file_list t.rcov = true output_root = ENV["CC_BUILD_ARTIFACTS"] || "spec" t.rcov_dir = "#{output_root}/rspec_coverage" t.rcov_opts = RCOV_OPTIONS end Any ideas? Thanks, Sean. On Tue, 27 May 2008 11:07:23 -0600, Ben Mabey wrote: > Pat Maddox wrote: >> On Tue, May 27, 2008 at 8:41 AM, Sean Miller wrote: >> >>> We've just added rspec stories to our CruiseControl.rb build. When > there's a failing scenario we see the failure in the log output, but it > doesn't cause the CruiseControl build to fail. We've also just upgraded > to the latest rspec version, 1.1.4, which fixes rspec bug 228, but the > CC.rb build is still passing. >>> >>> Has anyone got failing rspec stories making CruiseControl.rb fail? >>> >>> Thanks, >>> Sean Miller. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> I wasn't aware that CC.rb integrated with story runner yet. Are you >> sure it does? >> >> Pat >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > To integrate with CC.rb all is that required is that your build > task/process exits with the appropriate code (0 or non-zero for > failing.) I originally made the patch so that we could integrate it > with CC.rb... > > Sean, if you run the stories from the command line and it fails what is > the exit code? (run the stories and type 'echo $?' to find out.) If > you can verify that the exit code is correct then the problem might be > with your cc.rb rake task. Maybe you could post it? Also, what version > of ruby are you using? I have heard that a recent version of ruby had > an at_exit bug, so try it on different versions of ruby to see if it is > environment specific. > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Tue May 27 16:56:28 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 27 May 2008 14:56:28 -0600 Subject: [rspec-users] Failing rspec story not causing a CruiseControl.rb build to fail? In-Reply-To: References: <483C3FCB.9090303@benmabey.com> Message-ID: <483C757C.6030004@benmabey.com> Sean, This is what I have on a project that is running CC.rb with stories: desc "Task for cruise Control" task :cruise do RAILS_ENV = ENV['RAILS_ENV'] = 'test' # Without this, it will drop your production database. CruiseControl::invoke_rake_task 'db:reset_all' CruiseControl::invoke_rake_task 'cruise_coverage' CruiseControl::invoke_rake_task 'stories:all' sh "rake kablame:git:specs > #{ENV['CC_BUILD_ARTIFACTS']}/hall_of_shame.txt" end namespace :stories do desc "Run all stories (that are not pending)" task :all do ruby "stories/all.rb --format plain" end end I think your problem is that you are using a SpecTask to run the stories... I don't know if that is supported. I just open up a new ruby process to run the stories. Hope that helps, Ben Sean Miller wrote: > Thanks! The problem seems to be that the rake spec task is messing up the exit code of the story spec, but I still can't see how. > > When I run the failing story spec outside of a rake task (ruby stories/all.rb), I get the correct exit code of 1. > > When I run it in rake spec:stories, I get the incorrect exit code of 0. > > namespace :spec do > > desc "run spec user stories" > Spec::Rake::SpecTask.new('stories') do |t| > t.spec_files = FileList['stories/**/*_stories.rb'] > t.rcov = true > output_root = ENV["CC_BUILD_ARTIFACTS"] || "spec" > t.rcov_dir = "#{output_root}/user_stories_coverage" > t.rcov_opts = RCOV_OPTIONS > end > > But when I make one of the non-story specs fail, I get the exit code of 1 both running the spec outside of rake and as part of "rake spec:coverage", and the rake SpecTask is defined the same way: > > > desc "Run all examples with RCov" > Spec::Rake::SpecTask.new('coverage') do |t| > t.spec_files = full_spec_file_list > t.rcov = true > output_root = ENV["CC_BUILD_ARTIFACTS"] || "spec" > t.rcov_dir = "#{output_root}/rspec_coverage" > t.rcov_opts = RCOV_OPTIONS > end > > Any ideas? > > Thanks, > Sean. > > On Tue, 27 May 2008 11:07:23 -0600, Ben Mabey wrote: > >> Pat Maddox wrote: >> >>> On Tue, May 27, 2008 at 8:41 AM, Sean Miller wrote: >>> >>> >>>> We've just added rspec stories to our CruiseControl.rb build. When >>>> >> there's a failing scenario we see the failure in the log output, but it >> doesn't cause the CruiseControl build to fail. We've also just upgraded >> to the latest rspec version, 1.1.4, which fixes rspec bug 228, but the >> CC.rb build is still passing. >> >>>> Has anyone got failing rspec stories making CruiseControl.rb fail? >>>> >>>> Thanks, >>>> Sean Miller. >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> >>>> >>> I wasn't aware that CC.rb integrated with story runner yet. Are you >>> sure it does? >>> >>> Pat >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> To integrate with CC.rb all is that required is that your build >> task/process exits with the appropriate code (0 or non-zero for >> failing.) I originally made the patch so that we could integrate it >> with CC.rb... >> >> Sean, if you run the stories from the command line and it fails what is >> the exit code? (run the stories and type 'echo $?' to find out.) If >> you can verify that the exit code is correct then the problem might be >> with your cc.rb rake task. Maybe you could post it? Also, what version >> of ruby are you using? I have heard that a recent version of ruby had >> an at_exit bug, so try it on different versions of ruby to see if it is >> environment specific. >> >> -Ben >> >> _______________________________________________ >> 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 marcio.rails at gmail.com Tue May 27 18:33:38 2008 From: marcio.rails at gmail.com (marcio) Date: Tue, 27 May 2008 15:33:38 -0700 (PDT) Subject: [rspec-users] Permission error when installing rspec Message-ID: <7e1f65ec-275b-4c21-a1a0-bdb0ac2190cc@a1g2000hsb.googlegroups.com> hello from here! i'm new in rspec and i have a problem while installing rspec 1.1.4 gem: marcio at marcio-work:~$ gem install rspec Bulk updating Gem source index for: http://gems.rubyforge.org ERROR: While executing gem ... (Errno::EACCES) Permission denied - /var/lib/gems/1.8/cache/rspec-1.1.4.gem I did it with sudo and there was no problem, but when i attemp to use rspec (spec [RUBYFILE]), the sys does not find the gem! So i uninstalled it and now i'm having this permission problem. Anyone could help to me? Thanks anyway From pergesu at gmail.com Wed May 28 01:47:21 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 27 May 2008 22:47:21 -0700 Subject: [rspec-users] Permission error when installing rspec In-Reply-To: <7e1f65ec-275b-4c21-a1a0-bdb0ac2190cc@a1g2000hsb.googlegroups.com> References: <7e1f65ec-275b-4c21-a1a0-bdb0ac2190cc@a1g2000hsb.googlegroups.com> Message-ID: <810a540e0805272247t637751a9mb237fca09daa7f68@mail.gmail.com> On Tue, May 27, 2008 at 3:33 PM, marcio wrote: > hello from here! i'm new in rspec and i have a problem while > installing rspec 1.1.4 gem: > > marcio at marcio-work:~$ gem install rspec > Bulk updating Gem source index for: http://gems.rubyforge.org > ERROR: While executing gem ... (Errno::EACCES) > Permission denied - /var/lib/gems/1.8/cache/rspec-1.1.4.gem > > I did it with sudo and there was no problem, but when i attemp to use > rspec (spec [RUBYFILE]), the sys does not find the gem! So i > uninstalled it and now i'm having this permission problem. Anyone > could help to me? > > Thanks anyway > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I doubt this has anything to do with rspec. What happens when you try to install other gems? Pat From tek.katu at gmail.com Wed May 28 06:23:31 2008 From: tek.katu at gmail.com (T K) Date: Wed, 28 May 2008 19:23:31 +0900 Subject: [rspec-users] Permission error when installing rspec In-Reply-To: <810a540e0805272247t637751a9mb237fca09daa7f68@mail.gmail.com> References: <7e1f65ec-275b-4c21-a1a0-bdb0ac2190cc@a1g2000hsb.googlegroups.com> <810a540e0805272247t637751a9mb237fca09daa7f68@mail.gmail.com> Message-ID: <5c17ebdc0805280323pf04f6b2rc46d725301346ecc@mail.gmail.com> How about `sudo gem install rspec`? Then type your password. From marcio.rails at gmail.com Wed May 28 14:45:57 2008 From: marcio.rails at gmail.com (marcio) Date: Wed, 28 May 2008 11:45:57 -0700 (PDT) Subject: [rspec-users] Permission error when installing rspec In-Reply-To: <810a540e0805272247t637751a9mb237fca09daa7f68@mail.gmail.com> References: <7e1f65ec-275b-4c21-a1a0-bdb0ac2190cc@a1g2000hsb.googlegroups.com> <810a540e0805272247t637751a9mb237fca09daa7f68@mail.gmail.com> Message-ID: Hi Pat! Thanks a lot I realized that was not rspec the problem, i changed my linux distro and i forgot to update my gem , i had the 0.9 version! Now the rspec and all the others gem works perfectly. thanks a lot. On 28 mayo, 02:47, "Pat Maddox" wrote: > On Tue, May 27, 2008 at 3:33 PM, marcio wrote: > > hello from here! i'm new in rspec and i have a problem while > > installing rspec 1.1.4 gem: > > > marcio at marcio-work:~$ gem install rspec > > Bulk updating Gem source index for:http://gems.rubyforge.org > > ERROR: ?While executing gem ... (Errno::EACCES) > > ? Permission denied - /var/lib/gems/1.8/cache/rspec-1.1.4.gem > > > I did it with sudo and there was no problem, but when i attemp to use > > rspec (spec [RUBYFILE]), the sys does not find the gem! So i > > uninstalled it and now i'm having this permission problem. Anyone > > could help to me? > > > Thanks anyway > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > I doubt this has anything to do with rspec. ?What happens when you try > to install other gems? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From marcio.rails at gmail.com Wed May 28 14:47:53 2008 From: marcio.rails at gmail.com (marcio) Date: Wed, 28 May 2008 11:47:53 -0700 (PDT) Subject: [rspec-users] Permission error when installing rspec In-Reply-To: <5c17ebdc0805280323pf04f6b2rc46d725301346ecc@mail.gmail.com> References: <7e1f65ec-275b-4c21-a1a0-bdb0ac2190cc@a1g2000hsb.googlegroups.com> <810a540e0805272247t637751a9mb237fca09daa7f68@mail.gmail.com> <5c17ebdc0805280323pf04f6b2rc46d725301346ecc@mail.gmail.com> Message-ID: <9d3d80b5-932f-4c25-b455-6b0cf86eb27f@e53g2000hsa.googlegroups.com> indeed it was with sudo. that wasn't the problem. i installed another linux in my pc and i dah out of date my gem! now things works perfectly! definitely i'm a beginner! thanks a lot! On 28 mayo, 07:23, "T K" wrote: > How about `sudo gem install rspec`? > Then type your password. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From cn.peng.zuo at gmail.com Thu May 29 02:25:52 2008 From: cn.peng.zuo at gmail.com (zuo peng) Date: Thu, 29 May 2008 14:25:52 +0800 Subject: [rspec-users] how to write spec for infinite loop? Message-ID: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> Hi, I've got trouble when describe infinite loop. code snippet: def start_loop while true data = self.server.handle_client if data self.manager.dispatch(data) end end end without the loop, it is easy to test the logic. but how can I describe it to tell the developer ( me :-) ) that there should be an infinite loop inside. thanks. Regards, Peng Zuo From edvard at majakari.net Thu May 29 03:19:18 2008 From: edvard at majakari.net (Edvard Majakari) Date: Thu, 29 May 2008 10:19:18 +0300 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> Message-ID: On Thu, May 29, 2008 at 9:25 AM, zuo peng wrote: > Hi, > > I've got trouble when describe infinite loop. > > code snippet: > > def start_loop > while true Not a reply to your specific question, but hopefully even better. I stumbled into similar situation a while ago, when I was developing a daemon process using BDD. When writing the test, I came up naturally with the following kind of structure: def start_loop while loop_condition? do_the_magic end end the idea is to separate looping logic and the operations done inside. The whole method start_loop was very easy to test now: MyDaemon.stub!(:loop_condition?).and_return(true, false) # I didn't use RSpec at the time, so this might not work ... outcome.should be_something_expected The trick is in stubbing the class/module method loop_condition? so that it returns true the first time and false the second time, thus looping only once. In the actual implementation loop_condition? was implemented as follows: class MyDaemon def loop_condition?; true; end ... end thus making the while loop indefinite. Any smart developer could have come up with similar structure without using TDD/BDD. However, that particular solution came to me naturally exactly because of the way BDD works: it forces you -- in a tender way -- to write code that is easy to test automatically. -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure From mailing_lists at railsnewbie.com Thu May 29 03:31:06 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 29 May 2008 03:31:06 -0400 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> Message-ID: <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> On May 29, 2008, at 2:25 AM, zuo peng wrote: > Hi, > > I've got trouble when describe infinite loop. > > code snippet: > > def start_loop > while true > data = self.server.handle_client > if data > self.manager.dispatch(data) > end > end > end > > without the loop, it is easy to test the logic. > but how can I describe it to tell the developer ( me :-) ) that there > should be an infinite loop inside. Here's a tip which Aslak gave me several months ago, and I find myself repeating it in many different contexts on this mailing list: One way is with dependency injection: def start_loop(looping_infinitely = true) while looping_infinitely ... end end In your spec, you simply pass false (but production code can call the method as if there is no option). Scott From dchelimsky at gmail.com Thu May 29 03:33:57 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 May 2008 00:33:57 -0700 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> Message-ID: <1A56D690-173C-48BA-9C72-F2CE0E39AED6@gmail.com> On May 29, 2008, at 12:31 AM, Scott Taylor wrote: > > On May 29, 2008, at 2:25 AM, zuo peng wrote: > >> Hi, >> >> I've got trouble when describe infinite loop. >> >> code snippet: >> >> def start_loop >> while true >> data = self.server.handle_client >> if data >> self.manager.dispatch(data) >> end >> end >> end >> >> without the loop, it is easy to test the logic. >> but how can I describe it to tell the developer ( me :-) ) that there >> should be an infinite loop inside. > > Here's a tip which Aslak gave me several months ago, and I find > myself repeating it in many different contexts on this mailing list: > > One way is with dependency injection: > > def start_loop(looping_infinitely = true) :) I think calling this dependency injection is a bit of a stretch. I agree with the approach of having a logical default that you can override in the example, but what exactly is the dependency on? true? Regardless of its name, this is a very good solution to the problem at hand. > > while looping_infinitely > ... > end > end > > In your spec, you simply pass false (but production code can call > the method as if there is no option). > > Scott > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mailing_lists at railsnewbie.com Thu May 29 03:46:14 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 29 May 2008 03:46:14 -0400 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <1A56D690-173C-48BA-9C72-F2CE0E39AED6@gmail.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> <1A56D690-173C-48BA-9C72-F2CE0E39AED6@gmail.com> Message-ID: <29B7AD1E-5F9D-4982-98CE-A93CD17E3D57@railsnewbie.com> On May 29, 2008, at 3:33 AM, David Chelimsky wrote: > On May 29, 2008, at 12:31 AM, Scott Taylor wrote: > >> >> On May 29, 2008, at 2:25 AM, zuo peng wrote: >> >>> Hi, >>> >>> I've got trouble when describe infinite loop. >>> >>> code snippet: >>> >>> def start_loop >>> while true >>> data = self.server.handle_client >>> if data >>> self.manager.dispatch(data) >>> end >>> end >>> end >>> >>> without the loop, it is easy to test the logic. >>> but how can I describe it to tell the developer ( me :-) ) that >>> there >>> should be an infinite loop inside. >> >> Here's a tip which Aslak gave me several months ago, and I find >> myself repeating it in many different contexts on this mailing list: >> >> One way is with dependency injection: >> >> def start_loop(looping_infinitely = true) > > :) > > I think calling this dependency injection is a bit of a stretch. I > agree with the approach of having a logical default that you can > override in the example, but what exactly is the dependency on? true? > > Regardless of its name, this is a very good solution to the problem > at hand. Yeah, good point. It makes me laugh a bit too, now that I think about it. Also, shouldn't the dependency occur in the constructor for it to be real DI? Scott From lists at ruby-forum.com Thu May 29 04:19:31 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 May 2008 10:19:31 +0200 Subject: [rspec-users] Coloured output in rspec 1.1.4 Message-ID: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Hello. I have lost the coloured output in autotest after updating to rspec v1.1.4 I was already using the edge version and was ok then, before the last update. Anyone knows something about this? Thank you. -- Posted via http://www.ruby-forum.com/. From cn.peng.zuo at gmail.com Thu May 29 04:27:52 2008 From: cn.peng.zuo at gmail.com (zuo peng) Date: Thu, 29 May 2008 16:27:52 +0800 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <29B7AD1E-5F9D-4982-98CE-A93CD17E3D57@railsnewbie.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> <1A56D690-173C-48BA-9C72-F2CE0E39AED6@gmail.com> <29B7AD1E-5F9D-4982-98CE-A93CD17E3D57@railsnewbie.com> Message-ID: <4ef750680805290127r2b973eb9rdb2feef58c391668@mail.gmail.com> Thanks guys. Both ways work perfectly. Regards, Peng Zuo From pergesu at gmail.com Thu May 29 05:12:52 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 29 May 2008 02:12:52 -0700 Subject: [rspec-users] how to write spec for infinite loop? In-Reply-To: <1A56D690-173C-48BA-9C72-F2CE0E39AED6@gmail.com> References: <4ef750680805282325s1aa6e33du9ce80e003cc1b88f@mail.gmail.com> <2977EE4D-2314-4ED2-BA4D-937FC90436B7@railsnewbie.com> <1A56D690-173C-48BA-9C72-F2CE0E39AED6@gmail.com> Message-ID: <810a540e0805290212u169df966l69272ac47dadb5a0@mail.gmail.com> On Thu, May 29, 2008 at 12:33 AM, David Chelimsky wrote: > On May 29, 2008, at 12:31 AM, Scott Taylor wrote: > >> >> On May 29, 2008, at 2:25 AM, zuo peng wrote: >> >>> Hi, >>> >>> I've got trouble when describe infinite loop. >>> >>> code snippet: >>> >>> def start_loop >>> while true >>> data = self.server.handle_client >>> if data >>> self.manager.dispatch(data) >>> end >>> end >>> end >>> >>> without the loop, it is easy to test the logic. >>> but how can I describe it to tell the developer ( me :-) ) that there >>> should be an infinite loop inside. >> >> Here's a tip which Aslak gave me several months ago, and I find myself >> repeating it in many different contexts on this mailing list: >> >> One way is with dependency injection: >> >> def start_loop(looping_infinitely = true) > > :) > > I think calling this dependency injection is a bit of a stretch. I agree > with the approach of having a logical default that you can override in the > example, but what exactly is the dependency on? true? > > Regardless of its name, this is a very good solution to the problem at hand. If ever there were a time to drop Ruby and start using Java + Guice, this would be it. Pat From dchelimsky at gmail.com Thu May 29 09:04:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 May 2008 06:04:40 -0700 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Message-ID: On May 29, 2008, at 1:19 AM, Juanma Cervera wrote: > Hello. > > I have lost the coloured output in autotest after updating to rspec > v1.1.4 > I was already using the edge version and was ok then, before the last > update. > > Anyone knows something about this? First I've heard of it. I'm not having the same issue. What command are you using to run rspec? From luislavena at gmail.com Thu May 29 09:09:58 2008 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 29 May 2008 10:09:58 -0300 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Message-ID: <71166b3b0805290609k4a9c8932m8a8527a5437bf7b@mail.gmail.com> On Thu, May 29, 2008 at 5:19 AM, Juanma Cervera wrote: > Hello. > > I have lost the coloured output in autotest after updating to rspec > v1.1.4 > I was already using the edge version and was ok then, before the last > update. > > Anyone knows something about this? > Can you provide more information about your environment and version of stuff installed like zentest gem, OS, etc? Also if this error happens when running rake spec too? > > Thank you. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From dchelimsky at gmail.com Thu May 29 09:14:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 May 2008 06:14:52 -0700 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Message-ID: On May 29, 2008, at 6:04 AM, David Chelimsky wrote: > On May 29, 2008, at 1:19 AM, Juanma Cervera wrote: > >> Hello. >> >> I have lost the coloured output in autotest after updating to rspec >> v1.1.4 >> I was already using the edge version and was ok then, before the last >> update. >> >> Anyone knows something about this? > > First I've heard of it. I'm not having the same issue. > > What command are you using to run rspec? Oh - you said autotest. I do see the problem, and its source, but don't quite know what to do about it yet. It was introduced in http://github.com/dchelimsky/rspec/commit/3457a3a. I entered a ticket (http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/422 ) to get it on the radar. Cheers, David From lists at ruby-forum.com Thu May 29 09:15:17 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 May 2008 15:15:17 +0200 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Message-ID: David Chelimsky wrote: > On May 29, 2008, at 1:19 AM, Juanma Cervera wrote: > >> Hello. >> >> I have lost the coloured output in autotest after updating to rspec >> v1.1.4 >> I was already using the edge version and was ok then, before the last >> update. >> >> Anyone knows something about this? > > First I've heard of it. I'm not having the same issue. > > What command are you using to run rspec? David, I am wrong. I am using the edge version, from github, not 1.1.4 I see it is numbered 1.1.5 and has this patch applied == Version 1.1.5 (in git) * ... * Disable color codes on STDOUT when STDOUT.tty? is false (patch from Tim Pope). Closes #413. * ... Maybe this is not working in Ubuntu as expected. Besides, colours work well with 'rake spec' and don't work with 'autotest'. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu May 29 09:17:21 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 May 2008 06:17:21 -0700 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: <71166b3b0805290609k4a9c8932m8a8527a5437bf7b@mail.gmail.com> References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> <71166b3b0805290609k4a9c8932m8a8527a5437bf7b@mail.gmail.com> Message-ID: On May 29, 2008, at 6:09 AM, Luis Lavena wrote: > On Thu, May 29, 2008 at 5:19 AM, Juanma Cervera forum.com> wrote: >> Hello. >> >> I have lost the coloured output in autotest after updating to rspec >> v1.1.4 Actually - that is not from 1.1.4 - it's a patch that was introduced after the 1.1.4 release. Did you follow the install directions at http://github.com/dchelimsky/rspec-rails/wikis? >> >> I was already using the edge version and was ok then, before the last >> update. >> >> Anyone knows something about this? >> > > Can you provide more information about your environment and version of > stuff installed like zentest gem, OS, etc? > > Also if this error happens when running rake spec too? > >> >> Thank you. > > Regards, > -- > Luis Lavena > AREA 17 > - > Human beings, who are almost unique in having the ability to learn > from > the experience of others, are also remarkable for their apparent > disinclination to do so. > Douglas Adams > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Thu May 29 09:26:44 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 May 2008 15:26:44 +0200 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Message-ID: <7dac98a4a1b4ea7ce953dbdab314958f@ruby-forum.com> Excuse me Luis. These are the versions I am using. OS: Ubuntu 8.04 Edge Rails revision 888a2927b65889465ce7a1a71e87d37640a2b41b ZenTest 3.9.2 rspec 1.1.5 a021e7bdc0d65ab40ad4d441ab8844bcd9c12f0c rspec-rails e52bc93ce598f21da00cd0589cb7cebd2c1c5130 -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu May 29 09:31:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 May 2008 06:31:40 -0700 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> Message-ID: <7F9AFBDF-AA43-4667-8F35-39FB9E5E69C3@gmail.com> On May 29, 2008, at 6:14 AM, David Chelimsky wrote: > On May 29, 2008, at 6:04 AM, David Chelimsky wrote: > >> On May 29, 2008, at 1:19 AM, Juanma Cervera wrote: >> >>> Hello. >>> >>> I have lost the coloured output in autotest after updating to rspec >>> v1.1.4 >>> I was already using the edge version and was ok then, before the >>> last >>> update. >>> >>> Anyone knows something about this? >> >> First I've heard of it. I'm not having the same issue. >> >> What command are you using to run rspec? > > Oh - you said autotest. > > I do see the problem, and its source, but don't quite know what to > do about it yet. > > It was introduced in http://github.com/dchelimsky/rspec/commit/ > 3457a3a. > > I entered a ticket (http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/422 > ) to get it on the radar. I reverted 3457a3a so if you do a 'git pull' you should be OK. Cheers, David From lists at ruby-forum.com Thu May 29 09:32:08 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 29 May 2008 15:32:08 +0200 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> <71166b3b0805290609k4a9c8932m8a8527a5437bf7b@mail.gmail.com> Message-ID: <710788fbad59ec0f6e1cf4a1f5515167@ruby-forum.com> David Chelimsky wrote: > On May 29, 2008, at 6:09 AM, Luis Lavena wrote: > >> On Thu, May 29, 2008 at 5:19 AM, Juanma Cervera > forum.com> wrote: >>> Hello. >>> >>> I have lost the coloured output in autotest after updating to rspec >>> v1.1.4 > > Actually - that is not from 1.1.4 - it's a patch that was introduced > after the 1.1.4 release. Did you follow the install directions at > http://github.com/dchelimsky/rspec-rails/wikis? More or less. I have git-cloned from github repositories instead of make "script/plugin install" -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu May 29 09:35:01 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 29 May 2008 06:35:01 -0700 Subject: [rspec-users] Coloured output in rspec 1.1.4 In-Reply-To: <710788fbad59ec0f6e1cf4a1f5515167@ruby-forum.com> References: <37f6e67869f826e39cdfbd7f776a6b34@ruby-forum.com> <71166b3b0805290609k4a9c8932m8a8527a5437bf7b@mail.gmail.com> <710788fbad59ec0f6e1cf4a1f5515167@ruby-forum.com> Message-ID: <175B70FE-B706-4C03-8B20-C5B207268AD6@gmail.com> On May 29, 2008, at 6:32 AM, Juanma Cervera wrote: > David Chelimsky wrote: >> On May 29, 2008, at 6:09 AM, Luis Lavena wrote: >> >>> On Thu, May 29, 2008 at 5:19 AM, Juanma Cervera >> forum.com> wrote: >>>> Hello. >>>> >>>> I have lost the coloured output in autotest after updating to rspec >>>> v1.1.4 >> >> Actually - that is not from 1.1.4 - it's a patch that was introduced >> after the 1.1.4 release. Did you follow the install directions at >> http://github.com/dchelimsky/rspec-rails/wikis? > > More or less. > I have git-cloned from github repositories instead of make > "script/plugin install" script/plugin install doesn't support getting a specific version from git yet. To do that you have to use 'git clone' and then 'git checkout 1.1.4' (in this case). From svenfuchs at artweb-design.de Thu May 29 14:30:52 2008 From: svenfuchs at artweb-design.de (Sven Fuchs) Date: Thu, 29 May 2008 20:30:52 +0200 Subject: [rspec-users] Mocking Models in Controller Specs... In-Reply-To: References: <54A3B5BE-131C-4B6E-8CFF-567171CDB5BA@gmail.com> Message-ID: All the mentioned solutions are great, but for me they implied a bit too much hassle to set up and also, given a larger number of specs, a bit slow. This discussion actually motivated me to publish my own stubbing solution that I've recently implemented on GitHub. (This actually is a kind of a factory plus a dsl to define your stubs). http://github.com/svenfuchs/stubby/tree/master Like said in the readme, the code is pretty new and bugs/problems might well be present. Please let me know if you find any. On 27.05.2008, at 11:37, Jarkko Laine wrote: > > On 27.5.2008, at 10.52, Mark Dodwell wrote: > >> Also, any opinions on using a Factory pattern for instantiating >> mocks of >> models? I like the idea of maintaining mocks in one place as I >> frequently use them across several specs for models that have >> associations. Do you think it would create dependency issues >> between the >> specs using that Factory? > > I have built my own "factory" by creating methods such as mock_user > in the spec helper. That method will then fill in some reasonable > values and stub all the needed methods. Granted, the need for that > is less now with stub_model, but sometimes you also want to stub > some associations. That has certainly reduced the amount of > repetition in my specs. > > //jarkko > >> >> >> ~ Mark >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- sven fuchs svenfuchs at artweb-design.de artweb design http://www.artweb-design.de gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) From tek.katu at gmail.com Fri May 30 04:56:12 2008 From: tek.katu at gmail.com (T K) Date: Fri, 30 May 2008 17:56:12 +0900 Subject: [rspec-users] Any good Rails example app created with RSpec and Rspec on Rails? Message-ID: <5c17ebdc0805300156s1f07bd7bp60616ecd03f63441@mail.gmail.com> Hi, I'm pretty new to RSpec. I've been browsing http://opensourcerails.com to find a good app built using RSpec (and RSpec on Rails). Does anybody have a recommendation? I wanna see example of mocks/stubs, associated models and integrated_view. -T From joe at eshopworks.co.uk Fri May 30 09:14:23 2008 From: joe at eshopworks.co.uk (Joseph) Date: Fri, 30 May 2008 14:14:23 +0100 Subject: [rspec-users] Any good Rails example app created with RSpecandRspec on Rails? In-Reply-To: <5c17ebdc0805300156s1f07bd7bp60616ecd03f63441@mail.gmail.com> References: <5c17ebdc0805300156s1f07bd7bp60616ecd03f63441@mail.gmail.com> Message-ID: <1212153263.13620.7.camel@ESW023.esw.eshopworks.co.uk> I've found Radiant CMS a great source for example specs using rails: http://dev.radiantcms.org/ -- Joseph Wilk http://www.joesniff.co.uk On Fri, 2008-05-30 at 17:56 +0900, T K wrote: > Hi, > > I'm pretty new to RSpec. I've been browsing http://opensourcerails.com > to find a good app built using RSpec (and RSpec on Rails). Does > anybody have a recommendation? > > I wanna see example of mocks/stubs, associated models and integrated_view. > > -T > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Latest News - Linesearch.org 4 the latest version of the online enquiry system for the pipelines industry is now live. Mercedes-Benz Challenge Cup 2008 event website has been launched powered by WORKSsitebuilder.com ------------------------------------------------------------------- This email was obviously intended for the people nnotremed in the message. It may be confidential and/or legally privileged. If you have received it by mistake, please take no action based on it, copy it, or show it to anyone - just delete it and let us know about the error. Also, we should point out that any opinions expressed are not necessarily those of eShopworks. Unfortunately email cannot be guaranteed to be secure or error-free and thus this email should not be construed as a solicitation for, or offer of contract. If verification is required please ask us for a hard-copy. And finally, while we've scanned this email on 30/5/2008 to make sure it is virus free to be on the safe side we recommend that you also scan it with your own antivirus software. ------------------------------------------------------------------- From lists at ruby-forum.com Fri May 30 09:17:18 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Fri, 30 May 2008 15:17:18 +0200 Subject: [rspec-users] Any good Rails example app created with RSpec and Rspec In-Reply-To: <5c17ebdc0805300156s1f07bd7bp60616ecd03f63441@mail.gmail.com> References: <5c17ebdc0805300156s1f07bd7bp60616ecd03f63441@mail.gmail.com> Message-ID: <81cb283be5716efc3f7b55d8820e5037@ruby-forum.com> I've found Radiant CMS a great source of example specs with rails: http://dev.radiantcms.org/ -- Joseph Wilk http://www.joesniff.co.uk T K wrote: > Hi, > > I'm pretty new to RSpec. I've been browsing http://opensourcerails.com > to find a good app built using RSpec (and RSpec on Rails). Does > anybody have a recommendation? > > I wanna see example of mocks/stubs, associated models and > integrated_view. > > -T -- Posted via http://www.ruby-forum.com/.