From loop at superinfinite.com Tue Apr 1 03:40:29 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Tue, 1 Apr 2008 09:40:29 +0200 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> Message-ID: <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> On 31-mrt-2008, at 18:22, Ashley Moran wrote: > > On 31/03/2008, Bart Zonneveld wrote: > I'm having the same problem, also with controllers. Weird part is, I > mostly have it at work, running OS 10.4, but not at home, running > 10.5. My environment is the same, except for the OS... > > gr, > bartz > > Hi bartz > > What version of RSpec are you using at work and home? (I am using > Ubuntu at work BTW.) According to 'svn up', it's revision 3333 for both rspec and rspec_on_rails. Both at home and at work. From ashley.moran at patchspace.co.uk Tue Apr 1 03:48:01 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 1 Apr 2008 08:48:01 +0100 Subject: [rspec-users] Anyone seen weird autotest behaviour on trunk? In-Reply-To: <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> References: <9050B030-F61B-4375-A44D-B0374901FC58@superinfinite.com> <43B4A0DE-4CA8-459A-A341-140A6E6F7C4C@superinfinite.com> Message-ID: On 01/04/2008, Bart Zonneveld wrote: > > > According to 'svn up', it's revision 3333 for both rspec and > rspec_on_rails. Both at home and at work. Hmm, exact same revision as me. Are we the only one s having problems? I've also noticed errors along the lines of "ActionController not found" and "expected XXX to respond to respond_to?" (or something - that from the developer that sits behind me). Would love to know what's going on... Ashley -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080401/96eadb69/attachment.html From ashley.moran at patchspace.co.uk Tue Apr 1 03:50:31 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 1 Apr 2008 08:50:31 +0100 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: References: Message-ID: On 01/04/2008, Jed Hurt wrote: > > Is there an easy way to stub an instance method for every new instance of > a given class? I suppose I could just redefine the method, but I'm wondering > if the RSpec mocking framework has this built in. Hi Jed I hate it when other people ask this, but I can't help :) How come you need to do this? I've always wondered what the use case for this "mocking" strategy is Ashley -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080401/38d11038/attachment-0001.html From glenn at aldenta.com Tue Apr 1 08:21:42 2008 From: glenn at aldenta.com (Glenn Ford) Date: Tue, 1 Apr 2008 08:21:42 -0400 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: References: Message-ID: <5819CE97-1342-41D1-AFDC-A26FA377319A@aldenta.com> I think the general consensus is that if you need this feature, then you have ugly code that needs cleaning up :) If you're in a situation like me, where you're too noob to figure out a better solution for some legacy code that you inherited, go to this url and find the instructions for installing Mocha: http://wiki.rubyonrails.org/rails/pages/Testing+Plugins With it you can do: ModelName.any_instance.stubs(:the_method).returns(happy_times) However, I strongly encourage you to stare at your current code for a while and try to find a cleaner MVC-supportive solution. The general rule of thumb is that if it's difficult to write a spec for, then your code is ugly :) Hopefully in this case you can take this as an opportunity to improve your code. If not, Mocha works fairly well! Glenn On Apr 1, 2008, at 3:50 AM, Ashley Moran wrote: > On 01/04/2008, Jed Hurt wrote: > Is there an easy way to stub an instance method for every new > instance of a given class? I suppose I could just redefine the > method, but I'm wondering if the RSpec mocking framework has this > built in. > > Hi Jed > > I hate it when other people ask this, but I can't help :) How come > you need to do this? I've always wondered what the use case for > this "mocking" strategy is > > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080401/d65e1f0f/attachment.html From oliver.saunders at gmail.com Tue Apr 1 10:53:53 2008 From: oliver.saunders at gmail.com (Ollie Saunders) Date: Tue, 1 Apr 2008 15:53:53 +0100 Subject: [rspec-users] Tabs in the TextMate Bundle Message-ID: <13d820710804010753i3d58c941rd3b5591c52a2cfab@mail.gmail.com> I tried to post this to the devel list but it never seemed to get through. So I'm posting it here in the hope that someone from the development team will notice: Hello, I noticed that you are using spaces in all the snippets in the TextMate bundle. I have TM set to 4 spaces and when I use the RSpec bundle I get all these 3-spaced things that are inconsistent and difficult to work with. If you change all the spaces in the snippets to tabs they are expanded to the users preference as they are used. So users wanting 2, 3 or 4 spaces or actual tabs get what they want. I'm using revision 3333 btw. Second thing: I experienced some problems getting the correct version of ruby to work with RSpec (it was refusing to use the one that had all the gems installed), this isn't really your issue at all but I wondered if it might be nice to put a note about the issue in the README. Especially considering you can run these two lines of bash to make the problem magically vanish: mkdir ~/.MacOSX echo "{ PATH = \"$PATH\"; }" > ~/.MacOSX/environment.plist -- Ollie http://olliesaunders.net/ From dchelimsky at gmail.com Tue Apr 1 11:07:51 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 1 Apr 2008 11:07:51 -0400 Subject: [rspec-users] Tabs in the TextMate Bundle In-Reply-To: <13d820710804010753i3d58c941rd3b5591c52a2cfab@mail.gmail.com> References: <13d820710804010753i3d58c941rd3b5591c52a2cfab@mail.gmail.com> Message-ID: <57c63afe0804010807r9308334q3afdbf303ea2f97e@mail.gmail.com> On Tue, Apr 1, 2008 at 10:53 AM, Ollie Saunders wrote: > I tried to post this to the devel list but it never seemed to get > through. So I'm posting it here in the hope that someone from the > development team will notice: If you want the dev team to notice, please post a ticket to http://rspec.lighthouseapp.com. Cheers, David > > Hello, > > I noticed that you are using spaces in all the snippets in the > TextMate bundle. I have TM set to 4 spaces and when I use the RSpec > bundle I get all these 3-spaced things that are inconsistent and > difficult to work with. > > If you change all the spaces in the snippets to tabs they are expanded > to the users preference as they are used. So users wanting 2, 3 or 4 > spaces or actual tabs get what they want. I'm using revision 3333 btw. > > Second thing: I experienced some problems getting the correct version > of ruby to work with RSpec (it was refusing to use the one that had > all the gems installed), this isn't really your issue at all but I > wondered if it might be nice to put a note about the issue in the > README. Especially considering you can run these two lines of bash to > make the problem magically vanish: > > mkdir ~/.MacOSX > echo "{ PATH = \"$PATH\"; }" > ~/.MacOSX/environment.plist > > -- > Ollie > http://olliesaunders.net/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jed.hurt at gmail.com Tue Apr 1 13:19:47 2008 From: jed.hurt at gmail.com (Jed Hurt) Date: Tue, 1 Apr 2008 11:19:47 -0600 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: References: Message-ID: Haha, that's about the response I was expecting; I asked with some trepidation. I'm just looking for a quick hack to short-circuit Merb's render method to do some view/controller isolation testing until Merb officially supports it. I can't just stub methods on @controller (like in Rails) because the controller is instantiated after calling dispatch. I suppose I could whip up a different sort of hack to accomplish the isolation in the meantime, but now I'm not so sure; apparently I'm quite a noob ;) On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran wrote: > On 01/04/2008, Jed Hurt wrote: > > > Is there an easy way to stub an instance method for every new instance > > of a given class? I suppose I could just redefine the method, but I'm > > wondering if the RSpec mocking framework has this built in. > > > Hi Jed > > I hate it when other people ask this, but I can't help :) How come you > need to do this? I've always wondered what the use case for this "mocking" > strategy is > > Ashley > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080401/891520b2/attachment.html From coreyhaines at gmail.com Tue Apr 1 14:11:23 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Tue, 1 Apr 2008 14:11:23 -0400 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: References: Message-ID: <6bdacb70804011111m620acba1r34eb9f4f2e7ed5a2@mail.gmail.com> Could you stub out Controller.new and return your mock? On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt wrote: > Haha, that's about the response I was expecting; I asked with some > trepidation. I'm just looking for a quick hack to short-circuit Merb's > render method to do some view/controller isolation testing until Merb > officially supports it. I can't just stub methods on @controller (like in > Rails) because the controller is instantiated after calling dispatch. > I suppose I could whip up a different sort of hack to accomplish the > isolation in the meantime, but now I'm not so sure; apparently I'm quite a > noob ;) > > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran < > ashley.moran at patchspace.co.uk> wrote: > > > On 01/04/2008, Jed Hurt wrote: > > > > > Is there an easy way to stub an instance method for every new instance > > > of a given class? I suppose I could just redefine the method, but I'm > > > wondering if the RSpec mocking framework has this built in. > > > > > > Hi Jed > > > > I hate it when other people ask this, but I can't help :) How come you > > need to do this? I've always wondered what the use case for this "mocking" > > strategy is > > > > Ashley > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080401/53ada359/attachment.html From dchelimsky at gmail.com Tue Apr 1 14:12:24 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 1 Apr 2008 14:12:24 -0400 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: <6bdacb70804011111m620acba1r34eb9f4f2e7ed5a2@mail.gmail.com> References: <6bdacb70804011111m620acba1r34eb9f4f2e7ed5a2@mail.gmail.com> Message-ID: <57c63afe0804011112i2d501dcw3f43644c6e7894f9@mail.gmail.com> On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines wrote: > Could you stub out Controller.new and return your mock? Bingo. > > > > On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt wrote: > > Haha, that's about the response I was expecting; I asked with some > trepidation. I'm just looking for a quick hack to short-circuit Merb's > render method to do some view/controller isolation testing until Merb > officially supports it. I can't just stub methods on @controller (like in > Rails) because the controller is instantiated after calling dispatch. > > > > > > I suppose I could whip up a different sort of hack to accomplish the > isolation in the meantime, but now I'm not so sure; apparently I'm quite a > noob ;) > > > > > > > > > > > > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran > wrote: > > > > > > > > > > > > > > > > > On 01/04/2008, Jed Hurt wrote: > > > > > > > > > > Is there an easy way to stub an instance method for every new instance > of a given class? I suppose I could just redefine the method, but I'm > wondering if the RSpec mocking framework has this built in. > > > > > > > > > Hi Jed > > > > > > I hate it when other people ask this, but I can't help :) How come you > need to do this? I've always wondered what the use case for this "mocking" > strategy is > > > > > > Ashley > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > http://www.coreyhaines.com > The Internet's Premiere source of information about Corey Haines > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tmhaines at gmail.com Tue Apr 1 22:31:47 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 2 Apr 2008 15:31:47 +1300 Subject: [rspec-users] problem rendering template with story Message-ID: Hi y'all The problem is probably because I'm a newb. I have a home controller in the admin namespace. My controller spec is working as expected, and the following example is passing: it "should show the home page if logged in" do controller.send("current_user=", User.new) get :index response.should render_template('admin/home/index') end But my story is failing on the "then" step: When "I view the home page" do get admin_url end Then "I see the home page" do response.should_not be_redirect # this passes response.code.should == "200" # this passes response.should have_text(/"Client Administration."/) #this fails, as response.body is nil response.should render_template("admin/home/index") #this fails, with actual being nil. end It's as though the template isn't actually being rendered for some reason. Any clues as to why this might be? My login story uses render_template in a similar way and it works successfully.. Cheers, Tim. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/71c8201c/attachment-0001.html From tmhaines at gmail.com Wed Apr 2 00:06:40 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 2 Apr 2008 17:06:40 +1300 Subject: [rspec-users] problem rendering template with story In-Reply-To: References: Message-ID: Hi, Made a little progress here. In one of my "given" steps I was posting to the login action. when I take this post out (and make other changes required), the should render_template works correctly. It's as though the earlier post in the given step is meaning that the response isn't set correctly after the later post.. Tim. On 02/04/2008, Tim Haines wrote: > > Hi y'all > > The problem is probably because I'm a newb. I have a home controller in > the admin namespace. > > My controller spec is working as expected, and the following example is > passing: > > it "should show the home page if logged in" do > controller.send("current_user=", User.new) > get :index > response.should render_template('admin/home/index') > end > > > But my story is failing on the "then" step: > > When "I view the home page" do > get admin_url > end > > Then "I see the home page" do > response.should_not be_redirect # this passes > response.code.should == "200" # this passes > > response.should have_text(/"Client Administration."/) #this fails, as > response.body is nil > response.should render_template("admin/home/index") #this fails, with > actual being nil. > end > > It's as though the template isn't actually being rendered for some > reason. Any clues as to why this might be? My login story uses > render_template in a similar way and it works successfully.. > > Cheers, > > Tim. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/8d9a0ff5/attachment.html From jed.hurt at gmail.com Wed Apr 2 00:22:27 2008 From: jed.hurt at gmail.com (Jed Hurt) Date: Tue, 1 Apr 2008 22:22:27 -0600 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: <57c63afe0804011112i2d501dcw3f43644c6e7894f9@mail.gmail.com> References: <6bdacb70804011111m620acba1r34eb9f4f2e7ed5a2@mail.gmail.com> <57c63afe0804011112i2d501dcw3f43644c6e7894f9@mail.gmail.com> Message-ID: I'm not sure how that would work. For controller specs, I want to keep most of the controller intact so that I can verify its actual behavior. Am I missing something? On Tue, Apr 1, 2008 at 12:12 PM, David Chelimsky wrote: > On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines > wrote: > > Could you stub out Controller.new and return your mock? > > Bingo. > > > > > > > > > On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt wrote: > > > Haha, that's about the response I was expecting; I asked with some > > trepidation. I'm just looking for a quick hack to short-circuit Merb's > > render method to do some view/controller isolation testing until Merb > > officially supports it. I can't just stub methods on @controller (like > in > > Rails) because the controller is instantiated after calling dispatch. > > > > > > > > > I suppose I could whip up a different sort of hack to accomplish the > > isolation in the meantime, but now I'm not so sure; apparently I'm quite > a > > noob ;) > > > > > > > > > > > > > > > > > > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran > > wrote: > > > > > > > > > > > > > > > > > > > > > > > On 01/04/2008, Jed Hurt wrote: > > > > > > > > > > > > > Is there an easy way to stub an instance method for every new > instance > > of a given class? I suppose I could just redefine the method, but I'm > > wondering if the RSpec mocking framework has this built in. > > > > > > > > > > > > Hi Jed > > > > > > > > I hate it when other people ask this, but I can't help :) How come > you > > need to do this? I've always wondered what the use case for this > "mocking" > > strategy is > > > > > > > > Ashley > > > > > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > -- > > http://www.coreyhaines.com > > The Internet's Premiere source of information about Corey Haines > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080401/7e954f23/attachment.html From tmhaines at gmail.com Wed Apr 2 00:55:36 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 2 Apr 2008 17:55:36 +1300 Subject: [rspec-users] problem rendering template with story In-Reply-To: References: Message-ID: And I suspect this is because @first_render isn't being set for subsequent renders.... but it's time to go home now. On 02/04/2008, Tim Haines wrote: > > Hi, > > Made a little progress here. In one of my "given" steps I was posting to > the login action. when I take this post out (and make other changes > required), the should render_template works correctly. It's as though the > earlier post in the given step is meaning that the response isn't set > correctly after the later post.. > > Tim. > > On 02/04/2008, Tim Haines wrote: > > > > Hi y'all > > > > The problem is probably because I'm a newb. I have a home controller in > > the admin namespace. > > > > My controller spec is working as expected, and the following example is > > passing: > > > > it "should show the home page if logged in" do > > controller.send("current_user=", User.new) > > get :index > > response.should render_template('admin/home/index') > > end > > > > > > But my story is failing on the "then" step: > > > > When "I view the home page" do > > get admin_url > > end > > > > Then "I see the home page" do > > response.should_not be_redirect # this passes > > response.code.should == "200" # this passes > > > > response.should have_text(/"Client Administration."/) #this fails, > > as response.body is nil > > response.should render_template("admin/home/index") #this fails, > > with actual being nil. > > end > > > > It's as though the template isn't actually being rendered for some > > reason. Any clues as to why this might be? My login story uses > > render_template in a similar way and it works successfully.. > > > > Cheers, > > > > Tim. > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/4aff76f9/attachment.html From tmhaines at gmail.com Wed Apr 2 01:16:26 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 2 Apr 2008 18:16:26 +1300 Subject: [rspec-users] Given Logged In Message-ID: Hi there, Given my recent problems with .should render_template after a second post, I'm wondering if there's a way I set the state as logged in inside a given step without posting to sessions/create? I can't seem to directly set sessions[:user_id]. I'm using restful_authentication. This is a story as opposed to a spec.. Cheers, Tim. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/bba6eb55/attachment.html From dchelimsky at gmail.com Wed Apr 2 01:22:08 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 2 Apr 2008 01:22:08 -0400 Subject: [rspec-users] Given Logged In In-Reply-To: References: Message-ID: <57c63afe0804012222q2e10aed3q9158e33a6692fa7d@mail.gmail.com> On Wed, Apr 2, 2008 at 1:16 AM, Tim Haines wrote: > Hi there, > > Given my recent problems with .should render_template after a second post, > I'm wondering if there's a way I set the state as logged in inside a given > step without posting to sessions/create? Why not just post to sessions/create? That works, doesn't it? > I can't seem to directly set > sessions[:user_id]. I'm using restful_authentication. > > This is a story as opposed to a spec.. > > Cheers, > > Tim. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tmhaines at gmail.com Wed Apr 2 01:37:49 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 2 Apr 2008 18:37:49 +1300 Subject: [rspec-users] Given Logged In In-Reply-To: <57c63afe0804012222q2e10aed3q9158e33a6692fa7d@mail.gmail.com> References: <57c63afe0804012222q2e10aed3q9158e33a6692fa7d@mail.gmail.com> Message-ID: Hi David. That does the login. So - yes - probably. I had thought it was breaking the "should render_template" that I make after the subsequent post, but maybe something else is causing that to break.. Tim. On 02/04/2008, David Chelimsky wrote: > > On Wed, Apr 2, 2008 at 1:16 AM, Tim Haines wrote: > > Hi there, > > > > Given my recent problems with .should render_template after a second > post, > > I'm wondering if there's a way I set the state as logged in inside a > given > > step without posting to sessions/create? > > > Why not just post to sessions/create? That works, doesn't it? > > > > I can't seem to directly set > > sessions[:user_id]. I'm using restful_authentication. > > > > This is a story as opposed to a spec.. > > > > Cheers, > > > > Tim. > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/da56daa9/attachment-0001.html From lists at ruby-forum.com Wed Apr 2 04:13:12 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Wed, 2 Apr 2008 10:13:12 +0200 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever Message-ID: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> Hello I am learning rspec and trying to especify the activerecord validations of my models. How would I make a require_uniqueness_of specification for a field. Can I make this with mocks, without touching the database? Can somebody point me to some information or plugin for this issue. Thank you very much. Juan M. Cervera -- Posted via http://www.ruby-forum.com/. From court3nay at gmail.com Wed Apr 2 04:19:26 2008 From: court3nay at gmail.com (Courtenay) Date: Wed, 2 Apr 2008 01:19:26 -0700 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> Message-ID: IMO this function should be tested using the database, since it relies heavily on the data. ________________ Courtenay @(o..O)@ On Apr 2, 2008, at 1:13 AM, Juanma Cervera wrote: > Hello > > I am learning rspec and trying to especify the activerecord > validations > of my models. > > How would I make a require_uniqueness_of specification for a field. > Can I make this with mocks, without touching the database? > Can somebody point me to some information or plugin for this issue. > > Thank you very much. > > Juan M. Cervera > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pergesu at gmail.com Wed Apr 2 04:58:00 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 2 Apr 2008 01:58:00 -0700 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> Message-ID: <810a540e0804020158t3f42648fx111e51ea2becc3e2@mail.gmail.com> On Wed, Apr 2, 2008 at 1:19 AM, Courtenay wrote: > IMO this function should be tested using the database, since it relies > heavily on the data. Agreed. Create a record, then create another record with duplicate data, and verify that the second record is invalid. Pat From coreyhaines at gmail.com Wed Apr 2 10:18:19 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 2 Apr 2008 10:18:19 -0400 Subject: [rspec-users] [ANN] rspec_hpricot_matchers 1.0: have_tag on hpricot In-Reply-To: <60f3810c0803261208p4b3ea029xbeccec4f8fe5a52@mail.gmail.com> References: <60f3810c0803261208p4b3ea029xbeccec4f8fe5a52@mail.gmail.com> Message-ID: <6bdacb70804020718v6cdba515qf209a0439eaf0d4b@mail.gmail.com> Just thought I'd send out a little update on using this library. Great! We converted our tests over to using it, and I'm very happy with it. Good job, Kyle! Keep up the good work. It did take a bit of time to convert (using @ in attributes, for example), but it was well worth it. -Corey On Wed, Mar 26, 2008 at 3:08 PM, Kyle Hargraves wrote: > Hello everyone, > > A few weeks ago, I put together a little project that provides a > have_tag() matcher look-alike that can be used outside of Rails > projects, backed by Hpricot, which I very creatively named > rspec_hpricot_matchers. It's not a drop-in replacement for > rspec_on_rails' have_tag(): no substitution values, Hpricot's CSS > selectors aren't identical to assert_select's, and with_tag() has been > replaced by nested calls to have_tag(). But it's pretty close and even > enjoys a few benefits over the standard implementation. > > I finally got around to registering a project on RubyForge and pushing > a gem, so it is now available with just: > > gem install rspec_hpricot_matchers > > If you're interested, the source is hosted on github at: > > http://github.com/pd/rspec_hpricot_matchers > > I'm using this both in isolated XML-related libraries and in my Rails > projects, and I haven't come up with any features I want lately, so > it's reasonably stable in my experience. Usage examples are available > in the README, and the specs are simple enough to be another good set > of examples. > > Suggestions, patches and angry flames about list spamming are all welcome. > > Thanks > > Kyle > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/8a4b2761/attachment.html From coreyhaines at gmail.com Wed Apr 2 10:19:40 2008 From: coreyhaines at gmail.com (Corey Haines) Date: Wed, 2 Apr 2008 10:19:40 -0400 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: References: <6bdacb70804011111m620acba1r34eb9f4f2e7ed5a2@mail.gmail.com> <57c63afe0804011112i2d501dcw3f43644c6e7894f9@mail.gmail.com> Message-ID: <6bdacb70804020719q4da82c38u691ae4689fab0e73@mail.gmail.com> Create an instance of the controller contr = MyController.new MyController.stub!(:new).and_return contr contr.stub!(:method_i_want_to_stub).and_return 'sweetness' Something like this? -Corey On Wed, Apr 2, 2008 at 12:22 AM, Jed Hurt wrote: > I'm not sure how that would work. For controller specs, I want to keep > most of the controller intact so that I can verify its actual behavior. Am I > missing something? > > > On Tue, Apr 1, 2008 at 12:12 PM, David Chelimsky > wrote: > > > On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines > > wrote: > > > Could you stub out Controller.new and return your mock? > > > > Bingo. > > > > > > > > > > > > > > On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt wrote: > > > > Haha, that's about the response I was expecting; I asked with some > > > trepidation. I'm just looking for a quick hack to short-circuit Merb's > > > render method to do some view/controller isolation testing until Merb > > > officially supports it. I can't just stub methods on @controller (like > > in > > > Rails) because the controller is instantiated after calling dispatch. > > > > > > > > > > > > I suppose I could whip up a different sort of hack to accomplish the > > > isolation in the meantime, but now I'm not so sure; apparently I'm > > quite a > > > noob ;) > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 01/04/2008, Jed Hurt wrote: > > > > > > > > > > > > > > > > Is there an easy way to stub an instance method for every new > > instance > > > of a given class? I suppose I could just redefine the method, but I'm > > > wondering if the RSpec mocking framework has this built in. > > > > > > > > > > > > > > > Hi Jed > > > > > > > > > > I hate it when other people ask this, but I can't help :) How > > come you > > > need to do this? I've always wondered what the use case for this > > "mocking" > > > strategy is > > > > > > > > > > Ashley > > > > > > > > > > > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > -- > > > http://www.coreyhaines.com > > > The Internet's Premiere source of information about Corey Haines > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/9e2fa221/attachment.html From smingins at elctech.com Wed Apr 2 16:20:32 2008 From: smingins at elctech.com (Shane Mingins) Date: Thu, 3 Apr 2008 09:20:32 +1300 Subject: [rspec-users] Given Logged In In-Reply-To: References: Message-ID: Hi Tim I haven't had a chance to look at stories yet ... but can u not use the AuthenticatedTestHelper login_as method? Cheers Shane On 2/04/2008, at 6:16 PM, Tim Haines wrote: > Hi there, > > Given my recent problems with .should render_template after a second > post, I'm wondering if there's a way I set the state as logged in > inside a given step without posting to sessions/create? I can't > seem to directly set sessions[:user_id]. I'm using > restful_authentication. > > This is a story as opposed to a spec.. > > Cheers, > > Tim. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tmhaines at gmail.com Wed Apr 2 19:09:05 2008 From: tmhaines at gmail.com (Tim Haines) Date: Thu, 3 Apr 2008 12:09:05 +1300 Subject: [rspec-users] newb q: Can story steps report a view rendering error? Message-ID: Hi'ya I have a When step that calls get game_url. It turns out that calling this page is resulting in a render error, which explains my failing Then steps. It would help me if the story told me there was a problem rendering the response. Is there any way to get the story steps to automatically raise an error if such a problem occurs? For now I can add response.code.should == "200" or something similar.. Tim. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/8e40cd9f/attachment.html From philodespotos at gmail.com Wed Apr 2 20:31:38 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Wed, 2 Apr 2008 19:31:38 -0500 Subject: [rspec-users] newb q: Can story steps report a view rendering error? In-Reply-To: References: Message-ID: <60f3810c0804021731t6117892due4e12dae7f8e41cf@mail.gmail.com> On Wed, Apr 2, 2008 at 6:09 PM, Tim Haines wrote: > Hi'ya > > I have a When step that calls get game_url. It turns out that calling this > page is resulting in a render error, which explains my failing Then steps. > It would help me if the story told me there was a problem rendering the > response. Is there any way to get the story steps to automatically raise an > error if such a problem occurs? > > For now I can add response.code.should == "200" or something similar.. I just rely on test.log, inside of which you will find the typical stacktrace produced by errors that occur while rendering a template. So that will explain the problem; to catch the explosion before your stories move on, you are right that you have to check the response code. Your code check, or the equivalent 'response.should be_success', should suffice. webrat, for example, wraps its requests in a method 'request_page()', and after every request it calls 'assert_response :success' so that the story will fail fast. Kyle From tmhaines at gmail.com Wed Apr 2 20:38:03 2008 From: tmhaines at gmail.com (Tim Haines) Date: Thu, 3 Apr 2008 13:38:03 +1300 Subject: [rspec-users] problem rendering template with story In-Reply-To: References: Message-ID: I got this way wrong. It was due to pages not rendering due to there being an error in the view (that I wasn't aware of). The problem in the view was due to the test database not being up to date with the latest migrations... (so page was rendering correctly in dev mode) I'm happy I've persisted with it and now finally have a bunch of working stories... Tim. On 02/04/2008, Tim Haines wrote: > > And I suspect this is because @first_render isn't being set for subsequent > renders.... but it's time to go home now. > > On 02/04/2008, Tim Haines wrote: > > > > Hi, > > > > Made a little progress here. In one of my "given" steps I was posting > > to the login action. when I take this post out (and make other changes > > required), the should render_template works correctly. It's as though the > > earlier post in the given step is meaning that the response isn't set > > correctly after the later post.. > > > > Tim. > > > > On 02/04/2008, Tim Haines wrote: > > > > > > Hi y'all > > > > > > The problem is probably because I'm a newb. I have a home controller > > > in the admin namespace. > > > > > > My controller spec is working as expected, and the following example > > > is passing: > > > > > > it "should show the home page if logged in" do > > > controller.send("current_user=", User.new) > > > get :index > > > response.should render_template('admin/home/index') > > > end > > > > > > > > > But my story is failing on the "then" step: > > > > > > When "I view the home page" do > > > get admin_url > > > end > > > > > > Then "I see the home page" do > > > response.should_not be_redirect # this passes > > > response.code.should == "200" # this passes > > > > > > response.should have_text(/"Client Administration."/) #this > > > fails, as response.body is nil > > > response.should render_template("admin/home/index") #this fails, > > > with actual being nil. > > > end > > > > > > It's as though the template isn't actually being rendered for some > > > reason. Any clues as to why this might be? My login story uses > > > render_template in a similar way and it works successfully.. > > > > > > Cheers, > > > > > > Tim. > > > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/53d59eec/attachment.html From jed.hurt at gmail.com Thu Apr 3 00:29:53 2008 From: jed.hurt at gmail.com (Jed Hurt) Date: Wed, 2 Apr 2008 22:29:53 -0600 Subject: [rspec-users] Stub an instance method for every new instance of a class In-Reply-To: <6bdacb70804020719q4da82c38u691ae4689fab0e73@mail.gmail.com> References: <6bdacb70804011111m620acba1r34eb9f4f2e7ed5a2@mail.gmail.com> <57c63afe0804011112i2d501dcw3f43644c6e7894f9@mail.gmail.com> <6bdacb70804020719q4da82c38u691ae4689fab0e73@mail.gmail.com> Message-ID: Ahhh, clever. I see the light On Wed, Apr 2, 2008 at 8:19 AM, Corey Haines wrote: > Create an instance of the controller > > contr = MyController.new > > MyController.stub!(:new).and_return contr > > contr.stub!(:method_i_want_to_stub).and_return 'sweetness' > > Something like this? > > -Corey > > On Wed, Apr 2, 2008 at 12:22 AM, Jed Hurt wrote: > > > I'm not sure how that would work. For controller specs, I want to keep > > most of the controller intact so that I can verify its actual behavior. Am I > > missing something? > > > > > > On Tue, Apr 1, 2008 at 12:12 PM, David Chelimsky > > wrote: > > > > > On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines > > > wrote: > > > > Could you stub out Controller.new and return your mock? > > > > > > Bingo. > > > > > > > > > > > > > > > > > > > On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt wrote: > > > > > Haha, that's about the response I was expecting; I asked with some > > > > trepidation. I'm just looking for a quick hack to short-circuit > > > Merb's > > > > render method to do some view/controller isolation testing until > > > Merb > > > > officially supports it. I can't just stub methods on @controller > > > (like in > > > > Rails) because the controller is instantiated after calling > > > dispatch. > > > > > > > > > > > > > > > I suppose I could whip up a different sort of hack to accomplish > > > the > > > > isolation in the meantime, but now I'm not so sure; apparently I'm > > > quite a > > > > noob ;) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 01/04/2008, Jed Hurt wrote: > > > > > > > > > > > > > > > > > > > Is there an easy way to stub an instance method for every new > > > instance > > > > of a given class? I suppose I could just redefine the method, but > > > I'm > > > > wondering if the RSpec mocking framework has this built in. > > > > > > > > > > > > > > > > > > Hi Jed > > > > > > > > > > > > I hate it when other people ask this, but I can't help :) How > > > come you > > > > need to do this? I've always wondered what the use case for this > > > "mocking" > > > > strategy is > > > > > > > > > > > > Ashley > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > rspec-users mailing list > > > > > > rspec-users at rubyforge.org > > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-users at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > > > > > > > > > > -- > > > > http://www.coreyhaines.com > > > > The Internet's Premiere source of information about Corey Haines > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > http://www.coreyhaines.com > The Internet's Premiere source of information about Corey Haines > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080402/6a9b6bed/attachment.html From grail at goldweb.com.au Wed Apr 2 20:37:53 2008 From: grail at goldweb.com.au (Alex Satrapa) Date: Thu, 3 Apr 2008 11:37:53 +1100 Subject: [rspec-users] newb q: Can story steps report a view rendering error? In-Reply-To: References: Message-ID: <2AED31C1-B529-45E6-8F1E-11FC4C79ED8D@goldweb.com.au> On 03/04/2008, at 10:09 , Tim Haines wrote: > For now I can add response.code.should == "200" or something similar.. The page returned by Rails to provide you with the stack trace and stuff? That is a valid HTML page, and it comes along with a HTTP 200 OK response. What you need to do is look for stuff that you expect to see or not see on the page: # This will complain when your page isn't rendered using the expected template response.should have_tag('title', 'This is the title I expect to see') There used to be an article on using the have_tag matcher here: http://rubypond.com/articles/2008/03/31/using-rspec-have_tag/ ... however at the time of writing this email, I get a page stating only, "The page you are looking for is temporarily unavailable. Please try again later." Hopefully it comes back, I go back to read it for a refresher every now and then. Hope this helps! Alex From matt at mattberther.com Thu Apr 3 02:14:59 2008 From: matt at mattberther.com (Matt Berther) Date: Thu, 3 Apr 2008 00:14:59 -0600 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> Message-ID: <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> Hi Juanma, I do this this way: describe Model do def create(options={}) Model.create(options) end it "should not allow duplicate names" do model = create(:name => "name") new_model = create(:name => "name") new_model.should have_error_on(:name, :taken) end end -- Matt Berther http://www.mattberther.com On Apr 2, 2008, at 2:13 AM, Juanma Cervera wrote: > Hello > > I am learning rspec and trying to especify the activerecord > validations > of my models. > > How would I make a require_uniqueness_of specification for a field. > Can I make this with mocks, without touching the database? > Can somebody point me to some information or plugin for this issue. > > Thank you very much. > > Juan M. Cervera > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ashley.moran at patchspace.co.uk Thu Apr 3 04:56:52 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 3 Apr 2008 09:56:52 +0100 Subject: [rspec-users] Anyone experienced RSpec/Autotest forgetting models? Message-ID: Hi Saving a controller spec frequently gives me this error: 52) LoadError in 'UsersController GET /users with basic request params should find all the user types' Expected /home/amoran/Documents/becta/apps/Backend/app/models/user_type.rb to define UserType ./spec/controllers/users_controller_spec.rb:299: script/spec:4: I have to Ctrl-C autotest before it will load again. Anyone else seen this? Is it a known issue? I am on trunk r3333. Thanks Ashley -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/f5058091/attachment.html From joe at eshopworks.co.uk Thu Apr 3 05:15:04 2008 From: joe at eshopworks.co.uk (joseph) Date: Thu, 03 Apr 2008 10:15:04 +0100 Subject: [rspec-users] Advice / Turning a Usecase into a Rspec Story / Granularity ofstories In-Reply-To: <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> References: <94382B88-1DD2-44B0-8600-5DA6E5ADB5F8@superinfinite.com> <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> Message-ID: <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> Hello, I'm having some trouble working out what the granularity of stories should be. I have a use-case 'manage page', for a blogging system (like wordpress) I'm building. The single use-case covers - add page,delete page,edit page,preview page actions. With the use-case we avoided getting too fine a level of granularity (i.e. add page use-case, delete page use-case...), to keep the clients and us sane. I tried to maintain a convention of converting a use-case into a rspec story. Mainly to make it easier for the client to engage in the stories. Example Story (High level): Story: Web admin manages pages within the admin system Scenario: Add page Scenario: edit page. Scenario: delete page. I'm unsure if this granularity is productive for a rspec story. Whether it will lead to a bloated story and if the scenarios become less obviously link to the title/narrative. I have a nagging doubt that perhaps it should be: Example Story (Low level) Story: Web admin adds a page Scenario: without some special fields Scenario: Setting publish dates Have people experienced this issue before? Does anyone have any comments or suggestions? Thanks, Joseph Wilk http://www.joesniff.co.uk On Mon, 2008-03-17 at 09:40 +0100, Bart Zonneveld wrote: > No replies? That doesn't happen very often :). > > regards, > bartz > > On 13-mrt-2008, at 14:13, Bart Zonneveld wrote: > > > Hey list, > > > > I'm refactoring some much-used functionality into a common_steps step > > group. Methods like this are in there: > > > > steps_for :common do > > Given "a number of existing $types?" do |type| > > @initial_item_count = type.singularize.classify.constantize.count > > end > > > > When "the user adds an invalid $type" do |type| > > post "/#{type.pluralize}/create", type.to_sym => {} > > end > > > > When "the user adds a valid $type" do |type| > > post "/#{type.pluralize}/create", type.to_sym => valid_attributes > > end > > > > Then "there should be $number more $type? in the system" do | > > number, type| > > type.classify.constantize.count.should == (@initial_item_count + > > number.to_i) > > end > > > > Then "there should be an error message explaining what went > > wrong" do > > response.should have_tag('div#errorExplanation') > > end > > > > Then "the user should see the form again" do > > response.should have_tag('form[method=post]') > > end > > end > > > > This more or less works for me. However, I'm interested in two > > things. First, is this good practice? It's DRY, but I'm coupling my > > stories to these common steps in a way.. And second, is it possible > > to define a method in my specific stepgroup, that can be called from > > my common stepgroup? > > For instance, in the "user adds a valid type" step, I call a > > valid_attributes method. I'd like to define that on the specific > > stepgroup, but so far I haven't been able to get it called... > > > > thanks! > > bartz > > _______________________________________________ > > 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 Latest News:- * www.phaidon.com launch their new site on WORKSsitebuilder * www.pukkaherbs.com are experts in all things Ayurvedic. They have launched their new store on WORKSsitebuilder ------------------------------------------------------------------- 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 3/4/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 ashley.moran at patchspace.co.uk Thu Apr 3 05:34:10 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 3 Apr 2008 10:34:10 +0100 Subject: [rspec-users] Advice / Turning a Usecase into a Rspec Story / Granularity ofstories In-Reply-To: <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> References: <94382B88-1DD2-44B0-8600-5DA6E5ADB5F8@superinfinite.com> <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> Message-ID: On 03/04/2008, joseph wrote: > > > Example Story (High level): > > Story: Web admin manages pages within the admin system > Scenario: Add page > Scenario: edit page. > Scenario: delete page. > > I'm unsure if this granularity is productive for a rspec story. Hi Jospeh This seems too coarse to me. The controller I'm working on now will end up with a corresponding story for each of your scenarios. My scenarios are along the lines of "User edits page with valid details", "User edits page with missing details", "User edits page and clicks cancel", "User with insufficient priveleges tries to delete page" etc. I try to make a scenario for each common or complex thing that changes the state of the system - they would never fit in one story. Ashley -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/be4d86bc/attachment.html From lists at ruby-forum.com Thu Apr 3 07:38:41 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Thu, 3 Apr 2008 13:38:41 +0200 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> Message-ID: Thanks to all for your answers. I also have found a plugin with matchers for active record validations, associations and even useful matchers for views. It has a matcher for validates_uniqueness_of that doesn't got to the database. The url is http://code.google.com/p/rspec-on-rails-matchers/ ?What do you think of using this plugin? Juanma Cervera. -- Posted via http://www.ruby-forum.com/. From rick.denatale at gmail.com Thu Apr 3 08:03:21 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 3 Apr 2008 08:03:21 -0400 Subject: [rspec-users] newb q: Can story steps report a view rendering error? In-Reply-To: References: Message-ID: On Wed, Apr 2, 2008 at 7:09 PM, Tim Haines wrote: > Hi'ya > > I have a When step that calls get game_url. It turns out that calling this > page is resulting in a render error, which explains my failing Then steps. > It would help me if the story told me there was a problem rendering the > response. Is there any way to get the story steps to automatically raise an > error if such a problem occurs? > > For now I can add response.code.should == "200" or something similar.. I can't help but think that this level would more properly be covered by having good controller and view specs in addition to stories. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From rick.denatale at gmail.com Thu Apr 3 08:12:57 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 3 Apr 2008 08:12:57 -0400 Subject: [rspec-users] Advice / Turning a Usecase into a Rspec Story / Granularity ofstories In-Reply-To: References: <94382B88-1DD2-44B0-8600-5DA6E5ADB5F8@superinfinite.com> <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> Message-ID: On Thu, Apr 3, 2008 at 5:34 AM, Ashley Moran wrote: > On 03/04/2008, joseph wrote: > > > > > Example Story (High level): > > > > Story: Web admin manages pages within the admin system > > Scenario: Add page > > Scenario: edit page. > > Scenario: delete page. > This seems too coarse to me. The controller I'm working on now will end up > with a corresponding story for each of your scenarios. My scenarios are > along the lines of "User edits page with valid details", "User edits page > with missing details", "User edits page and clicks cancel", "User with > insufficient priveleges tries to delete page" etc. I try to make a scenario > for each common or complex thing that changes the state of the system - they > would never fit in one story. On the other hand. Keeping these finer grained scenarios within a single story allows branching using GivenScenario which only works with scenarios within the same story. Story: Web admin manages pages within the admin system Scenario: Add page Scenario: edit page with valid details GivenScenario: Add page Scenario: edit page with missing details GivenScenario: Add page Scenario: user with sufficient privileges deletes page GivenScenario: Add page Scenario: user with insufficient privileges deletes page GivenScenario: Add page -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From loop at superinfinite.com Thu Apr 3 08:25:22 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Thu, 3 Apr 2008 14:25:22 +0200 Subject: [rspec-users] Advice / Turning a Usecase into a Rspec Story / Granularity ofstories In-Reply-To: References: <94382B88-1DD2-44B0-8600-5DA6E5ADB5F8@superinfinite.com> <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> Message-ID: <10B4C604-ACB3-4E30-8DA1-20246DFDD135@superinfinite.com> On 3-apr-2008, at 14:12, Rick DeNatale wrote: > On Thu, Apr 3, 2008 at 5:34 AM, Ashley Moran > wrote: >> On 03/04/2008, joseph wrote: >> >>> >>> Example Story (High level): >>> >>> Story: Web admin manages pages within the admin system >>> Scenario: Add page >>> Scenario: edit page. >>> Scenario: delete page. > >> This seems too coarse to me. The controller I'm working on now >> will end up >> with a corresponding story for each of your scenarios. My >> scenarios are >> along the lines of "User edits page with valid details", "User >> edits page >> with missing details", "User edits page and clicks cancel", "User >> with >> insufficient priveleges tries to delete page" etc. I try to make >> a scenario >> for each common or complex thing that changes the state of the >> system - they >> would never fit in one story. > > On the other hand. Keeping these finer grained scenarios within a > single story allows branching using GivenScenario which only works > with scenarios within the same story. I am having the same struggles with the granularity. Is there a good "sample" app out there on the interweb? Or perhaps someone from the list wants to share their story? :) gr, bartz From dchelimsky at gmail.com Thu Apr 3 08:31:54 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 Apr 2008 08:31:54 -0400 Subject: [rspec-users] Advice / Turning a Usecase into a Rspec Story / Granularity ofstories In-Reply-To: <10B4C604-ACB3-4E30-8DA1-20246DFDD135@superinfinite.com> References: <94382B88-1DD2-44B0-8600-5DA6E5ADB5F8@superinfinite.com> <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> <10B4C604-ACB3-4E30-8DA1-20246DFDD135@superinfinite.com> Message-ID: <57c63afe0804030531i49dcc4es58a2277128872aed@mail.gmail.com> On Thu, Apr 3, 2008 at 8:25 AM, Bart Zonneveld wrote: > > > On 3-apr-2008, at 14:12, Rick DeNatale wrote: > > On Thu, Apr 3, 2008 at 5:34 AM, Ashley Moran > > wrote: > >> On 03/04/2008, joseph wrote: > >> > >>> > >>> Example Story (High level): > >>> > >>> Story: Web admin manages pages within the admin system > >>> Scenario: Add page > >>> Scenario: edit page. > >>> Scenario: delete page. > > > >> This seems too coarse to me. The controller I'm working on now > >> will end up > >> with a corresponding story for each of your scenarios. My > >> scenarios are > >> along the lines of "User edits page with valid details", "User > >> edits page > >> with missing details", "User edits page and clicks cancel", "User > >> with > >> insufficient priveleges tries to delete page" etc. I try to make > >> a scenario > >> for each common or complex thing that changes the state of the > >> system - they > >> would never fit in one story. > > > > On the other hand. Keeping these finer grained scenarios within a > > single story allows branching using GivenScenario which only works > > with scenarios within the same story. > > I am having the same struggles with the granularity. Is there a good > "sample" app out there on the interweb? > Or perhaps someone from the list wants to share their story? :) I addressed this in my talk at ETEC last week. Slides are here: http://www.chariotsolutions.com/slides/pdfs/ete2008-IntegrationTestingWithRSpec.pdf Cheers, David From mark.ryall at gmail.com Thu Apr 3 08:48:19 2008 From: mark.ryall at gmail.com (Mark Ryall) Date: Thu, 3 Apr 2008 23:48:19 +1100 Subject: [rspec-users] tags/categories for specs Message-ID: <43769a4a0804030548v22f67c5fs69a5c3437c705a3f@mail.gmail.com> Many thanks to David Chelimsky for answering my question about :type & :behaviour_type hash key: http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/4b76e2c5a1a8918d It has made me curious to know whether tagging specs is a feature anyone has requested before. The current project i'm working on has a vast number of specs - most using selenium - and consequently a very long build (cruisecontrol). We have a few of different independant streams of development, all working on the same codebase, each having an associated 'precheckin' build. We try to make sure these only take up to 10-15 mins by running a relevant subset of the specs. We'd ideally run the full build locally before every commit but we optimistically commit when the relevant precheckin build passes just so we can check in more frequently (the build server always runs the full build). There's effort going into reduing the overall build time (selenium grid and various other ideas) but this is a reasonable option right now. Currently we achieve this crudely by having a custom spec runner that loads specs according to whether the filename matches a set of inclusion regular expressions and doesn't match a set of exclusion regular expressions (each stream has a set of filters). A simpler method might have just been to put the specs in different directories but it's convenient to be able to include the same spec in more than one of these precheckin builds. It would be really cool to have just been able to write specs like this: describe 'some piece of functionality', :tags => [:ui, :search] do ... end describe 'some other piece of functionality', :tags => [:ui] do ... end and then execute only the first spec as a result of launching something like 'spec --tags search' - all of the specs can be loaded but only those that match the specified tag would be executed. Having poked around the code a little, it doesn't seem impossibly difficult to implement. Does the idea have any appeal to anyone? It doesn't seem an especially original idea so I wonder if anyone has already had a go at implementing it? Mark. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/b654804f/attachment.html From dchelimsky at gmail.com Thu Apr 3 08:56:17 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 Apr 2008 08:56:17 -0400 Subject: [rspec-users] Anyone experienced RSpec/Autotest forgetting models? In-Reply-To: References: Message-ID: <57c63afe0804030556h549c5b4t926dbe97006e5969@mail.gmail.com> On Thu, Apr 3, 2008 at 4:56 AM, Ashley Moran wrote: > Hi > > Saving a controller spec frequently gives me this error: > > 52) > LoadError in 'UsersController GET /users with basic request params should > find all the user types' > Expected /home/amoran/Documents/becta/apps/Backend/app/models/user_type.rb > to define UserType > ./spec/controllers/users_controller_spec.rb:299: > script/spec:4: > > I have to Ctrl-C autotest before it will load again. > > Anyone else seen this? Is it a known issue? This question comes up a lot. Please search at http://rspec.lighthouseapp.com for a ticket. If you don't find something, consider it "not known" and add a ticket. Thanks, David > I am on trunk r3333. > > Thanks > Ashley > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 3 08:58:54 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 3 Apr 2008 08:58:54 -0400 Subject: [rspec-users] newb q: Can story steps report a view rendering error? In-Reply-To: References: Message-ID: <57c63afe0804030558m5e7f9fd9u66b3ecc2a52531ca@mail.gmail.com> On Thu, Apr 3, 2008 at 8:03 AM, Rick DeNatale wrote: > On Wed, Apr 2, 2008 at 7:09 PM, Tim Haines wrote: > > > Hi'ya > > > > I have a When step that calls get game_url. It turns out that calling this > > page is resulting in a render error, which explains my failing Then steps. > > It would help me if the story told me there was a problem rendering the > > response. Is there any way to get the story steps to automatically raise an > > error if such a problem occurs? > > > > For now I can add response.code.should == "200" or something similar.. > > I can't help but think that this level would more properly be covered > by having good controller and view specs in addition to stories. I can't help agreeing with you Rick. > > -- > 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 philodespotos at gmail.com Thu Apr 3 10:58:09 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Thu, 3 Apr 2008 09:58:09 -0500 Subject: [rspec-users] Command line story runner Message-ID: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> Hullo all, It sucks to write wrapper .rb files just so stories/all.rb can find and run them. So I am trawling for feedback on a small project I pushed to github a day or two ago; it provides a 'story' executable that can be used to run your plain text stories from the command line, akin to the 'spec' command. It's based on Bryan Helmkamp's script/story command that he posted to this list -- http://rubyforge.org/pipermail/rspec-users/2007-December/005194.html -- and is still pretty much all his code. The project is available on github at http://github.com/pd/story and can be installed by cloning it, `rake gem`, then installing the gem in pkg/whatever.gem. I won't be pushing a gem of this to rubyforge for a while. The repository includes a brief readme detailing the features: - Options can be specified in stories/story.opts, which is automatically loaded if present (unlike spec, but I am too lazy to type -O so often) - Allows you to specify a single .story file, a directory full of them, nothing at all to run ./stories/stories/**/*.story, etc. - It works for both rails and non-rails projects, by allowing a --rails option to specify that stories should be run as a RailsStory - Step group definitions which should be accessible in every story can be listed using --global-steps - Deduces the default step groups to include by using the .story file's pathname. - Step groups to be included which could not be deduced from the story filename can be listed at the top of the file, eg: # +steps: foo, bar/baz, and a really long step group name - 'and a really long step group name' is a valid name; I prefer strings to symbols here (tho symbols will still work). This allows the story at stories/stories/foo/bar.story to include the 'foo/bar' step group, and also permits step group names such as 'data creation'. One achingly missing feature at the moment is hooking into the config options for Spec::Story::Runner, but I didn't have any immediate use for it so I didn't bother. But I will probably do so soon enough. (Also, specs =) This is very tied to the layout of my own projects, and I'd be surprised if it works out of the box for most people. Right now it does mostly everything I need, so I'm curious what would be necessary to make it a viable tool for others to use. ty Kyle From ashley.moran at patchspace.co.uk Thu Apr 3 10:59:16 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 3 Apr 2008 15:59:16 +0100 Subject: [rspec-users] Advice / Turning a Usecase into a Rspec Story / Granularity ofstories In-Reply-To: References: <94382B88-1DD2-44B0-8600-5DA6E5ADB5F8@superinfinite.com> <64B3E556-6A7C-4298-A9A9-C4BE941565F4@superinfinite.com> <1207214104.6571.23.camel@esw023.esw.eshopworks.co.uk> Message-ID: On 03/04/2008, Rick DeNatale wrote: > > > On the other hand. Keeping these finer grained scenarios within a > single story allows branching using GivenScenario which only works > with scenarios within the same story. Hi Rick I've never used GivenScenario - is there any documentation about it available? Google only returns answers about JBehave. Ashley -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/d5c21e37/attachment.html From pergesu at gmail.com Thu Apr 3 12:06:27 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 3 Apr 2008 09:06:27 -0700 Subject: [rspec-users] tags/categories for specs In-Reply-To: <43769a4a0804030548v22f67c5fs69a5c3437c705a3f@mail.gmail.com> References: <43769a4a0804030548v22f67c5fs69a5c3437c705a3f@mail.gmail.com> Message-ID: <810a540e0804030906u2db786dbw59b45d0ac3909435@mail.gmail.com> On Thu, Apr 3, 2008 at 5:48 AM, Mark Ryall wrote: > Many thanks to David Chelimsky for answering my question about :type & > :behaviour_type hash key: > > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/4b76e2c5a1a8918d > > It has made me curious to know whether tagging specs is a feature anyone has > requested before. I've heard this mentioned a couple times before. I don't think I've ever heard arguments against it...probably just that it's never itched bad enough for someone to scratch it. You should search the ticket tracking system (http://rspec.lighthouseapp.com/projects/5645-rspec/overview) for anything like that, and submit a feature request if you don't find anything. Ooh, a patch would be good too :) Pat From rick.denatale at gmail.com Thu Apr 3 14:43:29 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 3 Apr 2008 14:43:29 -0400 Subject: [rspec-users] newb q: Can story steps report a view rendering error? In-Reply-To: <57c63afe0804030558m5e7f9fd9u66b3ecc2a52531ca@mail.gmail.com> References: <57c63afe0804030558m5e7f9fd9u66b3ecc2a52531ca@mail.gmail.com> Message-ID: On Thu, Apr 3, 2008 at 8:58 AM, David Chelimsky wrote: > On Thu, Apr 3, 2008 at 8:03 AM, Rick DeNatale wrote: > > I can't help but think that this level would more properly be covered > > by having good controller and view specs in addition to stories. > > I can't help agreeing with you Rick. Great minds think alike! Or as an English friend of mine liked to say in reply. Fools fail to differ! -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From me at danielfischer.com Thu Apr 3 20:17:29 2008 From: me at danielfischer.com (Fischer, Daniel) Date: Thu, 3 Apr 2008 17:17:29 -0700 Subject: [rspec-users] Autotest RSpec Not Running on Model Save's? Message-ID: <7e565b5c0804031717l15f63d57w17c57a2cd6657817@mail.gmail.com> If I save my model while autotest is running, autotest doesn't run the model's specs, all I get in my window is /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S script/spec -O spec/spec.opts However if I go to the spec and save that, it'll automatically run that spec... it just won't do it from the model itself. If I remember correctly, autotest used to automatically map the model to the spec, didn't it? Or at least automatically run all specs everytime you save? Anyway, any help would be appreciated, thanks! -Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/f8fff78b/attachment.html From kamal.fariz at gmail.com Thu Apr 3 22:20:35 2008 From: kamal.fariz at gmail.com (Kamal Fariz) Date: Fri, 4 Apr 2008 10:20:35 +0800 Subject: [rspec-users] Command line story runner In-Reply-To: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> References: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> Message-ID: <63FD493A-2D1D-4EE8-B67B-E7209B6773D3@gmail.com> > It sucks to write wrapper .rb files just so stories/all.rb can find > and run them. Very nice. I was considering moving over to the Rubyesque stories so that I don't have to have .story files around and the wrapper like you mentioned. The wrapper is the story. http://continuousthinking.com/2008/3/5/trying-rspec-s-rubyesque-stories I'm gonna give this a try. Regards, kamal From phlip2005 at gmail.com Fri Apr 4 00:19:48 2008 From: phlip2005 at gmail.com (Phlip) Date: Thu, 03 Apr 2008 21:19:48 -0700 Subject: [rspec-users] [ANN] rspec_hpricot_matchers 1.0: have_tag on hpricot In-Reply-To: <6bdacb70804020718v6cdba515qf209a0439eaf0d4b@mail.gmail.com> References: <60f3810c0803261208p4b3ea029xbeccec4f8fe5a52@mail.gmail.com> <6bdacb70804020718v6cdba515qf209a0439eaf0d4b@mail.gmail.com> Message-ID: Corey Haines wrote: > A few weeks ago, I put together a little project that provides a > have_tag() matcher look-alike that can be used outside of Rails > projects, backed by Hpricot, which I very creatively named > rspec_hpricot_matchers. I bet it can easily do something like this (if you rspeckers will excuse the dreaded word "assert"!): def assert_all_embedded_images assert_any_xpath :img do |img| assert_public_image_file img[:src] false # :keep looping! end end def test_find_all_embedded_images get :some_action # a Rails functional test assert_all_embedded_images end def assert_public_image_file(src, line = nil) src.sub!(/^\//, '') # RailsRoot = Pathname.new(RAILS_ROOT) image_file = RailsRoot + 'public' + src # this file must be where the server and browser can see it assert_file(line){ image_file } end Those assertions scan every image in a page and ensure a file with the correct name appears in ./public/images/. (Our artists have recently been sending us new assets, and I didn't feel like manually checking we copied in all the right images...) The :img is a shortcut for the XPathic 'descendent-or-self::img', and the img[:src] is naturally a shortcut for the attribute. Those assertions - assert_xpath, assert_any_xpath, etc - work interchangeably with REXML, Hpricot, or Libxml for their parser. You just pick the one you want by adding to your setup() a call like invoke_rexml, invoke_hpricot, or invoke_libxml. Each provides various trades-off, but at work we have fixated on Libxml, naturally, because we use hundreds of these assertions, so we need its speed. Also, Libxml strictly enforces the Transitional XHTML type that appears in all our DOCTYPEs. (gem install assert_xpath, but I haven't documented the libxml variant yet...) My little trick with the image files is only the start of assert_xpath's abilities. You can also call it from inside an rspec; you just have to include its modules. And, like any of my assertions, it provides a detailed, comprehensive diagnostic if it fails. -- Phlip From court3nay at gmail.com Fri Apr 4 01:03:16 2008 From: court3nay at gmail.com (Courtenay) Date: Thu, 3 Apr 2008 22:03:16 -0700 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> Message-ID: <4b430c8f0804032203r3daecdb7n59179063e5c2610e@mail.gmail.com> On Thu, Apr 3, 2008 at 4:38 AM, Juanma Cervera wrote: > Thanks to all for your answers. > I also have found a plugin with matchers for active record validations, > associations and even useful matchers for views. > > It has a matcher for validates_uniqueness_of that doesn't got to the > database. > The test asserts that you call validates_uniqueness_of, but it doesn't actually test your logic. So it's useful to see if someone accidentally deletes your code, but if you have validates_uniqueness_of :user, :scope => :project_id or something more complex, it won't test this behavior. From steven at stevenrbaker.com Fri Apr 4 01:41:23 2008 From: steven at stevenrbaker.com (Steven Baker) Date: Fri, 4 Apr 2008 01:41:23 -0400 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: <4b430c8f0804032203r3daecdb7n59179063e5c2610e@mail.gmail.com> References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> <4b430c8f0804032203r3daecdb7n59179063e5c2610e@mail.gmail.com> Message-ID: >> > The test asserts that you call validates_uniqueness_of, but it doesn't > actually test your logic. > So it's useful to see if someone accidentally deletes your code, but > if you have > > validates_uniqueness_of :user, :scope => :project_id > > or something more complex, it won't test this behavior. One of the rules that I learned with TDD, that I brought with me to BDD, is that you only specify or test what you write. Everything else is assumed to behave as intended. This rule is, among other things, intended to keep us productive: we can't write a test suite for an entire framework every time we use that framework to implement an application. At some point, we have to trust that the frameworky bits work as intended. I don't exactly assume that the code I'm depending on is well tested, just that it's not my job to specify its behaviour. If you were to write an example that creates two models, and ensures that the duplicate errored appropriately, my "rule" is violated. Each of your examples is then specifying the behaviour of the validates_uniqueness_of method, which you didn't write. Doing this with mocks ensures that you called validates_uniqueness_of, and doesn't test the behaviour of the method which, since you didn't write it, get to assume behaves as expected. This is where my "rule" falls down: mocking the call prevents you from changing the implementation without changing the behaviour. That is to say that you may want to, in the future, roll your own uniqueness validation that is called in a different way than ActiveRecord's, but behaves in the same way. If you mocked, you could change the implementation without changing the behaviour, and still have a failing example. This is where the line is drawn for me: I need to be able to change the implementation, and only have my examples fail when I've changed the behaviour. So, in this case, using mocks and expecting Rails' built-in validation is fragile. But in general, I try to stick to the "rule" (let's say guideline from now on) that I outlined above. -Steven From pergesu at gmail.com Fri Apr 4 02:02:57 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 3 Apr 2008 23:02:57 -0700 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> <4b430c8f0804032203r3daecdb7n59179063e5c2610e@mail.gmail.com> Message-ID: <810a540e0804032302x2a266689n2a23d25685011eb7@mail.gmail.com> On Thu, Apr 3, 2008 at 10:41 PM, Steven Baker wrote: > If you were to write an example that creates two models, and ensures > that the duplicate errored appropriately, my "rule" is violated. Each > of your examples is then specifying the behaviour of the > validates_uniqueness_of method, which you didn't write. I don't really agree with this. The desired behavior is to disallow two records with the same data. v_u_o is simply a quick and easy means to that end. Pat From steven at stevenrbaker.com Fri Apr 4 02:12:47 2008 From: steven at stevenrbaker.com (Steven Baker) Date: Fri, 4 Apr 2008 02:12:47 -0400 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: <810a540e0804032302x2a266689n2a23d25685011eb7@mail.gmail.com> References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> <4b430c8f0804032203r3daecdb7n59179063e5c2610e@mail.gmail.com> <810a540e0804032302x2a266689n2a23d25685011eb7@mail.gmail.com> Message-ID: <18B17D42-B151-4169-86EF-7A7F3597E923@stevenrbaker.com> >> If you were to write an example that creates two models, and ensures >> that the duplicate errored appropriately, my "rule" is violated. >> Each >> of your examples is then specifying the behaviour of the >> validates_uniqueness_of method, which you didn't write. > > I don't really agree with this. The desired behavior is to disallow > two records with the same data. v_u_o is simply a quick and easy > means to that end. Right. As I said (or intended to) that particular example was so simple that it was a grey area. But it did cause me to think about the problem, and I found it interesting. -Steven From rick.denatale at gmail.com Fri Apr 4 07:31:51 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Fri, 4 Apr 2008 07:31:51 -0400 Subject: [rspec-users] spec'ing validates_uniqueness_of :whatever In-Reply-To: <18B17D42-B151-4169-86EF-7A7F3597E923@stevenrbaker.com> References: <0dd0eba5dd691ba9190d0abf31407fd1@ruby-forum.com> <38602246-DB07-4A2C-8FE8-0581DA35FDDE@mattberther.com> <4b430c8f0804032203r3daecdb7n59179063e5c2610e@mail.gmail.com> <810a540e0804032302x2a266689n2a23d25685011eb7@mail.gmail.com> <18B17D42-B151-4169-86EF-7A7F3597E923@stevenrbaker.com> Message-ID: On Fri, Apr 4, 2008 at 2:12 AM, Steven Baker wrote: > >> If you were to write an example that creates two models, and ensures > >> that the duplicate errored appropriately, my "rule" is violated. > >> Each > >> of your examples is then specifying the behaviour of the > >> validates_uniqueness_of method, which you didn't write. > > > > I don't really agree with this. The desired behavior is to disallow > > two records with the same data. v_u_o is simply a quick and easy > > means to that end. > > Right. As I said (or intended to) that particular example was so > simple that it was a grey area. But it did cause me to think about > the problem, and I found it interesting. While I certainly subscribe to the "don't test what you didn't write" philosophy for the most part. I do think that there are gray areas. Quoting Steven from a bit earlier in this thread: > I don't exactly assume that the code I'm depending on is well tested, > just that it's not my job to specify its behavior. One of the gray areas is that despite all good intentions, sometimes the specification of that behavior isn't entirely clear, even if that specification is written down somewhere as specs, or traditional documentation. Problems can creep in when my understanding doesn't exactly match the writer's intent. In these cases, it seems to me that writing a spec which proves that my interpretation of an interface by specifying the results rather than just the presence of the call, just MIGHT be a reasonable thing to do, and might protect against the possibility that the writer's interpretation changes due either to evolution or a 'bug-fix.' -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ From kamal.fariz at gmail.com Fri Apr 4 08:02:32 2008 From: kamal.fariz at gmail.com (Kamal Fariz) Date: Fri, 4 Apr 2008 20:02:32 +0800 Subject: [rspec-users] Command line story runner In-Reply-To: <63FD493A-2D1D-4EE8-B67B-E7209B6773D3@gmail.com> References: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> <63FD493A-2D1D-4EE8-B67B-E7209B6773D3@gmail.com> Message-ID: <0361EA29-6DD7-415A-8671-F5AE89A12432@gmail.com> Hi Kyle, I tried the story runner against a story. Unfortunately, it had problems executing webrat methods like 'visits'. Kindly check out this pastie: http://pastie.org/175204 I tried running it with the normal ruby wrapper and it works fine. Regards, Kamal From dchelimsky at gmail.com Fri Apr 4 09:23:01 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 Apr 2008 09:23:01 -0400 Subject: [rspec-users] Welcome Pat Maddox Message-ID: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> Hi all, I'm pleased to announce that Pat Maddox is joining the RSpec Development Team. As you may already know, Pat has been contributing great patches and participation on the rspec-users and rspec-devel mailing lists for quite some time. He has demonstrated a deep understanding of BDD in general, and specifically as it applies to Rails, which has certainly posed some of the more interesting questions on our mailing lists. We are all excited to have Pat on board and look forward to his continued contribution. Cheers, David From bryansray at gmail.com Fri Apr 4 10:30:55 2008 From: bryansray at gmail.com (Bryan Ray) Date: Fri, 4 Apr 2008 09:30:55 -0500 Subject: [rspec-users] [rspec-devel] Welcome Pat Maddox In-Reply-To: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> Message-ID: <29a0119e0804040730o54af6663m4466a85ad7d3bb0d@mail.gmail.com> Congratulations, man. On Fri, Apr 4, 2008 at 8:23 AM, David Chelimsky wrote: > Hi all, > > I'm pleased to announce that Pat Maddox is joining the RSpec Development > Team. > > As you may already know, Pat has been contributing great patches and > participation on the rspec-users and rspec-devel mailing lists for > quite some time. He has demonstrated a deep understanding of BDD in > general, and specifically as it applies to Rails, which has certainly > posed some of the more interesting questions on our mailing lists. > > We are all excited to have Pat on board and look forward to his > continued contribution. > > Cheers, > David > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -- Bryan Ray http://www.bryanray.net "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080404/823e2219/attachment.html From infernalsirius at gmail.com Fri Apr 4 10:35:50 2008 From: infernalsirius at gmail.com (Patrick Meunier) Date: Fri, 4 Apr 2008 10:35:50 -0400 Subject: [rspec-users] Welcome Pat Maddox In-Reply-To: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> Message-ID: This is a great news! Congratulations Pat. On 4-Apr-08, at 9:23 AM, David Chelimsky wrote: > Hi all, > > I'm pleased to announce that Pat Maddox is joining the RSpec > Development Team. > > As you may already know, Pat has been contributing great patches and > participation on the rspec-users and rspec-devel mailing lists for > quite some time. He has demonstrated a deep understanding of BDD in > general, and specifically as it applies to Rails, which has certainly > posed some of the more interesting questions on our mailing lists. > > We are all excited to have Pat on board and look forward to his > continued contribution. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Fri Apr 4 10:50:54 2008 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 4 Apr 2008 11:50:54 -0300 Subject: [rspec-users] Welcome Pat Maddox In-Reply-To: References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> Message-ID: <71166b3b0804040750j54cec670v8e4b5065df725268@mail.gmail.com> On Fri, Apr 4, 2008 at 11:35 AM, Patrick Meunier wrote: > This is a great news! Congratulations Pat. > +1 on that, The bdd-force within Pat is strong, and is good to see he is joining the good side of the force :-) -- Luis Lavena Multimedia systems - 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 aslak.hellesoy at gmail.com Fri Apr 4 13:26:44 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 4 Apr 2008 19:26:44 +0200 Subject: [rspec-users] Welcome Pat Maddox In-Reply-To: <71166b3b0804040750j54cec670v8e4b5065df725268@mail.gmail.com> References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> <71166b3b0804040750j54cec670v8e4b5065df725268@mail.gmail.com> Message-ID: <8d961d900804041026o273c30b2qc194a26a4981427f@mail.gmail.com> On 4/4/08, Luis Lavena wrote: > On Fri, Apr 4, 2008 at 11:35 AM, Patrick Meunier > wrote: > > This is a great news! Congratulations Pat. > > > > +1 on that, The bdd-force within Pat is strong, and is good to see he > is joining the good side of the force :-) > Pat is a much needed and welcome member to the core team. I expect we'll see a lot of great contribs from him in the time to come. Welcome onboard, Pat! Aslak > -- > Luis Lavena > Multimedia systems > - > 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 pergesu at gmail.com Fri Apr 4 14:34:53 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 4 Apr 2008 11:34:53 -0700 Subject: [rspec-users] Welcome Pat Maddox In-Reply-To: <8d961d900804041026o273c30b2qc194a26a4981427f@mail.gmail.com> References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> <71166b3b0804040750j54cec670v8e4b5065df725268@mail.gmail.com> <8d961d900804041026o273c30b2qc194a26a4981427f@mail.gmail.com> Message-ID: <810a540e0804041134x11df6594m891b48817cdd56a7@mail.gmail.com> On Fri, Apr 4, 2008 at 10:26 AM, aslak hellesoy wrote: > On 4/4/08, Luis Lavena wrote: > > On Fri, Apr 4, 2008 at 11:35 AM, Patrick Meunier > > wrote: > > > This is a great news! Congratulations Pat. > > > > > > > +1 on that, The bdd-force within Pat is strong, and is good to see he > > is joining the good side of the force :-) > > > > Pat is a much needed and welcome member to the core team. I expect > we'll see a lot of great contribs from him in the time to come. > > Welcome onboard, Pat! Thank you for the kind words, everyone. Pat From brian.takita at gmail.com Fri Apr 4 14:42:53 2008 From: brian.takita at gmail.com (Brian Takita) Date: Fri, 4 Apr 2008 11:42:53 -0700 Subject: [rspec-users] Welcome Pat Maddox In-Reply-To: <8d961d900804041026o273c30b2qc194a26a4981427f@mail.gmail.com> References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> <71166b3b0804040750j54cec670v8e4b5065df725268@mail.gmail.com> <8d961d900804041026o273c30b2qc194a26a4981427f@mail.gmail.com> Message-ID: <1d7ddd110804041142s1314d081t37090d98f95d85c2@mail.gmail.com> On Fri, Apr 4, 2008 at 10:26 AM, aslak hellesoy wrote: > On 4/4/08, Luis Lavena wrote: > > On Fri, Apr 4, 2008 at 11:35 AM, Patrick Meunier > > wrote: > > > This is a great news! Congratulations Pat. > > > > > > > +1 on that, The bdd-force within Pat is strong, and is good to see he > > is joining the good side of the force :-) > > > > Pat is a much needed and welcome member to the core team. I expect > we'll see a lot of great contribs from him in the time to come. > > Welcome onboard, Pat! Welcome Pat. > > Aslak > > > -- > > > > Luis Lavena > > Multimedia systems > > - > > 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From omen.king at gmail.com Fri Apr 4 14:52:38 2008 From: omen.king at gmail.com (Andrew WC Brown) Date: Fri, 4 Apr 2008 14:52:38 -0400 Subject: [rspec-users] Welcome Pat Maddox In-Reply-To: <1d7ddd110804041142s1314d081t37090d98f95d85c2@mail.gmail.com> References: <57c63afe0804040623k6fb1fe02v3eca214773424bf4@mail.gmail.com> <71166b3b0804040750j54cec670v8e4b5065df725268@mail.gmail.com> <8d961d900804041026o273c30b2qc194a26a4981427f@mail.gmail.com> <1d7ddd110804041142s1314d081t37090d98f95d85c2@mail.gmail.com> Message-ID: Gooble Goble, Gooble Goble, One of Us! One of Us! On Fri, Apr 4, 2008 at 2:42 PM, Brian Takita wrote: > On Fri, Apr 4, 2008 at 10:26 AM, aslak hellesoy > wrote: > > On 4/4/08, Luis Lavena wrote: > > > On Fri, Apr 4, 2008 at 11:35 AM, Patrick Meunier > > > wrote: > > > > This is a great news! Congratulations Pat. > > > > > > > > > > +1 on that, The bdd-force within Pat is strong, and is good to see he > > > is joining the good side of the force :-) > > > > > > > Pat is a much needed and welcome member to the core team. I expect > > we'll see a lot of great contribs from him in the time to come. > > > > Welcome onboard, Pat! > Welcome Pat. > > > > Aslak > > > > > -- > > > > > > > Luis Lavena > > > Multimedia systems > > > - > > > 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 > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080404/b4474a07/attachment-0001.html From joe at pinkpucker.net Fri Apr 4 18:18:02 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Fri, 4 Apr 2008 15:18:02 -0700 Subject: [rspec-users] webrat bugs Message-ID: Where do I report webrat bugs? Seems that when there's a parenthesis in the link text, doing: session.clicks_link("link with (parens)") fails to find the link text. From joe at pinkpucker.net Fri Apr 4 18:21:53 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Fri, 4 Apr 2008 15:21:53 -0700 Subject: [rspec-users] Command line story runner In-Reply-To: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> References: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> Message-ID: On Thu, Apr 3, 2008 at 7:58 AM, Kyle Hargraves wrote: > Hullo all, > > It sucks to write wrapper .rb files just so stories/all.rb can find > and run them. Here's what my stories/all.rb looks like: require File.dirname(__FILE__) + '/helper' Dir[File.dirname(__FILE__) + '/../steps/*.rb'].each { |f| require f } with_steps_for(:general, :sessions, :blogs, :game_moderation, :user_completed_games, :searching, :puzzles, :user_media) do run_local_story "blog_story" run_local_story "user_completed_games_story" run_local_story "searching_story" run_local_story "puzzle_story" run_local_story "picathon_uploads_story" #run_local_story "game_moderation_story" end Last one is commented out, since I just added a bunch of ajaxy stuff to the pages and haven't converted the stories over to ajax yet (if that's possible). Each one of the steps corresponds to a controller step file that's in /steps. Works pretty well, not much of a hassle running stories. This is for http://tanga.com. Joe From timcharper at gmail.com Fri Apr 4 18:48:53 2008 From: timcharper at gmail.com (Tim Harper) Date: Fri, 4 Apr 2008 16:48:53 -0600 Subject: [rspec-users] changes to RSpec Bundle Message-ID: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> Hi, I forked the rspec bundle on github and added a new command to it (an Update RSpec Bundle command). I sent a pull request, but haven't heard back from anyone on it. David, did you get my pull request? Or did it get lost in the black whole of cyberspace? (if you were too busy to respond, that's fine, just wanted to follow up) Thanks, Tim From joe at pinkpucker.net Fri Apr 4 19:10:59 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Fri, 4 Apr 2008 16:10:59 -0700 Subject: [rspec-users] Attachment-fu + Story Runner In-Reply-To: <57c63afe0803210546q314323b4g63d5029a71d64291@mail.gmail.com> References: <14291797.post@talk.nabble.com> <57c63afe0712120554j147ffbe6lcff9faf8d5af743f@mail.gmail.com> <57c63afe0803210546q314323b4g63d5029a71d64291@mail.gmail.com> Message-ID: On Fri, Mar 21, 2008 at 5:46 AM, David Chelimsky wrote: > > On Fri, Mar 21, 2008 at 1:35 AM, Joe Van Dyk wrote: > > On Thu, Mar 20, 2008 at 3:34 AM, Rick DeNatale wrote: > > > On 3/20/08, Joe Van Dyk wrote: > > > > What was the resolution on this? How do you people test uploads with > > > > rspec stories? > > > > > > I submitted a Rails patch to address the underlying problem > > > http://dev.rubyonrails.org/ticket/11091 > > > > > > It got in as changeset 8978 and should be in edge rails. > > > > Would it be worth it to monkeypatch that patch into rspec? > > Why would we do that? It's already in edge rails. Because I can't upgrade to edge rails. And I want to be able to test file uploads. I've applied the 8978 changeset to my stable rails -- but I'm still unsure of how to test file uploads in the context of a rspec story. Normally, I'd use fixture_file_upload, but that method doesn't seem to be available in rspec. Do I need to do anything special? Is anyone testing file uploads with rspec stories? From ben at benmabey.com Fri Apr 4 19:21:39 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 04 Apr 2008 17:21:39 -0600 Subject: [rspec-users] webrat bugs In-Reply-To: References: Message-ID: <47F6B803.1090009@benmabey.com> Joe Van Dyk wrote: > Where do I report webrat bugs? > > Seems that when there's a parenthesis in the link text, doing: > > session.clicks_link("link with (parens)") > > fails to find the link text. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey, Brian relasesed webrat: http://www.brynary.com/2007/12/8/webrat-0-1-0-released But AFAIK there is no project page for it.... I would suggest this: Fix the issue and send him the patch. OR Clone it on github: http://github.com/brynary/webrat/tree/master fork the repo, fix it, and make a pull request on github Chances are the problem will get fixed a lot sooner that way. :) -Ben From joe at pinkpucker.net Fri Apr 4 19:33:58 2008 From: joe at pinkpucker.net (Joe Van Dyk) Date: Fri, 4 Apr 2008 16:33:58 -0700 Subject: [rspec-users] Attachment-fu + Story Runner In-Reply-To: References: <14291797.post@talk.nabble.com> <57c63afe0712120554j147ffbe6lcff9faf8d5af743f@mail.gmail.com> <57c63afe0803210546q314323b4g63d5029a71d64291@mail.gmail.com> Message-ID: On Fri, Apr 4, 2008 at 4:10 PM, Joe Van Dyk wrote: > On Fri, Mar 21, 2008 at 5:46 AM, David Chelimsky wrote: > > > > On Fri, Mar 21, 2008 at 1:35 AM, Joe Van Dyk wrote: > > > On Thu, Mar 20, 2008 at 3:34 AM, Rick DeNatale wrote: > > > > On 3/20/08, Joe Van Dyk wrote: > > > > > What was the resolution on this? How do you people test uploads with > > > > > rspec stories? > > > > > > > > I submitted a Rails patch to address the underlying problem > > > > http://dev.rubyonrails.org/ticket/11091 > > > > > > > > It got in as changeset 8978 and should be in edge rails. > > > > > > Would it be worth it to monkeypatch that patch into rspec? > > > > Why would we do that? It's already in edge rails. > > Because I can't upgrade to edge rails. And I want to be able to test > file uploads. > > I've applied the 8978 changeset to my stable rails -- but I'm still > unsure of how to test file uploads in the context of a rspec story. > Normally, I'd use fixture_file_upload, but that method doesn't seem to > be available in rspec. Do I need to do anything special? > > Is anyone testing file uploads with rspec stories? Think I got it working, here's an example step: When("$username uploads a picathon image") do |username| params = { :media => ActionController::TestUploadedFile.new(RAILS_ROOT + '/test/fixtures/files/image.jpg') } @sessions[username].post user_uploads_path(@users[username]), params @sessions[username].visits user_uploads_path(@users[username]) end From pergesu at gmail.com Fri Apr 4 19:48:08 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 4 Apr 2008 16:48:08 -0700 Subject: [rspec-users] changes to RSpec Bundle In-Reply-To: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> References: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> Message-ID: <810a540e0804041648w8b578aesa0f0a9aea3724aa9@mail.gmail.com> On Fri, Apr 4, 2008 at 3:48 PM, Tim Harper wrote: > Hi, > > I forked the rspec bundle on github and added a new command to it (an > Update RSpec Bundle command). I sent a pull request, but haven't > heard back from anyone on it. > > David, did you get my pull request? Or did it get lost in the black > whole of cyberspace? (if you were too busy to respond, that's fine, > just wanted to follow up) > > Thanks, > Tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I think the preferred method is to file a ticket on lighthouse with a link to the relevant commit. Pat From ben at benmabey.com Fri Apr 4 19:54:40 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 04 Apr 2008 17:54:40 -0600 Subject: [rspec-users] changes to RSpec Bundle In-Reply-To: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> References: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> Message-ID: <47F6BFC0.6090405@benmabey.com> Tim Harper wrote: > Hi, > > I forked the rspec bundle on github and added a new command to it (an > Update RSpec Bundle command). I sent a pull request, but haven't > heard back from anyone on it. > > David, did you get my pull request? Or did it get lost in the black > whole of cyberspace? (if you were too busy to respond, that's fine, > just wanted to follow up) > > Thanks, > Tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey Tim, I just asked about the use of pull request vs patches on the dev list. According to David things should still be added to the project tracker: http://rspec.lighthouseapp.com/ So you can either upload a patch there or just give the commit link on github he could pull from. Either way they want to keep track of this stuff on lighthouse I think. Also, there was some talk of moving the bundle in a separate bundle and using git modules... I don't think that has happened yet though... -Ben From pergesu at gmail.com Fri Apr 4 20:05:53 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 4 Apr 2008 17:05:53 -0700 Subject: [rspec-users] changes to RSpec Bundle In-Reply-To: <47F6BFC0.6090405@benmabey.com> References: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> <47F6BFC0.6090405@benmabey.com> Message-ID: <810a540e0804041705j7c834dcbh2323b31657716687@mail.gmail.com> On Fri, Apr 4, 2008 at 4:54 PM, Ben Mabey wrote: > > Tim Harper wrote: > > Hi, > > > > I forked the rspec bundle on github and added a new command to it (an > > Update RSpec Bundle command). I sent a pull request, but haven't > > heard back from anyone on it. > > > > David, did you get my pull request? Or did it get lost in the black > > whole of cyberspace? (if you were too busy to respond, that's fine, > > just wanted to follow up) > > > > Thanks, > > Tim > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > Hey Tim, > I just asked about the use of pull request vs patches on the dev list. > According to David things should still be added to the project tracker: > http://rspec.lighthouseapp.com/ > > So you can either upload a patch there or just give the commit link on > github he could pull from. Either way they want to keep track of this > stuff on lighthouse I think. Ideal way is to give a commit link. > Also, there was some talk of moving the bundle in a separate bundle and > using git modules... I don't think that has happened yet though... David actually made all these changes last night. If you go to http://github.com/dchelimsky you can see all the repositories. To get the latest and greatest version of the code, do git clone git://github.com/dchelimsky/rspec-dev.git cd rspec-dev git submodule init git submodule update And you're all set. So Tim, you should check out the latest code (or perhaps just the TM bundle, if you want), create your patch, and then submit a ticket on lighthouse with a link to the commit. Pat From philodespotos at gmail.com Fri Apr 4 21:19:20 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Fri, 4 Apr 2008 20:19:20 -0500 Subject: [rspec-users] Command line story runner In-Reply-To: References: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> Message-ID: <60f3810c0804041819v47293792qf4c0935f736f6ae7@mail.gmail.com> On Fri, Apr 4, 2008 at 5:21 PM, Joe Van Dyk wrote: > On Thu, Apr 3, 2008 at 7:58 AM, Kyle Hargraves wrote: > > Hullo all, > > > > It sucks to write wrapper .rb files just so stories/all.rb can find > > and run them. > > Here's what my stories/all.rb looks like: > > require File.dirname(__FILE__) + '/helper' > Dir[File.dirname(__FILE__) + '/../steps/*.rb'].each { |f| require f } > > with_steps_for(:general, :sessions, :blogs, :game_moderation, > :user_completed_games, :searching, :puzzles, :user_media) do > run_local_story "blog_story" > run_local_story "user_completed_games_story" > run_local_story "searching_story" > run_local_story "puzzle_story" > run_local_story "picathon_uploads_story" > #run_local_story "game_moderation_story" > end > > Last one is commented out, since I just added a bunch of ajaxy stuff > to the pages and haven't converted the stories over to ajax yet (if > that's possible). > > Each one of the steps corresponds to a controller step file that's in > /steps. Works pretty well, not much of a hassle running stories. > This is for http://tanga.com. > > Joe This works for a while, and it's what I started with. But it didn't scale in my experience. Firstly, I started using the same wording for steps, but they had different meanings by context; you can no longer just include everything, or you can end up running the wrong step. Moreover, one of my current suites has about 180 scenarios, which takes a minute and a half or so to run all the way through. When I'm working on a single feature, I don't want to run 90% of the scenarios, just one or two of the stories surrounding that feature. all.rb makes that impossible, AFAIK. So you start writing individual .rb files you can run separately, which all.rb just sources. I ended up spending a lot of time managing the infrastructure instead of getting work done. brynary's script/story relieved that headache for me. BTW, what is run_local_story? k From philodespotos at gmail.com Fri Apr 4 21:22:52 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Fri, 4 Apr 2008 20:22:52 -0500 Subject: [rspec-users] Command line story runner In-Reply-To: <0361EA29-6DD7-415A-8671-F5AE89A12432@gmail.com> References: <60f3810c0804030758s654af605q4cf06714a556fcf9@mail.gmail.com> <63FD493A-2D1D-4EE8-B67B-E7209B6773D3@gmail.com> <0361EA29-6DD7-415A-8671-F5AE89A12432@gmail.com> Message-ID: <60f3810c0804041822q4a9ba1acu52a4371c6253d051@mail.gmail.com> On Fri, Apr 4, 2008 at 7:02 AM, Kamal Fariz wrote: > Hi Kyle, > > I tried the story runner against a story. Unfortunately, it had > problems executing webrat methods like 'visits'. > > Kindly check out this pastie: http://pastie.org/175204 > > I tried running it with the normal ruby wrapper and it works fine. Eh, dunno. Did you use --rails? That's the same as my helper.rb, except I don't require webrat (it's a plugin, so it's loaded automatically by rails). Ding me in #rspec at freenode if --rails fixes it, or doesn't for that matter. My nick is pd. kyle From timcharper at gmail.com Fri Apr 4 22:58:43 2008 From: timcharper at gmail.com (Tim Harper) Date: Fri, 4 Apr 2008 20:58:43 -0600 Subject: [rspec-users] changes to RSpec Bundle In-Reply-To: <810a540e0804041705j7c834dcbh2323b31657716687@mail.gmail.com> References: <19527F20-C4E2-4B9D-888E-2CC8980F26B2@gmail.com> <47F6BFC0.6090405@benmabey.com> <810a540e0804041705j7c834dcbh2323b31657716687@mail.gmail.com> Message-ID: Created: http://rspec.lighthouseapp.com/projects/5645/tickets/365-feature-rspec-bundle-update-rspec-bundle Thanks everyone! Tim On Fri, Apr 4, 2008 at 6:05 PM, Pat Maddox wrote: > On Fri, Apr 4, 2008 at 4:54 PM, Ben Mabey wrote: > > > > Tim Harper wrote: > > > Hi, > > > > > > I forked the rspec bundle on github and added a new command to it (an > > > Update RSpec Bundle command). I sent a pull request, but haven't > > > heard back from anyone on it. > > > > > > David, did you get my pull request? Or did it get lost in the black > > > whole of cyberspace? (if you were too busy to respond, that's fine, > > > just wanted to follow up) > > > > > > Thanks, > > > Tim > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > Hey Tim, > > I just asked about the use of pull request vs patches on the dev list. > > According to David things should still be added to the project tracker: > > http://rspec.lighthouseapp.com/ > > > > So you can either upload a patch there or just give the commit link on > > github he could pull from. Either way they want to keep track of this > > stuff on lighthouse I think. > > Ideal way is to give a commit link. > > > > > Also, there was some talk of moving the bundle in a separate bundle and > > using git modules... I don't think that has happened yet though... > > David actually made all these changes last night. If you go to > http://github.com/dchelimsky you can see all the repositories. > > To get the latest and greatest version of the code, do > git clone git://github.com/dchelimsky/rspec-dev.git > cd rspec-dev > git submodule init > git submodule update > > And you're all set. > > So Tim, you should check out the latest code (or perhaps just the TM > bundle, if you want), create your patch, and then submit a ticket on > lighthouse with a link to the commit. > > Pat > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From will.sargent at gmail.com Fri Apr 4 23:45:33 2008 From: will.sargent at gmail.com (Will Sargent) Date: Fri, 4 Apr 2008 20:45:33 -0700 Subject: [rspec-users] laziness plugin Message-ID: Just for general entertainment, apparently you can get Rails to write your unit tests now: "Laziness isn't just helpful in development mode, though - it also comes into play in production. If you've installed the exception_notification plugin (and you really should have - if not, go ahead; I'll wait), then laziness will add its generated test to the email you receive whenever your production app throws an unexpected exception." http://www.culann.com/2008/03/and-the-greatest-of-these-is-laziness Looks interesting, although it doesn't seem to handle rspec. Will. From peter.fitzgibbons at gmail.com Sat Apr 5 00:28:00 2008 From: peter.fitzgibbons at gmail.com (Peter Fitzgibbons) Date: Fri, 4 Apr 2008 23:28:00 -0500 Subject: [rspec-users] Newbie : how to require to lib from spec under autotest? Message-ID: <670a00380804042128r77bcf723v2f9546f6d2399ec8@mail.gmail.com> Hello all, I have the RSpec sample in ./rspec_bowling, with... ./rspec_bowling/lib/bowling.rb ./rspec_bowling/spec/spec.opts ./rspec_bowling/spec/bowling_spec.rb when I autotest, I get this: $autotest loading autotest/rspec /usr/local/bin/ruby -S /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.3/bin/spec -O spec/spec.opts spec/spec_helper.rb spec/bowling_spec.rb F 1) ArgumentError in 'Bowling should score 0 for gutter game' wrong number of arguments (1 for 0) [..snip..] Finished in 0.254 seconds 1 example, 1 failure /usr/local/bin/ruby -S /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.3/bin/spec -O spec/spec.opts spec/bowling_spec.rb *./spec/bowling_spec.rb:3:in `require': no such file to load -- bowling (LoadError) * from ./spec/bowling_spec.rb:3 My RUBYPATH = ../lib:./lib:$PATH, which caused autotest to load the 1st run correctly. Could someone help me understand how to correctly set the search path for repeated loading under autotest ? Thanks! -- Peter Fitzgibbons ------------------------------ iPhone -- "IT"-ness. href= http://www.macdailynews.com/index.php/weblog/comments/apples_iphone_could_become_iconic_it_object ------------------------------ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080404/bdcff836/attachment.html From dchelimsky at gmail.com Sat Apr 5 00:38:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Apr 2008 00:38:23 -0400 Subject: [rspec-users] Newbie : how to require to lib from spec under autotest? In-Reply-To: <670a00380804042128r77bcf723v2f9546f6d2399ec8@mail.gmail.com> References: <670a00380804042128r77bcf723v2f9546f6d2399ec8@mail.gmail.com> Message-ID: <1BBF8573-C053-47A0-82E5-4376085D58C5@gmail.com> On Apr 5, 2008, at 12:28 AM, "Peter Fitzgibbons" wrote: > Hello all, > > I have the RSpec sample in ./rspec_bowling, with... > ./rspec_bowling/lib/bowling.rb > ./rspec_bowling/spec/spec.opts > ./rspec_bowling/spec/bowling_spec.rb > > when I autotest, I get this: > $autotest > loading autotest/rspec > /usr/local/bin/ruby -S /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.3/ > bin/spec -O spec/spec.opts spec/spec_helper.rb spec/bowling_spec.rb > F > > 1) > ArgumentError in 'Bowling should score 0 for gutter game' > wrong number of arguments (1 for 0) > [..snip..] This is the error - no path problem. There is a method expecting no arguments that is being called with one. HTH, David > > Finished in 0.254 seconds > > 1 example, 1 failure > /usr/local/bin/ruby -S /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.3/ > bin/spec -O spec/spec.opts spec/bowling_spec.rb > ./spec/bowling_spec.rb:3:in `require': no such file to load -- > bowling (LoadError) > from ./spec/bowling_spec.rb:3 > > My RUBYPATH = ../lib:./lib:$PATH, which caused autotest to load the > 1st run correctly. > > Could someone help me understand how to correctly set the search > path for repeated loading under autotest ? > > Thanks! > > > -- > Peter Fitzgibbons > ------------------------------ > iPhone -- "IT"-ness. > href=http://www.macdailynews.com/index.php/weblog/comments/apples_iphone_could_become_iconic_it_object > ------------------------------ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080405/893beee1/attachment.html From cwdinfo at gmail.com Sat Apr 5 00:46:58 2008 From: cwdinfo at gmail.com (s.ross) Date: Fri, 4 Apr 2008 21:46:58 -0700 Subject: [rspec-users] laziness plugin In-Reply-To: References: Message-ID: On Apr 4, 2008, at 8:45 PM, Will Sargent wrote: > Just for general entertainment, apparently you can get Rails to write > your unit tests now: > > "Laziness isn't just helpful in development mode, though - it also > comes into play in production. If you've installed the > exception_notification plugin (and you really should have - if not, go > ahead; I'll wait), then laziness will add its generated test to the > email you receive whenever your production app throws an unexpected > exception." > > http://www.culann.com/2008/03/and-the-greatest-of-these-is-laziness > > Looks interesting, although it doesn't seem to handle rspec. > > Will. This looks pretty slick. Just browsing the source on github, it looks like the code checks for RAILS_ROOT/spec/spec_helper.rb and uses that to decide whether to emit rSpec or Test::Unit tests. From mailing_lists at railsnewbie.com Sat Apr 5 01:00:57 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 5 Apr 2008 01:00:57 -0400 Subject: [rspec-users] webrat bugs In-Reply-To: References: Message-ID: <095E5A13-D6CF-4BDD-BFCF-41AC6B3C5DAE@railsnewbie.com> On Apr 4, 2008, at 6:18 PM, Joe Van Dyk wrote: > Where do I report webrat bugs? > > Seems that when there's a parenthesis in the link text, doing: > > session.clicks_link("link with (parens)") > > fails to find the link text. I believe (with my limited experience with webrat) that this is occurring because it expects a regex. I bet if you escaped the parents "\(parens\)" it would start to work. Scott From mailing_lists at railsnewbie.com Sat Apr 5 01:03:41 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Sat, 5 Apr 2008 01:03:41 -0400 Subject: [rspec-users] Newbie : how to require to lib from spec under autotest? In-Reply-To: <1BBF8573-C053-47A0-82E5-4376085D58C5@gmail.co