From lists at ruby-forum.com Wed Apr 1 02:50:23 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Wed, 1 Apr 2009 08:50:23 +0200 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> Message-ID: > http://peepcode.com/products/rspec-basics > http://peepcode.com/products/rspec-mocks-and-models > http://peepcode.com/products/rspec-controllers-and-tools > I didn't like at all the peepcode episodes on RSpec. You'll have to rewrite his valid_attributes trick from scratch if your models use attr_accessible, and some other stuff. The part about mocking is hard to grasp (although mocking is just such an easy concept). He uses fixtures, and tests for too many things in the views. I don't spec at all the way he shows, I might be doing things wrong, but I am very happy with my workflow. -- Posted via http://www.ruby-forum.com/. From pablolmiranda at gmail.com Wed Apr 1 08:03:12 2009 From: pablolmiranda at gmail.com (Pablo L. de Miranda) Date: Wed, 1 Apr 2009 09:03:12 -0300 Subject: [rspec-users] Good introduction to rspec In-Reply-To: References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> Message-ID: <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> @Fernando - So what material you recommend to start a study in rSpec? Att, Pablo Lacerda de Miranda pablolmiranda at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dipen at complitech.net Wed Apr 1 08:55:38 2009 From: dipen at complitech.net (Dipen Bhanushali) Date: Wed, 1 Apr 2009 18:25:38 +0530 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> Message-ID: Hi All, I think New user for rspec once need to see the peepcode videos. It is very helpful for the starter to understand how the rspec is working. Other wise the http://rspec.info documentation is providing the good information for any rails developer to use and test it in the application. Thanks, Dipen Bhanushali Complitech Solutions Private Limited (http://complitech.net) 2009/4/1 Pablo L. de Miranda > @Fernando - So what material you recommend to start a study in rSpec? > > Att, > > Pablo Lacerda de Miranda > pablolmiranda at gmail.com > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aidy.lewis at googlemail.com Wed Apr 1 09:01:19 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 1 Apr 2009 14:01:19 +0100 Subject: [rspec-users] RSpec makes me want to write better code In-Reply-To: <57c63afe0903311059y29feb0f6p807edb1e0d4d0fb9@mail.gmail.com> References: <25ae8c0f5f9b09f50538e8be2539f1f0@ruby-forum.com> <537533f3441d1651cb688abe73790685@ruby-forum.com> <57c63afe0903311059y29feb0f6p807edb1e0d4d0fb9@mail.gmail.com> Message-ID: <7ac2300c0904010601x71f62ebn5246481575ad85c9@mail.gmail.com> Hi David 2009/3/31 David Chelimsky : > The point of TDD is writing small examples and small bits of code in a > cycle. The point of BDD is to write high level scenarios so you know > what code to write, but then drive it out in detail with TDD. Does this necessitate that the same person or pair should be doing both the TDD and BDD for the same area? My problem at the moment is that as a software tester I would in combination with a customer create the feature Acceptance Criteria (AC). The AC would be used by the developer to guide his\her design, but he\she would be unlikely to implement the automated test, which would normally be done by the tester (using Watir\Cucumber). My feeling is that if we are to get the optimal benefit from TDD\BDD then the developer(s) should be automating the AC. What do you think? I don't think this removes the need of the tester as he/she may be more likely to have a skill-set that is aware of bigger-than-unit-test-tools and frameworks, but I think they should be pairing with the developer. However the problem then arises if the developer and tester use different languages. I use Ruby while the production code is in .Net. The TDD interplay would be more seamless I think with a single language. But as a tester it would be insane for me to use a static and compiled language to - in effect - test a web site. Aidy From dchelimsky at gmail.com Wed Apr 1 09:35:01 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 1 Apr 2009 08:35:01 -0500 Subject: [rspec-users] RSpec makes me want to write better code In-Reply-To: <7ac2300c0904010601x71f62ebn5246481575ad85c9@mail.gmail.com> References: <25ae8c0f5f9b09f50538e8be2539f1f0@ruby-forum.com> <537533f3441d1651cb688abe73790685@ruby-forum.com> <57c63afe0903311059y29feb0f6p807edb1e0d4d0fb9@mail.gmail.com> <7ac2300c0904010601x71f62ebn5246481575ad85c9@mail.gmail.com> Message-ID: <57c63afe0904010635x652e30e3k939e2d0fa21c25fd@mail.gmail.com> On Wed, Apr 1, 2009 at 8:01 AM, aidy lewis wrote: > Hi David > > 2009/3/31 David Chelimsky : > >> The point of TDD is writing small examples and small bits of code in a >> cycle. The point of BDD is to write high level scenarios so you know >> what code to write, but then drive it out in detail with TDD. > > Does this necessitate that the same person or pair should be doing > both the TDD and BDD for the same area? My problem at the moment is > that as a software tester I would in combination with a customer > create the feature Acceptance Criteria (AC). The AC would be used by > the developer to guide his\her design, but he\she would be unlikely to > implement the automated test, which would normally be done by the > tester (using Watir\Cucumber). My feeling is that if we are to get the > optimal benefit from TDD\BDD then the developer(s) should be > automating the AC. What do you think? Given that I don't know the skill-set available on your team, it's difficult for me to say what would provide optimum benefit for *your team*. That said, in some idealistic BDD fashion, I'd think the best deal would be the tester and developer pairing on automating AC. Then that developer would pair with another developer driving out the code w/ TDD. > I don't think this removes the need of the tester as he/she may be > more likely to have a skill-set that is aware of > bigger-than-unit-test-tools and frameworks, but I think they should be > pairing with the developer. I honestly wrote the above before I read this :) Yes, I agree, tester and developer pairing is *generally* a good thing. > However the problem then arises if the > developer and tester use different languages. I use Ruby while the > production code is in .Net. The TDD interplay would be more seamless I > think with a single language. But as a tester it would be insane for > me to use a static and compiled language to - in effect - test a web > site. I'm going to go out on a limb here and suggest that if you're proficient in Ruby and you're pairing with a reasonably skilled developer in any C-based language like C Sharp, the language barrier will be fairly small. There are some hoops, like meta-programming, blocks and iterators, but not too many beyond that. I don't mean that to be flippant. Even if the dev has zero experience with these concepts, he really doesn't need to understand them in order to progress if you're pairing. HTH, David > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Wed Apr 1 09:57:42 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 1 Apr 2009 06:57:42 -0700 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> Message-ID: <1fb4df0904010657x4dc54347j652e6e051e3d1217@mail.gmail.com> 2009/4/1 Pablo L. de Miranda : > @Fernando - So what material you recommend to start a study in rSpec? 1.) The Web site documentation at http://rspec.info 2.) Use it and build experience. 3.) Get the beta of the RSpec book. 4.) Use it and build experience. 5.) Google is your friend. 6.) Use it and build experience. Finally, if in doubt... Try using it and building some experience. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Wed Apr 1 10:23:32 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 1 Apr 2009 07:23:32 -0700 Subject: [rspec-users] Good introduction to rspec In-Reply-To: References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> Message-ID: <1fb4df0904010723g15ec4ebav5c8ab3478a0ab96d@mail.gmail.com> On Tue, Mar 31, 2009 at 11:50 PM, Fernando Perez wrote: > > I don't spec at all the way he shows, I might be doing things wrong, but > I am very happy with my workflow. http://www.kipling.org.uk/poems_neolithic.htm (The poem's by Rudyard Kipling, if the URL doesn't make it clear.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From slabounty at gmail.com Wed Apr 1 10:53:03 2009 From: slabounty at gmail.com (Scott LaBounty) Date: Wed, 1 Apr 2009 07:53:03 -0700 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <1fb4df0904010657x4dc54347j652e6e051e3d1217@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> <1fb4df0904010657x4dc54347j652e6e051e3d1217@mail.gmail.com> Message-ID: <7de47a040904010753t231a0f50u201ebdf7e19d6f47@mail.gmail.com> I've looked at the web site and I guess I'm looking for more examples. I'd like to see some simple basic ruby code and then some rSpec code testing it. No Rails, no nothing else. I haven't tried the book yet, but there does not seem to be a lot of code out there at this basic a level. Any ideas? Scott On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: > 2009/4/1 Pablo L. de Miranda : > > @Fernando - So what material you recommend to start a study in rSpec? > > 1.) The Web site documentation at http://rspec.info > > 2.) Use it and build experience. > > 3.) Get the beta of the RSpec book. > > 4.) Use it and build experience. > > 5.) Google is your friend. > > 6.) Use it and build experience. > > Finally, if in doubt... Try using it and building some experience. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Scott http://steamcode.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Apr 1 11:44:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 1 Apr 2009 10:44:02 -0500 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <7de47a040904010753t231a0f50u201ebdf7e19d6f47@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> <1fb4df0904010657x4dc54347j652e6e051e3d1217@mail.gmail.com> <7de47a040904010753t231a0f50u201ebdf7e19d6f47@mail.gmail.com> Message-ID: <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5@mail.gmail.com> 2009/4/1 Scott LaBounty : > I've looked at the web site and I guess I'm looking for more examples. I'd > like to see some simple basic ruby code and then some rSpec code testing it. > No Rails, no nothing else. I haven't tried the book yet, but there does not > seem to be a lot of code out there at this basic a level. > > Any ideas? Try this: http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i Cheers, David > > Scott > > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >> >> 2009/4/1 Pablo L. de Miranda : >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> 1.) The Web site documentation at http://rspec.info >> >> 2.) Use it and build experience. >> >> 3.) Get the beta of the RSpec book. >> >> 4.) Use it and build experience. >> >> 5.) Google is your friend. >> >> 6.) Use it and build experience. >> >> Finally, if in doubt... ?Try using it and building some experience. >> >> >> -- >> Have Fun, >> ? Steve Eley (sfeley at gmail.com) >> ? ESCAPE POD - The Science Fiction Podcast Magazine >> ? http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Scott > http://steamcode.blogspot.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From slabounty at gmail.com Wed Apr 1 11:47:33 2009 From: slabounty at gmail.com (Scott LaBounty) Date: Wed, 1 Apr 2009 08:47:33 -0700 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> <1fb4df0904010657x4dc54347j652e6e051e3d1217@mail.gmail.com> <7de47a040904010753t231a0f50u201ebdf7e19d6f47@mail.gmail.com> <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5@mail.gmail.com> Message-ID: <7de47a040904010847s64a648c9r9fa5a469e3b7110e@mail.gmail.com> David, That's more what I was looking for. Thanks, Scott On Wed, Apr 1, 2009 at 8:44 AM, David Chelimsky wrote: > 2009/4/1 Scott LaBounty : > > I've looked at the web site and I guess I'm looking for more examples. > I'd > > like to see some simple basic ruby code and then some rSpec code testing > it. > > No Rails, no nothing else. I haven't tried the book yet, but there does > not > > seem to be a lot of code out there at this basic a level. > > > > Any ideas? > > Try this: > > http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i > > Cheers, > David > > > > > > > Scott > > > > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: > >> > >> 2009/4/1 Pablo L. de Miranda : > >> > @Fernando - So what material you recommend to start a study in rSpec? > >> > >> 1.) The Web site documentation at http://rspec.info > >> > >> 2.) Use it and build experience. > >> > >> 3.) Get the beta of the RSpec book. > >> > >> 4.) Use it and build experience. > >> > >> 5.) Google is your friend. > >> > >> 6.) Use it and build experience. > >> > >> Finally, if in doubt... Try using it and building some experience. > >> > >> > >> -- > >> Have Fun, > >> Steve Eley (sfeley at gmail.com) > >> ESCAPE POD - The Science Fiction Podcast Magazine > >> http://www.escapepod.org > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > > Scott > > http://steamcode.blogspot.com/ > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Scott http://steamcode.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Apr 1 11:50:37 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 1 Apr 2009 17:50:37 +0200 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> Message-ID: <3aa7f36197e80e5ac2525cb38e252958@ruby-forum.com> Pablo L. de Miranda wrote: > @Fernando - So what material you recommend to start a study in rSpec? > This might be heresy, but I suggest that you start with Cucumber and simply use RSpec matcher syntax in your step definitions. Once you have the hang of how to express expectations in the step definitions, then move on to using RSpec on its own; providing that you still want to. I really did not get the hang of any of this, TDD, BDD, Rails or Ruby until I latched on to Cucumber and started -- very, very poorly mind you -- to discover how to express behaviour and, more importantly, what behaviour to express. It was, for me, a tumultuous journey and one that I am still traveling. I am now at the point where, simply by expressing one little bit of desired bwhaviour in a cucumber scenario, I uncovered a requirement to leave Rails for a bit and implement a set of SQL triggers. This would have been discovered at some point anyway, but I rather suspect that without BDD the implementation would have been written first in Ruby for ActiveRecord only to be discarded sometime later when the need for a trigger became manifest. Peepcode is good, I have watched and learned lots there. Just recall that the episodes go far back in time insofar as Rails and RSpec are concerned. These two products have undergone extensive change since many of the episodes were recorded. -- Posted via http://www.ruby-forum.com/. From aidy.lewis at googlemail.com Wed Apr 1 12:06:45 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 1 Apr 2009 17:06:45 +0100 Subject: [rspec-users] ticket 44 Message-ID: <7ac2300c0904010906s8c72be4vb1486b7bb53c0d0@mail.gmail.com> Hi, Ticket 44 is resolved, I am using 0.2.3 and attempting to throw the html upon a failure Before do |scenario| @sc = scenario end After do puts @sc.methods.sort throw $browser.html @sc.failed? end Have these getters not been released or is my implementation flawed? Thanks Aidy From aidy.lewis at googlemail.com Wed Apr 1 12:24:21 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 1 Apr 2009 17:24:21 +0100 Subject: [rspec-users] RSpec makes me want to write better code In-Reply-To: <57c63afe0904010635x652e30e3k939e2d0fa21c25fd@mail.gmail.com> References: <25ae8c0f5f9b09f50538e8be2539f1f0@ruby-forum.com> <537533f3441d1651cb688abe73790685@ruby-forum.com> <57c63afe0903311059y29feb0f6p807edb1e0d4d0fb9@mail.gmail.com> <7ac2300c0904010601x71f62ebn5246481575ad85c9@mail.gmail.com> <57c63afe0904010635x652e30e3k939e2d0fa21c25fd@mail.gmail.com> Message-ID: <7ac2300c0904010924o65996d8co404aef578831bfc1@mail.gmail.com> Hi David 2009/4/1 David Chelimsky : >. That said, in some idealistic BDD fashion, I'd think the best > deal would be the tester and developer pairing on automating AC. Then > that developer would pair with another developer driving out the code > w/ TDD. If we have two different sets of people implementing the AC and driving code with TDD then does this not prevent the TDD\BDD interplay? Development is in small steps, so if we create a mock for the first AC step see it fail then move down into TDD to make that pass, refactor then move up (red => green => refactor) again - then this - to me -, has surely got to be done by the same set off people. I think the user step mocks are likely to be re-factored out when we have some tangible output (e.g a GUI) > I'm going to go out on a limb here and suggest that if you're > proficient in Ruby and you're pairing with a reasonably skilled > developer in any C-based language like C Sharp, the language barrier > will be fairly small. There are some hoops, like meta-programming, > blocks and iterators, but not too many beyond that. I don't mean that > to be flippant. Even if the dev has zero experience with these > concepts, he really doesn't need to understand them in order to > progress if you're pairing. > When you go to Harversters they ask 'have you been here before?'. Maybe not, but I can eat with a knife and fork. However, - I will put myself on a limb - some programmers have been conditioned by MS on the practices and uses of tools. No intellisense, no visual debugger, no static assignment or compilation, a command line!*@? Many are just not happy with it. Aidy From charleno at gmail.com Wed Apr 1 12:29:15 2009 From: charleno at gmail.com (Charleno Pires) Date: Wed, 1 Apr 2009 13:29:15 -0300 Subject: [rspec-users] rspec-users Digest, Vol 34, Issue 2 In-Reply-To: References: Message-ID: <3f5ee3410904010929v7ba7dc73sa152408afa98b341@mail.gmail.com> 2009/4/1, rspec-users-request at rubyforge.org : > Send rspec-users mailing list submissions to > rspec-users at rubyforge.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://rubyforge.org/mailman/listinfo/rspec-users > or, via email, send a message with subject or body 'help' to > rspec-users-request at rubyforge.org > > You can reach the person managing the list at > rspec-users-owner at rubyforge.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of rspec-users digest..." > > > Today's Topics: > > 1. Re: RSpec makes me want to write better code (aidy lewis) > 2. Re: RSpec makes me want to write better code (David Chelimsky) > 3. Re: Good introduction to rspec (Stephen Eley) > 4. Re: Good introduction to rspec (Stephen Eley) > 5. Re: Good introduction to rspec (Scott LaBounty) > 6. Re: Good introduction to rspec (David Chelimsky) > 7. Re: Good introduction to rspec (Scott LaBounty) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 1 Apr 2009 14:01:19 +0100 > From: aidy lewis > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <7ac2300c0904010601x71f62ebn5246481575ad85c9 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi David > > 2009/3/31 David Chelimsky : > >> The point of TDD is writing small examples and small bits of code in a >> cycle. The point of BDD is to write high level scenarios so you know >> what code to write, but then drive it out in detail with TDD. > > Does this necessitate that the same person or pair should be doing > both the TDD and BDD for the same area? My problem at the moment is > that as a software tester I would in combination with a customer > create the feature Acceptance Criteria (AC). The AC would be used by > the developer to guide his\her design, but he\she would be unlikely to > implement the automated test, which would normally be done by the > tester (using Watir\Cucumber). My feeling is that if we are to get the > optimal benefit from TDD\BDD then the developer(s) should be > automating the AC. What do you think? > > I don't think this removes the need of the tester as he/she may be > more likely to have a skill-set that is aware of > bigger-than-unit-test-tools and frameworks, but I think they should be > pairing with the developer. However the problem then arises if the > developer and tester use different languages. I use Ruby while the > production code is in .Net. The TDD interplay would be more seamless I > think with a single language. But as a tester it would be insane for > me to use a static and compiled language to - in effect - test a web > site. > > Aidy > > > ------------------------------ > > Message: 2 > Date: Wed, 1 Apr 2009 08:35:01 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <57c63afe0904010635x652e30e3k939e2d0fa21c25fd at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Apr 1, 2009 at 8:01 AM, aidy lewis > wrote: >> Hi David >> >> 2009/3/31 David Chelimsky : >> >>> The point of TDD is writing small examples and small bits of code in a >>> cycle. The point of BDD is to write high level scenarios so you know >>> what code to write, but then drive it out in detail with TDD. >> >> Does this necessitate that the same person or pair should be doing >> both the TDD and BDD for the same area? My problem at the moment is >> that as a software tester I would in combination with a customer >> create the feature Acceptance Criteria (AC). The AC would be used by >> the developer to guide his\her design, but he\she would be unlikely to >> implement the automated test, which would normally be done by the >> tester (using Watir\Cucumber). My feeling is that if we are to get the >> optimal benefit from TDD\BDD then the developer(s) should be >> automating the AC. What do you think? > > Given that I don't know the skill-set available on your team, it's > difficult for me to say what would provide optimum benefit for *your > team*. That said, in some idealistic BDD fashion, I'd think the best > deal would be the tester and developer pairing on automating AC. Then > that developer would pair with another developer driving out the code > w/ TDD. > >> I don't think this removes the need of the tester as he/she may be >> more likely to have a skill-set that is aware of >> bigger-than-unit-test-tools and frameworks, but I think they should be >> pairing with the developer. > > I honestly wrote the above before I read this :) Yes, I agree, tester > and developer pairing is *generally* a good thing. > >> However the problem then arises if the >> developer and tester use different languages. I use Ruby while the >> production code is in .Net. The TDD interplay would be more seamless I >> think with a single language. But as a tester it would be insane for >> me to use a static and compiled language to - in effect - test a web >> site. > > I'm going to go out on a limb here and suggest that if you're > proficient in Ruby and you're pairing with a reasonably skilled > developer in any C-based language like C Sharp, the language barrier > will be fairly small. There are some hoops, like meta-programming, > blocks and iterators, but not too many beyond that. I don't mean that > to be flippant. Even if the dev has zero experience with these > concepts, he really doesn't need to understand them in order to > progress if you're pairing. > > HTH, > David > >> >> Aidy >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 3 > Date: Wed, 1 Apr 2009 06:57:42 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <1fb4df0904010657x4dc54347j652e6e051e3d1217 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Pablo L. de Miranda : >> @Fernando - So what material you recommend to start a study in rSpec? > > 1.) The Web site documentation at http://rspec.info > > 2.) Use it and build experience. > > 3.) Get the beta of the RSpec book. > > 4.) Use it and build experience. > > 5.) Google is your friend. > > 6.) Use it and build experience. > > Finally, if in doubt... Try using it and building some experience. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 4 > Date: Wed, 1 Apr 2009 07:23:32 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users at rubyforge.org > Message-ID: > <1fb4df0904010723g15ec4ebav5c8ab3478a0ab96d at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Tue, Mar 31, 2009 at 11:50 PM, Fernando Perez > wrote: >> >> I don't spec at all the way he shows, I might be doing things wrong, but >> I am very happy with my workflow. > > http://www.kipling.org.uk/poems_neolithic.htm > > (The poem's by Rudyard Kipling, if the URL doesn't make it clear.) > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 5 > Date: Wed, 1 Apr 2009 07:53:03 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010753t231a0f50u201ebdf7e19d6f47 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > I've looked at the web site and I guess I'm looking for more examples. I'd > like to see some simple basic ruby code and then some rSpec code testing it. > No Rails, no nothing else. I haven't tried the book yet, but there does not > seem to be a lot of code out there at this basic a level. > > Any ideas? > > Scott > > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: > >> 2009/4/1 Pablo L. de Miranda : >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> 1.) The Web site documentation at http://rspec.info >> >> 2.) Use it and build experience. >> >> 3.) Get the beta of the RSpec book. >> >> 4.) Use it and build experience. >> >> 5.) Google is your friend. >> >> 6.) Use it and build experience. >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > Message: 6 > Date: Wed, 1 Apr 2009 10:44:02 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Scott LaBounty : >> I've looked at the web site and I guess I'm looking for more examples. I'd >> like to see some simple basic ruby code and then some rSpec code testing >> it. >> No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> seem to be a lot of code out there at this basic a level. >> >> Any ideas? > > Try this: > > http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i > > Cheers, > David > > > >> >> Scott >> >> On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >>> >>> 2009/4/1 Pablo L. de Miranda : >>> > @Fernando - So what material you recommend to start a study in rSpec? >>> >>> 1.) The Web site documentation at http://rspec.info >>> >>> 2.) Use it and build experience. >>> >>> 3.) Get the beta of the RSpec book. >>> >>> 4.) Use it and build experience. >>> >>> 5.) Google is your friend. >>> >>> 6.) Use it and build experience. >>> >>> Finally, if in doubt... ?Try using it and building some experience. >>> >>> >>> -- >>> Have Fun, >>> ? Steve Eley (sfeley at gmail.com) >>> ? ESCAPE POD - The Science Fiction Podcast Magazine >>> ? http://www.escapepod.org >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> Scott >> http://steamcode.blogspot.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 7 > Date: Wed, 1 Apr 2009 08:47:33 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010847s64a648c9r9fa5a469e3b7110e at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > David, > > That's more what I was looking for. > > Thanks, > > Scott > > On Wed, Apr 1, 2009 at 8:44 AM, David Chelimsky wrote: > >> 2009/4/1 Scott LaBounty : >> > I've looked at the web site and I guess I'm looking for more examples. >> I'd >> > like to see some simple basic ruby code and then some rSpec code testing >> it. >> > No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> > seem to be a lot of code out there at this basic a level. >> > >> > Any ideas? >> >> Try this: >> >> http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i >> >> Cheers, >> David >> >> >> >> > >> > Scott >> > >> > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >> >> >> >> 2009/4/1 Pablo L. de Miranda : >> >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> >> >> 1.) The Web site documentation at http://rspec.info >> >> >> >> 2.) Use it and build experience. >> >> >> >> 3.) Get the beta of the RSpec book. >> >> >> >> 4.) Use it and build experience. >> >> >> >> 5.) Google is your friend. >> >> >> >> 6.) Use it and build experience. >> >> >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> >> >> >> -- >> >> Have Fun, >> >> Steve Eley (sfeley at gmail.com) >> >> ESCAPE POD - The Science Fiction Podcast Magazine >> >> http://www.escapepod.org >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > >> > -- >> > Scott >> > http://steamcode.blogspot.com/ >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > End of rspec-users Digest, Vol 34, Issue 2 > ****************************************** > -- Enviado do meu celular Atenciosamente, Charleno Pires Desenvolvedor Web - Teresina Piau? www.charlenopires.com.br (building) Msn: charlenopires at hotmail.com GTalk: charleno at gmail.com From charleno at gmail.com Wed Apr 1 12:30:17 2009 From: charleno at gmail.com (Charleno Pires) Date: Wed, 1 Apr 2009 13:30:17 -0300 Subject: [rspec-users] rspec-users Digest, Vol 34, Issue 2 In-Reply-To: References: Message-ID: <3f5ee3410904010930g454db7q8e901d217ea998de@mail.gmail.com> 2009/4/1, rspec-users-request at rubyforge.org : > Send rspec-users mailing list submissions to > rspec-users at rubyforge.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://rubyforge.org/mailman/listinfo/rspec-users > or, via email, send a message with subject or body 'help' to > rspec-users-request at rubyforge.org > > You can reach the person managing the list at > rspec-users-owner at rubyforge.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of rspec-users digest..." > > > Today's Topics: > > 1. Re: RSpec makes me want to write better code (aidy lewis) > 2. Re: RSpec makes me want to write better code (David Chelimsky) > 3. Re: Good introduction to rspec (Stephen Eley) > 4. Re: Good introduction to rspec (Stephen Eley) > 5. Re: Good introduction to rspec (Scott LaBounty) > 6. Re: Good introduction to rspec (David Chelimsky) > 7. Re: Good introduction to rspec (Scott LaBounty) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 1 Apr 2009 14:01:19 +0100 > From: aidy lewis > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <7ac2300c0904010601x71f62ebn5246481575ad85c9 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi David > > 2009/3/31 David Chelimsky : > >> The point of TDD is writing small examples and small bits of code in a >> cycle. The point of BDD is to write high level scenarios so you know >> what code to write, but then drive it out in detail with TDD. > > Does this necessitate that the same person or pair should be doing > both the TDD and BDD for the same area? My problem at the moment is > that as a software tester I would in combination with a customer > create the feature Acceptance Criteria (AC). The AC would be used by > the developer to guide his\her design, but he\she would be unlikely to > implement the automated test, which would normally be done by the > tester (using Watir\Cucumber). My feeling is that if we are to get the > optimal benefit from TDD\BDD then the developer(s) should be > automating the AC. What do you think? > > I don't think this removes the need of the tester as he/she may be > more likely to have a skill-set that is aware of > bigger-than-unit-test-tools and frameworks, but I think they should be > pairing with the developer. However the problem then arises if the > developer and tester use different languages. I use Ruby while the > production code is in .Net. The TDD interplay would be more seamless I > think with a single language. But as a tester it would be insane for > me to use a static and compiled language to - in effect - test a web > site. > > Aidy > > > ------------------------------ > > Message: 2 > Date: Wed, 1 Apr 2009 08:35:01 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <57c63afe0904010635x652e30e3k939e2d0fa21c25fd at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Apr 1, 2009 at 8:01 AM, aidy lewis > wrote: >> Hi David >> >> 2009/3/31 David Chelimsky : >> >>> The point of TDD is writing small examples and small bits of code in a >>> cycle. The point of BDD is to write high level scenarios so you know >>> what code to write, but then drive it out in detail with TDD. >> >> Does this necessitate that the same person or pair should be doing >> both the TDD and BDD for the same area? My problem at the moment is >> that as a software tester I would in combination with a customer >> create the feature Acceptance Criteria (AC). The AC would be used by >> the developer to guide his\her design, but he\she would be unlikely to >> implement the automated test, which would normally be done by the >> tester (using Watir\Cucumber). My feeling is that if we are to get the >> optimal benefit from TDD\BDD then the developer(s) should be >> automating the AC. What do you think? > > Given that I don't know the skill-set available on your team, it's > difficult for me to say what would provide optimum benefit for *your > team*. That said, in some idealistic BDD fashion, I'd think the best > deal would be the tester and developer pairing on automating AC. Then > that developer would pair with another developer driving out the code > w/ TDD. > >> I don't think this removes the need of the tester as he/she may be >> more likely to have a skill-set that is aware of >> bigger-than-unit-test-tools and frameworks, but I think they should be >> pairing with the developer. > > I honestly wrote the above before I read this :) Yes, I agree, tester > and developer pairing is *generally* a good thing. > >> However the problem then arises if the >> developer and tester use different languages. I use Ruby while the >> production code is in .Net. The TDD interplay would be more seamless I >> think with a single language. But as a tester it would be insane for >> me to use a static and compiled language to - in effect - test a web >> site. > > I'm going to go out on a limb here and suggest that if you're > proficient in Ruby and you're pairing with a reasonably skilled > developer in any C-based language like C Sharp, the language barrier > will be fairly small. There are some hoops, like meta-programming, > blocks and iterators, but not too many beyond that. I don't mean that > to be flippant. Even if the dev has zero experience with these > concepts, he really doesn't need to understand them in order to > progress if you're pairing. > > HTH, > David > >> >> Aidy >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 3 > Date: Wed, 1 Apr 2009 06:57:42 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <1fb4df0904010657x4dc54347j652e6e051e3d1217 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Pablo L. de Miranda : >> @Fernando - So what material you recommend to start a study in rSpec? > > 1.) The Web site documentation at http://rspec.info > > 2.) Use it and build experience. > > 3.) Get the beta of the RSpec book. > > 4.) Use it and build experience. > > 5.) Google is your friend. > > 6.) Use it and build experience. > > Finally, if in doubt... Try using it and building some experience. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 4 > Date: Wed, 1 Apr 2009 07:23:32 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users at rubyforge.org > Message-ID: > <1fb4df0904010723g15ec4ebav5c8ab3478a0ab96d at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Tue, Mar 31, 2009 at 11:50 PM, Fernando Perez > wrote: >> >> I don't spec at all the way he shows, I might be doing things wrong, but >> I am very happy with my workflow. > > http://www.kipling.org.uk/poems_neolithic.htm > > (The poem's by Rudyard Kipling, if the URL doesn't make it clear.) > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 5 > Date: Wed, 1 Apr 2009 07:53:03 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010753t231a0f50u201ebdf7e19d6f47 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > I've looked at the web site and I guess I'm looking for more examples. I'd > like to see some simple basic ruby code and then some rSpec code testing it. > No Rails, no nothing else. I haven't tried the book yet, but there does not > seem to be a lot of code out there at this basic a level. > > Any ideas? > > Scott > > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: > >> 2009/4/1 Pablo L. de Miranda : >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> 1.) The Web site documentation at http://rspec.info >> >> 2.) Use it and build experience. >> >> 3.) Get the beta of the RSpec book. >> >> 4.) Use it and build experience. >> >> 5.) Google is your friend. >> >> 6.) Use it and build experience. >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > Message: 6 > Date: Wed, 1 Apr 2009 10:44:02 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Scott LaBounty : >> I've looked at the web site and I guess I'm looking for more examples. I'd >> like to see some simple basic ruby code and then some rSpec code testing >> it. >> No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> seem to be a lot of code out there at this basic a level. >> >> Any ideas? > > Try this: > > http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i > > Cheers, > David > > > >> >> Scott >> >> On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >>> >>> 2009/4/1 Pablo L. de Miranda : >>> > @Fernando - So what material you recommend to start a study in rSpec? >>> >>> 1.) The Web site documentation at http://rspec.info >>> >>> 2.) Use it and build experience. >>> >>> 3.) Get the beta of the RSpec book. >>> >>> 4.) Use it and build experience. >>> >>> 5.) Google is your friend. >>> >>> 6.) Use it and build experience. >>> >>> Finally, if in doubt... ?Try using it and building some experience. >>> >>> >>> -- >>> Have Fun, >>> ? Steve Eley (sfeley at gmail.com) >>> ? ESCAPE POD - The Science Fiction Podcast Magazine >>> ? http://www.escapepod.org >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> Scott >> http://steamcode.blogspot.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 7 > Date: Wed, 1 Apr 2009 08:47:33 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010847s64a648c9r9fa5a469e3b7110e at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > David, > > That's more what I was looking for. > > Thanks, > > Scott > > On Wed, Apr 1, 2009 at 8:44 AM, David Chelimsky wrote: > >> 2009/4/1 Scott LaBounty : >> > I've looked at the web site and I guess I'm looking for more examples. >> I'd >> > like to see some simple basic ruby code and then some rSpec code testing >> it. >> > No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> > seem to be a lot of code out there at this basic a level. >> > >> > Any ideas? >> >> Try this: >> >> http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i >> >> Cheers, >> David >> >> >> >> > >> > Scott >> > >> > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >> >> >> >> 2009/4/1 Pablo L. de Miranda : >> >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> >> >> 1.) The Web site documentation at http://rspec.info >> >> >> >> 2.) Use it and build experience. >> >> >> >> 3.) Get the beta of the RSpec book. >> >> >> >> 4.) Use it and build experience. >> >> >> >> 5.) Google is your friend. >> >> >> >> 6.) Use it and build experience. >> >> >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> >> >> >> -- >> >> Have Fun, >> >> Steve Eley (sfeley at gmail.com) >> >> ESCAPE POD - The Science Fiction Podcast Magazine >> >> http://www.escapepod.org >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > >> > -- >> > Scott >> > http://steamcode.blogspot.com/ >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > End of rspec-users Digest, Vol 34, Issue 2 > ****************************************** > -- Enviado do meu celular Atenciosamente, Charleno Pires Desenvolvedor Web - Teresina Piau? www.charlenopires.com.br (building) Msn: charlenopires at hotmail.com GTalk: charleno at gmail.com From charleno at gmail.com Wed Apr 1 12:31:19 2009 From: charleno at gmail.com (Charleno Pires) Date: Wed, 1 Apr 2009 13:31:19 -0300 Subject: [rspec-users] rspec-users Digest, Vol 34, Issue 2 In-Reply-To: References: Message-ID: <3f5ee3410904010931u7134fdeo254029373a56ae03@mail.gmail.com> 2009/4/1, rspec-users-request at rubyforge.org : > Send rspec-users mailing list submissions to > rspec-users at rubyforge.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://rubyforge.org/mailman/listinfo/rspec-users > or, via email, send a message with subject or body 'help' to > rspec-users-request at rubyforge.org > > You can reach the person managing the list at > rspec-users-owner at rubyforge.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of rspec-users digest..." > > > Today's Topics: > > 1. Re: RSpec makes me want to write better code (aidy lewis) > 2. Re: RSpec makes me want to write better code (David Chelimsky) > 3. Re: Good introduction to rspec (Stephen Eley) > 4. Re: Good introduction to rspec (Stephen Eley) > 5. Re: Good introduction to rspec (Scott LaBounty) > 6. Re: Good introduction to rspec (David Chelimsky) > 7. Re: Good introduction to rspec (Scott LaBounty) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 1 Apr 2009 14:01:19 +0100 > From: aidy lewis > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <7ac2300c0904010601x71f62ebn5246481575ad85c9 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi David > > 2009/3/31 David Chelimsky : > >> The point of TDD is writing small examples and small bits of code in a >> cycle. The point of BDD is to write high level scenarios so you know >> what code to write, but then drive it out in detail with TDD. > > Does this necessitate that the same person or pair should be doing > both the TDD and BDD for the same area? My problem at the moment is > that as a software tester I would in combination with a customer > create the feature Acceptance Criteria (AC). The AC would be used by > the developer to guide his\her design, but he\she would be unlikely to > implement the automated test, which would normally be done by the > tester (using Watir\Cucumber). My feeling is that if we are to get the > optimal benefit from TDD\BDD then the developer(s) should be > automating the AC. What do you think? > > I don't think this removes the need of the tester as he/she may be > more likely to have a skill-set that is aware of > bigger-than-unit-test-tools and frameworks, but I think they should be > pairing with the developer. However the problem then arises if the > developer and tester use different languages. I use Ruby while the > production code is in .Net. The TDD interplay would be more seamless I > think with a single language. But as a tester it would be insane for > me to use a static and compiled language to - in effect - test a web > site. > > Aidy > > > ------------------------------ > > Message: 2 > Date: Wed, 1 Apr 2009 08:35:01 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <57c63afe0904010635x652e30e3k939e2d0fa21c25fd at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Apr 1, 2009 at 8:01 AM, aidy lewis > wrote: >> Hi David >> >> 2009/3/31 David Chelimsky : >> >>> The point of TDD is writing small examples and small bits of code in a >>> cycle. The point of BDD is to write high level scenarios so you know >>> what code to write, but then drive it out in detail with TDD. >> >> Does this necessitate that the same person or pair should be doing >> both the TDD and BDD for the same area? My problem at the moment is >> that as a software tester I would in combination with a customer >> create the feature Acceptance Criteria (AC). The AC would be used by >> the developer to guide his\her design, but he\she would be unlikely to >> implement the automated test, which would normally be done by the >> tester (using Watir\Cucumber). My feeling is that if we are to get the >> optimal benefit from TDD\BDD then the developer(s) should be >> automating the AC. What do you think? > > Given that I don't know the skill-set available on your team, it's > difficult for me to say what would provide optimum benefit for *your > team*. That said, in some idealistic BDD fashion, I'd think the best > deal would be the tester and developer pairing on automating AC. Then > that developer would pair with another developer driving out the code > w/ TDD. > >> I don't think this removes the need of the tester as he/she may be >> more likely to have a skill-set that is aware of >> bigger-than-unit-test-tools and frameworks, but I think they should be >> pairing with the developer. > > I honestly wrote the above before I read this :) Yes, I agree, tester > and developer pairing is *generally* a good thing. > >> However the problem then arises if the >> developer and tester use different languages. I use Ruby while the >> production code is in .Net. The TDD interplay would be more seamless I >> think with a single language. But as a tester it would be insane for >> me to use a static and compiled language to - in effect - test a web >> site. > > I'm going to go out on a limb here and suggest that if you're > proficient in Ruby and you're pairing with a reasonably skilled > developer in any C-based language like C Sharp, the language barrier > will be fairly small. There are some hoops, like meta-programming, > blocks and iterators, but not too many beyond that. I don't mean that > to be flippant. Even if the dev has zero experience with these > concepts, he really doesn't need to understand them in order to > progress if you're pairing. > > HTH, > David > >> >> Aidy >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 3 > Date: Wed, 1 Apr 2009 06:57:42 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <1fb4df0904010657x4dc54347j652e6e051e3d1217 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Pablo L. de Miranda : >> @Fernando - So what material you recommend to start a study in rSpec? > > 1.) The Web site documentation at http://rspec.info > > 2.) Use it and build experience. > > 3.) Get the beta of the RSpec book. > > 4.) Use it and build experience. > > 5.) Google is your friend. > > 6.) Use it and build experience. > > Finally, if in doubt... Try using it and building some experience. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 4 > Date: Wed, 1 Apr 2009 07:23:32 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users at rubyforge.org > Message-ID: > <1fb4df0904010723g15ec4ebav5c8ab3478a0ab96d at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Tue, Mar 31, 2009 at 11:50 PM, Fernando Perez > wrote: >> >> I don't spec at all the way he shows, I might be doing things wrong, but >> I am very happy with my workflow. > > http://www.kipling.org.uk/poems_neolithic.htm > > (The poem's by Rudyard Kipling, if the URL doesn't make it clear.) > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 5 > Date: Wed, 1 Apr 2009 07:53:03 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010753t231a0f50u201ebdf7e19d6f47 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > I've looked at the web site and I guess I'm looking for more examples. I'd > like to see some simple basic ruby code and then some rSpec code testing it. > No Rails, no nothing else. I haven't tried the book yet, but there does not > seem to be a lot of code out there at this basic a level. > > Any ideas? > > Scott > > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: > >> 2009/4/1 Pablo L. de Miranda : >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> 1.) The Web site documentation at http://rspec.info >> >> 2.) Use it and build experience. >> >> 3.) Get the beta of the RSpec book. >> >> 4.) Use it and build experience. >> >> 5.) Google is your friend. >> >> 6.) Use it and build experience. >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > Message: 6 > Date: Wed, 1 Apr 2009 10:44:02 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Scott LaBounty : >> I've looked at the web site and I guess I'm looking for more examples. I'd >> like to see some simple basic ruby code and then some rSpec code testing >> it. >> No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> seem to be a lot of code out there at this basic a level. >> >> Any ideas? > > Try this: > > http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i > > Cheers, > David > > > >> >> Scott >> >> On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >>> >>> 2009/4/1 Pablo L. de Miranda : >>> > @Fernando - So what material you recommend to start a study in rSpec? >>> >>> 1.) The Web site documentation at http://rspec.info >>> >>> 2.) Use it and build experience. >>> >>> 3.) Get the beta of the RSpec book. >>> >>> 4.) Use it and build experience. >>> >>> 5.) Google is your friend. >>> >>> 6.) Use it and build experience. >>> >>> Finally, if in doubt... ?Try using it and building some experience. >>> >>> >>> -- >>> Have Fun, >>> ? Steve Eley (sfeley at gmail.com) >>> ? ESCAPE POD - The Science Fiction Podcast Magazine >>> ? http://www.escapepod.org >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> Scott >> http://steamcode.blogspot.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 7 > Date: Wed, 1 Apr 2009 08:47:33 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010847s64a648c9r9fa5a469e3b7110e at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > David, > > That's more what I was looking for. > > Thanks, > > Scott > > On Wed, Apr 1, 2009 at 8:44 AM, David Chelimsky wrote: > >> 2009/4/1 Scott LaBounty : >> > I've looked at the web site and I guess I'm looking for more examples. >> I'd >> > like to see some simple basic ruby code and then some rSpec code testing >> it. >> > No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> > seem to be a lot of code out there at this basic a level. >> > >> > Any ideas? >> >> Try this: >> >> http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i >> >> Cheers, >> David >> >> >> >> > >> > Scott >> > >> > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >> >> >> >> 2009/4/1 Pablo L. de Miranda : >> >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> >> >> 1.) The Web site documentation at http://rspec.info >> >> >> >> 2.) Use it and build experience. >> >> >> >> 3.) Get the beta of the RSpec book. >> >> >> >> 4.) Use it and build experience. >> >> >> >> 5.) Google is your friend. >> >> >> >> 6.) Use it and build experience. >> >> >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> >> >> >> -- >> >> Have Fun, >> >> Steve Eley (sfeley at gmail.com) >> >> ESCAPE POD - The Science Fiction Podcast Magazine >> >> http://www.escapepod.org >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > >> > -- >> > Scott >> > http://steamcode.blogspot.com/ >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > End of rspec-users Digest, Vol 34, Issue 2 > ****************************************** > -- Enviado do meu celular Atenciosamente, Charleno Pires Desenvolvedor Web - Teresina Piau? www.charlenopires.com.br (building) Msn: charlenopires at hotmail.com GTalk: charleno at gmail.com From charleno at gmail.com Wed Apr 1 12:32:20 2009 From: charleno at gmail.com (Charleno Pires) Date: Wed, 1 Apr 2009 13:32:20 -0300 Subject: [rspec-users] rspec-users Digest, Vol 34, Issue 2 In-Reply-To: References: Message-ID: <3f5ee3410904010932r599beef2l710caba759385d99@mail.gmail.com> 2009/4/1, rspec-users-request at rubyforge.org : > Send rspec-users mailing list submissions to > rspec-users at rubyforge.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://rubyforge.org/mailman/listinfo/rspec-users > or, via email, send a message with subject or body 'help' to > rspec-users-request at rubyforge.org > > You can reach the person managing the list at > rspec-users-owner at rubyforge.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of rspec-users digest..." > > > Today's Topics: > > 1. Re: RSpec makes me want to write better code (aidy lewis) > 2. Re: RSpec makes me want to write better code (David Chelimsky) > 3. Re: Good introduction to rspec (Stephen Eley) > 4. Re: Good introduction to rspec (Stephen Eley) > 5. Re: Good introduction to rspec (Scott LaBounty) > 6. Re: Good introduction to rspec (David Chelimsky) > 7. Re: Good introduction to rspec (Scott LaBounty) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 1 Apr 2009 14:01:19 +0100 > From: aidy lewis > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <7ac2300c0904010601x71f62ebn5246481575ad85c9 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi David > > 2009/3/31 David Chelimsky : > >> The point of TDD is writing small examples and small bits of code in a >> cycle. The point of BDD is to write high level scenarios so you know >> what code to write, but then drive it out in detail with TDD. > > Does this necessitate that the same person or pair should be doing > both the TDD and BDD for the same area? My problem at the moment is > that as a software tester I would in combination with a customer > create the feature Acceptance Criteria (AC). The AC would be used by > the developer to guide his\her design, but he\she would be unlikely to > implement the automated test, which would normally be done by the > tester (using Watir\Cucumber). My feeling is that if we are to get the > optimal benefit from TDD\BDD then the developer(s) should be > automating the AC. What do you think? > > I don't think this removes the need of the tester as he/she may be > more likely to have a skill-set that is aware of > bigger-than-unit-test-tools and frameworks, but I think they should be > pairing with the developer. However the problem then arises if the > developer and tester use different languages. I use Ruby while the > production code is in .Net. The TDD interplay would be more seamless I > think with a single language. But as a tester it would be insane for > me to use a static and compiled language to - in effect - test a web > site. > > Aidy > > > ------------------------------ > > Message: 2 > Date: Wed, 1 Apr 2009 08:35:01 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <57c63afe0904010635x652e30e3k939e2d0fa21c25fd at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Apr 1, 2009 at 8:01 AM, aidy lewis > wrote: >> Hi David >> >> 2009/3/31 David Chelimsky : >> >>> The point of TDD is writing small examples and small bits of code in a >>> cycle. The point of BDD is to write high level scenarios so you know >>> what code to write, but then drive it out in detail with TDD. >> >> Does this necessitate that the same person or pair should be doing >> both the TDD and BDD for the same area? My problem at the moment is >> that as a software tester I would in combination with a customer >> create the feature Acceptance Criteria (AC). The AC would be used by >> the developer to guide his\her design, but he\she would be unlikely to >> implement the automated test, which would normally be done by the >> tester (using Watir\Cucumber). My feeling is that if we are to get the >> optimal benefit from TDD\BDD then the developer(s) should be >> automating the AC. What do you think? > > Given that I don't know the skill-set available on your team, it's > difficult for me to say what would provide optimum benefit for *your > team*. That said, in some idealistic BDD fashion, I'd think the best > deal would be the tester and developer pairing on automating AC. Then > that developer would pair with another developer driving out the code > w/ TDD. > >> I don't think this removes the need of the tester as he/she may be >> more likely to have a skill-set that is aware of >> bigger-than-unit-test-tools and frameworks, but I think they should be >> pairing with the developer. > > I honestly wrote the above before I read this :) Yes, I agree, tester > and developer pairing is *generally* a good thing. > >> However the problem then arises if the >> developer and tester use different languages. I use Ruby while the >> production code is in .Net. The TDD interplay would be more seamless I >> think with a single language. But as a tester it would be insane for >> me to use a static and compiled language to - in effect - test a web >> site. > > I'm going to go out on a limb here and suggest that if you're > proficient in Ruby and you're pairing with a reasonably skilled > developer in any C-based language like C Sharp, the language barrier > will be fairly small. There are some hoops, like meta-programming, > blocks and iterators, but not too many beyond that. I don't mean that > to be flippant. Even if the dev has zero experience with these > concepts, he really doesn't need to understand them in order to > progress if you're pairing. > > HTH, > David > >> >> Aidy >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 3 > Date: Wed, 1 Apr 2009 06:57:42 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <1fb4df0904010657x4dc54347j652e6e051e3d1217 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Pablo L. de Miranda : >> @Fernando - So what material you recommend to start a study in rSpec? > > 1.) The Web site documentation at http://rspec.info > > 2.) Use it and build experience. > > 3.) Get the beta of the RSpec book. > > 4.) Use it and build experience. > > 5.) Google is your friend. > > 6.) Use it and build experience. > > Finally, if in doubt... Try using it and building some experience. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 4 > Date: Wed, 1 Apr 2009 07:23:32 -0700 > From: Stephen Eley > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users at rubyforge.org > Message-ID: > <1fb4df0904010723g15ec4ebav5c8ab3478a0ab96d at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Tue, Mar 31, 2009 at 11:50 PM, Fernando Perez > wrote: >> >> I don't spec at all the way he shows, I might be doing things wrong, but >> I am very happy with my workflow. > > http://www.kipling.org.uk/poems_neolithic.htm > > (The poem's by Rudyard Kipling, if the URL doesn't make it clear.) > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > > > ------------------------------ > > Message: 5 > Date: Wed, 1 Apr 2009 07:53:03 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010753t231a0f50u201ebdf7e19d6f47 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > I've looked at the web site and I guess I'm looking for more examples. I'd > like to see some simple basic ruby code and then some rSpec code testing it. > No Rails, no nothing else. I haven't tried the book yet, but there does not > seem to be a lot of code out there at this basic a level. > > Any ideas? > > Scott > > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: > >> 2009/4/1 Pablo L. de Miranda : >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> 1.) The Web site documentation at http://rspec.info >> >> 2.) Use it and build experience. >> >> 3.) Get the beta of the RSpec book. >> >> 4.) Use it and build experience. >> >> 5.) Google is your friend. >> >> 6.) Use it and build experience. >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> -- >> Have Fun, >> Steve Eley (sfeley at gmail.com) >> ESCAPE POD - The Science Fiction Podcast Magazine >> http://www.escapepod.org >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > Message: 6 > Date: Wed, 1 Apr 2009 10:44:02 -0500 > From: David Chelimsky > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <57c63afe0904010844p6bd992f8pd8e8119d6865f8f5 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > 2009/4/1 Scott LaBounty : >> I've looked at the web site and I guess I'm looking for more examples. I'd >> like to see some simple basic ruby code and then some rSpec code testing >> it. >> No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> seem to be a lot of code out there at this basic a level. >> >> Any ideas? > > Try this: > > http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i > > Cheers, > David > > > >> >> Scott >> >> On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >>> >>> 2009/4/1 Pablo L. de Miranda : >>> > @Fernando - So what material you recommend to start a study in rSpec? >>> >>> 1.) The Web site documentation at http://rspec.info >>> >>> 2.) Use it and build experience. >>> >>> 3.) Get the beta of the RSpec book. >>> >>> 4.) Use it and build experience. >>> >>> 5.) Google is your friend. >>> >>> 6.) Use it and build experience. >>> >>> Finally, if in doubt... ?Try using it and building some experience. >>> >>> >>> -- >>> Have Fun, >>> ? Steve Eley (sfeley at gmail.com) >>> ? ESCAPE POD - The Science Fiction Podcast Magazine >>> ? http://www.escapepod.org >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> Scott >> http://steamcode.blogspot.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > ------------------------------ > > Message: 7 > Date: Wed, 1 Apr 2009 08:47:33 -0700 > From: Scott LaBounty > Subject: Re: [rspec-users] Good introduction to rspec > To: rspec-users > Message-ID: > <7de47a040904010847s64a648c9r9fa5a469e3b7110e at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > David, > > That's more what I was looking for. > > Thanks, > > Scott > > On Wed, Apr 1, 2009 at 8:44 AM, David Chelimsky wrote: > >> 2009/4/1 Scott LaBounty : >> > I've looked at the web site and I guess I'm looking for more examples. >> I'd >> > like to see some simple basic ruby code and then some rSpec code testing >> it. >> > No Rails, no nothing else. I haven't tried the book yet, but there does >> not >> > seem to be a lot of code out there at this basic a level. >> > >> > Any ideas? >> >> Try this: >> >> http://blog.davidchelimsky.net/2007/5/14/an-introduction-to-rspec-part-i >> >> Cheers, >> David >> >> >> >> > >> > Scott >> > >> > On Wed, Apr 1, 2009 at 6:57 AM, Stephen Eley wrote: >> >> >> >> 2009/4/1 Pablo L. de Miranda : >> >> > @Fernando - So what material you recommend to start a study in rSpec? >> >> >> >> 1.) The Web site documentation at http://rspec.info >> >> >> >> 2.) Use it and build experience. >> >> >> >> 3.) Get the beta of the RSpec book. >> >> >> >> 4.) Use it and build experience. >> >> >> >> 5.) Google is your friend. >> >> >> >> 6.) Use it and build experience. >> >> >> >> Finally, if in doubt... Try using it and building some experience. >> >> >> >> >> >> -- >> >> Have Fun, >> >> Steve Eley (sfeley at gmail.com) >> >> ESCAPE POD - The Science Fiction Podcast Magazine >> >> http://www.escapepod.org >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > >> > -- >> > Scott >> > http://steamcode.blogspot.com/ >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > > ------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > End of rspec-users Digest, Vol 34, Issue 2 > ****************************************** > -- Enviado do meu celular Atenciosamente, Charleno Pires Desenvolvedor Web - Teresina Piau? www.charlenopires.com.br (building) Msn: charlenopires at hotmail.com GTalk: charleno at gmail.com From zach.dennis at gmail.com Wed Apr 1 12:59:24 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 1 Apr 2009 12:59:24 -0400 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <3aa7f36197e80e5ac2525cb38e252958@ruby-forum.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> <3aa7f36197e80e5ac2525cb38e252958@ruby-forum.com> Message-ID: <85d99afe0904010959i2922f00btcf7053d66f6a2f2f@mail.gmail.com> On Wed, Apr 1, 2009 at 11:50 AM, James Byrne wrote: > Pablo L. de Miranda wrote: >> @Fernando - So what material you recommend to start a study in rSpec? >> > > This might be heresy, but I suggest that you start with Cucumber and > simply use RSpec matcher syntax in your step definitions. ? Once you > have the hang of how to express expectations in the step definitions, > then move on to using RSpec on its own; providing that you still want > to. > > I really did not get the hang of any of this, TDD, BDD, Rails or Ruby > until I latched on to Cucumber and started -- very, very poorly mind you > -- to discover how to express behaviour and, more importantly, what > behaviour to express. ?It was, for me, a tumultuous journey and one that > I am still traveling. > > I am now at the point where, simply by expressing one little bit of > desired bwhaviour in a cucumber scenario, I uncovered a requirement to > leave Rails for a bit and implement a set of SQL triggers. ?This would > have been discovered at some point anyway, but I rather suspect that > without BDD the implementation would have been written first in Ruby for > ActiveRecord only to be discarded sometime later when the need for a > trigger became manifest. > > Peepcode is good, I have watched and learned lots there. ?Just recall > that the episodes go far back in time insofar as Rails and RSpec are > concerned. ?These two products have undergone extensive change since > many of the episodes were recorded. Thanks for sharing James. I know when you first joined the list there were a few frustrating moments, and it's really good to hear about where you've come and how you've gotten there. This is helpful to both newbs and seasoned BDDers alike, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From marcus.rosentrater at digitalscientists.com Wed Apr 1 11:35:34 2009 From: marcus.rosentrater at digitalscientists.com (rosentraterds) Date: Wed, 1 Apr 2009 08:35:34 -0700 (PDT) Subject: [rspec-users] Autospec stops running after tests are complete Message-ID: <22829288.post@talk.nabble.com> I installed an app template into an existing rails install. In the process I upgraded to RSpec 1.2.2 and I'm running Rails 2.3.2. Now autospec will run once and then exit. Returning me to the CLI prompt. Any ideas? Thanks! -- View this message in context: http://www.nabble.com/Autospec-stops-running-after-tests-are-complete-tp22829288p22829288.html Sent from the rspec-users mailing list archive at Nabble.com. From marcus.rosentrater at digitalscientists.com Wed Apr 1 12:31:22 2009 From: marcus.rosentrater at digitalscientists.com (rosentraterds) Date: Wed, 1 Apr 2009 09:31:22 -0700 (PDT) Subject: [rspec-users] Autospec stops running after tests are complete In-Reply-To: <22829288.post@talk.nabble.com> References: <22829288.post@talk.nabble.com> Message-ID: <22830431.post@talk.nabble.com> I'm thinking now the problem may be ZenTest 4.0. I reverted back to 3.11 and it was working there. But 3.11 has conflicts with Rails 2.3.2 and I need to run rails. Still need help if anybody has some for me. Thanks again. rosentraterds wrote: > > I installed an app template into an existing rails install. In the process > I upgraded to RSpec 1.2.2 and I'm running Rails 2.3.2. > > Now autospec will run once and then exit. Returning me to the CLI prompt. > > Any ideas? > > Thanks! > -- View this message in context: http://www.nabble.com/Autospec-stops-running-after-tests-are-complete-tp22829288p22830431.html Sent from the rspec-users mailing list archive at Nabble.com. From marcus.rosentrater at digitalscientists.com Wed Apr 1 13:14:36 2009 From: marcus.rosentrater at digitalscientists.com (rosentraterds) Date: Wed, 1 Apr 2009 10:14:36 -0700 (PDT) Subject: [rspec-users] Autospec stops running after tests are complete Message-ID: <22830431.post@talk.nabble.com> I'm thinking now the problem may be ZenTest 4.0. I reverted back to 3.11 and it was working there. But 3.11 has conflicts with Rails 2.3.2 and I need to run rails. Still need help if anybody has some for me. Thanks again. rosentraterds wrote: > > I installed an app template into an existing rails install. In the process > I upgraded to RSpec 1.2.2 and I'm running Rails 2.3.2. > > Now autospec will run once and then exit. Returning me to the CLI prompt. > > Any ideas? > > Thanks! > -- View this message in context: http://www.nabble.com/Autospec-stops-running-after-tests-are-complete-tp22829288p22830431.html Sent from the rspec-users mailing list archive at Nabble.com. From lists at ruby-forum.com Wed Apr 1 14:28:04 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 1 Apr 2009 20:28:04 +0200 Subject: [rspec-users] Good introduction to rspec In-Reply-To: <85d99afe0904010959i2922f00btcf7053d66f6a2f2f@mail.gmail.com> References: <2b1500990903311000r618ca3bahae123596df3b012c@mail.gmail.com> <914d407218e4980dfc36d1132b96cc22@ruby-forum.com> <2b1500990903311501o65399d9bq1396dfc8899f03c1@mail.gmail.com> <44821e060903311547v63255b7axf6386863a65a2328@mail.gmail.com> <2b1500990904010503i66ee4f59sc67ecf12838b1f06@mail.gmail.com> <3aa7f36197e80e5ac2525cb38e252958@ruby-forum.com> <85d99afe0904010959i2922f00btcf7053d66f6a2f2f@mail.gmail.com> Message-ID: Zach Dennis wrote: > > > Thanks for sharing James. I know when you first joined the list there > were a few frustrating moments, and it's really good to hear about > where you've come and how you've gotten there. This is helpful to both > newbs and seasoned BDDers alike, > I am very, very grateful for all of the advice and assistance that has been given to me here. I am also very grateful for all the tools provided to me by the community, of which Cucumber and RSpec are probably most important to me after Ruby and Rails. I am still making mistakes of course, but now only one of each kind. I hope. -- Posted via http://www.ruby-forum.com/. From marcus.rosentrater at digitalscientists.com Wed Apr 1 14:40:25 2009 From: marcus.rosentrater at digitalscientists.com (rosentraterds) Date: Wed, 1 Apr 2009 11:40:25 -0700 (PDT) Subject: [rspec-users] Autospec stops running after tests are complete In-Reply-To: <22830431.post@talk.nabble.com> References: <22829288.post@talk.nabble.com> <22830431.post@talk.nabble.com> Message-ID: <22832758.post@talk.nabble.com> Maybe related. When I try to run RSpactor (since autospec isn't working) it only runs 1 example. Still no solution. rosentraterds wrote: > > I'm thinking now the problem may be ZenTest 4.0. I reverted back to 3.11 > and it was working there. But 3.11 has conflicts with Rails 2.3.2 and I > need to run rails. Still need help if anybody has some for me. > > Thanks again. > > > rosentraterds wrote: >> >> I installed an app template into an existing rails install. In the >> process I upgraded to RSpec 1.2.2 and I'm running Rails 2.3.2. >> >> Now autospec will run once and then exit. Returning me to the CLI prompt. >> >> Any ideas? >> >> Thanks! >> > > -- View this message in context: http://www.nabble.com/Autospec-stops-running-after-tests-are-complete-tp22829288p22832758.html Sent from the rspec-users mailing list archive at Nabble.com. From u.alberton at gmail.com Wed Apr 1 15:40:42 2009 From: u.alberton at gmail.com (Bira) Date: Wed, 1 Apr 2009 16:40:42 -0300 Subject: [rspec-users] RSpec-Rails 1.2.2 and Controllers without views - what to do? Message-ID: I'm trying to upgrade to RSpec 1.2.2 in a Rails app, and reading Upgrade.rdoc I see that now every controller action must have a corresponding template for their specs to pass. However, we have a few controllers which only return XML or JSON as generated by Rails' to_xml and to_json methods, and so use only render :xml/:json calls rather than views. With 1.2.2, we get a lot of failing specs in that section that used to pass with 1.1.12, because of the "missing" templates. What do you recommend I do in this case? Is there any good solution other than making up templates consisting entirely of a single "<%= @obj.to_xml %>" line? -- Bira http://compexplicita.wordpress.com http://compexplicita.tumblr.com From marcus.rosentrater at digitalscientists.com Wed Apr 1 16:38:07 2009 From: marcus.rosentrater at digitalscientists.com (rosentraterds) Date: Wed, 1 Apr 2009 13:38:07 -0700 (PDT) Subject: [rspec-users] Autospec stops running after tests are complete In-Reply-To: <22832758.post@talk.nabble.com> References: <22829288.post@talk.nabble.com> <22830431.post@talk.nabble.com> <22832758.post@talk.nabble.com> Message-ID: <22834751.post@talk.nabble.com> SOLVED: OK the problem was coming from Carlos Brando autotest-notification 1.9.0. It had to do with invalid checking of constants. Testing SUCCESS_SOUND.empty? instead of const_defined?("SUCCESS_SOUND"). I've fixed it in my fork. http://github.com/marcusrosentrater/autotest-notification/tree/master And sent a pull request to Carlos Brando and Team. -- View this message in context: http://www.nabble.com/Autospec-stops-running-after-tests-are-complete-tp22829288p22834751.html Sent from the rspec-users mailing list archive at Nabble.com. From timcharper at gmail.com Wed Apr 1 18:51:14 2009 From: timcharper at gmail.com (Tim Harper) Date: Wed, 1 Apr 2009 16:51:14 -0600 Subject: [rspec-users] [cucumber] How to add a after failure hook? Message-ID: Is currently a way to add a upon failure hook? I'd like to make it so that, in the event of a failed assertion, Webrat will take the last requested page and open it in a browser. Thanks :) Tim -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Wed Apr 1 19:35:19 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 2 Apr 2009 01:35:19 +0200 Subject: [rspec-users] [cucumber] How to add a after failure hook? In-Reply-To: References: Message-ID: <8d961d900904011635k2343c915s347fa61962f07d22@mail.gmail.com> 2009/4/2 Tim Harper > Is currently a way to add a upon failure hook? I'd like to make it so > that, in the event of a failed assertion, Webrat will take the last > requested page and open it in a browser. > http://wiki.github.com/aslakhellesoy/cucumber/hooks After do |scenario| # currently no simple way to query scenario for status though :-( end Please open a ticket for this if you really need it. Aslak > > Thanks :) > > Tim > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From programmer2188 at gmail.com Wed Apr 1 21:25:32 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Wed, 1 Apr 2009 21:25:32 -0400 Subject: [rspec-users] Problem with Custom matcher and Blocks Message-ID: <000001c9b331$ec7e9d60$c57bd820$@com> Hi, I'm trying to write my first custom matcher. Here's a bit of my example group. describe "/contact/index" do include FormMatchers before(:each) do render 'contact/index' end it "should show the contact form" do response.should have_a_contact_form end describe "the contact form" do context "before it has been submitted" do it "should have a subject dropdown box" do response.should have_a_contact_form do |form| form.should have_a_subject_field end end # it "should have a subject dropdown box" # This should be failing it "should have a name field" do response.should have_a_contact_form do |form| form.should have_a_name_field end end # it "should have a name field" describe "the subject dropdown box" do it "should have a feedback option" do response.should have_a_contact_form do |form| form.should have_a_subject_field do |subject| subject.should have_selector('option', :content => 'Feedback') end end end # it "should have a feedback option" # Etc... end # describe "the subject dropdown box" end # context "before the form has been submitted" end # Describe "the contact form" end # describe "/contact/index" Right now, everything before the describe "the subject dropdown box" is passing, even though the one testing the name field should not because I've not added that field yet. When it gets to the describe block for the subject, I get: NoMethodError in '/contact/index the contact form before it has been submitted the subject dropdown box should have a blank option' undefined method `have_selector' for # The have_a_contact_form method is as follows: def have_a_contact_form &block have_a_form_with_id 'contact', &block end That calls a have_a_form_with_id method, which calls the haveAFormWithID class. module FormMatchers class HaveAFormWithID def initialize id, &block @id = id @block = block end def matches? response response.should have_selector('form#%s' % [@id]) do |form| !@block or @block.call form end end def description "have a form with id #{@id}" end def failure_message "expected to have a form with ID #{@id}" end def negative_failure_message "expected not to have a form with ID #{@id}" end end def have_a_form_with_id id, &block HaveAFormWithID.new id, &block end end Sorry for all the code. Again this is my first custom matcher, so I could be doing something very wrong. Any help much appreciated. Thanks, Brandon From aidy.lewis at googlemail.com Thu Apr 2 12:31:21 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 2 Apr 2009 17:31:21 +0100 Subject: [rspec-users] [cucumber] How to add a after failure hook? In-Reply-To: References: Message-ID: <7ac2300c0904020931i4beef06by4a9cd23201bcb4c6@mail.gmail.com> Hi Tim, I have used a custom formatter, if this is any help class ExceptionFormatter < Cucumber::Ast::Visitor def initialize(step_mother, io, options) super(step_mother) end def visit_feature_name(name) if name =~ /Feature:\s(.*)/i @name = $1 else @name = name end end def visit_exception(exception, status) exception_file = "#{File.dirname(__FILE__)}/#{@name}.html" open(exception_file, 'w') { |f| f << browser.html } end end Aidy On 01/04/2009, Tim Harper wrote: > Is currently a way to add a upon failure hook? I'd like to make it so that, > in the event of a failed assertion, Webrat will take the last requested page > and open it in a browser. > > Thanks :) > > Tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Thu Apr 2 13:38:53 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 02 Apr 2009 11:38:53 -0600 Subject: [rspec-users] [cucumber] How to add a after failure hook? In-Reply-To: <8d961d900904011635k2343c915s347fa61962f07d22@mail.gmail.com> References: <8d961d900904011635k2343c915s347fa61962f07d22@mail.gmail.com> Message-ID: <49D4F82D.7010901@benmabey.com> aslak hellesoy wrote: > > > 2009/4/2 Tim Harper > > > Is currently a way to add a upon failure hook? I'd like to make > it so that, in the event of a failed assertion, Webrat will take > the last requested page and open it in a browser. > > > http://wiki.github.com/aslakhellesoy/cucumber/hooks > |After do |scenario| > # currently no simple way to query scenario for status though :-( > end > | > Please open a ticket for this if you really need it. > > Aslak Convo has been moved to LH: https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/272-pick-up-failure-on-after-hook#ticket-272-2 -Ben > > > > Thanks :) > > 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 From phlip2005 at gmail.com Thu Apr 2 13:56:38 2009 From: phlip2005 at gmail.com (Phlip) Date: Thu, 02 Apr 2009 10:56:38 -0700 Subject: [rspec-users] a wiki to host Cuke & webrat? Message-ID: Would a wiki with these features interest anyone? - config.yaml points to your projects - serve, highlight, edit & run each Cucumber file - paint the tested website in into an iframe - update the iframe in realtime as the test runs I have researched how to do each of those items, and I could get them working very easily in a lite wiki using only Rails & Ajax. They would run on any platform, without special JS or plugins... -- Phlip http://www.zeroplayer.com/ From matt at mattwynne.net Thu Apr 2 15:55:06 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Apr 2009 20:55:06 +0100 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <000001c9b331$ec7e9d60$c57bd820$@com> References: <000001c9b331$ec7e9d60$c57bd820$@com> Message-ID: <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> On 2 Apr 2009, at 02:25, Brandon Olivares wrote: > Hi, > > I'm trying to write my first custom matcher. > > Here's a bit of my example group. > > describe "/contact/index" do > include FormMatchers > > before(:each) do > render 'contact/index' > end > > it "should show the contact form" do > response.should have_a_contact_form > end > > describe "the contact form" do > context "before it has been submitted" do > it "should have a subject dropdown box" do > response.should have_a_contact_form do |form| > form.should have_a_subject_field > end > end # it "should have a subject dropdown box" > > # This should be failing > it "should have a name field" do > response.should have_a_contact_form do |form| > form.should have_a_name_field > end > end # it "should have a name field" > > describe "the subject dropdown box" do > it "should have a feedback option" do > response.should have_a_contact_form do |form| > form.should have_a_subject_field do |subject| > subject.should have_selector('option', :content => > 'Feedback') > end > end > end # it "should have a feedback option" > > # Etc... > > end # describe "the subject dropdown box" > > end # context "before the form has been submitted" > > end # Describe "the contact form" > > end # describe "/contact/index" > > Right now, everything before the describe "the subject dropdown box" > is > passing, even though the one testing the name field should not > because I've > not added that field yet. > > When it gets to the describe block for the subject, I get: > > NoMethodError in '/contact/index the contact form before it has been > submitted the subject dropdown box should have a blank option' > undefined method `have_selector' for > # #have_selector is part of webrat. Have you required the appropriate files so that method is visible to your new matcher class? > The have_a_contact_form method is as follows: > > def have_a_contact_form &block > have_a_form_with_id 'contact', &block > end > > That calls a have_a_form_with_id method, which calls the > haveAFormWithID > class. > > module FormMatchers > > class HaveAFormWithID > > def initialize id, &block > @id = id > @block = block > end > > def matches? response > response.should have_selector('form#%s' % [@id]) do |form| > !@block or @block.call form > end > end > > def description > "have a form with id #{@id}" > end > > def failure_message > "expected to have a form with ID #{@id}" > end > > def negative_failure_message > "expected not to have a form with ID #{@id}" > end > > end > > def have_a_form_with_id id, &block > HaveAFormWithID.new id, &block > end > > end > > Sorry for all the code. Again this is my first custom matcher, so I > could be > doing something very wrong. > > Any help much appreciated. > > Thanks, > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users As a P.S. I hate to take the wind out of your sails here, but I was reflecting only today how, after 9 months of using RSpec to TDD our Rails app, we have massaged the view specs down to almost nothing. IMO 99% of the time you should be writing a Cucumber feature instead and leaving it at that. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From Peer.Allan at canadadrugs.com Thu Apr 2 16:12:37 2009 From: Peer.Allan at canadadrugs.com (Peer Allan) Date: Thu, 02 Apr 2009 15:12:37 -0500 Subject: [rspec-users] Rspec 1.2.2 unpacking Message-ID: Hello all, I am trying to unpack rspec 1.2.2 and rspec-rails 1.2.2 into my application. I have them included in the test.rb environment file with config.gem options as described on the Rspec github site. I can unpack rspec-rails without issue, but when I try to do rspec nothing happens. I mean that literally, it does nothing. No warnings, no errors and the gem is not in the vendor/gems folder. I tried running --trace and it was no help. $ rake gems RAILS_ENV=test - [R] rspec >= 1.2.0 - [F] rspec-rails >= 1.2.0 - [R] rspec = 1.2.2 - [I] rack >= 0.4.0 $ sudo rake gems:unpack GEM=rspec RAILS_ENV=test --trace ** Invoke gems:unpack (first_time) ** Invoke gems:install (first_time) ** Invoke gems:base (first_time) ** Execute gems:base ** Invoke environment (first_time) ** Execute environment ** Execute gems:install ** Execute gems:unpack $ ls -l vendor/gems/ total 0 drwxr-xr-x 16 pallan admin 544 2 Apr 13:05 rspec-rails-1.2.2 Does anyone have any idea how to debug this? Peer From lists at ruby-forum.com Thu Apr 2 16:14:16 2009 From: lists at ruby-forum.com (Matt Wynne) Date: Thu, 2 Apr 2009 22:14:16 +0200 Subject: [rspec-users] Running cucumber distributed across hardware In-Reply-To: References: <1AF4B59F-AF4D-48D3-AD8C-41813B9D8D1B@railsnewbie.com> Message-ID: <4995f93a526ab48955e6de65444aa619@ruby-forum.com> Bryan Helmkamp wrote: > On Mon, Sep 22, 2008 at 9:57 PM, Scott Taylor > wrote: >> Let me know if you come up with something - I'd be interested in >> contributing to such a project. > > I started working on a project I'm calling Testjour to solve this at > http://github.com/brynary/testjour/tree/master . > > It's not at all usable for general consumption, but there's a base to > hack on. Here's what I have working: > > * Using Bonjour autodiscovery of available test running slaves > * Sending feature files to be run and results back and forth over DRb > * Setting up and tearing down new MySQL databases for each test run to > avoid conflicts > > There's plenty that needs to be done before it's really usable, > specifically: > > * Adding RSync support to transfer code to worker servers > * Daemonizing/detaching the slave process > * Adding logging and PID tracking > * And more in the TODO.txt > > If I can get this running well, we're going to purchase Mac Mini build > nodes for the office. My (ambitious) goal is to cut the story run time > on a developer machine from 12 minutes down to two. > > Example from two Terminal windows: > > $ testjour_slave > Broadcasting: Ready to run tests under name 'bhelmkamp' on port 51814... > > Running tests from queue druby://Fozzie.local:51818 on PID 16482 > > ---------------------- > > $ testjour_run features/authentication/authenticaton.feature > ....F_... > > 1) > BOOM > /Users/bhelmkamp/p/weplay/features/steps/authentication.rb:10:in `When > "I login"' > /Users/bhelmkamp/p/weplay/features/authentication/authenticaton.feature:13:in > `When I login' I'm resurrecting this thread. This is becoming a major issue for us, and we have some allocated time coming into play soon to work on a solution. What's the current state of the art for distributed test runs? Is anybody doing it for real? As part of the build or before check-in? Where would be the best place to contribute effort? Testjour looks the most likely... Any others out there? cheers, Matt -- Posted via http://www.ruby-forum.com/. From timcharper at gmail.com Thu Apr 2 16:16:55 2009 From: timcharper at gmail.com (Tim Harper) Date: Thu, 2 Apr 2009 14:16:55 -0600 Subject: [rspec-users] [cucumber] How to add a after failure hook? In-Reply-To: <7ac2300c0904020931i4beef06by4a9cd23201bcb4c6@mail.gmail.com> References: <7ac2300c0904020931i4beef06by4a9cd23201bcb4c6@mail.gmail.com> Message-ID: Aidy, This is a great work around, being disadvantaged only by having to specify a different formatter :) Still, a general purpose way of hooking in to the after feature fail would be premium. Thanks for opening the ticket. Tim On Thu, Apr 2, 2009 at 10:31 AM, aidy lewis wrote: > Hi Tim, > > I have used a custom formatter, if this is any help > > class ExceptionFormatter < Cucumber::Ast::Visitor > > def initialize(step_mother, io, options) > super(step_mother) > end > > def visit_feature_name(name) > if name =~ /Feature:\s(.*)/i > @name = $1 > else > @name = name > end > end > > def visit_exception(exception, status) > exception_file = "#{File.dirname(__FILE__)}/#{@name}.html" > open(exception_file, 'w') { |f| f << browser.html } > end > end > > Aidy > > On 01/04/2009, Tim Harper wrote: > > Is currently a way to add a upon failure hook? I'd like to make it so > that, > > in the event of a failed assertion, Webrat will take the last requested > page > > and open it in a browser. > > > > Thanks :) > > > > 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: From joe at josephwilk.net Thu Apr 2 16:21:51 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Thu, 02 Apr 2009 21:21:51 +0100 Subject: [rspec-users] Running cucumber distributed across hardware In-Reply-To: <4995f93a526ab48955e6de65444aa619@ruby-forum.com> References: <1AF4B59F-AF4D-48D3-AD8C-41813B9D8D1B@railsnewbie.com> <4995f93a526ab48955e6de65444aa619@ruby-forum.com> Message-ID: <49D51E5F.10302@josephwilk.net> Matt Wynne wrote: > Bryan Helmkamp wrote: > >> On Mon, Sep 22, 2008 at 9:57 PM, Scott Taylor >> wrote: >> >>> Let me know if you come up with something - I'd be interested in >>> contributing to such a project. >>> >> I started working on a project I'm calling Testjour to solve this at >> http://github.com/brynary/testjour/tree/master . >> >> It's not at all usable for general consumption, but there's a base to >> hack on. Here's what I have working: >> >> * Using Bonjour autodiscovery of available test running slaves >> * Sending feature files to be run and results back and forth over DRb >> * Setting up and tearing down new MySQL databases for each test run to >> avoid conflicts >> >> There's plenty that needs to be done before it's really usable, >> specifically: >> >> * Adding RSync support to transfer code to worker servers >> * Daemonizing/detaching the slave process >> * Adding logging and PID tracking >> * And more in the TODO.txt >> >> If I can get this running well, we're going to purchase Mac Mini build >> nodes for the office. My (ambitious) goal is to cut the story run time >> on a developer machine from 12 minutes down to two. >> >> Example from two Terminal windows: >> >> $ testjour_slave >> Broadcasting: Ready to run tests under name 'bhelmkamp' on port 51814... >> >> Running tests from queue druby://Fozzie.local:51818 on PID 16482 >> >> ---------------------- >> >> $ testjour_run features/authentication/authenticaton.feature >> ....F_... >> >> 1) >> BOOM >> /Users/bhelmkamp/p/weplay/features/steps/authentication.rb:10:in `When >> "I login"' >> /Users/bhelmkamp/p/weplay/features/authentication/authenticaton.feature:13:in >> `When I login' >> > > I'm resurrecting this thread. This is becoming a major issue for us, and > we have some allocated time coming into play soon to work on a solution. > > What's the current state of the art for distributed test runs? Is > anybody doing it for real? As part of the build or before check-in? > Where would be the best place to contribute effort? Testjour looks the > most likely... If you are thinking Selenium then there is the Selenium grid direction. > Any others out there? > > cheers, > Matt > -- Joseph Wilk http://blog.josephwilk.net From matt at mattwynne.net Thu Apr 2 17:01:34 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Apr 2009 22:01:34 +0100 Subject: [rspec-users] a wiki to host Cuke & webrat? In-Reply-To: References: Message-ID: On 2 Apr 2009, at 18:56, Phlip wrote: > Would a wiki with these features interest anyone? > > - config.yaml points to your projects > - serve, highlight, edit & run each Cucumber file > - paint the tested website in into an iframe > - update the iframe in realtime as the test runs > > I have researched how to do each of those items, and I could get > them working very easily in a lite wiki using only Rails & Ajax. > They would run on any platform, without special JS or plugins... This sounds a lot like something I've been thinking off, although I hadn't got onto the idea of a wiki function for editing - just been thinking about a HTTP/HTML interface for Cucumber test runs. I think Aslak had something in mind that was lighter-weight than Rails, built into Cucumber, though last time I looked at the 0.2 code it didn't really lend itself to building other UIs than the console one - the logic for executing the test run is currently quite coupled up with the console UI stuff I think. The really nice thing (IMO) would be to avoid having to re-load a rails env for the SUT every time, so you'd start to get the same responsive feel as you get when you just code & fix in the browser in development mode. Anyway I've been thinking about this quite a bit and I'm definitely interested in the concept. I've also pondered on the idea of a 'unified' test run API for RSpec and Cucumber so you could use the same HTML UI / HTTP API to run both sets of tests. In my mind it would look a bit like the good old JUnit test runner, but obviously sexier. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Thu Apr 2 17:02:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Apr 2009 22:02:50 +0100 Subject: [rspec-users] Running cucumber distributed across hardware In-Reply-To: <49D51E5F.10302@josephwilk.net> References: <1AF4B59F-AF4D-48D3-AD8C-41813B9D8D1B@railsnewbie.com> <4995f93a526ab48955e6de65444aa619@ruby-forum.com> <49D51E5F.10302@josephwilk.net> Message-ID: On 2 Apr 2009, at 21:21, Joseph Wilk wrote: > If you are thinking Selenium then there is the Selenium grid > direction. Thanks. Right now we're just running against the rails integration session using Webrat, but that does definitely look useful for when we get more Ajax heavy. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Thu Apr 2 17:20:28 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 2 Apr 2009 16:20:28 -0500 Subject: [rspec-users] Rspec 1.2.2 unpacking In-Reply-To: References: Message-ID: <57c63afe0904021420y43de67f7lfe1ee8e35f1c0f08@mail.gmail.com> On Thu, Apr 2, 2009 at 3:12 PM, Peer Allan wrote: > Hello all, > > I am trying to unpack rspec 1.2.2 and rspec-rails 1.2.2 into my application. > I have them included in the test.rb environment file with config.gem options > as described on the Rspec github site. > > I can unpack rspec-rails without issue, but when I try to do rspec nothing > happens. ?I mean that literally, it does nothing. ?No warnings, no errors > and the gem is not in the vendor/gems folder. ?I tried running --trace and > it was no help. > > $ rake gems RAILS_ENV=test > ?- [R] rspec >= 1.2.0 > ?- [F] rspec-rails >= 1.2.0 > ? ?- [R] rspec = 1.2.2 > ? ?- [I] rack >= 0.4.0 > $ sudo rake gems:unpack GEM=rspec RAILS_ENV=test --trace > ** Invoke gems:unpack (first_time) > ** Invoke gems:install (first_time) > ** Invoke gems:base (first_time) > ** Execute gems:base > ** Invoke environment (first_time) > ** Execute environment > ** Execute gems:install > ** Execute gems:unpack > $ ls -l vendor/gems/ > total 0 > drwxr-xr-x ?16 pallan ?admin ?544 ?2 Apr 13:05 rspec-rails-1.2.2 > > Does anyone have any idea how to debug this? You probably have an old version of lib/tasks/rspec.rake, which requires 'spec' (the new one only does so when you try to run a spec task). Try removing that first, then unpack, then "script/generate rspec" to regenerate the new rake file. Cheers, David > > Peer > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Thu Apr 2 17:20:18 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Thu, 2 Apr 2009 17:20:18 -0400 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> Message-ID: <003001c9b3d8$d463d4f0$7d2b7ed0$@com> Hi, > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Matt Wynne > Sent: Thursday, April 02, 2009 3:55 PM > To: rspec-users > Subject: Re: [rspec-users] Problem with Custom matcher and Blocks > > > #have_selector is part of webrat. Have you required the appropriate > files so that method is visible to your new matcher class? > Oops, forgot that. OK, so I added: Require 'webrat/core/matchers/have_selector' On the first line, and directly within the class: Include Webrat::Matchers Is this correct? OK, so now all 16 examples pass. But one of them should be failing -- the one with the name. Do you see any reason that is still passing? Again my matches? Method is as follows: def matches? response response.should have_selector('form#%s' % [@id]) do |form| !@block or @block.call form end end > As a P.S. I hate to take the wind out of your sails here, but I was > reflecting only today how, after 9 months of using RSpec to TDD our > Rails app, we have massaged the view specs down to almost nothing. IMO > 99% of the time you should be writing a Cucumber feature instead and > leaving it at that. Yeah, I'm really confused about that. I thought I've read from some people that they recommend doing Cucumber, but also view specs, and controller and model specs to test the different layers. Others say they don't test the view with specs, so I don't know. I'm doing it for now and see how I feel about it. Thanks, Brandon From zach.dennis at gmail.com Thu Apr 2 17:21:40 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 2 Apr 2009 17:21:40 -0400 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> Message-ID: <85d99afe0904021421s7a59d5eat92399bc37a1b59d4@mail.gmail.com> On Thu, Apr 2, 2009 at 3:55 PM, Matt Wynne wrote: > > On 2 Apr 2009, at 02:25, Brandon Olivares wrote: > >> Hi, >> >> I'm trying to write my first custom matcher. >> >> Here's a bit of my example group. >> >> describe "/contact/index" do >> ?include FormMatchers >> >> ?before(:each) do >> ? render 'contact/index' >> ?end >> >> ?it "should show the contact form" do >> ? response.should have_a_contact_form >> ?end >> >> ?describe "the contact form" do >> ? context "before it has been submitted" do >> ? ? it "should have a subject dropdown box" do >> ? ? ? response.should have_a_contact_form do |form| >> ? ? ? ? form.should have_a_subject_field >> ? ? ? end >> ? ? end # it "should have a subject dropdown box" >> >> ? ? # This should be failing >> ? ? it "should have a name field" do >> ? ? ? response.should have_a_contact_form do |form| >> ? ? ? ? form.should have_a_name_field >> ? ? ? end >> ? ? end # it "should have a name field" >> >> ? ? describe "the subject dropdown box" do >> ? ? ? it "should have a feedback option" do >> ? ? ? ? response.should have_a_contact_form do |form| >> ? ? ? ? ? form.should have_a_subject_field do |subject| >> ? ? ? ? ? ? subject.should have_selector('option', :content => 'Feedback') >> ? ? ? ? ? end >> ? ? ? ? end >> ? ? ? end # it "should have a feedback option" >> >> ? ? ? # Etc... >> >> ? ? end # describe "the subject dropdown box" >> >> ? end # context "before the form has been submitted" >> >> ?end # Describe "the contact form" >> >> end # describe "/contact/index" >> >> Right now, everything before the describe "the subject dropdown box" is >> passing, even though the one testing the name field should not because >> I've >> not added that field yet. >> >> When it gets to the describe block for the subject, I get: >> >> NoMethodError in '/contact/index the contact form before it has been >> submitted the subject dropdown box should have a blank option' >> undefined method `have_selector' for >> # > > #have_selector is part of webrat. Have you required the appropriate files so > that method is visible to your new matcher class? > >> The have_a_contact_form method is as follows: >> >> ?def have_a_contact_form &block >> ? have_a_form_with_id 'contact', &block >> ?end >> >> That calls a have_a_form_with_id method, which calls the haveAFormWithID >> class. >> >> module FormMatchers >> >> ?class HaveAFormWithID >> >> ? def initialize id, &block >> ? ? @id = id >> ? ? @block = block >> ? end >> >> ? def matches? response >> ? ? response.should have_selector('form#%s' % [@id]) do |form| >> ? ? ? !@block or @block.call form >> ? ? end >> ? end >> >> ? def description >> ? ? "have a form with id #{@id}" >> ? end >> >> ? def failure_message >> ? ? "expected to have a form with ID #{@id}" >> ? end >> >> ? def negative_failure_message >> ? ? "expected not to have a form with ID #{@id}" >> ? end >> >> ?end >> >> ?def have_a_form_with_id id, &block >> ? HaveAFormWithID.new id, &block >> ?end >> >> end >> >> Sorry for all the code. Again this is my first custom matcher, so I could >> be >> doing something very wrong. >> >> Any help much appreciated. >> >> Thanks, >> Brandon >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > As a P.S. I hate to take the wind out of your sails here, but I was > reflecting only today how, after 9 months of using RSpec to TDD our Rails > app, we have massaged the view specs down to almost nothing. IMO 99% of the > time you should be writing a Cucumber feature instead and leaving it at > that. > To share, one project I'm on has had scenarios provided by the customer and it is an app with a lot of business rules and the system contains many components (not a typical Rails CRUD app). The scenarios themselves focus on high level behaviour. We've used view specs to drive out the views, and we've only placed the minimal code in the steps to use the system to prove out the behaviour. Relying solely on scenarios and step definitions did not work well for the short time it was tried. On another project that is entirely different the scenarios themselves actually fleshed out the requirements of the UI. But the type of app is vastly different than the first and it just made sense. While I don't agree that 99% is a rule of thumb I can see where different apps have different needs, and some will naturally drive out more of the UI from the scenarios, whereas others will have details to the UI which may not be the driving force of the feature and its scenarios, but they need to exist. I know that style comes into play at some point to. There are some folks who are cool with putting all view stuff in step definitions and there are folks who prefer to have minimally sized step definitions with the details in specs. I can't say who's right or wrong, but I know where my comfort level is. Matt, can you say where you gauge your app? - Are there many little scenarios covering the details of the page? - Are the scenarios comprised of many steps which look at all aspects of the page? - Are the step definitions detail oriented? e.g.: looking at the project looks at all of the pieces of information it should be displaying I'm really interested in this topic as I think I've seen when Cucumber is relied on too much and I've definitely seen where it's been relied on too little. So naturally I'm interested to find out more about people's projects to help gauge where things fall on the continuum, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From programmer2188 at gmail.com Thu Apr 2 17:56:27 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Thu, 2 Apr 2009 17:56:27 -0400 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> Message-ID: <003a01c9b3dd$e081b130$a1851390$@com> Hi again, Well, I looked in the Webrat matchers code, and saw they also have a block argument to the matches? Method, though I don't know why. So I copied what they did there, and got a bit more informative output. Unfortunately now I have more errors. Before I continue, do you know why I have to include &block as the second argument to `matches?'? So now it won't recognize my subject field. The error is something like this: '/contact/index the contact form before it has been submitted the subject dropdown box should have a feedback option' FAILED expected following output to contain a tag:
./spec/views/contact/index.html.erb_spec.rb:39: /home/Brandon/projects/bartenders-to-go/spec/views/matchers/form_matchers/ha ve_a_form_with_id.rb:16:in `call' /home/Brandon/projects/bartenders-to-go/spec/views/matchers/form_matchers/ha ve_a_form_with_id.rb:16:in `matches?' /home/Brandon/projects/bartenders-to-go/vendor/gems/webrat-0.4.3/lib/webrat/ core/matchers/have_xpath.rb:21:in `call' /home/Brandon/projects/bartenders-to-go/vendor/gems/webrat-0.4.3/lib/webrat/ core/matchers/have_xpath.rb:21:in `matches?' /home/Brandon/projects/bartenders-to-go/spec/views/matchers/form_matchers/ha ve_a_form_with_id.rb:15:in `matches?' ./spec/views/contact/index.html.erb_spec.rb:38: That example is something like: it "should have a feedback option" do response.should have_a_contact_form do |form| form.should have_selector('select', :id => 'subject') do |subject| subject.should have_selector('option', :content => 'Feedback') end end end # it "should have a feedback option" Thanks for any help. Brandon From matt at mattwynne.net Thu Apr 2 18:03:36 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Apr 2009 23:03:36 +0100 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <003001c9b3d8$d463d4f0$7d2b7ed0$@com> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> <003001c9b3d8$d463d4f0$7d2b7ed0$@com> Message-ID: <4A715770-E63E-4021-918C-CDB22401BA44@mattwynne.net> On 2 Apr 2009, at 22:20, Brandon Olivares wrote: > Hi, > >> -----Original Message----- >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> bounces at rubyforge.org] On Behalf Of Matt Wynne >> Sent: Thursday, April 02, 2009 3:55 PM >> To: rspec-users >> Subject: Re: [rspec-users] Problem with Custom matcher and Blocks >> >> >> #have_selector is part of webrat. Have you required the appropriate >> files so that method is visible to your new matcher class? >> > > Oops, forgot that. > > OK, so I added: > > Require 'webrat/core/matchers/have_selector' > > On the first line, and directly within the class: > > Include Webrat::Matchers > > Is this correct? Think so. Did the error go away? > OK, so now all 16 examples pass. But one of them should be failing > -- the > one with the name. Do you see any reason that is still passing? > > Again my matches? Method is as follows: > > def matches? response > response.should have_selector('form#%s' % [@id]) do |form| > !@block or @block.call form > end > end I don't think you want to be using #should here. If that fails it will raise an exception but the expected behaviour of a matcher is to return true / false from #matches? so that will be one problem you have. Try just hard-coding the #matches? method to return false and see if you get one of your tests to fail. What are you imagining that #response is going to return in this instance? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Thu Apr 2 18:18:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Apr 2009 23:18:50 +0100 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <85d99afe0904021421s7a59d5eat92399bc37a1b59d4@mail.gmail.com> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> <85d99afe0904021421s7a59d5eat92399bc37a1b59d4@mail.gmail.com> Message-ID: On 2 Apr 2009, at 22:21, Zach Dennis wrote: > Matt, can you say where you gauge your app? > - Are there many little scenarios covering the details of the page? > - Are the scenarios comprised of many steps which look at all aspects > of the page? > - Are the step definitions detail oriented? e.g.: looking at the > project looks at all of the pieces of information it should be > displaying > > I'm really interested in this topic as I think I've seen when Cucumber > is relied on too much and I've definitely seen where it's been relied > on too little. So naturally I'm interested to find out more about > people's projects to help gauge where things fall on the continuum, What we have are a relatively small number of pages that have a lot of different stuff on them, and that stuff depends a lot on the context. So for example, a Concert page will show media about that concert, but we juggle the media around depending on what there happens to be - we'll prefer to show a poster if someone has uploaded one, but otherwise we'll show a photo if there's one of those. Then, depending on the aspect (landscape / portrait) of the photo, we'll use a different grid layout for the media and show different numbers of them. All these little rules get complex pretty quickly, and there are two advantages I've found for expressing them in Cucumber. (1) They're super easy to read for both the CSS / markup guy who fiddles with the layout, the product owner, and anyone else who wants to get a handle on them (2) They're totally de-coupled from the implementation, which means I can start with some ugly thing that filters and juggles arrays, while we figure out exactly how we want it to work, then later optimize it into a database query once the requirements have solidified. This is the key thing for me about driving everything out from acceptance tests - you get absolute flexibility about your implementation with the confidence to know you can change whatever you like and you're still covered. The trade-off I guess is the length of the build, and possibly the maintainability of the test suite if people get sloppy about keeping it tidy. The first is definitely an issue for us now, but the second is not really a problem at all for us as yet - 910 scenarios and counting..! :) So to answer your questions, we would parts of the behaviour of each page on the site as different features - so I guess this maps to what you call 'many little scenarios covering the details of the page' If you email me directly I'll send you a beta invite and you can take a look for yourself :) Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Thu Apr 2 18:22:15 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Apr 2009 23:22:15 +0100 Subject: [rspec-users] Thought on a quality metric for Cucumber test suites Message-ID: <1C411C9A-3057-44EB-8968-D25E93AE7F28@mattwynne.net> Writing another post to Zach I had a thought about a quality metric for Cucumber suites: Ratio of #steps executed / #step matchers For example, if you can run 100 steps with only 10 step matchers, you have a nice low ratio of 100 / 10, meaning you are getting loads of testing done with only a few step matchers to maintain. WDYT? Is there a way to pull out the stat of the number of step matchers defined? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From ben at benmabey.com Thu Apr 2 18:43:36 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 02 Apr 2009 16:43:36 -0600 Subject: [rspec-users] Thought on a quality metric for Cucumber test suites In-Reply-To: <1C411C9A-3057-44EB-8968-D25E93AE7F28@mattwynne.net> References: <1C411C9A-3057-44EB-8968-D25E93AE7F28@mattwynne.net> Message-ID: <49D53F98.6020908@benmabey.com> Matt Wynne wrote: > Writing another post to Zach I had a thought about a quality metric > for Cucumber suites: Ratio of #steps executed / #step matchers > > For example, if you can run 100 steps with only 10 step matchers, you > have a nice low ratio of 100 / 10, meaning you are getting loads of > testing done with only a few step matchers to maintain. > > WDYT? I don't think a metric like that would be enough. That doesn't take into account what type of steps these are. If you are aiming for extremely high reuse you are probably going to end up with extremely imperative style scenarios.. Which *could* be a bad thing. So I would be wary of using any such calculation to determine a "quality". With something like Cucumber, the quality is really in the eye of the customer. :) (I may be out of context however since I haven't read the other thread.. I will go do that now..) If you are trying to get a metric then I would say you would need to also use the number of scenarios... What if you have 100 steps, 10 step matchers, and *1* scenario? Would you really want such a scenario in your app? :p > > Is there a way to pull out the stat of the number of step matchers > defined? Use the usage formatter.... -Ben From programmer2188 at gmail.com Thu Apr 2 19:04:28 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Thu, 2 Apr 2009 19:04:28 -0400 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <4A715770-E63E-4021-918C-CDB22401BA44@mattwynne.net> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> <003001c9b3d8$d463d4f0$7d2b7ed0$@com> <4A715770-E63E-4021-918C-CDB22401BA44@mattwynne.net> Message-ID: <005001c9b3e7$6158b2f0$240a18d0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Matt Wynne > Sent: Thursday, April 02, 2009 6:04 PM > To: rspec-users > Subject: Re: [rspec-users] Problem with Custom matcher and Blocks > > > I don't think you want to be using #should here. If that fails it will > raise an exception but the expected behaviour of a matcher is to > return true / false from #matches? so that will be one problem you > have. Try just hard-coding the #matches? method to return false and > see if you get one of your tests to fail. > > What are you imagining that #response is going to return in this > instance? Oh OK. Well what I want is to be able to test if that form exists on the page. So how would you recommend going about it otherwise? I tried putting a begin ... end block around it, but that doesn't seem to work either. def matches? response, &block @block ||= block begin response.should have_selector('form#%s' % [@id]) do |form| !@block or @block.call form end rescue false else true end end It still has an error, but now it's covered up by my failure_message. I output $! As a test, though, and it's the same error. Brandon From cernenus at gmail.com Wed Apr 1 14:34:52 2009 From: cernenus at gmail.com (Chuck van der Linden) Date: Wed, 1 Apr 2009 11:34:52 -0700 Subject: [rspec-users] RSpec makes me want to write better code Message-ID: <9f9c63d60904011134h303e5af2v99b2f0f25df28685@mail.gmail.com> dammit me be moron, forgot to edit subject On Wed, Apr 1, 2009 at 11:33 AM, Chuck van der Linden wrote: > > > >> Date: Wed, 1 Apr 2009 17:24:21 +0100 >> From: aidy lewis >> Subject: Re: [rspec-users] RSpec makes me want to write better code >> To: rspec-users >> Message-ID: >> <7ac2300c0904010924o65996d8co404aef578831bfc1 at mail.gmail.com> >> Content-Type: text/plain; charset=ISO-8859-1 >> >> Hi David >> >> 2009/4/1 David Chelimsky : >> >> >...that if you're >> > proficient in Ruby and you're pairing with a reasonably skilled >> > developer in any C-based language like C Sharp, the language barrier >> > will be fairly small. There are some hoops, like meta-programming, >> > blocks and iterators, but not too many beyond that. I don't mean that >> > to be flippant. Even if the dev has zero experience with these >> > concepts, he really doesn't need to understand them in order to >> > progress if you're pairing. >> > >> >> When you go to Harversters they ask 'have you been here before?'. >> Maybe not, but I can eat with a knife and fork. >> >> However, - I will put myself on a limb - some programmers have been >> conditioned by MS on the practices and uses of tools. No intellisense, >> no visual debugger, no static assignment or compilation, a command >> line!*@? Many are just not happy with it. >> >> Aidy >> > Aidy, if they need the security blanket of the MS tools and Visual Studio > IDE you could always suggest the Ruby in Steel product from the > SapphireSteel people. it's not free, but compared to the price of VSTS > it's dirt cheap. > > I've been playing with it (because I'm QA in a .net shop) and so far I'm > pretty happy with it. it's got all the stuff to make those devs comfortable > (debugger, intellisense) even if you most likely don't really need those > things most of the time for working with stuff like Ruby and Watir. (it's > also got a little IRB console window, which is handy) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cernenus at gmail.com Wed Apr 1 14:33:12 2009 From: cernenus at gmail.com (Chuck van der Linden) Date: Wed, 1 Apr 2009 11:33:12 -0700 Subject: [rspec-users] rspec-users Digest, Vol 34, Issue 3 In-Reply-To: References: Message-ID: <9f9c63d60904011133y4afeb73fsc1df94d49031efb4@mail.gmail.com> > Date: Wed, 1 Apr 2009 17:24:21 +0100 > From: aidy lewis > Subject: Re: [rspec-users] RSpec makes me want to write better code > To: rspec-users > Message-ID: > <7ac2300c0904010924o65996d8co404aef578831bfc1 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi David > > 2009/4/1 David Chelimsky : > > >...that if you're > > proficient in Ruby and you're pairing with a reasonably skilled > > developer in any C-based language like C Sharp, the language barrier > > will be fairly small. There are some hoops, like meta-programming, > > blocks and iterators, but not too many beyond that. I don't mean that > > to be flippant. Even if the dev has zero experience with these > > concepts, he really doesn't need to understand them in order to > > progress if you're pairing. > > > > When you go to Harversters they ask 'have you been here before?'. > Maybe not, but I can eat with a knife and fork. > > However, - I will put myself on a limb - some programmers have been > conditioned by MS on the practices and uses of tools. No intellisense, > no visual debugger, no static assignment or compilation, a command > line!*@? Many are just not happy with it. > > Aidy > Aidy, if they need the security blanket of the MS tools and Visual Studio IDE you could always suggest the Ruby in Steel product from the SapphireSteel people. it's not free, but compared to the price of VSTS it's dirt cheap. I've been playing with it (because I'm QA in a .net shop) and so far I'm pretty happy with it. it's got all the stuff to make those devs comfortable (debugger, intellisense) even if you most likely don't really need those things most of the time for working with stuff like Ruby and Watir. (it's also got a little IRB console window, which is handy) -------------- next part -------------- An HTML attachment was scrubbed... URL: From Peer.Allan at canadadrugs.com Fri Apr 3 09:35:22 2009 From: Peer.Allan at canadadrugs.com (Peer Allan) Date: Fri, 03 Apr 2009 08:35:22 -0500 Subject: [rspec-users] Rspec 1.2.2 unpacking In-Reply-To: <57c63afe0904021420y43de67f7lfe1ee8e35f1c0f08@mail.gmail.com> Message-ID: Thanks for the advice. I had run the updated generator, but it must have been reverted at some point. I did it again and followed your instructions, but I am experiencing the same problem. I suspect that some of the custom code we have that is using rspec is getting in the way. If I can find out what it is I will let you know. Thanks! Peer Allan Development Team Lead, e-Business CanadaDrugs.com 24 Terracon Place Winnipeg, MB, Canada R2J 4G7 Phone: (204) 654-7951 Fax: (204) 654-7910 www.canadadrugs.com > From: David Chelimsky > Reply-To: rspec-users > Date: Thu, 2 Apr 2009 16:20:28 -0500 > To: rspec-users > Subject: Re: [rspec-users] Rspec 1.2.2 unpacking > > On Thu, Apr 2, 2009 at 3:12 PM, Peer Allan wrote: >> Hello all, >> >> I am trying to unpack rspec 1.2.2 and rspec-rails 1.2.2 into my application. >> I have them included in the test.rb environment file with config.gem options >> as described on the Rspec github site. >> >> I can unpack rspec-rails without issue, but when I try to do rspec nothing >> happens. ?I mean that literally, it does nothing. ?No warnings, no errors >> and the gem is not in the vendor/gems folder. ?I tried running --trace and >> it was no help. >> >> $ rake gems RAILS_ENV=test >> ?- [R] rspec >= 1.2.0 >> ?- [F] rspec-rails >= 1.2.0 >> ? ?- [R] rspec = 1.2.2 >> ? ?- [I] rack >= 0.4.0 >> $ sudo rake gems:unpack GEM=rspec RAILS_ENV=test --trace >> ** Invoke gems:unpack (first_time) >> ** Invoke gems:install (first_time) >> ** Invoke gems:base (first_time) >> ** Execute gems:base >> ** Invoke environment (first_time) >> ** Execute environment >> ** Execute gems:install >> ** Execute gems:unpack >> $ ls -l vendor/gems/ >> total 0 >> drwxr-xr-x ?16 pallan ?admin ?544 ?2 Apr 13:05 rspec-rails-1.2.2 >> >> Does anyone have any idea how to debug this? > > You probably have an old version of lib/tasks/rspec.rake, which > requires 'spec' (the new one only does so when you try to run a spec > task). Try removing that first, then unpack, then "script/generate > rspec" to regenerate the new rake file. > > Cheers, > David > >> >> Peer >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Apr 3 11:03:45 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 3 Apr 2009 10:03:45 -0500 Subject: [rspec-users] Rspec 1.2.2 unpacking In-Reply-To: References: <57c63afe0904021420y43de67f7lfe1ee8e35f1c0f08@mail.gmail.com> Message-ID: <57c63afe0904030803u7a7c5799u6d3e316b7e74f4a@mail.gmail.com> On Fri, Apr 3, 2009 at 8:35 AM, Peer Allan wrote: > Thanks for the advice. ?I had run the updated generator, but it must have > been reverted at some point. ?I did it again and followed your instructions, > but I am experiencing the same problem. ?I suspect that some of the custom > code we have that is using rspec is getting in the way. ?If I can find out > what it is I will let you know. Thanks! OK - just a hint - look for any rake files or files that they require that require 'spec' in them. > > Peer Allan > Development Team Lead, e-Business > > CanadaDrugs.com > 24 ?Terracon Place > Winnipeg, MB, Canada > R2J ?4G7 > > Phone: (204) 654-7951 > Fax: ?(204) 654-7910 > www.canadadrugs.com > > > >> From: David Chelimsky >> Reply-To: rspec-users >> Date: Thu, 2 Apr 2009 16:20:28 -0500 >> To: rspec-users >> Subject: Re: [rspec-users] Rspec 1.2.2 unpacking >> >> On Thu, Apr 2, 2009 at 3:12 PM, Peer Allan wrote: >>> Hello all, >>> >>> I am trying to unpack rspec 1.2.2 and rspec-rails 1.2.2 into my application. >>> I have them included in the test.rb environment file with config.gem options >>> as described on the Rspec github site. >>> >>> I can unpack rspec-rails without issue, but when I try to do rspec nothing >>> happens. ?I mean that literally, it does nothing. ?No warnings, no errors >>> and the gem is not in the vendor/gems folder. ?I tried running --trace and >>> it was no help. >>> >>> $ rake gems RAILS_ENV=test >>> ?- [R] rspec >= 1.2.0 >>> ?- [F] rspec-rails >= 1.2.0 >>> ? ?- [R] rspec = 1.2.2 >>> ? ?- [I] rack >= 0.4.0 >>> $ sudo rake gems:unpack GEM=rspec RAILS_ENV=test --trace >>> ** Invoke gems:unpack (first_time) >>> ** Invoke gems:install (first_time) >>> ** Invoke gems:base (first_time) >>> ** Execute gems:base >>> ** Invoke environment (first_time) >>> ** Execute environment >>> ** Execute gems:install >>> ** Execute gems:unpack >>> $ ls -l vendor/gems/ >>> total 0 >>> drwxr-xr-x ?16 pallan ?admin ?544 ?2 Apr 13:05 rspec-rails-1.2.2 >>> >>> Does anyone have any idea how to debug this? >> >> You probably have an old version of lib/tasks/rspec.rake, which >> requires 'spec' (the new one only does so when you try to run a spec >> task). Try removing that first, then unpack, then "script/generate >> rspec" to regenerate the new rake file. >> >> Cheers, >> David >> >>> >>> Peer >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Fri Apr 3 12:04:56 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 3 Apr 2009 12:04:56 -0400 Subject: [rspec-users] [ANN] BDD w/Rails class in June Message-ID: <85d99afe0904030904o2fcae6eaq5e4bcf884c72aed9@mail.gmail.com> I apologize in advanced if this seems like a shameless plug, but it feels like an appropriate place to announce it. The first week of June I'm going to teaching a class on BDD w/Rails in sunny west Michigan: Announcement - http://mutuallyhuman.com/2009/4/3/bdd-with-rails-class Course - http://ideafoundry.info/behavior-driven-development Happy rubying, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Fri Apr 3 13:32:45 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 3 Apr 2009 19:32:45 +0200 Subject: [rspec-users] [ANN] BDD w/Rails class in June In-Reply-To: <85d99afe0904030904o2fcae6eaq5e4bcf884c72aed9@mail.gmail.com> References: <85d99afe0904030904o2fcae6eaq5e4bcf884c72aed9@mail.gmail.com> Message-ID: <8d961d900904031032j54668bb3rfe1d0d02bad1e910@mail.gmail.com> On Fri, Apr 3, 2009 at 6:04 PM, Zach Dennis wrote: > I apologize in advanced if this seems like a shameless plug, but it > feels like an appropriate place to announce it. The first week of June > I'm going to teaching a class on BDD w/Rails in sunny west Michigan: > > Announcement - http://mutuallyhuman.com/2009/4/3/bdd-with-rails-class > Course - http://ideafoundry.info/behavior-driven-development > This looks great Zach. I'd love to go myself! :-) Good luck with it! Aslak > > Happy rubying, > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgoodsen at radsoft.com Fri Apr 3 14:22:32 2009 From: jgoodsen at radsoft.com (John Goodsen) Date: Fri, 3 Apr 2009 14:22:32 -0400 Subject: [rspec-users] a wiki to host Cuke & webrat? In-Reply-To: References: Message-ID: this was my vision with rcumber - I haven't worked on it for a few months, but it's basically a rails plugin that provides a web interface to edit and run cucumber tests.... I'd love some help and ideas from others to take this to a more universally usable tool - we use it right now on 1 project. rcumber is at http://github.com/jgoodsen/rcumber/tree/master John On Thu, Apr 2, 2009 at 1:56 PM, Phlip wrote: > Would a wiki with these features interest anyone? > > - config.yaml points to your projects > - serve, highlight, edit & run each Cucumber file > - paint the tested website in into an iframe > - update the iframe in realtime as the test runs > > I have researched how to do each of those items, and I could get them > working very easily in a lite wiki using only Rails & Ajax. They would run > on any platform, without special JS or plugins... > > -- > Phlip > http://www.zeroplayer.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- John Goodsen RADSoft / Better Software Faster jgoodsen at radsoft.com Lean/Agile/XP/Scrum Coaching and Training http://www.radsoft.com Ruby on Rails and Java Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From joshknowles at gmail.com Fri Apr 3 15:54:16 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 3 Apr 2009 15:54:16 -0400 Subject: [rspec-users] Running cucumber distributed across hardware In-Reply-To: <4995f93a526ab48955e6de65444aa619@ruby-forum.com> References: <1AF4B59F-AF4D-48D3-AD8C-41813B9D8D1B@railsnewbie.com> <4995f93a526ab48955e6de65444aa619@ruby-forum.com> Message-ID: On Thu, Apr 2, 2009 at 4:14 PM, Matt Wynne wrote: > What's the current state of the art for distributed test runs? Is > anybody doing it for real? As part of the build or before check-in? > Where would be the best place to contribute effort? Testjour looks the > most likely... Any others out there? We (weplay) use Testjour on a daily basis. That said, its a bit temperamental and requires a bit of effort to get it up and running. I'd love to see more adoption, and am happy to work with whomever is interested on making it easier to get up and running. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From phlip2005 at gmail.com Fri Apr 3 18:52:51 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 03 Apr 2009 15:52:51 -0700 Subject: [rspec-users] a wiki to host Cuke & webrat? In-Reply-To: References: Message-ID: John Goodsen wrote: > this was my vision with rcumber - I haven't worked on it for a few > months, but it's basically a rails plugin that provides a web interface > to edit and run cucumber tests.... I'd love some help and ideas from > others to take this to a more universally usable tool - we use it right > now on 1 project. rcumber is at > http://github.com/jgoodsen/rcumber/tree/master I didn't see a "plugin" here. Just a lite wiki, without even security or other heavy wiki features, that you prop up next to your projects. Put another way, if I were installing this, I didn't want to have to plug it into an existing project... From cflipse at gmail.com Fri Apr 3 19:58:44 2009 From: cflipse at gmail.com (Chris Flipse) Date: Fri, 3 Apr 2009 19:58:44 -0400 Subject: [rspec-users] Running cucumber distributed across hardware In-Reply-To: References: <1AF4B59F-AF4D-48D3-AD8C-41813B9D8D1B@railsnewbie.com> <4995f93a526ab48955e6de65444aa619@ruby-forum.com> Message-ID: I'm thinking about trying to get TestJour in place to run on a single system, but one with a crapload of processors, since that's about the only way to make anything run reasonably on a Sparc ... I think I remember seeing that there was a Bonjour protocol client for Solaris, but I'm not sure where. Of course, if there was some way I could specify a number of processes for cucumber to spawn, that would work just as well for my particular case .... Desparately need to do _something_, because right now, our Cucumber tests take about 30 minutes to run ... Ruby on Solaris/Sparc is *painfully* slow, but that's the architecture I'm stuck on ... On Fri, Apr 3, 2009 at 3:54 PM, Josh Knowles wrote: > On Thu, Apr 2, 2009 at 4:14 PM, Matt Wynne wrote: > > > What's the current state of the art for distributed test runs? Is > > anybody doing it for real? As part of the build or before check-in? > > Where would be the best place to contribute effort? Testjour looks the > > most likely... Any others out there? > > We (weplay) use Testjour on a daily basis. That said, its a bit > temperamental and requires a bit of effort to get it up and running. > I'd love to see more adoption, and am happy to work with whomever is > interested on making it easier to get up and running. > > -- > Josh Knowles > phone: 509-979-1593 > email: joshknowles at gmail.com > web: http://joshknowles.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- // anything worth taking seriously is worth making fun of // http://blog.devcaffeine.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From programmer2188 at gmail.com Fri Apr 3 22:21:57 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 3 Apr 2009 22:21:57 -0400 Subject: [rspec-users] Problem with Custom matcher and Blocks In-Reply-To: <4A715770-E63E-4021-918C-CDB22401BA44@mattwynne.net> References: <000001c9b331$ec7e9d60$c57bd820$@com> <9D259075-339B-47DF-8DAE-D9BC5181F4E5@mattwynne.net> <003001c9b3d8$d463d4f0$7d2b7ed0$@com> <4A715770-E63E-4021-918C-CDB22401BA44@mattwynne.net> Message-ID: <000301c9b4cc$22ed39b0$68c7ad10$@com> Hi, I've still been working on this, and can't figure it out. I did see this old thread that covers a similar problem down the page a bit: http://groups.google.com/group/rspec/browse_thread/thread/b0c08ffd06c0f9e6#m sg_25d4f7ccf7362853 The OP eventually links to a project where it explains how to do what he was trying to do, which is here: http://github.com/yura/howto-rspec-custom-matchers/tree/master So I looked through, and it seems promising, but it's still not working. I mean that the difference is that he is doing something like: response.should have_form('/users') do with_text_field 'First name', 'user_first_name' end Etc. But I want to pass a variable to the block with the scope, so I want to do something like: response.should have_form('/users') do |form| form.should have_text_field 'First name' end I find that more readable. So does anyone know how I can do this? Also, in this person's code, he passes a scope to the matcher, like: Def have_form(action, &block) HaveForm.new action, self, &block End And then he uses it in matches? Like: response.should @scope.have_tag('form[action=?]', @action) do |form| @block.call if @block end So I'm stumped. Any help would be much appreciated, as I've been working on this for at least three days now. Thanks, Brandon > -----Original Message----- > From: Brandon Olivares [mailto:programmer2188 at gmail.com] > Sent: Thursday, April 02, 2009 7:04 PM > To: 'rspec-users' > Subject: RE: [rspec-users] Problem with Custom matcher and Blocks > > > > > -----Original Message----- > > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > > bounces at rubyforge.org] On Behalf Of Matt Wynne > > Sent: Thursday, April 02, 2009 6:04 PM > > To: rspec-users > > Subject: Re: [rspec-users] Problem with Custom matcher and Blocks > > > > > > I don't think you want to be using #should here. If that fails it > will > > raise an exception but the expected behaviour of a matcher is to > > return true / false from #matches? so that will be one problem you > > have. Try just hard-coding the #matches? method to return false and > > see if you get one of your tests to fail. > > > > What are you imagining that #response is going to return in this > > instance? > > Oh OK. Well what I want is to be able to test if that form exists on > the page. > > So how would you recommend going about it otherwise? I tried putting a > begin ... end block around it, but that doesn't seem to work either. > > def matches? response, &block > @block ||= block > begin > response.should have_selector('form#%s' % [@id]) do |form| > !@block or @block.call form > end > rescue > false > else > true > end > end > > It still has an error, but now it's covered up by my failure_message. I > output $! As a test, though, and it's the same error. > > Brandon From programmer2188 at gmail.com Sat Apr 4 02:14:22 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 4 Apr 2009 02:14:22 -0400 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks Message-ID: <004501c9b4ec$99f9b450$cded1cf0$@com> Hi, I just found a custom matcher created by Phlip at http://gist.github.com/76136 So I added that to my project, and it mostly works great for what I'm trying to do, and the syntax is pretty nice. But anytime I try to use select, I get an error. I wonder if it's conflicting with another method somewhere else? So I wondered if there is a way to get around this, since I'd like to test that my select field is there. it "should have a subject dropdown box" do response.body.should be_html_with { form :id => 'contact' do label 'Subject' select :id => 'subject' end } end # it "should have a subject dropdown box" Thanks, Brandon From phlip2005 at gmail.com Sat Apr 4 08:40:07 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 04 Apr 2009 05:40:07 -0700 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: <004501c9b4ec$99f9b450$cded1cf0$@com> References: <004501c9b4ec$99f9b450$cded1cf0$@com> Message-ID: Brandon Olivares wrote: > I just found a custom matcher created by Phlip at > http://gist.github.com/76136 That's just a sketch. The real deal is at... gem install nokogiri assert2 require 'assert2/xhtml' Report if that works better. You might find its inside source code is a little nicer, too. > So I added that to my project, and it mostly works great for what I'm trying > to do, and the syntax is pretty nice. > > But anytime I try to use select, I get an error. I wonder if it's > conflicting with another method somewhere else? http://groups.google.com/group/merb/browse_thread/thread/3588d3f75fa0e65c Use select!. That's a missing feature in Nokogiri::HTML::Builder, and its author might fix it. Until then, Nokogiri and I use bangs for three reasons: convert a misunderstanding into innocent HTML convert potential HTML into a new keyword (:xpath!, without!) convert an element.class shortcut into an element.id! > So I wondered if there is a way to get around this, since I'd like to test > that my select field is there. it "should have a subject dropdown box" do response.body.should be_html_with { form.contact! do label 'Subject' select! :id => 'subject' end } end # it "should have a subject dropdown box" Notice two things, folks - Brandon started his assertion with a unique container object. That's nearly the only way to get reasonable diagnostics. I gave up on trying to report the "closest match", and now I only report the "first extent of HTML that matches your first element". Also notice that all assertions should have a "diagostic message" facility - like the third argument to the lowly assert_equal(in, out, message = nil). But assert_xhtml does not have a message=nil yet. I'm too busy this weekend making it interpret Ajax, as a drop-in replacement for assert_rjs: assert_rjs :replace_html, :label_7 do input.Top_Ranking! :type => :checked, :value => :Y input.cross_sale_1, :type => :hidden, :value => 7 end You write the RJS you need to match (like assert_rjs classic uses), and then you add an assert_xhtml block, and it works on the Element.update() payload itself. http://groups.google.com/group/ruby-talk-google/msg/b94d83ad2d5e6536 -- Phlip http://www.zeroplayer.com/ From phlip2005 at gmail.com Sat Apr 4 09:10:50 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 04 Apr 2009 06:10:50 -0700 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: <004501c9b4ec$99f9b450$cded1cf0$@com> References: <004501c9b4ec$99f9b450$cded1cf0$@com> Message-ID: <49D75C5A.5050902@gmail.com> Uh oh. > select! :id => 'subject' select!.subject! ! From programmer2188 at gmail.com Sat Apr 4 10:42:36 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 4 Apr 2009 10:42:36 -0400 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: References: <004501c9b4ec$99f9b450$cded1cf0$@com> Message-ID: <000001c9b533$99eaa0e0$cdbfe2a0$@com> Phlip, Wow thank you very much. Sorry for the double post, I originally accidently sent my post from another email address. Anyway, that'll be a lot better, and more refined than my previous syntax. Also I really like your RJS assertions. I'll have to test that out when I get to using AJAX. Thanks, Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Saturday, April 04, 2009 8:40 AM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Phlip's be_html_with was RE: Problem with > Custom matcher and Blocks > > Brandon Olivares wrote: > > > I just found a custom matcher created by Phlip at > > http://gist.github.com/76136 > > That's just a sketch. The real deal is at... > > gem install nokogiri assert2 > > require 'assert2/xhtml' > > Report if that works better. You might find its inside source code is a > little > nicer, too. > > > So I added that to my project, and it mostly works great for what I'm > trying > > to do, and the syntax is pretty nice. > > > > But anytime I try to use select, I get an error. I wonder if it's > > conflicting with another method somewhere else? > > http://groups.google.com/group/merb/browse_thread/thread/3588d3f75fa0e6 > 5c > > Use select!. That's a missing feature in Nokogiri::HTML::Builder, and > its author > might fix it. Until then, Nokogiri and I use bangs for three reasons: > > convert a misunderstanding into innocent HTML > convert potential HTML into a new keyword (:xpath!, without!) > convert an element.class shortcut into an element.id! > > > So I wondered if there is a way to get around this, since I'd like to > test > > that my select field is there. > > it "should have a subject dropdown box" do > response.body.should be_html_with { > form.contact! do > label 'Subject' > select! :id => 'subject' > end > } > end # it "should have a subject dropdown box" > > Notice two things, folks - Brandon started his assertion with a unique > container > object. That's nearly the only way to get reasonable diagnostics. I > gave up on > trying to report the "closest match", and now I only report the "first > extent of > HTML that matches your first element". > > Also notice that all assertions should have a "diagostic message" > facility - > like the third argument to the lowly assert_equal(in, out, message = > nil). But > assert_xhtml does not have a message=nil yet. > > I'm too busy this weekend making it interpret Ajax, as a drop-in > replacement for > assert_rjs: > > assert_rjs :replace_html, :label_7 do > input.Top_Ranking! :type => :checked, :value => :Y > input.cross_sale_1, :type => :hidden, :value => 7 > end > > You write the RJS you need to match (like assert_rjs classic uses), and > then you > add an assert_xhtml block, and it works on the Element.update() payload > itself. > > http://groups.google.com/group/ruby-talk-google/msg/b94d83ad2d5e6536 > > -- > Phlip > http://www.zeroplayer.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From programmer2188 at gmail.com Sat Apr 4 11:13:14 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 4 Apr 2009 11:13:14 -0400 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: References: <004501c9b4ec$99f9b450$cded1cf0$@com> Message-ID: <001901c9b537$e1149120$a33db360$@com> Phlip, Well, now it's not failing if there is an error. This passes: it "should have a subject dropdown box" do response.body.should be_html_with { form.contact! do label 'Subject' select!.subject! end } end # it "should have a subject dropdown box" As it should, but the following passes as well, which should not: it "should have a name field" do response.body.should be_html_with { form.contact! do label 'Name' input.name! end } end # it "should have a name field" There is most definitely not a name field, nor its associated label. Thanks, Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Saturday, April 04, 2009 8:40 AM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Phlip's be_html_with was RE: Problem with > Custom matcher and Blocks > > Brandon Olivares wrote: > > > I just found a custom matcher created by Phlip at > > http://gist.github.com/76136 > > That's just a sketch. The real deal is at... > > gem install nokogiri assert2 > > require 'assert2/xhtml' > > Report if that works better. You might find its inside source code is a > little > nicer, too. > > > So I added that to my project, and it mostly works great for what I'm > trying > > to do, and the syntax is pretty nice. > > > > But anytime I try to use select, I get an error. I wonder if it's > > conflicting with another method somewhere else? > > http://groups.google.com/group/merb/browse_thread/thread/3588d3f75fa0e6 > 5c > > Use select!. That's a missing feature in Nokogiri::HTML::Builder, and > its author > might fix it. Until then, Nokogiri and I use bangs for three reasons: > > convert a misunderstanding into innocent HTML > convert potential HTML into a new keyword (:xpath!, without!) > convert an element.class shortcut into an element.id! > > > So I wondered if there is a way to get around this, since I'd like to > test > > that my select field is there. > > it "should have a subject dropdown box" do > response.body.should be_html_with { > form.contact! do > label 'Subject' > select! :id => 'subject' > end > } > end # it "should have a subject dropdown box" > > Notice two things, folks - Brandon started his assertion with a unique > container > object. That's nearly the only way to get reasonable diagnostics. I > gave up on > trying to report the "closest match", and now I only report the "first > extent of > HTML that matches your first element". > > Also notice that all assertions should have a "diagostic message" > facility - > like the third argument to the lowly assert_equal(in, out, message = > nil). But > assert_xhtml does not have a message=nil yet. > > I'm too busy this weekend making it interpret Ajax, as a drop-in > replacement for > assert_rjs: > > assert_rjs :replace_html, :label_7 do > input.Top_Ranking! :type => :checked, :value => :Y > input.cross_sale_1, :type => :hidden, :value => 7 > end > > You write the RJS you need to match (like assert_rjs classic uses), and > then you > add an assert_xhtml block, and it works on the Element.update() payload > itself. > > http://groups.google.com/group/ruby-talk-google/msg/b94d83ad2d5e6536 > > -- > Phlip > http://www.zeroplayer.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From phlip2005 at gmail.com Sat Apr 4 13:46:07 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 04 Apr 2009 10:46:07 -0700 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: <001901c9b537$e1149120$a33db360$@com> References: <004501c9b4ec$99f9b450$cded1cf0$@com> <001901c9b537$e1149120$a33db360$@com> Message-ID: Brandon Olivares wrote: > it "should have a name field" do > response.body.should be_html_with { > form.contact! do > label 'Name' > input.name! > end > } > end # it "should have a name field" > > There is most definitely not a name field, nor its associated label. Can you try the assert_xhtml version? I think it will drop in with: Spec::Runner.configure do |c| c.include Test::Unit::Assertions end be_html_with{} is something of a nail-soup issue for me because we always only use test/unit at my day job... sorry! I will look at the issue this weekend - the @failure_message might not bubble up to the RSpec wrapper correctly... From programmer2188 at gmail.com Sat Apr 4 16:07:47 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 4 Apr 2009 16:07:47 -0400 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: References: <004501c9b4ec$99f9b450$cded1cf0$@com> <001901c9b537$e1149120$a33db360$@com> Message-ID: <004101c9b561$0734b640$159e22c0$@com> Hi, Yes that's great! That works perfectly. I'd appreciate it if you could let me know about the be_html_with issue when you can though, as I like the natural language better. Thank you very much. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Saturday, April 04, 2009 1:46 PM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Phlip's be_html_with was RE: Problem with > Custom matcher and Blocks > > Brandon Olivares wrote: > > > it "should have a name field" do > > response.body.should be_html_with { > > form.contact! do > > label 'Name' > > input.name! > > end > > } > > end # it "should have a name field" > > > > There is most definitely not a name field, nor its associated label. > > Can you try the assert_xhtml version? I think it will drop in with: > > Spec::Runner.configure do |c| > c.include Test::Unit::Assertions > end > > be_html_with{} is something of a nail-soup issue for me because we > always only > use test/unit at my day job... sorry! > > I will look at the issue this weekend - the @failure_message might not > bubble up > to the RSpec wrapper correctly... > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Sat Apr 4 19:08:51 2009 From: lists at ruby-forum.com (Mike Williams) Date: Sun, 5 Apr 2009 01:08:51 +0200 Subject: [rspec-users] Problems installing the rspec and rspec-rails gems Message-ID: <1be6e98e959cd635453c4d2b3ad74376@ruby-forum.com> Hello, Just purchased my first mac for Ruby on Rails development and I'm in the process of setting up the environment and installing rspec and rspec-rails. I'm getting the following error message when trying to install the gem. I'm using: sudo gem install rspec I get: Successfully installed rspec-1.2.2 1 gem installed Installing ri documentation for rspec-1.2.2... Installing RDoc documentation for rspec-1.2.2... Could not find main page README.rdoc Could not find main page README.rdoc Could not find main page README.rdoc Could not find main page README.rdoc When I try to run cucumber, it says that rspec and rspec-rails aren't installed. What can I do to remedy this? I'm using Leopard. Thanks! -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Sat Apr 4 20:15:44 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Sat, 4 Apr 2009 17:15:44 -0700 Subject: [rspec-users] Problems installing the rspec and rspec-rails gems In-Reply-To: <1be6e98e959cd635453c4d2b3ad74376@ruby-forum.com> References: <1be6e98e959cd635453c4d2b3ad74376@ruby-forum.com> Message-ID: <2c7e61990904041715p54aaabffrc367d1eb4e1e7840@mail.gmail.com> The rspec gem did install successfully, not sure what those doc warnings are. Did you install rspec-rails as well? Pat On Sat, Apr 4, 2009 at 4:08 PM, Mike Williams wrote: > Hello, > > Just purchased my first mac for Ruby on Rails development and I'm in the > process of setting up the environment and installing rspec and > rspec-rails. I'm getting the following error message when trying to > install the gem. > > I'm using: sudo gem install rspec > > I get: > > Successfully installed rspec-1.2.2 > 1 gem installed > Installing ri documentation for rspec-1.2.2... > Installing RDoc documentation for rspec-1.2.2... > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > > When I try to run cucumber, it says that rspec and rspec-rails aren't > installed. > > What can I do to remedy this? > > I'm using Leopard. > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sat Apr 4 20:52:36 2009 From: lists at ruby-forum.com (Mike Williams) Date: Sun, 5 Apr 2009 02:52:36 +0200 Subject: [rspec-users] Problems installing the rspec and rspec-rails gems In-Reply-To: <2c7e61990904041715p54aaabffrc367d1eb4e1e7840@mail.gmail.com> References: <1be6e98e959cd635453c4d2b3ad74376@ruby-forum.com> <2c7e61990904041715p54aaabffrc367d1eb4e1e7840@mail.gmail.com> Message-ID: <09ff70a32694aea73a8a9884f92eb6cb@ruby-forum.com> Pat Maddox wrote: > The rspec gem did install successfully, not sure what those doc > warnings are. Did you install rspec-rails as well? > > Pat I get the same output with rspec-rails when I try to install it. When I try to run cucumber feature -n I get: Missing these required gems: rpsec >= 1.2.2 rpsec-rails >= 1.2.2 You're running: ruby 1.8.6.114 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby rubygems 1.3.1 at /Users/mike/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sat Apr 4 22:46:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 4 Apr 2009 21:46:16 -0500 Subject: [rspec-users] Problems installing the rspec and rspec-rails gems In-Reply-To: <09ff70a32694aea73a8a9884f92eb6cb@ruby-forum.com> References: <1be6e98e959cd635453c4d2b3ad74376@ruby-forum.com> <2c7e61990904041715p54aaabffrc367d1eb4e1e7840@mail.gmail.com> <09ff70a32694aea73a8a9884f92eb6cb@ruby-forum.com> Message-ID: <8642DBE8-C751-4785-B620-EEED4638212E@gmail.com> Hey Mike, Looks like the problem is installing the rdoc. Try installing with the --no-rdoc option. Cheers, David Sent from my iPhone On Apr 4, 2009, at 7:52 PM, Mike Williams wrote: > Pat Maddox wrote: >> The rspec gem did install successfully, not sure what those doc >> warnings are. Did you install rspec-rails as well? >> >> Pat > > > I get the same output with rspec-rails when I try to install it. > > When I try to run cucumber feature -n I get: > > Missing these required gems: > rpsec >= 1.2.2 > rpsec-rails >= 1.2.2 > > You're running: > ruby 1.8.6.114 at > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby > rubygems 1.3.1 at /Users/mike/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8 > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From programmer2188 at gmail.com Sat Apr 4 22:56:43 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 4 Apr 2009 22:56:43 -0400 Subject: [rspec-users] Best practices: How small to make examples? Message-ID: <00ab01c9b59a$27d56fa0$77804ee0$@com> Hi, How small should examples be? Let's say I have a form, should there be one example per field? If there's a dropdown, should I describe the dropdown and have one example per option? I thought that at first but now, because of the duplication and sheer verbosity, it seems too much. So what do you think? Brandon From phlip2005 at gmail.com Sat Apr 4 22:59:02 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 04 Apr 2009 19:59:02 -0700 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: <004101c9b561$0734b640$159e22c0$@com> References: <004501c9b4ec$99f9b450$cded1cf0$@com> <001901c9b537$e1149120$a33db360$@com> <004101c9b561$0734b640$159e22c0$@com> Message-ID: Brandon Olivares wrote: > Yes that's great! That works perfectly. > > I'd appreciate it if you could let me know about the be_html_with issue when > you can though, as I like the natural language better. i dunno about "natural language", but I expect to fix the RSpec language this weekend. (-; From programmer2188 at gmail.com Sat Apr 4 23:35:47 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 4 Apr 2009 23:35:47 -0400 Subject: [rspec-users] RSpec Formats with Strange Characters Message-ID: <00df01c9b59f$9d3df280$d7b9d780$@com> Hi, Sorry for another post. I have spec.opts writing certain formats to certain files. It looks like this: --colour --format progress --format nested:doc/nested.txt --format profile:doc/profile.txt --loadby mtime --reverse So I took a look at doc/nested.txt, and it shows the following: /contact/index the contact form before it has been submitted  should have a subject dropdown box  should have a name field  should show the contact form Finished in 0.656 seconds 3 examples, 0 failures It was working ok a few weeks ago, so I'm confused. Thanks, Brandon From phlip2005 at gmail.com Sun Apr 5 00:08:53 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 04 Apr 2009 21:08:53 -0700 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: <004101c9b561$0734b640$159e22c0$@com> References: <004501c9b4ec$99f9b450$cded1cf0$@com> <001901c9b537$e1149120$a33db360$@com> <004101c9b561$0734b640$159e22c0$@com> Message-ID: Brandon Olivares wrote: > I'd appreciate it if you could let me know about the be_html_with issue when > you can though, as I like the natural language better. Add this monkey patch below require 'assert2/xhtml': class BeHtmlWith def matches?(stwing, &block) @block ||= block @scope.wrap_expectation self do @doc = Nokogiri::HTML(stwing) return run_all_xpaths(build_xpaths) end end end Now, I'm off to finish manual tests of the new assert_rjs, and to pop a new version... From programmer2188 at gmail.com Sun Apr 5 04:29:03 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 5 Apr 2009 04:29:03 -0400 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: References: <004501c9b4ec$99f9b450$cded1cf0$@com> <001901c9b537$e1149120$a33db360$@com> <004101c9b561$0734b640$159e22c0$@com> Message-ID: <000f01c9b5c8$952079f0$bf616dd0$@com> Hi, Thank you very much. Is there any documentation of the rest of assert2? I found a web site I think (assuming it's the same thing), but there wasn't really documentation for assert_xhtml or assert_rjs. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Sunday, April 05, 2009 12:09 AM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Phlip's be_html_with was RE: Problem with > Custom matcher and Blocks > > Brandon Olivares wrote: > > > I'd appreciate it if you could let me know about the be_html_with > issue when > > you can though, as I like the natural language better. > > Add this monkey patch below require 'assert2/xhtml': > > class BeHtmlWith > def matches?(stwing, &block) > @block ||= block > @scope.wrap_expectation self do > @doc = Nokogiri::HTML(stwing) > return run_all_xpaths(build_xpaths) > end > end > end > > Now, I'm off to finish manual tests of the new assert_rjs, and to pop a > new > version... > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Sun Apr 5 05:24:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 5 Apr 2009 10:24:50 +0100 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <00ab01c9b59a$27d56fa0$77804ee0$@com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> Message-ID: On 5 Apr 2009, at 03:56, Brandon Olivares wrote: > Hi, > > How small should examples be? > > Let's say I have a form, should there be one example per field? If > there's a > dropdown, should I describe the dropdown and have one example per > option? I > thought that at first but now, because of the duplication and sheer > verbosity, it seems too much. > > So what do you think? http://blog.jayfields.com/2007/06/testing-one-assertion-per-test.html Again, I would urge you to listen to the tests and question whether writing unit tests for your views is worthwhile. If you're finding it a hassle, there might be a reason for that :) Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Sun Apr 5 06:50:12 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 5 Apr 2009 12:50:12 +0200 Subject: [rspec-users] RSpec Formats with Strange Characters In-Reply-To: <00df01c9b59f$9d3df280$d7b9d780$@com> References: <00df01c9b59f$9d3df280$d7b9d780$@com> Message-ID: <8d961d900904050350t21396c2ag8af494d474b1158d@mail.gmail.com> On Sun, Apr 5, 2009 at 5:35 AM, Brandon Olivares wrote: > Sorry for another post. I have spec.opts writing certain formats to certain > files. It looks like this: --colour --format progress --format > nested:doc/nested.txt --format profile:doc/profile.txt --loadby mtime > --reverse So I took a look at doc/nested.txt, and it shows the following: > /contact/index the contact form before it has been submitted [32m > should have a subject dropdown box [32m should have a name field [32m > should show the contact form Finished in 0.656 seconds [32m3 examples, 0 > failures It was working ok a few weeks ago, so I'm confused. Thanks, Brandon > _______________________________________________ Please describe your environment. OS, various versions etc. > rspec-users mailing list rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From phlip2005 at gmail.com Sun Apr 5 06:56:26 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 05 Apr 2009 03:56:26 -0700 Subject: [rspec-users] Phlip's be_html_with was RE: Problem with Custom matcher and Blocks In-Reply-To: <000f01c9b5c8$952079f0$bf616dd0$@com> References: <004501c9b4ec$99f9b450$cded1cf0$@com> <001901c9b537$e1149120$a33db360$@com> <004101c9b561$0734b640$159e22c0$@com> <000f01c9b5c8$952079f0$bf616dd0$@com> Message-ID: Brandon Olivares wrote: > Is there any documentation of the rest of assert2? I found a web site I > think (assuming it's the same thing), but there wasn't really documentation > for assert_xhtml or assert_rjs. assert_rjs is still in the oven, and assert_xhtml arrived too fast to get anything more than its README: http://assert2.rubyforge.org/svn/README I used to take a train to work - that's why the assert{ 2.0 } documentation itself is so... florid... From dchelimsky at gmail.com Sun Apr 5 08:20:34 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 5 Apr 2009 07:20:34 -0500 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: References: <00ab01c9b59a$27d56fa0$77804ee0$@com> Message-ID: <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> On Sun, Apr 5, 2009 at 4:24 AM, Matt Wynne wrote: > On 5 Apr 2009, at 03:56, Brandon Olivares wrote: > >> Hi, >> >> How small should examples be? >> >> Let's say I have a form, should there be one example per field? If there's >> a >> dropdown, should I describe the dropdown and have one example per option? >> I >> thought that at first but now, because of the duplication and sheer >> verbosity, it seems too much. >> >> So what do you think? > > http://blog.jayfields.com/2007/06/testing-one-assertion-per-test.html or http://rubyurl.com/yCt3 > > Again, I would urge you to listen to the tests and question whether writing > unit tests for your views is worthwhile. If you're finding it a hassle, > there might be a reason for that :) There is a trend these days away from isolated view specs. My own opinion is that this is *generally* a good thing *if* you've got something like cucumber scenarios that take you through the views in question. That said, I'm not yet convinced that view specs shouldn't still be part of your toolkit. I generally use RSpec and Cucumber these days, and I like to progress in small, verifiable steps. So let's say I set up a cucumber scenario in the declarative style: Given I register for a conference Then my name should be on the list of conference attendees And the conference should be my list of conferences Note that lack of "When I fill in ..." sort of steps. The first given is going to take care of the details of filling in the form. This way, if something about the form changes, I need to change the underlying step definition, but I don't need to revisit all the scenarios that use it. So lets say the form has 10 fields split out into two pages. That's going to take some time to get working, and the whole time I'm developing the parts, I'm going to have this one failing step. In a case like this, I might spec the view using rspec, so that I can add one field at a time and verify each field as its done. This way I'm getting green bars every minute or so, which keeps me relaxed as I go. But that's me. And I don't do it or recommend doing it for everything all the time. Paraphrasing Matt, "listen to your specs." Cheers, David > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sun Apr 5 10:23:55 2009 From: lists at ruby-forum.com (Enrico Listemann) Date: Sun, 5 Apr 2009 16:23:55 +0200 Subject: [rspec-users] Can't use Cucumber with Webrat and Selenium Message-ID: Hi, I followed the instructions at http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium to get Selenium and Webrat to work with Cucumber. I have no problems using Webrat but when I switch to use Selenium, I get the following error message when I try to access the browser(e.g. calling visit(login_path)) in a step definition. Die angeforderte Adresse ist in diesem Kontext ung?ltig. - connect(2) (Errno::EADDRNOTAVAIL) E:/SOFTWAREENTWICKLUNG/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout' (eval):2:in `visit' (for those who don't speak german: The requested address is invalid in this context.) I also tried to use Cucumber and Selenium without Webrat and it works without any problems. I'm using Rails 2.3.0, Cucumber 0.2.3, Webrat 0.4.3 and RSpec 1.2.2 on a WinXP machine. I would be very pleased if anyone had an idea about the reason for this failure. Enrico -- Posted via http://www.ruby-forum.com/. From programmer2188 at gmail.com Sun Apr 5 10:45:46 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 5 Apr 2009 10:45:46 -0400 Subject: [rspec-users] RSpec Formats with Strange Characters In-Reply-To: <8d961d900904050350t21396c2ag8af494d474b1158d@mail.gmail.com> References: <00df01c9b59f$9d3df280$d7b9d780$@com> <8d961d900904050350t21396c2ag8af494d474b1158d@mail.gmail.com> Message-ID: <003f01c9b5fd$35592dc0$a00b8940$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of aslak hellesoy > Sent: Sunday, April 05, 2009 6:50 AM > To: rspec-users > Subject: Re: [rspec-users] RSpec Formats with Strange Characters > > > Please describe your environment. OS, various versions etc. > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. Thanks, Brandon From dchelimsky at gmail.com Sun Apr 5 12:23:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 5 Apr 2009 11:23:52 -0500 Subject: [rspec-users] Problem with colorized output in cygwin on Vista (was: RSpec Formats with Strange Characters) Message-ID: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> Changing the name of this to hopefully catch the eye of other Vista/cygwin/rspec users. On Sun, Apr 5, 2009 at 9:45 AM, Brandon Olivares wrote: > > >> -----Original Message----- >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> bounces at rubyforge.org] On Behalf Of aslak hellesoy >> Sent: Sunday, April 05, 2009 6:50 AM >> To: rspec-users >> Subject: Re: [rspec-users] RSpec Formats with Strange Characters >> >> >> Please describe your environment. OS, various versions etc. >> > > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. Those characters are for coloring the output. I'm running XP in Parallels w/ ruby 1.8.7 and cygwin and I get colored output rather than seeing those characters. I'm guessing Vista is different :) Anybody else running Vista that knows how to get this to work? > > Thanks, > Brandon > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Sun Apr 5 13:03:40 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 5 Apr 2009 10:03:40 -0700 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> Message-ID: <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> On Sun, Apr 5, 2009 at 5:20 AM, David Chelimsky wrote: > Given I register for a conference > Then my name should be on the list of conference attendees > And the conference should be my list of conferences If I were describing 'register for a conference' in this scenario, then I would think it important to specify the steps that are used: Given I am logged in And I go to the registration page And I fill in the email field And I click "Register" Then my name should be on the list of conference attendees And the conference should be my list of conferences That's the level of detail the story would have, so that's what I want to show works. On the other hand, this could simply be describing what appears on the screen when I am registered for a conference (as opposed to how I got there). In that case, the Given would simply add a database row. But there would be a different story for the process of filling out the form. Sometimes, they can be combined. But my point is that scenarios still have to describe how the user relates to the form and 'Given I register for a conference' doesn't do that. When you do have a scenario that includes this level of detail, you don't need a view spec, IMO. And you can still code step-by-step. ///ark From dchelimsky at gmail.com Sun Apr 5 13:56:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 5 Apr 2009 12:56:47 -0500 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> Message-ID: <57c63afe0904051056r59eaedc1q3dc5e38323e7db47@mail.gmail.com> On Sun, Apr 5, 2009 at 12:03 PM, Mark Wilden wrote: > On Sun, Apr 5, 2009 at 5:20 AM, David Chelimsky wrote: > >> Given I register for a conference >> Then my name should be on the list of conference attendees >> And the conference should be my list of conferences > > If I were describing 'register for a conference' in this scenario, > then I would think it important to specify the steps that are used: > > ?Given I am logged in > ?And I go to the registration page > ?And I fill in the email field > ?And I click "Register" > ?Then my name should be on the list of conference attendees > ?And the conference should be my list of conferences > > That's the level of detail the story would have, so that's what I want > to show works. > > On the other hand, this could simply be describing what appears on the > screen when I am registered for a conference (as opposed to how I got > there). In that case, the Given would simply add a database row. But > there would be a different story for the process of filling out the > form. Not necessarily. More on that below. > > Sometimes, they can be combined. But my point is that scenarios still > have to describe how the user relates to the form and 'Given I > register for a conference' doesn't do that. Scenarios have to do no such thing. Scenarios are a communication/collaboration tool. What they contain should support that role, and is going to vary greatly from team to team. What you describe might be right for your team, but that doesn't mean it's right for mine. Keep in mind that the more imperative the scenarios are, the more of a maintenance burden they become. The scenario I described above could be run against a set of step definitions that run against a browser, an API, a desktop app or even a command line shell. We could support all of those interfaces and not have to change the scenario to do so. That's a huge amount of flexibility. The tradeoff is that you don't see the details of the scenarios. For some that is a deal breaker. But for others, not so much. > When you do have a > scenario that includes this level of detail, you don't need a view > spec, IMO. And you can still code step-by-step. Agreed. David > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Sun Apr 5 13:58:59 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 5 Apr 2009 13:58:59 -0400 Subject: [rspec-users] Problem with colorized output in cygwin on Vista (was: RSpec Formats with Strange Characters) In-Reply-To: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> References: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> Message-ID: <006701c9b618$335f3e40$9a1dbac0$@com> Hi, Well the output on the console works fine, it's when it is output to a text file when I see those characters. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Sunday, April 05, 2009 12:24 PM > To: rspec-users > Subject: [rspec-users] Problem with colorized output in cygwin on Vista > (was: RSpec Formats with Strange Characters) > > Changing the name of this to hopefully catch the eye of other > Vista/cygwin/rspec users. > > On Sun, Apr 5, 2009 at 9:45 AM, Brandon Olivares > wrote: > > > > > >> -----Original Message----- > >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > >> bounces at rubyforge.org] On Behalf Of aslak hellesoy > >> Sent: Sunday, April 05, 2009 6:50 AM > >> To: rspec-users > >> Subject: Re: [rspec-users] RSpec Formats with Strange Characters > >> > >> > >> Please describe your environment. OS, various versions etc. > >> > > > > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. > > Those characters are for coloring the output. I'm running XP in > Parallels w/ ruby 1.8.7 and cygwin and I get colored output rather > than seeing those characters. I'm guessing Vista is different :) > > Anybody else running Vista that knows how to get this to work? > > > > > Thanks, > > Brandon > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Sun Apr 5 14:16:15 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 5 Apr 2009 14:16:15 -0400 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> Message-ID: <85d99afe0904051116m6ed5412dx1eb053a75f949ce2@mail.gmail.com> On Sun, Apr 5, 2009 at 1:03 PM, Mark Wilden wrote: > On Sun, Apr 5, 2009 at 5:20 AM, David Chelimsky wrote: > >> Given I register for a conference >> Then my name should be on the list of conference attendees >> And the conference should be my list of conferences > > If I were describing 'register for a conference' in this scenario, > then I would think it important to specify the steps that are used: > > ?Given I am logged in > ?And I go to the registration page > ?And I fill in the email field > ?And I click "Register" > ?Then my name should be on the list of conference attendees > ?And the conference should be my list of conferences > > That's the level of detail the story would have, so that's what I want > to show works. > > On the other hand, this could simply be describing what appears on the > screen when I am registered for a conference (as opposed to how I got > there). In that case, the Given would simply add a database row. But > there would be a different story for the process of filling out the > form. > > Sometimes, they can be combined. But my point is that scenarios still > have to describe how the user relates to the form and 'Given I > register for a conference' doesn't do that. When you do have a > scenario that includes this level of detail, you don't need a view > spec, IMO. And you can still code step-by-step. It seems that when developers write scenarios they often walk through everything logically and fill in every input field from a scenario. When my customers write scenarios they don't do this, they tend to think higher level. They write: "Given I register for a conference". Over time I've found I lean towards the scenarios remaining higher level. When scenarios too detailed oriented for how "registering for a conference is done" then it becomes a maintenance burden any time how registering for a conference is updated. I like allowing my scenario to remain expressive about the behaviour of the app while leaving out the details about every form field being filled in. In a way it's parallel with refactoring a public method. You can change the details w/o changing how everything uses it. I find that's akin to scenarios. They should only change when the actual behaviour changes (or at least that's my goal to shoot for), not necessarily when the UI gets reworked, or input fields get added or removed. I also don't think the scenario should try to relate the forms on the UI to the user. There are better tools for this job: wireframes, screen mockups, and the actual UI itself. It sounds like you may have an expectation that the scenarios should read like step by step instructions for using the app? An interesting idea, but it adds an additional responsibility to the scenarios which I think will ultimately convolute the value they are trying to express. At least it has when I tried to do that months back. > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From pat.maddox at gmail.com Sun Apr 5 14:39:55 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Sun, 5 Apr 2009 11:39:55 -0700 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> Message-ID: <2c7e61990904051139i5aad2622h73f8a8ec22fad7a0@mail.gmail.com> On Sun, Apr 5, 2009 at 10:03 AM, Mark Wilden wrote: > Sometimes, they can be combined. But my point is that scenarios still > have to describe how the user relates to the form Scenarios should describe how a user relates to the application. Whether you choose to do that by using fine- or course-grained stories is context-dependent - what level of explicitness makes your customer happy, other test coverage, etc. > and 'Given I > register for a conference' doesn't do that. When you do have a > scenario that includes this level of detail, you don't need a view > spec, IMO. And you can still code step-by-step. True. Although you invariably lose defect isolation when you do it this way. There are a lot more potential causes of failure when you go through the whole stack than when you render a view in isolation. Whether defect isolation is valuable enough to incur the cost of view specs is up to you. Pat From lists at ruby-forum.com Sun Apr 5 15:41:18 2009 From: lists at ruby-forum.com (Mateusz Juraszek) Date: Sun, 5 Apr 2009 21:41:18 +0200 Subject: [rspec-users] [cucumber] webrat+selenium integration problem: record n In-Reply-To: <8aa5aba65e3d4a53021bbbe32e211708@ruby-forum.com> References: <49C830BF.1040401@benmabey.com> <49C964F3.9000600@benmabey.com> <8aa5aba65e3d4a53021bbbe32e211708@ruby-forum.com> Message-ID: <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> Balint Erdi wrote: > Ben Mabey wrote: > >> Couple things I'd like to point out. In your enhanced.rb you don't need >> to do the Before hook yourself. You can just require >> 'database_cleaner/cucumber'. I've updated your gist to use that. >> In your plain.rb it seems like you are trying to truncate your database >> just once upon startup. If that is the case then the recommended way is >> to use the clean_with method like so: >> DatabaseCleaner.clean_with :truncation >> >> Again, I have updated the gist to reflect this. >> >> -Ben > > Hey Ben, thanks a lot. > > The problem I am experiencing now is that information stored in the > session does not seem to be retained between steps (again, only in the > case of selenium sessions, plain sesssion work fine). So the login > function works fine now but when I go to another page afterwards it > throws a big error because the action tries to render something based on > the current user. > > Is the session store I am using relevant? I used the default > cookie-based storage and then tried to change to the active-record based > one to no avail. My config is at http://gist.github.com/83635 > > Thank you, > Balint hi Ben I am newbie with cucumber and bdd. I was wondering if you can take a look on my problems. I have similar problem like Balint. I test my own and clearance features with selenium and webrat. I don't have to say that with werbrat everything is perfect. When I run features with selenium I get error nil.session what is connected with code from clearance features ie:
Then /^I should not be signed in$/ do
  assert_nil request.session[:user_id]
end
in clearance_step file It seems like selenium has problem with access to "request" object That makes my test fail all the time. Another problem I met is with waiting for response after "press button" method All the time I get response with code before button pressed It's connected with selenium_session.rb code and require me to change a bit
    def click_button(button_text_or_regexp = nil, options = {})
      if button_text_or_regexp.is_a?(Hash) && options == {}
        pattern, options = nil, button_text_or_regexp
      elsif button_text_or_regexp
        pattern = adjust_if_regexp(button_text_or_regexp)
      end
      pattern ||= '*'
      locator = "button=#{pattern}"

      selenium.wait_for_element locator, :timeout_in_seconds => 5
      selenium.click locator
      selenium.wait_for_page_to_load(5) ## add this line to get correct 
response
    end
I don't know why I have to change it Thanks -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sun Apr 5 16:05:42 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 5 Apr 2009 13:05:42 -0700 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <85d99afe0904051116m6ed5412dx1eb053a75f949ce2@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> <85d99afe0904051116m6ed5412dx1eb053a75f949ce2@mail.gmail.com> Message-ID: <3c30da400904051305m13633baaw773113a637d6571e@mail.gmail.com> On Sun, Apr 5, 2009 at 11:16 AM, Zach Dennis wrote: > > It seems that when developers write scenarios they often walk through > everything logically and fill in every input field from a scenario. > When my customers write scenarios they don't do this, they tend to > think higher level. They write: "Given I register for a conference". My customers give me mockups and indeed specify what fields must be filled in. >?When scenarios too detailed oriented for how "registering for > a conference is done" then it becomes a maintenance burden any time > how registering for a conference is updated. Fine, but then you've shifted the maintenance burden to your view specs. > ?I like allowing my > scenario to remain expressive about the behaviour of the app while > leaving out the details about every form field being filled in. In many cases, if not most, what the user types is part of the behavior of the app. Not for merely descriptive information - agreed. But in my current app, most fields lead to differences in behavior. E.g., the challenge is public, Zach has been invited to it, it expires on a certain day, etc. I consider this information essential to the behavior of the app, not "merely" the UI. Of course, I've always felt that the UI is the most important part of the app, anyway. I feel that if certain user actions lead to certain physical output, then I've fufllled the requirements of the app. > I also don't think the scenario should try to relate the forms on the > UI to the user. There are better tools for this job: wireframes, > screen mockups, and the actual UI itself. It sounds like you may have > an expectation that the scenarios should read like step by step > instructions for using the app? An interesting idea, but it adds an > additional responsibility to the scenarios which I think will > ultimately convolute the value they are trying to express. At least it > has when I tried to do that months back. You have to test this stuff somewhere. And perhaps I'm just old-school, but to me, a user story does indeed specify what the user does. If it's too general, that makes its acceptance criteria problematic. ///ark From mark at mwilden.com Sun Apr 5 16:15:16 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 5 Apr 2009 13:15:16 -0700 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <57c63afe0904051056r59eaedc1q3dc5e38323e7db47@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> <57c63afe0904051056r59eaedc1q3dc5e38323e7db47@mail.gmail.com> Message-ID: <3c30da400904051315x421f2c5bp5110fc08716ab264@mail.gmail.com> On Sun, Apr 5, 2009 at 10:56 AM, David Chelimsky wrote: > What you > describe might be right for your team, but that doesn't mean it's > right for mine. Agreed. > Keep in mind that the more imperative the scenarios are, the more of a > maintenance burden they become. I do work on this code, so I have some idea of the maintenance burden. :) But as I said to Zach, you still have the maintenance burden if you defer this level of detail to view specs. > The scenario I described above could > be run against a set of step definitions that run against a browser, > an API, a desktop app or even a command line shell. We could support > all of those interfaces and not have to change the scenario to do so. > That's a huge amount of flexibility. I am actually not a big fan of "flexibility." It's great if it's free, but I don't find it persuasive in and of itself. I think this aligns with the original principles of XP. I have had projects where a new interface was required at some point. But the vast majority have not. > The tradeoff is that you don't > see the details of the scenarios. For some that is a deal breaker. But > for others, not so much. I was really describing the way I approach scenarios, not prescribing anything for others. I really hate writing view and controller specs, and I've found (so far, at least), that describing user interaction in scenarios obviates them and is better for communication with users. Other people's mileage may certainly vary. ///ark From dchelimsky at gmail.com Sun Apr 5 16:20:24 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 5 Apr 2009 15:20:24 -0500 Subject: [rspec-users] Problem with colorized output in cygwin on Vista (was: RSpec Formats with Strange Characters) In-Reply-To: <006701c9b618$335f3e40$9a1dbac0$@com> References: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> <006701c9b618$335f3e40$9a1dbac0$@com> Message-ID: <57c63afe0904051320x6d8ff0en56b5a8e86038cf15@mail.gmail.com> On Sun, Apr 5, 2009 at 12:58 PM, Brandon Olivares wrote: > Hi, > > Well the output on the console works fine, it's when it is output to a text > file when I see those characters. Ah - well, in theory that shouldn't happen, because the colorizing checks to see if it's printing to a console or not. So it sounds like there is a bug related to your specific environment. Would you please report that to http://rspec.lighthouseapp.com? In the mean time, as a workaround, just exclude the --color option and you should be fine. > > Brandon > >> -----Original Message----- >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> bounces at rubyforge.org] On Behalf Of David Chelimsky >> Sent: Sunday, April 05, 2009 12:24 PM >> To: rspec-users >> Subject: [rspec-users] Problem with colorized output in cygwin on Vista >> (was: RSpec Formats with Strange Characters) >> >> Changing the name of this to hopefully catch the eye of other >> Vista/cygwin/rspec users. >> >> On Sun, Apr 5, 2009 at 9:45 AM, Brandon Olivares >> wrote: >> > >> > >> >> -----Original Message----- >> >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> >> bounces at rubyforge.org] On Behalf Of aslak hellesoy >> >> Sent: Sunday, April 05, 2009 6:50 AM >> >> To: rspec-users >> >> Subject: Re: [rspec-users] RSpec Formats with Strange Characters >> >> >> >> >> >> Please describe your environment. OS, various versions etc. >> >> >> > >> > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. >> >> Those characters are for coloring the output. I'm running XP in >> Parallels w/ ruby 1.8.7 and cygwin and I get colored output rather >> than seeing those characters. I'm guessing Vista is different :) >> >> Anybody else running Vista that knows how to get this to work? >> >> > >> > Thanks, >> > Brandon >> > >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Apr 5 16:37:39 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 5 Apr 2009 15:37:39 -0500 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <3c30da400904051305m13633baaw773113a637d6571e@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> <85d99afe0904051116m6ed5412dx1eb053a75f949ce2@mail.gmail.com> <3c30da400904051305m13633baaw773113a637d6571e@mail.gmail.com> Message-ID: <57c63afe0904051337j7fbda3b0scc2c2fa7447569@mail.gmail.com> On Sun, Apr 5, 2009 at 3:05 PM, Mark Wilden wrote: > On Sun, Apr 5, 2009 at 11:16 AM, Zach Dennis wrote: >> >> It seems that when developers write scenarios they often walk through >> everything logically and fill in every input field from a scenario. >> When my customers write scenarios they don't do this, they tend to >> think higher level. They write: "Given I register for a conference". > > My customers give me mockups and indeed specify what fields must be filled in. > >>?When scenarios too detailed oriented for how "registering for >> a conference is done" then it becomes a maintenance burden any time >> how registering for a conference is updated. > > Fine, but then you've shifted the maintenance burden to your view specs. View specs the domain of me and my co-developers. We are free to maintain them using all the knowledge that we have about maintaining code. Shifting the burden away from the scenarios to view specs actually reduces the overall cost, in my view, as we don't need to have a meeting every time I want to refactor something. > >> ?I like allowing my >> scenario to remain expressive about the behaviour of the app while >> leaving out the details about every form field being filled in. > > In many cases, if not most, what the user types is part of the > behavior of the app. Not for merely descriptive information - agreed. > But in my current app, most fields lead to differences in behavior. > E.g., the challenge is public, Zach has been invited to it, it expires > on a certain day, etc. I consider this information essential to the > behavior of the app, not "merely" the UI. > > Of course, I've always felt that the UI is the most important part of > the app, anyway. I feel that if certain user actions lead to certain > physical output, then I've fufllled the requirements of the app. > >> I also don't think the scenario should try to relate the forms on the >> UI to the user. There are better tools for this job: wireframes, >> screen mockups, and the actual UI itself. It sounds like you may have >> an expectation that the scenarios should read like step by step >> instructions for using the app? An interesting idea, but it adds an >> additional responsibility to the scenarios which I think will >> ultimately convolute the value they are trying to express. At least it >> has when I tried to do that months back. > > You have to test this stuff somewhere. And perhaps I'm just > old-school, but to me, a user story does indeed specify what the user > does. If it's too general, that makes its acceptance criteria > problematic. It's not about old-school or new-school or any school. It's about the individual needs of your team, and what it is you need to communicate. What you're doing is perfectly fine if the details of every interaction need to be communicated at this level. Also, this isn't necessarily an all or nothing deal. One way I've approached this that works well is to have a single scenario that describes the details we're talking about, and a lot more scenarios that are more declarative. Now you have the best of all worlds. FWIW, David > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Sun Apr 5 16:30:18 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 05 Apr 2009 14:30:18 -0600 Subject: [rspec-users] [cucumber] checking if a user is logged in (Was: webrat+selenium integration problem: record n) In-Reply-To: <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> References: <49C830BF.1040401@benmabey.com> <49C964F3.9000600@benmabey.com> <8aa5aba65e3d4a53021bbbe32e211708@ruby-forum.com> <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> Message-ID: <49D914DA.6060107@benmabey.com> Mateusz Juraszek wrote: > Balint Erdi wrote: > >> Ben Mabey wrote: >> >> >>> Couple things I'd like to point out. In your enhanced.rb you don't need >>> to do the Before hook yourself. You can just require >>> 'database_cleaner/cucumber'. I've updated your gist to use that. >>> In your plain.rb it seems like you are trying to truncate your database >>> just once upon startup. If that is the case then the recommended way is >>> to use the clean_with method like so: >>> DatabaseCleaner.clean_with :truncation >>> >>> Again, I have updated the gist to reflect this. >>> >>> -Ben >>> >> Hey Ben, thanks a lot. >> >> The problem I am experiencing now is that information stored in the >> session does not seem to be retained between steps (again, only in the >> case of selenium sessions, plain sesssion work fine). So the login >> function works fine now but when I go to another page afterwards it >> throws a big error because the action tries to render something based on >> the current user. >> >> Is the session store I am using relevant? I used the default >> cookie-based storage and then tried to change to the active-record based >> one to no avail. My config is at http://gist.github.com/83635 >> >> Thank you, >> Balint >> > > hi Ben > > I am newbie with cucumber and bdd. I was wondering if you can take a > look on my problems. > I have similar problem like Balint. I test my own and clearance features > with selenium and webrat. I don't have to say that with werbrat > everything is perfect. When I run features with selenium I get error > nil.session what is connected with code from clearance features ie: >
> Then /^I should not be signed in$/ do
>   assert_nil request.session[:user_id]
> end
> 
> Yuck! I realize that you didn't write this and that Clearance gave you this step out of the box: http://github.com/thoughtbot/clearance/blob/fa424b8fe9fd8f151f32a726982a3fd42940b328/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb It is, IMO, a very bad way to verify if the user is logged in. (I actually used an example very similar to this in my MWRC presentation[1]. One of the reasons that makes it bad is that it makes it difficult to switch from using rails integration session to an automated browser solution like Selenium. > in clearance_step file > > It seems like selenium has problem with access to "request" object > That makes my test fail all the time. > Yep, that object exists in rails integration sessions, which is what webrat's :rails mode uses. To avoid this error you will need to specify behaviour, not implementation. I'm guessing that this step is called after you have logged out. So, the way I would test this is that I would test it from the point of view of the user. The user doesn't know about a session, much less how we are implementing our authentication system. :) When this user logs out they probably see a message indicating that they have been logged out though. So, something like this would be better: Then /^I should not be signed in$/ do response.should contain("You have been logged out.") end (Note: I'm not sure if clearance says this exactly, but you get the idea...) Using a step like this will allow you to switch between multiple adapters since you should always have the response object. > Another problem I met is with waiting for response after "press button" > method > All the time I get response with code before button pressed > It's connected with selenium_session.rb code and require me to change a > bit >
>     def click_button(button_text_or_regexp = nil, options = {})
>       if button_text_or_regexp.is_a?(Hash) && options == {}
>         pattern, options = nil, button_text_or_regexp
>       elsif button_text_or_regexp
>         pattern = adjust_if_regexp(button_text_or_regexp)
>       end
>       pattern ||= '*'
>       locator = "button=#{pattern}"
>
>       selenium.wait_for_element locator, :timeout_in_seconds => 5
>       selenium.click locator
>       selenium.wait_for_page_to_load(5) ## add this line to get correct 
> response
>     end
> 
> I don't know why I have to change it > Hmmm.. Yeah, I don't know about that. You should probably ask the webrat mailing list or open up a ticket[2]. -Ben 1. http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html 2. http://wiki.github.com/brynary/webrat/get-in-touch From lists at ruby-forum.com Sun Apr 5 17:08:53 2009 From: lists at ruby-forum.com (Balint Erdi) Date: Sun, 5 Apr 2009 23:08:53 +0200 Subject: [rspec-users] [cucumber] webrat+selenium integration problem: record n In-Reply-To: <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> References: <49C830BF.1040401@benmabey.com> <49C964F3.9000600@benmabey.com> <8aa5aba65e3d4a53021bbbe32e211708@ruby-forum.com> <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> Message-ID: <43bc899fe082ffd35df409c56da8db5c@ruby-forum.com> Hi Mateusz, > > hi Ben > > I am newbie with cucumber and bdd. I was wondering if you can take a > look on my problems. > I have similar problem like Balint. I test my own and clearance features > with selenium and webrat. I don't have to say that with werbrat > everything is perfect. When I run features with selenium I get error > nil.session what is connected with code from clearance features ie: >
> Then /^I should not be signed in$/ do
>   assert_nil request.session[:user_id]
> end
> 
> in clearance_step file > > It seems like selenium has problem with access to "request" object > That makes my test fail all the time. I cannot tell you whether step definitions should have access to the request via the request variable (they probably should). But are you sure you need to test the session directly like this? I searched for 'request' or 'session' in my step definitions and have not found any. Usually I check whether 1. a certain thing is on the page which usually involves checking the response body with the help of the webrat steps file (e.g I should see "You are logged in") 2. a new model instance has (not) been created or have an attribute set to a certain value, etc. In brief, database related things. > > Another problem I met is with waiting for response after "press button" > method > All the time I get response with code before button pressed > It's connected with selenium_session.rb code and require me to change a > bit (...) > I don't know why I have to change it > Thanks That's a bug in webrat I also came across and fixed: https://webrat.lighthouseapp.com/projects/10503/tickets/205-patch-timeout-parameter-passed-incorrectly-to-selenium It will surely be integrated in the next webrat release, you can use the supplied patch. Hope that helps, Balint -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sun Apr 5 17:47:50 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 5 Apr 2009 14:47:50 -0700 Subject: [rspec-users] Best practices: How small to make examples? In-Reply-To: <57c63afe0904051337j7fbda3b0scc2c2fa7447569@mail.gmail.com> References: <00ab01c9b59a$27d56fa0$77804ee0$@com> <57c63afe0904050520w284d9b8bt93e572904b3c7d0d@mail.gmail.com> <3c30da400904051003u2f3712cfsf3d291133a85bee9@mail.gmail.com> <85d99afe0904051116m6ed5412dx1eb053a75f949ce2@mail.gmail.com> <3c30da400904051305m13633baaw773113a637d6571e@mail.gmail.com> <57c63afe0904051337j7fbda3b0scc2c2fa7447569@mail.gmail.com> Message-ID: <3c30da400904051447p59fb8d0fncdb195f45fb0626d@mail.gmail.com> On Sun, Apr 5, 2009 at 1:37 PM, David Chelimsky wrote: > > Also, this isn't necessarily an all or nothing deal. One way I've > approached this that works well is to have a single scenario that > describes the details we're talking about, and a lot more scenarios > that are more declarative. Now you have the best of all worlds. That's what I do. One member of our team believes that every scenario has to follow the UI all the way from login to the end result. I don't go that far. ///ark From btelles at gmail.com Sun Apr 5 13:51:44 2009 From: btelles at gmail.com (Bernie) Date: Sun, 5 Apr 2009 10:51:44 -0700 (PDT) Subject: [rspec-users] Problem with colorized output in cygwin on Vista (was: RSpec Formats with Strange Characters) In-Reply-To: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> References: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> Message-ID: Brandon, This was a tough one, although I still don't have color on autospec (only have color when running specs manually ), AND I forgot exactly how the problem was solved, but hopefully this will get you in the right direction. 1. here are two gems that may help: gem install term-ansicolor gem install win32console and then for some reason I aded the following to my /cygdrive/c/ Users//irbrc file (I'm not sure if this is necessary for running specs, but you may want to try it). require 'win32console' 2. finally installing and using the RXVT shell instead may have solved the problem (again, I compleletely forgot) You can find it in the "Shells" section of the CYGWIN installer. Here are the three checks I used: rxvt: VT102... rxvt-unicode-X: An improved... rxvt-unicode-common: An improved.... 3. If you're doing a lot of work on IRB, you may want to also install Wirble and add a few more lines to your irbrc: require 'wirble' Wirble.init Wirble.colorize Wellp, hope this at least got you in the right direction...if you find out how to colorize autospec, could you let me know? Bernie On Apr 5, 12:23?pm, David Chelimsky wrote: > Changing the name of this to hopefully catch the eye of other > Vista/cygwin/rspec users. > > On Sun, Apr 5, 2009 at 9:45 AM, Brandon Olivares > > wrote: > > >> -----Original Message----- > >> From: rspec-users-boun... at rubyforge.org [mailto:rspec-users- > >> boun... at rubyforge.org] On Behalf Of aslak hellesoy > >> Sent: Sunday, April 05, 2009 6:50 AM > >> To: rspec-users > >> Subject: Re: [rspec-users] RSpec Formats with Strange Characters > > >> Please describe your environment. OS, various versions etc. > > > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. > > Those characters are for coloring the output. I'm running XP in > Parallels w/ ruby 1.8.7 and cygwin and I get colored output rather > than seeing those characters. I'm guessing Vista is different :) > > Anybody else running Vista that knows how to get this to work? > > > > > Thanks, > > Brandon > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From morten at gmin.org Sun Apr 5 16:40:04 2009 From: morten at gmin.org (GMin, Morten K. Holst) Date: Sun, 5 Apr 2009 22:40:04 +0200 Subject: [rspec-users] [cucumber] Nested resource in paths.rb Message-ID: Hello Rspec Users, I was wondering how you specify a nested resource in cucumber. So for example: Given I have a blogpost titled Question For Nice Rspec Users When I am on the list of comments for Question For Nice Rspec Users Then I should see "Answer" Now, as one might expect, blogpost has_many :comments, so my question is this: How should I write the "when-case" for "the list of comments for Question For Nice Rspec Users" in paths.rb? What I'm asking about in particular is how to extract the "Question For Nice Rspec Users" part and use it to find the blogpost I created earlier and thus generate the path from a nested route e.g. comments_path(blogpost). Many thanks in advance. - Morten -------------- next part -------------- An HTML attachment was scrubbed... URL: From programmer2188 at gmail.com Sun Apr 5 21:35:29 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 5 Apr 2009 21:35:29 -0400 Subject: [rspec-users] Problem with colorized output in cygwin on Vista (was: RSpec Formats with Strange Characters) In-Reply-To: References: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> Message-ID: <001401c9b657$f9b3f420$ed1bdc60$@com> Hi, Thanks. Installing term-ansicolor worked. The console still shows the colors and the text files do not have strange characters. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Bernie > Sent: Sunday, April 05, 2009 1:52 PM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Problem with colorized output in cygwin on > Vista (was: RSpec Formats with Strange Characters) > > Brandon, > This was a tough one, although I still don't have color on autospec > (only have color when running specs manually ), AND I forgot exactly > how the problem was solved, but hopefully this will get you in the > right direction. > > 1. here are two gems that may help: > gem install term-ansicolor > gem install win32console > and then for some reason I aded the following to my /cygdrive/c/ > Users//irbrc file (I'm not sure if this is necessary for > running specs, but you may want to try it). > require 'win32console' > > 2. finally installing and using the RXVT shell instead may have solved > the problem (again, I compleletely forgot) > You can find it in the "Shells" section of the CYGWIN installer. > Here are the three checks I used: > rxvt: VT102... > rxvt-unicode-X: An improved... > rxvt-unicode-common: An improved.... > > 3. If you're doing a lot of work on IRB, you may want to also install > Wirble and add a few more lines to your irbrc: > require 'wirble' > Wirble.init > Wirble.colorize > > Wellp, hope this at least got you in the right direction...if you find > out how to colorize autospec, could you let me know? > Bernie > > On Apr 5, 12:23?pm, David Chelimsky wrote: > > Changing the name of this to hopefully catch the eye of other > > Vista/cygwin/rspec users. > > > > On Sun, Apr 5, 2009 at 9:45 AM, Brandon Olivares > > > > wrote: > > > > >> -----Original Message----- > > >> From: rspec-users-boun... at rubyforge.org [mailto:rspec-users- > > >> boun... at rubyforge.org] On Behalf Of aslak hellesoy > > >> Sent: Sunday, April 05, 2009 6:50 AM > > >> To: rspec-users > > >> Subject: Re: [rspec-users] RSpec Formats with Strange Characters > > > > >> Please describe your environment. OS, various versions etc. > > > > > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. > > > > Those characters are for coloring the output. I'm running XP in > > Parallels w/ ruby 1.8.7 and cygwin and I get colored output rather > > than seeing those characters. I'm guessing Vista is different :) > > > > Anybody else running Vista that knows how to get this to work? > > > > > > > > > Thanks, > > > Brandon > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-us... at rubyforge.org > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec- > users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From programmer2188 at gmail.com Sun Apr 5 21:39:39 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 5 Apr 2009 21:39:39 -0400 Subject: [rspec-users] Problem with colorized output in cygwin on Vista (was: RSpec Formats with Strange Characters) In-Reply-To: References: <57c63afe0904050923q642f510elf05cd6da38a7186@mail.gmail.com> Message-ID: <001501c9b658$8efb7030$acf25090$@com> Hi, Nevermind that. I realized it works fine if I run rake spec, but not if I run script/autospec and only some of the examples run. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Bernie > Sent: Sunday, April 05, 2009 1:52 PM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Problem with colorized output in cygwin on > Vista (was: RSpec Formats with Strange Characters) > > Brandon, > This was a tough one, although I still don't have color on autospec > (only have color when running specs manually ), AND I forgot exactly > how the problem was solved, but hopefully this will get you in the > right direction. > > 1. here are two gems that may help: > gem install term-ansicolor > gem install win32console > and then for some reason I aded the following to my /cygdrive/c/ > Users//irbrc file (I'm not sure if this is necessary for > running specs, but you may want to try it). > require 'win32console' > > 2. finally installing and using the RXVT shell instead may have solved > the problem (again, I compleletely forgot) > You can find it in the "Shells" section of the CYGWIN installer. > Here are the three checks I used: > rxvt: VT102... > rxvt-unicode-X: An improved... > rxvt-unicode-common: An improved.... > > 3. If you're doing a lot of work on IRB, you may want to also install > Wirble and add a few more lines to your irbrc: > require 'wirble' > Wirble.init > Wirble.colorize > > Wellp, hope this at least got you in the right direction...if you find > out how to colorize autospec, could you let me know? > Bernie > > On Apr 5, 12:23?pm, David Chelimsky wrote: > > Changing the name of this to hopefully catch the eye of other > > Vista/cygwin/rspec users. > > > > On Sun, Apr 5, 2009 at 9:45 AM, Brandon Olivares > > > > wrote: > > > > >> -----Original Message----- > > >> From: rspec-users-boun... at rubyforge.org [mailto:rspec-users- > > >> boun... at rubyforge.org] On Behalf Of aslak hellesoy > > >> Sent: Sunday, April 05, 2009 6:50 AM > > >> To: rspec-users > > >> Subject: Re: [rspec-users] RSpec Formats with Strange Characters > > > > >> Please describe your environment. OS, various versions etc. > > > > > Ruby 1.8.7, RSpec 1.2.2, Cygwin on Windows Vista. > > > > Those characters are for coloring the output. I'm running XP in > > Parallels w/ ruby 1.8.7 and cygwin and I get colored output rather > > than seeing those characters. I'm guessing Vista is different :) > > > > Anybody else running Vista that knows how to get this to work? > > > > > > > > > Thanks, > > > Brandon > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-us... at rubyforge.org > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec- > users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Mon Apr 6 00:56:45 2009 From: lists at ruby-forum.com (Mateusz Juraszek) Date: Mon, 6 Apr 2009 06:56:45 +0200 Subject: [rspec-users] =?utf-8?q?=5Bcucumber=5D_checking_if_a_user_is_logg?= =?utf-8?q?ed_in_=28Was=3A_webrat+selenium_integration_problem=3A?= =?utf-8?q?=09record_n=29?= In-Reply-To: <49D914DA.6060107@benmabey.com> References: <49C830BF.1040401@benmabey.com> <49C964F3.9000600@benmabey.com> <8aa5aba65e3d4a53021bbbe32e211708@ruby-forum.com> <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> <49D914DA.6060107@benmabey.com> Message-ID: That makes more sense than my theory. Thank you Ben and thank you Balint. BTW nice presentation -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Apr 6 01:22:08 2009 From: lists at ruby-forum.com (Mateusz Juraszek) Date: Mon, 6 Apr 2009 07:22:08 +0200 Subject: [rspec-users] [cucumber] webrat+selenium integration problem: record n In-Reply-To: <43bc899fe082ffd35df409c56da8db5c@ruby-forum.com> References: <49C830BF.1040401@benmabey.com> <49C964F3.9000600@benmabey.com> <8aa5aba65e3d4a53021bbbe32e211708@ruby-forum.com> <7c64a7ca84ff85cf810e3f8aa96405ec@ruby-forum.com> <43bc899fe082ffd35df409c56da8db5c@ruby-forum.com> Message-ID: >> Another problem I met is with waiting for response after "press button" >> method >> All the time I get response with code before button pressed >> It's connected with selenium_session.rb code and require me to change a >> bit > (...) >> I don't know why I have to change it >> Thanks > > That's a bug in webrat I also came across and fixed: > https://webrat.lighthouseapp.com/projects/10503/tickets/205-patch-timeout-parameter-passed-incorrectly-to-selenium > > It will surely be integrated in the next webrat release, you can use the > supplied patch. > > Hope that helps, > Balint As you can see in my first post I actually used your solution first (selenium.wait_for_element locator, :timeout_in_seconds => 5 for each method) but it doesn't work for me, because in my case selenium compares expectations with page source before action (page source before sending form and get redirection etc). Then I added selenium.wait_for_page_to_load(5) to get correct request. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Apr 6 04:34:09 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 6 Apr 2009 10:34:09 +0200 Subject: [rspec-users] [cucumber] Nested resource in paths.rb In-Reply-To: References: Message-ID: <8d961d900904060134v5e92be9dma96dcc9372b8f31c@mail.gmail.com> On Sun, Apr 5, 2009 at 10:40 PM, GMin, Morten K. Holst wrote: > Hello Rspec Users, > I was wondering how you specify a nested resource in cucumber. So for > example: > > Given I have a blogpost titled Question For Nice Rspec Users > When I am on the list of comments for Question For Nice Rspec Users > Then I should see "Answer" > > Now, as one might expect, blogpost has_many :comments, so my question is > this: > > How should I write the "when-case" for "the list of comments for Question > For Nice Rspec Users" in paths.rb? > You shouldn't. It wasn't meant for that. I just wrote a more detailed explanation (and tip) in RDoc: http://github.com/aslakhellesoy/cucumber/commit/78ba010b4b7186675841fbd4cc57a60a50686221 Aslak > > What I'm asking about in particular is how to extract the "Question For > Nice Rspec Users" part and use it to find the blogpost I created earlier and > thus generate the path from a nested route e.g. comments_path(blogpost). > > Many thanks in advance. > > - Morten > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Apr 6 08:11:41 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Mon, 6 Apr 2009 14:11:41 +0200 Subject: [rspec-users] debuggin cucmber script in ruby Message-ID: basically to debug a ruby script we use: ruby -rspecs -rdebug file.rb which would debug ruby script line by line. Is there any such debuging feauture in cucumber. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Mon Apr 6 09:55:54 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 06 Apr 2009 07:55:54 -0600 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: References: Message-ID: <49DA09EA.1010103@benmabey.com> Anil Gollaa wrote: > basically to debug a ruby script we use: > ruby -rspecs -rdebug file.rb > which would debug ruby script line by line. > > Is there any such debuging feauture in cucumber. > I just require 'ruby-debug' and set a debugger statement where I want to stop it. When you run cucumber it will pop into rdg where you set the breakpoint. If that doesn't make sense, this post has more detail: http://technicalpickles.com/posts/debugging-cucumber -Ben From byrnejb at harte-lyne.ca Mon Apr 6 11:02:12 2009 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Mon, 6 Apr 2009 11:02:12 -0400 (EDT) Subject: [rspec-users] Best practices: How small to make > examples? In-Reply-To: References: Message-ID: <54422.216.185.71.24.1239030132.squirrel@webmail.harte-lyne.ca> On: Sun, 5 Apr 2009 10:03:40 -0700, Mark Wilden wrote: > > On Sun, Apr 5, 2009 at 5:20 AM, David Chelimsky > wrote: > >> Given I register for a conference >> Then my name should be on the list of conference attendees >> And the conference should be my list of conferences > > If I were describing 'register for a conference' in this scenario, > then I would think it important to specify the steps that are used: > > Given I am logged in > And I go to the registration page > And I fill in the email field > And I click "Register" > Then my name should be on the list of conference attendees > And the conference should be my list of conferences > > That's the level of detail the story would have, so that's what I > want to show works. > At the moment, I tend to take a "middle of the road" approach. (Typically Canadian, eh?) Given user "myuser" is authenticated When they visit the registration page And they provide all required registration data And they choose "register" Then they should see a registration success message And ... In the step definitions, one then chooses exactly what constitutes /all required registration data/, or how /choose "register"/ is implemented (button, link), or what a /registration success message/ looks like. If it is deemed absolutely essential to prove that a specific input field is available in the view then this can be slipped in under the /required ... data/ clause. And they provide all required registration data And they enter the email address "myuser at example.com" In my, admittedly limited, experience this approach gives you all the essential elements that the client needs to approve. Yet, it still provides flexibility on how meeting the requirements are implemented and tested, without breaking the scenario clauses. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From lists at ruby-forum.com Mon Apr 6 11:41:14 2009 From: lists at ruby-forum.com (Anil Gollaa) Date: Mon, 6 Apr 2009 17:41:14 +0200 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <49DA09EA.1010103@benmabey.com> References: <49DA09EA.1010103@benmabey.com> Message-ID: <427205c9c9f13cacba511275d94cf132@ruby-forum.com> hi, Thanks for the information, When i run cucumber testfile.feature, I was able to halt execution at breakpoint, but when i type 'n'. it is getting in to /lib/cucumber/ast/step_invocation.rb:33 and some other lib files of cucumber. I just want to debug line by line of the script, instead of getting in to cucumber files. please help me in this regard -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Mon Apr 6 12:21:42 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 06 Apr 2009 10:21:42 -0600 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <427205c9c9f13cacba511275d94cf132@ruby-forum.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> Message-ID: <49DA2C16.6090208@benmabey.com> Anil Gollaa wrote: > hi, > Thanks for the information, > When i run cucumber testfile.feature, I was able to halt execution at > breakpoint, but when i type 'n'. it is getting in to > /lib/cucumber/ast/step_invocation.rb:33 and some other lib files of > cucumber. > > I just want to debug line by line of the script, instead of getting in > to cucumber files. > > please help me in this regard > Sorry, but I don't know of anything that will automatically allow you to skip over framework code.. Although, that would be very cool. My best suggestion would be to set multiple breakpoints and hit "c" to continue to the next one so you can skip through all of Cucumber's code. -Ben From mark at mwilden.com Mon Apr 6 12:36:50 2009 From: mark at mwilden.com (Mark Wilden) Date: Mon, 6 Apr 2009 09:36:50 -0700 Subject: [rspec-users] Best practices: How small to make > examples? In-Reply-To: <54422.216.185.71.24.1239030132.squirrel@webmail.harte-lyne.ca> References: <54422.216.185.71.24.1239030132.squirrel@webmail.harte-lyne.ca> Message-ID: <3c30da400904060936h5397f55w12c8c5d834bdfb7@mail.gmail.com> On Mon, Apr 6, 2009 at 8:02 AM, James B. Byrne wrote: > > ?Given user "myuser" is authenticated > ?When they visit the registration page > ? And they provide all required registration data > ? And they choose "register" > ?Then they should see a registration success message I have two issues with this: 1) How could this story be "acceptable"? In other words, how could business say that it's done? The success of this scenario would not indicate very much about the success of the application. 2) There are different levels of granularity here. There are very specific steps ('they visit the registration page', 'they should see a registration success message') that relate to a specific URL or page element. Then there is the catch-all 'all required registration data.' To me, this doesn't communicate anything meaningful to business. It's akin to 'Then it should work'. Obviously, a scenario is not a formal requirements document. Nevertheless, if what it asserts is too generic, how much benefit is there in executing it? ///ark From jgoodsen at radsoft.com Mon Apr 6 13:29:55 2009 From: jgoodsen at radsoft.com (John Goodsen) Date: Mon, 6 Apr 2009 13:29:55 -0400 Subject: [rspec-users] a wiki to host Cuke & webrat? In-Reply-To: References: Message-ID: I never said it was done - you are supposed to help out Phlip! On Fri, Apr 3, 2009 at 6:52 PM, Phlip wrote: > John Goodsen wrote: > >> this was my vision with rcumber - I haven't worked on it for a few months, >> but it's basically a rails plugin that provides a web interface to edit and >> run cucumber tests.... I'd love some help and ideas from others to take >> this to a more universally usable tool - we use it right now on 1 project. >> rcumber is at http://github.com/jgoodsen/rcumber/tree/master >> > > I didn't see a "plugin" here. Just a lite wiki, without even security or > other heavy wiki features, that you prop up next to your projects. Put > another way, if I were installing this, I didn't want to have to plug it > into an existing project... > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- John Goodsen RADSoft / Better Software Faster jgoodsen at radsoft.com Lean/Agile/XP/Scrum Coaching and Training http://www.radsoft.com Ruby on Rails and Java Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From oli.azevedo.barnes at gmail.com Mon Apr 6 18:39:10 2009 From: oli.azevedo.barnes at gmail.com (Oliver Barnes) Date: Mon, 6 Apr 2009 19:39:10 -0300 Subject: [rspec-users] [cucumber] more than one keyword translation Message-ID: <6466d9040904061539w54dbab83k342fe46a083d5bc0@mail.gmail.com> Hello, I'm trying to get Given in Portuguese to have two translations, "Dado" and "Dada" (variations on gender), so that the features are more readable. so I have this in my languages.yml: given: Dado|Dada (found this syntax in a comment within the cucumber codebase) but when I run cucumber -l pt -f progress features/ the second option isn't read: ./features/step_definitions/clipping/gerenciamento_de_clippings_steps.rb:1: undefined method `Dado' for # (NoMethodError) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:76:in `require_files' from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:74:in `each' from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:74:in `require_files' from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:34:in `execute!' from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' from /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 from /usr/bin/cucumber:19:in `load' from /usr/bin/cucumber:19 what's the correct way to do this? - Oliver From zach.dennis at gmail.com Mon Apr 6 18:59:04 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 6 Apr 2009 18:59:04 -0400 Subject: [rspec-users] Best practices: How small to make > examples? In-Reply-To: <3c30da400904060936h5397f55w12c8c5d834bdfb7@mail.gmail.com> References: <54422.216.185.71.24.1239030132.squirrel@webmail.harte-lyne.ca> <3c30da400904060936h5397f55w12c8c5d834bdfb7@mail.gmail.com> Message-ID: <85d99afe0904061559v6f0d099bh2cdba54147dab265@mail.gmail.com> On Mon, Apr 6, 2009 at 12:36 PM, Mark Wilden wrote: > On Mon, Apr 6, 2009 at 8:02 AM, James B. Byrne wrote: >> >> ?Given user "myuser" is authenticated >> ?When they visit the registration page >> ? And they provide all required registration data >> ? And they choose "register" >> ?Then they should see a registration success message > You left out the "And..." which I believe James used to denote anything else that needed to be done to ensure the registration was successful. Maybe on purpose, maybe by accident, but it seems to have impacted your response. Maybe what you responded with was exactly what you meant to say, but it feels like a response made with haste. > I have two issues with this: > > 1) How could this story be "acceptable"? In other words, how could > business say that it's done? The success of this scenario would not > indicate very much about the success of the application. > > 2) There are different levels of granularity here. There are very > specific steps ('they visit the registration page', 'they should see a > registration success message') that relate to a specific URL or page > element. Then there is the catch-all 'all required registration data.' > To me, this doesn't communicate anything meaningful to business. It's > akin to 'Then it should work'. > > Obviously, a scenario is not a formal requirements document. > Nevertheless, if what it asserts is too generic, how much benefit is > there in executing it? > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From akleak at gmail.com Mon Apr 6 17:50:04 2009 From: akleak at gmail.com (Arco) Date: Mon, 6 Apr 2009 14:50:04 -0700 (PDT) Subject: [rspec-users] Autospec Infinite Loop ?? Message-ID: <80248ec8-a49b-492b-b63f-c5a46cc0e6a3@r33g2000yqn.googlegroups.com> When I run autospec and I have a red example, autospec goes into an infinite loop and runs over and over until I get rid of the red. I hate this. I want my tests to just run once when my ruby file is saved - even if I have red examples. The infinite loop does not happen if my examples are all green, all yellow or a mix of green and yellow. I have tried ZenTest 3.11, Zentest 4.0, and autotest (http:// github.com/grosser/autotest/tree/master). Is there a way to make autospec run just once if it sees a red example? I am using rspec 1.2.2, platform: cygwin - testing a standalone ruby class. Thanks!!! From dchelimsky at gmail.com Mon Apr 6 19:50:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 6 Apr 2009 18:50:02 -0500 Subject: [rspec-users] Autospec Infinite Loop ?? In-Reply-To: <80248ec8-a49b-492b-b63f-c5a46cc0e6a3@r33g2000yqn.googlegroups.com> References: <80248ec8-a49b-492b-b63f-c5a46cc0e6a3@r33g2000yqn.googlegroups.com> Message-ID: <57c63afe0904061650v473ffeb4g2ae978d1ba00bed2@mail.gmail.com> On Mon, Apr 6, 2009 at 4:50 PM, Arco wrote: > When I run autospec and I have a red example, autospec goes into an > infinite loop and runs over and over until I get rid of the red. > > I hate this. ?I want my tests to just run once when my ruby file is > saved - even if I have red examples. > > The infinite loop does not happen if my examples are all green, all > yellow or a mix of green and yellow. > > I have tried ZenTest 3.11, Zentest 4.0, and autotest (http:// > github.com/grosser/autotest/tree/master). > > Is there a way to make autospec run just once if it sees a red > example? > > I am using rspec 1.2.2, platform: cygwin - testing a standalone ruby > class. What's in your spec/spec.opts file? > > Thanks!!! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Mon Apr 6 20:02:25 2009 From: mark at mwilden.com (Mark Wilden) Date: Mon, 6 Apr 2009 17:02:25 -0700 Subject: [rspec-users] Best practices: How small to make > examples? In-Reply-To: <85d99afe0904061559v6f0d099bh2cdba54147dab265@mail.gmail.com> References: <54422.216.185.71.24.1239030132.squirrel@webmail.harte-lyne.ca> <3c30da400904060936h5397f55w12c8c5d834bdfb7@mail.gmail.com> <85d99afe0904061559v6f0d099bh2cdba54147dab265@mail.gmail.com> Message-ID: <3c30da400904061702x350c87fbye202625e04a23ee6@mail.gmail.com> On Mon, Apr 6, 2009 at 3:59 PM, Zach Dennis wrote: > On Mon, Apr 6, 2009 at 12:36 PM, Mark Wilden wrote: >> On Mon, Apr 6, 2009 at 8:02 AM, James B. Byrne wrote: >>> >>> ?Given user "myuser" is authenticated >>> ?When they visit the registration page >>> ? And they provide all required registration data >>> ? And they choose "register" >>> ?Then they should see a registration success message >> > > You left out the "And..." which I believe James used to denote > anything else that needed to be done to ensure the registration was > successful. The "And..." was a part of the "Then", and I was talking about the "When...". Also, James talked about putting requirements in the step definitions, and I believe my two concerns are still relevant in that case. However, admittedly I did gloss over "If it is deemed absolutely essential to prove that a specific input field is available in the view then this can be slipped in under the /required ... data/ clause." But I still think this represents a different viewpoint my own. The user's input is indeed essential to make a verifiable and descriptive scenario like this one, IMO. Sorry if I distorted James message to try to reiterate that point. ///ark > Maybe on purpose, maybe by accident, but it seems to have > impacted your response. Maybe what you responded with was exactly what > you meant to say, but it feels like a response made with haste. > >> I have two issues with this: >> >> 1) How could this story be "acceptable"? In other words, how could >> business say that it's done? The success of this scenario would not >> indicate very much about the success of the application. >> >> 2) There are different levels of granularity here. There are very >> specific steps ('they visit the registration page', 'they should see a >> registration success message') that relate to a specific URL or page >> element. Then there is the catch-all 'all required registration data.' >> To me, this doesn't communicate anything meaningful to business. It's >> akin to 'Then it should work'. >> >> Obviously, a scenario is not a formal requirements document. >> Nevertheless, if what it asserts is too generic, how much benefit is >> there in executing it? >> >> ///ark >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Mon Apr 6 20:10:34 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 6 Apr 2009 20:10:34 -0400 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <49DA2C16.6090208@benmabey.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> Message-ID: <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> On Mon, Apr 6, 2009 at 12:21 PM, Ben Mabey wrote: > Anil Gollaa wrote: >> >> hi, >> Thanks for the information, >> When i run cucumber testfile.feature, I was able to halt execution at >> breakpoint, but when i type 'n'. it is getting in to >> /lib/cucumber/ast/step_invocation.rb:33 and some other lib files of >> cucumber. >> >> I just want to debug line by line of the script, instead of getting in to >> cucumber files. >> >> please help me in this regard >> > > Sorry, but I don't know of anything that will automatically allow you to > skip over framework code.. Although, that would be very cool. ?My best > suggestion would be to set multiple breakpoints and hit "c" to continue to > the next one so you can skip through all of Cucumber's code. > I will sometimes set a global variable to help me flag when to debug, if the code in question gets executed multiple times. e.g. $c = true if my_condition_is_met And then... debugger if $c > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Mon Apr 6 20:34:27 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 6 Apr 2009 19:34:27 -0500 Subject: [rspec-users] [rspec] Deprecate --dry-run Message-ID: <57c63afe0904061734o386500bdwf9a879bd608cf76f@mail.gmail.com> Hey all, Anybody use the --dry-run command line option? I'm planning to deprecate it if nobody has a compelling reason to keep it. Please post your comments in the ticket: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/781-deprecate-dry-run Thanks, David From byrnejb at harte-lyne.ca Mon Apr 6 21:29:05 2009 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Mon, 6 Apr 2009 21:29:05 -0400 (EDT) Subject: [rspec-users] Best practices: How small to make > > examples? In-Reply-To: References: Message-ID: <60790.65.92.52.21.1239067745.squirrel@webmail.harte-lyne.ca> On: Mon, 6 Apr 2009 09:36:50 -0700, Mark Wilden wrote: > On Mon, Apr 6, 2009 at 8:02 AM, James B. Byrne > wrote: >> >> ?Given user "myuser" is authenticated >> ?When they visit the registration page >> ? And they provide all required registration data >> ? And they choose "register" >> ?Then they should see a registration success message > > I have two issues with this: > > 1) How could this story be "acceptable"? In other words, how could > business say that it's done? The success of this scenario would not > indicate very much about the success of the application. I venture that few solitary scenarios ever say much about the success of the application. This example is only a single (incomplete and somewhat contrived) scenario within a feature that itself is but one of several that describe just one aspect of an application. I do not think that one can lay too much weight upon it. > > 2) There are different levels of granularity here. There are very > specific steps ('they visit the registration page', 'they should see > a registration success message') that relate to a specific URL or > page element. Then there is the catch-all 'all required registration > data.' Which clause serves as shorthand after what constitutes "all required registration data" is defined elsewhere. Some of the detail is provided to set up the scenario. Perhaps there are better ways of accomplishing this but this practice serves and is neither obscure nor overwhelmingly detailed. > To me, this doesn't communicate anything meaningful to business. > It's akin to 'Then it should work'. Well, perhaps I have missed the point again. Nonetheless, this sort of approach seems to provide me with a reasonable balance between too much detail: inputs "x at y.com" in the email box inputs "Jeffery Q. Nameless" in the user name field clicks on "Update" And too little: Given an application home page When a visitor visits the application Then they see "Welcome to X" And they see a login field. > > Obviously, a scenario is not a formal requirements document. > Nevertheless, if what it asserts is too generic, how much benefit is > there in executing it? Whether my current practice is right or wrong I do not know, but I am finding that much of the implementation detail has migrated from the scenarios into the step definitions. I find that I am using the scenarios to drive the functional aspects of the application. At the moment for instance I am dealing with this scenario: ... When we visit the new entity page And we enter valid entity data And we fill in "Common Name" with "Short N" And we press create Then the entity named "Short N" should have an alias "short n" Now this last clause drives this step: When /the entity named "([^\"]*)" should have an alias "([^\"]*)"/ do |name,aka| my_identifiers = Entity.find_by_entity_common_name!( name.hll_normalise).identifiers ... end The mix of granularity, And we enter valid entity data And we fill in "Common Name" with "Short N" And we press create Then the entity named "Short N" should have an alias "short n" removes the clutter of background detail and focuses on the bit of functionality that I want to explore here, the creation of an alias. It may not be canonical usage, but it is working for me. As I obtain greater skills and experience then no doubt my practices will evolve. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From michael at schuerig.de Mon Apr 6 21:56:57 2009 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 7 Apr 2009 03:56:57 +0200 Subject: [rspec-users] JSON matcher Message-ID: <200904070356.57692.michael@schuerig.de> Curiously, there doesn't seem to be a matcher around that matches a JSON string against an expected ruby object. Below is what I've come up with, including some Rails idiosyncrasies. Any suggestions for improvements? Michael module Spec module JSONMatchers class BeJsonEql def initialize(expected) @raw_expected = expected @expected = decode(expected, 'expected') end def matches?(target) @raw_target = target @target = decode(target, 'target') @target == @expected end def failure_message "expected\n#{@raw_target}\n" + "to be JSON code equivalent to\n#{@raw_expected}\n" + "Difference:\n#{@expected.diff(@target).inspect}" end def negative_failure_message "expected\n#{@raw_target}\n" + "to be JSON code different from\n#{@raw_expected}" end private def decode(s, which) ActiveSupport::JSON.decode(s) rescue ActiveSupport::JSON::ParseError raise ArgumentError, "Invalid #{which} JSON string: #{s.inspect}" end end def be_json_eql(expected) BeJsonEql.new(expected) end end end -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From phlip2005 at gmail.com Mon Apr 6 22:08:35 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 06 Apr 2009 19:08:35 -0700 Subject: [rspec-users] a wiki to host Cuke & webrat? In-Reply-To: References: Message-ID: John Goodsen wrote: > I never said it was done - you are supposed to help out Phlip! Verbiage issue - sorry! > I didn't see a "plugin" here. I didn't "envision a plugin in this problem space". I didn't mean I didn't physically see one in your site... > Just a lite wiki, without even > security or other heavy wiki features, that you prop up next to your > projects. Put another way, if I were installing this, I didn't want > to have to plug it into an existing project... From phlip2005 at gmail.com Mon Apr 6 22:22:52 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 06 Apr 2009 19:22:52 -0700 Subject: [rspec-users] JSON matcher In-Reply-To: <200904070356.57692.michael@schuerig.de> References: <200904070356.57692.michael@schuerig.de> Message-ID: Michael Schuerig wrote: > def failure_message > "expected\n#{@raw_target}\n" + > "to be JSON code equivalent to\n#{@raw_expected}\n" + > "Difference:\n#{@expected.diff(@target).inspect}" > end Nice - this fixes the common problem with assertions on large bulky variables - they often leave you squinting, trying to see the line that's different. But where did .diff() come from? should I know it's part of ActiveSupport::JSON or something? From jared at yourelevation.com Mon Apr 6 20:06:08 2009 From: jared at yourelevation.com (jared) Date: Mon, 6 Apr 2009 17:06:08 -0700 (PDT) Subject: [rspec-users] spec'ing theme views Message-ID: I'm using the theme support plugin on one of my apps, and I would like to spec the views for each of my themes, but having a little trouble and hoping someone can point me in the right direction. Themed views are located at /themes/my_theme/views that override the views in app/views when that theme is active. I created a themes/ my_theme/spec directory, and to spec the file at /themes/my_theme/ views/default/index.html.erb I created the following file at themes/ my_theme/spec/default/index.html.erb_spec.rb require File.expand_path(File.dirname(__FILE__) + '/../../../../spec/ spec_helper') describe "/default/index.html.erb" do include DefaultHelper it "should render" do render end end Two major questions here: 1) I'm not sure what to put for the describe parameter since I'm assuming "/default/index.html.erb" is referencing the app/views directory 2) Running this spec gives: NameError in '/default/index.html.erb should render' undefined local variable or method `render' for # themes/my_theme/spec/default/index.html.erb_spec.rb:11: any suggestions on how to approach this? Thanks! From zach.dennis at gmail.com Tue Apr 7 00:03:29 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 7 Apr 2009 00:03:29 -0400 Subject: [rspec-users] spec'ing theme views In-Reply-To: References: Message-ID: <85d99afe0904062103m67761930q515e4fe0c84ca2b5@mail.gmail.com> On Mon, Apr 6, 2009 at 8:06 PM, jared wrote: > I'm using the theme support plugin on one of my apps, and I would like > to spec the views for each of my themes, but having a little trouble > and hoping someone can point me in the right direction. > > Themed views are located at /themes/my_theme/views that override the > views in app/views when that theme is active. I created a themes/ > my_theme/spec directory, and to spec the file at /themes/my_theme/ > views/default/index.html.erb I created the following file at themes/ > my_theme/spec/default/index.html.erb_spec.rb > > require File.expand_path(File.dirname(__FILE__) + '/../../../../spec/ > spec_helper') > > describe "/default/index.html.erb" do > ?include DefaultHelper > > ?it "should render" do > ? ?render > ?end > > end > > Two major questions here: > > 1) I'm not sure what to put for the describe parameter since I'm > assuming "/default/index.html.erb" is referencing the app/views > directory This is a textual description used to help you. It doesn't actually mean anything to rspec at this time AFAIK. RSpec is able to to treat specs found in "spec/views/" as ViewExampleGroups based on the "view" directory naming convention, IIRC. > > 2) Running this spec gives: > > NameError in '/default/index.html.erb should render' > undefined local variable or method `render' for > # > themes/my_theme/spec/default/index.html.erb_spec.rb:11: > > any suggestions on how to approach this? Try passing in :type => "view" to your describe. e.g.: describe "your/partial", :type => "view" do # ... end Where does that take you? > > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Tue Apr 7 00:23:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 6 Apr 2009 23:23:54 -0500 Subject: [rspec-users] spec'ing theme views In-Reply-To: References: Message-ID: <57c63afe0904062123q31358a82o55d48b8448521198@mail.gmail.com> On Mon, Apr 6, 2009 at 7:06 PM, jared wrote: > I'm using the theme support plugin on one of my apps, and I would like > to spec the views for each of my themes, but having a little trouble > and hoping someone can point me in the right direction. > > Themed views are located at /themes/my_theme/views that override the > views in app/views when that theme is active. I created a themes/ > my_theme/spec directory, and to spec the file at /themes/my_theme/ > views/default/index.html.erb I created the following file at themes/ > my_theme/spec/default/index.html.erb_spec.rb > > require File.expand_path(File.dirname(__FILE__) + '/../../../../spec/ > spec_helper') > > describe "/default/index.html.erb" do > ?include DefaultHelper > > ?it "should render" do > ? ?render > ?end > > end > > Two major questions here: > > 1) I'm not sure what to put for the describe parameter since I'm > assuming "/default/index.html.erb" is referencing the app/views > directory Try this: describe "/default/index.html.erb", :type => :view do include DefaultHelper it "should render" do template.view_paths=(File.join(File.dirname(__FILE__), "/../../../themes/my_theme/")) render end end Cheers, David > > 2) Running this spec gives: > > NameError in '/default/index.html.erb should render' > undefined local variable or method `render' for > # > themes/my_theme/spec/default/index.html.erb_spec.rb:11: > > any suggestions on how to approach this? > > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Tue Apr 7 00:59:45 2009 From: phlip2005 at gmail.com (Phlip) Date: Mon, 06 Apr 2009 21:59:45 -0700 Subject: [rspec-users] spec'ing theme views In-Reply-To: <57c63afe0904062123q31358a82o55d48b8448521198@mail.gmail.com> References: <57c63afe0904062123q31358a82o55d48b8448521198@mail.gmail.com> Message-ID: David Chelimsky wrote: > Try this: > > describe "/default/index.html.erb", :type => :view do > include DefaultHelper > > it "should render" do > template.view_paths=(File.join(File.dirname(__FILE__), > "/../../../themes/my_theme/")) > render > end And why isn't that DRY with the matching /../../../themes code on the production side? BTW, as a meta-answer, I implemented this algorithm for a test once... for each theme in themes/* render the theme assert the theme passes Tidy validation assert all the a hrefs point somewhere assert every image appears in public/images Hours of fun! If you have two many themes, you can pick a random assortment for each integration test run... From dchelimsky at gmail.com Tue Apr 7 01:12:40 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 00:12:40 -0500 Subject: [rspec-users] spec'ing theme views In-Reply-To: References: <57c63afe0904062123q31358a82o55d48b8448521198@mail.gmail.com> Message-ID: <57c63afe0904062212p2187f6b8he9ad928cbf2fce0c@mail.gmail.com> On Mon, Apr 6, 2009 at 11:59 PM, Phlip wrote: > David Chelimsky wrote: > >> Try this: >> >> describe "/default/index.html.erb", :type => :view do >> ?include DefaultHelper >> >> ?it "should render" do >> ? template.view_paths=(File.join(File.dirname(__FILE__), >> "/../../../themes/my_theme/")) >> ? render >> ?end > > And why isn't that DRY with the matching /../../../themes code on the > production side? Because nobody has asked for support for views outside the standard directories, and *you* haven't submitted a patch! http://rspec.lighthouseapp.com Cheers, David > > BTW, as a meta-answer, I implemented this algorithm for a test once... > > ?for each theme in themes/* > ? render the theme > ? assert the theme passes Tidy validation > ? assert all the a hrefs point somewhere > ? assert every image appears in public/images > > Hours of fun! If you have two many themes, you can pick a random assortment > for each integration test run... > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From michael at schuerig.de Tue Apr 7 03:37:58 2009 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 7 Apr 2009 09:37:58 +0200 Subject: [rspec-users] JSON matcher In-Reply-To: References: <200904070356.57692.michael@schuerig.de> Message-ID: <200904070937.58244.michael@schuerig.de> On Tuesday 07 April 2009, Phlip wrote: > Michael Schuerig wrote: > > def failure_message > > "expected\n#{@raw_target}\n" + > > "to be JSON code equivalent to\n#{@raw_expected}\n" + > > "Difference:\n#{@expected.diff(@target).inspect}" > > end > > Nice - this fixes the common problem with assertions on large bulky > variables - they often leave you squinting, trying to see the line > that's different. > > But where did .diff() come from? should I know it's part of > ActiveSupport::JSON or something? Hash#diff is part of ActiveSupport and when you look at its code you'll probably have to squint. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From phlip2005 at gmail.com Tue Apr 7 08:34:05 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 07 Apr 2009 05:34:05 -0700 Subject: [rspec-users] spec'ing theme views In-Reply-To: <57c63afe0904062212p2187f6b8he9ad928cbf2fce0c@mail.gmail.com> References: <57c63afe0904062123q31358a82o55d48b8448521198@mail.gmail.com> <57c63afe0904062212p2187f6b8he9ad928cbf2fce0c@mail.gmail.com> Message-ID: David Chelimsky wrote: >>> it "should render" do >>> template.view_paths=(File.join(File.dirname(__FILE__), >>> "/../../../themes/my_theme/")) >>> render >>> end >> And why isn't that DRY with the matching /../../../themes code on the >> production side? > > Because nobody has asked for support for views outside the standard > directories, and *you* haven't submitted a patch! I'd probably (mumble) get the architecture wrong... BTW "DRY" does not strictly apply across the test/code boundary, otherwise all the test and code in the world would disappear with a "thoomp" into a singularity. From aslak.hellesoy at gmail.com Tue Apr 7 08:50:22 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 7 Apr 2009 14:50:22 +0200 Subject: [rspec-users] [Cucumber] Spring cleaning Message-ID: <8d961d900904070550v1cb7b9c3oe74e94f2dd4c1052@mail.gmail.com> There are a lot of open tickets in Cucumber, and it's hard for me to know which ones to prioritize. Several of them are either obsolete or not very important. I need your help to decide. I'm therefore going to put all tickets on hold. If you feel a particular ticket should be reopened, please comment on it and specify the following: * Is this still an issue with the latest code in github? (follow "Building the Gem yourself" instructions on http://wiki.github.com/aslakhellesoy/cucumber and mention the SHA). * Are you going to provide a patch for it? (in your own forked repo). If not, please argue why someone else should spend time fixing it for you. Thanks for your understanding and help, Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From Peer.Allan at canadadrugs.com Tue Apr 7 09:47:06 2009 From: Peer.Allan at canadadrugs.com (Peer Allan) Date: Tue, 07 Apr 2009 08:47:06 -0500 Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 In-Reply-To: Message-ID: We are finally starting to narrow this down somewhat. Turns out we are getting the errors because the XHTML is invalid when it comes back from webrat/selenium. The specific problem right now happens when attempting to validate that there are x number of rows in a table. In a normal rspec view test this works just fine: response.body.should have_tag('table[class="data"]') do with_tag('tr', :count => 5) end But as a step in cucumber it fails. Here is the full step Then /^there should be (\d+) data rows in the table$/ do |count| response.body.should have_tag('table[class="data"]') do with_tag('tr', :count => count.to_i) end end The error is always similar to "Expected at least 30 elements matching "tr", found 3." Doing a 'save_and_open_page' in this step and looking at the source code we find that all of our self-closing tags (img, link, etc.) are not closed. If we pause the browser while running the features and view source all those tags are closed. Save_and_open_page source example, Content Browser source, Content Next we took the invalid HTML and threw it into a normal rspec view test using the same matcher as above. It failed the same way as the feature does. If we fix the invalid html by closing the unclosed tags the test passes. After that long winded explanation it appears that we are getting invalid HTML back from webrat and selenium and the matchers in rspec are choking on it. Is there some way to get rspec to deal with this or should we dig in and figure out why Selenium/Webrat is returning the "broken" XHTML? We have several people beating their heads against a wall on this one so any suggestions are welcome. Thanks. For reference, we are using: rspec 1.2.2 Rails 2.3.2 Cucumber 0.2.3 webrat 0.4.3 (patched http://github.com/mmurphy/webrat/tree/master) Selenium client 1.2.14 Haml 2.0.9 Peer > From: Peer Allan > Reply-To: rspec-users > Date: Tue, 24 Mar 2009 13:02:31 -0500 > To: > Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 > > Hello all, > > I have some cucumber features that are making me scratch my head. After > updating the Rspec 1.2 my features are now generating thousands of "ignoring > attempt to close tag with other tag" when I run them. The W3C validator > tells me that the XHTML is valid. The good news is that the tests still > pass, but you the nice output is gone. > > I experimented with some different combinations of gems to figure it out but > it all came down to Rspec 1.2.x. If I remove it then the errors go away. > This happens under both Rails 2.2.2 and Rails 2.3.2 > > Has anyone else run into this? > > Peer > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Tue Apr 7 10:11:55 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 7 Apr 2009 16:11:55 +0200 Subject: [rspec-users] [Cucumber] Spring cleaning In-Reply-To: <8d961d900904070550v1cb7b9c3oe74e94f2dd4c1052@mail.gmail.com> References: <8d961d900904070550v1cb7b9c3oe74e94f2dd4c1052@mail.gmail.com> Message-ID: <8d961d900904070711w3894201drbb86fc6702b78288@mail.gmail.com> On Tue, Apr 7, 2009 at 2:50 PM, aslak hellesoy wrote: > There are a lot of open tickets in Cucumber, and it's hard for me to know > which ones to prioritize. > Several of them are either obsolete or not very important. I need your help > to decide. > > I'm therefore going to put all tickets on hold. If you feel a particular > ticket should be reopened, please comment on it and specify the following: > That was fun - with a mix of Lighthouse's ruby API and cURL I got rid of 57 tickets in no time! :-) http://gist.github.com/91248 Now I hope you'll help me reopen the important ones... Aslak > * Is this still an issue with the latest code in github? (follow "Building > the Gem yourself" instructions on > http://wiki.github.com/aslakhellesoy/cucumber and mention the SHA). > * Are you going to provide a patch for it? (in your own forked repo). If > not, please argue why someone else should spend time fixing it for you. > > Thanks for your understanding and help, > Aslak > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Tue Apr 7 10:13:40 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 7 Apr 2009 16:13:40 +0200 Subject: [rspec-users] [Cucumber] Spring cleaning In-Reply-To: <8d961d900904070711w3894201drbb86fc6702b78288@mail.gmail.com> References: <8d961d900904070550v1cb7b9c3oe74e94f2dd4c1052@mail.gmail.com> <8d961d900904070711w3894201drbb86fc6702b78288@mail.gmail.com> Message-ID: <8d961d900904070713r315ba908w8aa86407580c601f@mail.gmail.com> On Tue, Apr 7, 2009 at 4:11 PM, aslak hellesoy wrote: > > > On Tue, Apr 7, 2009 at 2:50 PM, aslak hellesoy wrote: > >> There are a lot of open tickets in Cucumber, and it's hard for me to know >> which ones to prioritize. >> Several of them are either obsolete or not very important. I need your >> help to decide. >> >> I'm therefore going to put all tickets on hold. If you feel a particular >> ticket should be reopened, please comment on it and specify the following: >> > > That was fun - with a mix of Lighthouse's ruby API and cURL I got rid of 57 > tickets in no time! :-) > http://gist.github.com/91248 > Unfortunately it looks like tags were cleared, so please add them back if you comment on tickets on hold... Aslak > > Now I hope you'll help me reopen the important ones... > > Aslak > > >> * Is this still an issue with the latest code in github? (follow "Building >> the Gem yourself" instructions on >> http://wiki.github.com/aslakhellesoy/cucumber and mention the SHA). >> * Are you going to provide a patch for it? (in your own forked repo). If >> not, please argue why someone else should spend time fixing it for you. >> >> Thanks for your understanding and help, >> Aslak >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Apr 7 10:25:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 09:25:02 -0500 Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 In-Reply-To: References: Message-ID: <57c63afe0904070725t2c2d748cq65ae542c1a3860da@mail.gmail.com> On Tue, Apr 7, 2009 at 8:47 AM, Peer Allan wrote: > We are finally starting to narrow this down somewhat. ?Turns out we are > getting the errors because the XHTML is invalid when it comes back from > webrat/selenium. > > The specific problem right now happens when attempting to validate that > there are x number of rows in a table. In a normal rspec view test this > works just fine: > > response.body.should have_tag('table[class="data"]') do > ?with_tag('tr', :count => 5) > end > > But as a step in cucumber it fails. Here is the full step > > Then /^there should be (\d+) data rows in the table$/ do |count| > ?response.body.should have_tag('table[class="data"]') do > ? ?with_tag('tr', :count => count.to_i) > ?end > end > > The error is always similar to "Expected at least 30 elements matching "tr", > found 3." > > Doing a 'save_and_open_page' in this step and looking at the source code we > find that all of our self-closing tags (img, link, etc.) are not closed. ?If > we pause the browser while running the features and view source all those > tags are closed. > > Save_and_open_page source example, > > > ?Content > ? > > > Browser source, > > > ?Content > ? > > > Next we took the invalid HTML and threw it into a normal rspec view test > using the same matcher as above. ?It failed the same way as the feature > does. ?If we fix the invalid html by closing the unclosed tags the test > passes. > > After that long winded explanation it appears that we are getting invalid > HTML back from webrat and selenium and the matchers in rspec are choking on > it. This is going to sound a lot like buck-passing, but the have_tag matcher in rspec-rails is a wrapper for Rails' assert_select, which is what does the actual parsing. So if the fix is to make it more tolerant of poorly formatted XHTML, that's going to have to go to the rails project. >?Is there some way to get rspec to deal with this or should we dig in > and figure out why Selenium/Webrat is returning the "broken" XHTML? ?We have > several people beating their heads against a wall on this one so any > suggestions are welcome. ?Thanks. > > For reference, we are using: > rspec 1.2.2 > Rails 2.3.2 > Cucumber 0.2.3 > webrat 0.4.3 (patched http://github.com/mmurphy/webrat/tree/master) > Selenium client 1.2.14 > Haml 2.0.9 > > Peer > > >> From: Peer Allan >> Reply-To: rspec-users >> Date: Tue, 24 Mar 2009 13:02:31 -0500 >> To: >> Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 >> >> Hello all, >> >> I have some cucumber features that are making me scratch my head. ?After >> updating the Rspec 1.2 my features are now generating thousands of "ignoring >> attempt to close tag with other tag" when I run them. The W3C validator >> tells me that the XHTML is valid. ?The good news is that the tests still >> pass, but you the nice output is gone. >> >> I experimented with some different combinations of gems to figure it out but >> it all came down to Rspec 1.2.x. ?If I remove it then the errors go away. >> This happens under both Rails 2.2.2 and Rails 2.3.2 >> >> Has anyone else run into this? >> >> Peer >> >> _______________________________________________ >> 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 aidy.lewis at googlemail.com Tue Apr 7 10:30:45 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 7 Apr 2009 15:30:45 +0100 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> Message-ID: <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> On 07/04/2009, Zach Dennis wrote: > On Mon, Apr 6, 2009 at 12:21 PM, Ben Mabey wrote: > > My best > > suggestion would be to set multiple breakpoints and hit "c" to continue to > > the next one so you can skip through all of Cucumber's code. > I will sometimes set a global variable to help me flag when to debug, > if the code in question gets executed multiple times. e.g. > > $c = true if my_condition_is_met > > And then... > > debugger if $c Some useful tips, but I feel the ruby-debug tutorials that exist are lacking. Would it be fitting for me to add a Cucumber and ruby-debug page on the Wiki? Aidy From Peer.Allan at canadadrugs.com Tue Apr 7 10:53:23 2009 From: Peer.Allan at canadadrugs.com (Peer Allan) Date: Tue, 07 Apr 2009 09:53:23 -0500 Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 In-Reply-To: <57c63afe0904070725t2c2d748cq65ae542c1a3860da@mail.gmail.com> Message-ID: > This is going to sound a lot like buck-passing, but the have_tag > matcher in rspec-rails is a wrapper for Rails' assert_select, which is > what does the actual parsing. So if the fix is to make it more > tolerant of poorly formatted XHTML, that's going to have to go to the > rails project. > You given us a new direction to pursue, so don't feel too bad ;) Thanks. Peer From aslak.hellesoy at gmail.com Tue Apr 7 10:54:45 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 7 Apr 2009 16:54:45 +0200 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> Message-ID: <8d961d900904070754q5ce8c3bw9d0f87e2b43b31c4@mail.gmail.com> On Tue, Apr 7, 2009 at 4:30 PM, aidy lewis wrote: > On 07/04/2009, Zach Dennis wrote: > > On Mon, Apr 6, 2009 at 12:21 PM, Ben Mabey wrote: > > > > My best > > > suggestion would be to set multiple breakpoints and hit "c" to > continue to > > > the next one so you can skip through all of Cucumber's code. > > > I will sometimes set a global variable to help me flag when to debug, > > if the code in question gets executed multiple times. e.g. > > > > $c = true if my_condition_is_met > > > > And then... > > > > debugger if $c > > Some useful tips, but I feel the ruby-debug tutorials that exist are > lacking. Would it be fitting for me to add a Cucumber and ruby-debug > page on the Wiki? > A page titled ruby-debug would be great Aidy! Aslak > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim at theboohers.org Tue Apr 7 07:41:30 2009 From: tim at theboohers.org (Tim Booher) Date: Tue, 7 Apr 2009 07:41:30 -0400 Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace Message-ID: I am trying to get my workflow down and am confused on several fronts. The first is how to get my rspec_scaffold tests to run. The problem is that i generated my scaffold, then moved my controller into a namespace named :admin. So I have the following familiar code. How can i change this to avoid: --------------------------------------------- my error on run --------------------------------------------- /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in `load_missing_constant': uninitialized constant SponsorsController (NameError) from /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in `const_missing' from /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in `const_missing' from /home/tim/web_apps/lovd_by_fitwit/spec/controllers/sponsors_controller_spec.rb:3 from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in `load' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in `each' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in `run_examples' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in `run' from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 --------------------------------------------- sponsors_controller_spec.rb --------------------------------------------- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe SponsorsController do def mock_sponsor(stubs={}) @mock_sponsor ||= mock_model(Sponsor, stubs) end describe "responding to GET index" do it "should expose all sponsors as @sponsors" do Sponsor.should_receive(:find).with(:all).and_return([mock_sponsor]) get :index assigns[:sponsors].should == [mock_sponsor] end . . . . end -------------- next part -------------- An HTML attachment was scrubbed... URL: From tbbooher at gmail.com Tue Apr 7 07:47:04 2009 From: tbbooher at gmail.com (TimBooher) Date: Tue, 7 Apr 2009 04:47:04 -0700 (PDT) Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace Message-ID: I am trying to get my workflow down and am confused on several fronts. The first is how to get my rspec_scaffold tests to run. The problem is that i generated my scaffold, then moved my controller into a namespace named :admin. So I have the following familiar code. How can i change this to avoid: --------------------------------------------- my error on run --------------------------------------------- /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:445:in `load_missing_constant': uninitialized constant SponsorsController (NameError) from /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:77:in `const_missing' from /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:89:in `const_missing' from /home/tim/web_apps/lovd_by_fitwit/spec/controllers/ sponsors_controller_spec.rb:3 from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ example_group_runner.rb:15:in `load' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ example_group_runner.rb:15:in `load_files' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ example_group_runner.rb:14:in `each' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ example_group_runner.rb:14:in `load_files' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ options.rb:97:in `run_examples' from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ command_line.rb:9:in `run' from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 --------------------------------------------- sponsors_controller_spec.rb --------------------------------------------- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe SponsorsController do def mock_sponsor(stubs={}) @mock_sponsor ||= mock_model(Sponsor, stubs) end describe "responding to GET index" do it "should expose all sponsors as @sponsors" do Sponsor.should_receive(:find).with(:all).and_return ([mock_sponsor]) get :index assigns[:sponsors].should == [mock_sponsor] end . . . . end From scott at railsnewbie.com Tue Apr 7 11:45:08 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 7 Apr 2009 11:45:08 -0400 Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace In-Reply-To: References: Message-ID: <930CD94E-5A2B-40CB-881B-461E78460734@railsnewbie.com> On Apr 7, 2009, at 7:47 AM, TimBooher wrote: > I am trying to get my workflow down and am confused on several fronts. > The first is how to get my rspec_scaffold tests to run. The problem is > that i generated my scaffold, then moved my controller into a > namespace named :admin. > > So I have the following familiar code. How can i change this to avoid: > > --------------------------------------------- > my error on run > --------------------------------------------- > > /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ > dependencies.rb:445:in `load_missing_constant': uninitialized constant > SponsorsController (NameError) > from /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ > active_support/dependencies.rb:77:in `const_missing' > from /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ > active_support/dependencies.rb:89:in `const_missing' > from /home/tim/web_apps/lovd_by_fitwit/spec/controllers/ > sponsors_controller_spec.rb:3 > from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ > example_group_runner.rb:15:in `load' > from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ > example_group_runner.rb:15:in `load_files' > from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ > example_group_runner.rb:14:in `each' > from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ > example_group_runner.rb:14:in `load_files' > from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ > options.rb:97:in `run_examples' > from /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ > command_line.rb:9:in `run' > from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 > > --------------------------------------------- > sponsors_controller_spec.rb > --------------------------------------------- > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe SponsorsController do Should the controller be named Admin::SponsoredController ? Scott > > > def mock_sponsor(stubs={}) > @mock_sponsor ||= mock_model(Sponsor, stubs) > end > > describe "responding to GET index" do > > it "should expose all sponsors as @sponsors" do > Sponsor.should_receive(:find).with(:all).and_return > ([mock_sponsor]) > get :index > assigns[:sponsors].should == [mock_sponsor] > end > > . . . . > > end > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Tue Apr 7 11:54:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 7 Apr 2009 09:54:16 -0600 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> Message-ID: <08ACF3F4-880D-485F-82E8-135B1021341E@benmabey.com> On Apr 7, 2009, at 8:30 AM, aidy lewis wrote: > On 07/04/2009, Zach Dennis wrote: >> On Mon, Apr 6, 2009 at 12:21 PM, Ben Mabey wrote: > >>> My best >>> suggestion would be to set multiple breakpoints and hit "c" to >>> continue to >>> the next one so you can skip through all of Cucumber's code. > >> I will sometimes set a global variable to help me flag when to debug, >> if the code in question gets executed multiple times. e.g. >> >> $c = true if my_condition_is_met >> >> And then... >> >> debugger if $c > > Some useful tips, but I feel the ruby-debug tutorials that exist are > lacking. Would it be fitting for me to add a Cucumber and ruby-debug > page on the Wiki? > > Aidy That would be great! Thanks for offering. -Ben From mark at mwilden.com Tue Apr 7 12:01:22 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 7 Apr 2009 09:01:22 -0700 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> Message-ID: <3c30da400904070901u70c7dfaai60a23c7f59fed740@mail.gmail.com> On Tue, Apr 7, 2009 at 7:30 AM, aidy lewis wrote: > > Some useful tips, but I feel the ruby-debug tutorials that exist are > lacking. Would it be fitting for me to add a Cucumber and ruby-debug > page on the Wiki? With webrat, the following is pretty useful: When /^I view the response$/ do save_and_open_page end From scott at railsnewbie.com Tue Apr 7 12:23:45 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 7 Apr 2009 12:23:45 -0400 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <08ACF3F4-880D-485F-82E8-135B1021341E@benmabey.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> <08ACF3F4-880D-485F-82E8-135B1021341E@benmabey.com> Message-ID: <88634D6B-2927-4257-9CDD-6CF04D15FB25@railsnewbie.com> On Apr 7, 2009, at 11:54 AM, Ben Mabey wrote: > > On Apr 7, 2009, at 8:30 AM, aidy lewis wrote: > >> On 07/04/2009, Zach Dennis wrote: >>> On Mon, Apr 6, 2009 at 12:21 PM, Ben Mabey wrote: >> >>>> My best >>>> suggestion would be to set multiple breakpoints and hit "c" to >>>> continue to >>>> the next one so you can skip through all of Cucumber's code. >> >>> I will sometimes set a global variable to help me flag when to >>> debug, >>> if the code in question gets executed multiple times. e.g. >>> >>> $c = true if my_condition_is_met >>> >>> And then... >>> >>> debugger if $c >> >> Some useful tips, but I feel the ruby-debug tutorials that exist are >> lacking. Would it be fitting for me to add a Cucumber and ruby-debug >> page on the Wiki? >> >> Aidy > > > That would be great! Thanks for offering. I've been meaning to do a ruby-debug screencast for quite some time. Although it won't be specific to cucumber, I'll post it on the wiki when I get around to it. Scott > > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From Peer.Allan at canadadrugs.com Tue Apr 7 13:08:54 2009 From: Peer.Allan at canadadrugs.com (Peer Allan) Date: Tue, 07 Apr 2009 12:08:54 -0500 Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 In-Reply-To: Message-ID: We found the issue and it was related to how rspec wraps assert_select. In rspec-rails 1.1.12 HTML::Document is initialized differently for response.body than for strings. In 1.2.2 this was changed so that they were initialized in the same way. This caused the string to be validated as XML and generated the warnings and matcher errors we were seeing . We patched assert_select.rb so that strings are initialized the old way and all the errors went away. I forked the project on github and the patch is available there (but not as a gem) http://github.com/pallan/rspec-rails/tree/master Thanks Peer Allan Development Team Lead, e-Business CanadaDrugs.com 24 Terracon Place Winnipeg, MB, Canada R2J 4G7 Phone: (204) 654-7951 Fax: (204) 654-7910 www.canadadrugs.com > From: Peer Allan > Reply-To: rspec-users > Date: Tue, 07 Apr 2009 09:53:23 -0500 > To: rspec-users > Subject: Re: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 > >> This is going to sound a lot like buck-passing, but the have_tag >> matcher in rspec-rails is a wrapper for Rails' assert_select, which is >> what does the actual parsing. So if the fix is to make it more >> tolerant of poorly formatted XHTML, that's going to have to go to the >> rails project. >> > > You given us a new direction to pursue, so don't feel too bad ;) Thanks. > > Peer > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From byrnejb at harte-lyne.ca Tue Apr 7 13:32:20 2009 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Tue, 7 Apr 2009 13:32:20 -0400 (EDT) Subject: [rspec-users] rake db:test:prepare and pending migrations Message-ID: <37264.216.185.71.24.1239125540.squirrel@webmail.harte-lyne.ca> I have run into a minor glitch and would like to know what others think. I am working on a test/expectation and as part of the process of debugging I am rolling back db:migrations one step at a time to discover where the problem was introduced. My workflow looks like this: $ cucumber ... feature:xx fail $ rake db:rollback $ rake db:test:prepare fail ... you have pending migrations. Now, it seems to me that while testing one is interested only in those migrations that have been applied, not which ones are available. It is nice to be notified that unapplied migrations exist but I am not sure that one should be constrained to apply them to conduct tests. What do others think? -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From scott at railsnewbie.com Tue Apr 7 13:44:12 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 7 Apr 2009 13:44:12 -0400 Subject: [rspec-users] rake db:test:prepare and pending migrations In-Reply-To: <37264.216.185.71.24.1239125540.squirrel@webmail.harte-lyne.ca> References: <37264.216.185.71.24.1239125540.squirrel@webmail.harte-lyne.ca> Message-ID: On Apr 7, 2009, at 1:32 PM, James B. Byrne wrote: > > I have run into a minor glitch and would like to know what others > think. I am working on a test/expectation and as part of the > process of debugging I am rolling back db:migrations one step at a > time to discover where the problem was introduced. > > My workflow looks like this: > > $ cucumber ... feature:xx > fail > $ rake db:rollback > $ rake db:test:prepare > fail ... you have pending migrations. > > Now, it seems to me that while testing one is interested only in > those migrations that have been applied, not which ones are > available. It is nice to be notified that unapplied migrations > exist but I am not sure that one should be constrained to apply them > to conduct tests. > > What do others think? If you are using git, it might be wiser to create a branch and reset -- hard back to those migrations. Or, use git's bisect, and migrate:reset from a clean db each time Scott > > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Apr 7 13:48:51 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 12:48:51 -0500 Subject: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 In-Reply-To: References: Message-ID: <57c63afe0904071048o77e35d44ta653599aaf4904d7@mail.gmail.com> On Tue, Apr 7, 2009 at 12:08 PM, Peer Allan wrote: > We found the issue and it was related to how rspec wraps assert_select. ?In > rspec-rails 1.1.12 HTML::Document is initialized differently for > response.body than for strings. ?In 1.2.2 this was changed so that they were > initialized in the same way. This caused the string to be validated as XML > and generated the warnings and matcher errors we were seeing . ?We patched > assert_select.rb so that strings are initialized the old way and all the > errors went away. > > I forked the project on github and the patch is available there (but not as > a gem) > > http://github.com/pallan/rspec-rails/tree/master Hey Peer - would you mind putting in a lighthouse ticket so this stays on my radar? http:://rspec.lighthouseapp.com/ Cheers, David > > Thanks > > Peer Allan > Development Team Lead, e-Business > > CanadaDrugs.com > 24 ?Terracon Place > Winnipeg, MB, Canada > R2J ?4G7 > > Phone: (204) 654-7951 > Fax: ?(204) 654-7910 > www.canadadrugs.com > > > >> From: Peer Allan >> Reply-To: rspec-users >> Date: Tue, 07 Apr 2009 09:53:23 -0500 >> To: rspec-users >> Subject: Re: [rspec-users] (x)HTML Parsing Errors, Cuc 0.2.0 + Rspec 1.2 >> >>> This is going to sound a lot like buck-passing, but the have_tag >>> matcher in rspec-rails is a wrapper for Rails' assert_select, which is >>> what does the actual parsing. So if the fix is to make it more >>> tolerant of poorly formatted XHTML, that's going to have to go to the >>> rails project. >>> >> >> You given us a new direction to pursue, so don't feel too bad ;) ?Thanks. >> >> Peer >> >> _______________________________________________ >> 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 mark at mwilden.com Tue Apr 7 13:56:02 2009 From: mark at mwilden.com (Mark Wilden) Date: Tue, 7 Apr 2009 10:56:02 -0700 Subject: [rspec-users] rake db:test:prepare and pending migrations In-Reply-To: References: <37264.216.185.71.24.1239125540.squirrel@webmail.harte-lyne.ca> Message-ID: <3c30da400904071056t830fbb1p109a47aaf2d8ad4a@mail.gmail.com> On Tue, Apr 7, 2009 at 10:44 AM, Scott Taylor wrote: > > On Apr 7, 2009, at 1:32 PM, James B. Byrne wrote: > >> >> I have run into a minor glitch and would like to know what others >> think. ?I am working on a test/expectation and as part of the >> process of debugging I am rolling back db:migrations one step at a >> time to discover where the problem was introduced. >> >> My workflow looks like this: >> >> $ cucumber ... feature:xx >> fail >> $ rake db:rollback >> $ rake db:test:prepare >> ?fail ... you have pending migrations. >> >> Now, it seems to me that while testing one is interested only in >> those migrations that have been applied, not which ones are >> available. ?It is nice to be notified that unapplied migrations >> exist but I am not sure that one should be constrained to apply them >> to conduct tests. >> >> What do others think? > > If you are using git, it might be wiser to create a branch and reset --hard > back to those migrations. > > Or, use git's bisect, and migrate:reset from a clean db each time This also might be useful: http://outofti.me/post/90028018/rake-db-rollback-to-common From itsme213 at hotmail.com Tue Apr 7 16:26:20 2009 From: itsme213 at hotmail.com (Sophie (itsme213)) Date: Tue, 7 Apr 2009 15:26:20 -0500 Subject: [rspec-users] Web-based story runner? Message-ID: Some time ago I had come across a web-based story editor for scenarios. I'm not sure if it was a full runner, and it was probably before cucumber. Anyone know where I can find it? Thanks From aslak.hellesoy at gmail.com Tue Apr 7 17:19:44 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 7 Apr 2009 23:19:44 +0200 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team Message-ID: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Ben Mabey has accepted my invitation to be on the core Cucumber team. Ben has been a long time contributor to Cucumber's ecosystem and knows it inside out. Here is a quote from IRC today: mabes: Yeah but you're the cucumber God. The core Cucumber team now consists of Joseph Wilk, Ben Mabey and myself. Welcome Ben! Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Tue Apr 7 17:33:49 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 7 Apr 2009 17:33:49 -0400 Subject: [rspec-users] Web-based story runner? In-Reply-To: References: Message-ID: <65B52AE7-8F5C-4CC6-BAA0-F1F2AEE46EBA@railsnewbie.com> On Apr 7, 2009, at 4:26 PM, Sophie (itsme213) wrote: > Some time ago I had come across a web-based story editor for > scenarios. I'm > not sure if it was a full runner, and it was probably before cucumber. > > Anyone know where I can find it? Aslak had a prototype a while back - although it was only a prototype (and it was for the Story Runner - not for Cucumber). Has a new one been developed? Scott From dchelimsky at gmail.com Tue Apr 7 17:40:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 16:40:46 -0500 Subject: [rspec-users] Web-based story runner? In-Reply-To: References: Message-ID: <57c63afe0904071440g56511163q494892c24dcae569@mail.gmail.com> On Tue, Apr 7, 2009 at 3:26 PM, Sophie (itsme213) wrote: > Some time ago I had come across a web-based story editor for scenarios. I'm > not sure if it was a full runner, and it was probably before cucumber. > > Anyone know where I can find it? It was only a protoype with some javascript to make it look nice - no integration to anything real - but, you can find it here: http://github.com/dchelimsky/rspec-stories/tree/master Look in the story_server directory. Cheers, David From ben at benmabey.com Tue Apr 7 17:50:23 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 07 Apr 2009 15:50:23 -0600 Subject: [rspec-users] Web-based story runner? In-Reply-To: <57c63afe0904071440g56511163q494892c24dcae569@mail.gmail.com> References: <57c63afe0904071440g56511163q494892c24dcae569@mail.gmail.com> Message-ID: <49DBCA9F.8020303@benmabey.com> David Chelimsky wrote: > On Tue, Apr 7, 2009 at 3:26 PM, Sophie (itsme213) wrote: > >> Some time ago I had come across a web-based story editor for scenarios. I'm >> not sure if it was a full runner, and it was probably before cucumber. >> >> Anyone know where I can find it? >> > > It was only a protoype with some javascript to make it look nice - no > integration to anything real - but, you can find it here: > > http://github.com/dchelimsky/rspec-stories/tree/master > > Look in the story_server directory. > > Also, take a look at rcumber: http://github.com/jgoodsen/rcumber/tree/master -Ben From dchelimsky at gmail.com Tue Apr 7 17:52:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 16:52:58 -0500 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: <57c63afe0904071452y4bda778fxd38678d2f943104d@mail.gmail.com> On Tue, Apr 7, 2009 at 4:19 PM, aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the core Cucumber team. > Ben has been a long time contributor to Cucumber's ecosystem and knows it > inside out. > Here is a quote from IRC today: > > ? mabes: Yeah but you're the cucumber God. > > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and myself. > Welcome Ben! Congrats Ben!!!! Well deserved. Cheers, David > > Aslak > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From scott at railsnewbie.com Tue Apr 7 17:53:00 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 7 Apr 2009 17:53:00 -0400 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: <54341A92-E02C-4AD6-A3D1-0EDC4643318A@railsnewbie.com> On Apr 7, 2009, at 5:19 PM, aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the core Cucumber team. > Ben has been a long time contributor to Cucumber's ecosystem and > knows it inside out. > Here is a quote from IRC today: > > mabes: Yeah but you're the cucumber God. > > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and > myself. Welcome Ben! Congrats Ben Scott From ben at benmabey.com Tue Apr 7 17:53:33 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 07 Apr 2009 15:53:33 -0600 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: <49DBCB5D.6020805@benmabey.com> aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the core Cucumber team. > Ben has been a long time contributor to Cucumber's ecosystem and knows > it inside out. > Here is a quote from IRC today: > > mabes: Yeah but you're the cucumber God. > > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and > myself. Welcome Ben! > > Aslak Thanks for the welcome! Just to be clear.. I did not say that I was the "cucumber God"... someone said that to me. :) -Ben From joahking at gmail.com Tue Apr 7 18:15:34 2009 From: joahking at gmail.com (Joaquin Rivera Padron) Date: Wed, 8 Apr 2009 00:15:34 +0200 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <54341A92-E02C-4AD6-A3D1-0EDC4643318A@railsnewbie.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> <54341A92-E02C-4AD6-A3D1-0EDC4643318A@railsnewbie.com> Message-ID: <8277b7f40904071515tef5894bv3c8d30155f12705e@mail.gmail.com> by the way, cool presentation at mountain west :-) congrats 2009/4/7 Scott Taylor > > On Apr 7, 2009, at 5:19 PM, aslak hellesoy wrote: > > Ben Mabey has accepted my invitation to be on the core Cucumber team. >> Ben has been a long time contributor to Cucumber's ecosystem and knows it >> inside out. >> Here is a quote from IRC today: >> >> mabes: Yeah but you're the cucumber God. >> >> The core Cucumber team now consists of Joseph Wilk, Ben Mabey and myself. >> Welcome Ben! >> > > Congrats Ben > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- www.least-significant-bit.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielpennypacker at gmail.com Tue Apr 7 18:34:56 2009 From: danielpennypacker at gmail.com (danielpennypacker) Date: Tue, 7 Apr 2009 15:34:56 -0700 (PDT) Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly Message-ID: <22939702.post@talk.nabble.com> Here's an intro to what I'm working on... - We're adding Beast Forums to our site and we decided to integrate the code instead of have it run in a separate app. - Beast uses rspec, and this was the first time I've been exposed to it, we use boring old unit tests. Beast also uses the rspec_on_rails_on_crack plugin. - I was doing work on a development branch and eventually got all of the specs written for Beast to past after they had been integrated into our site. - I merged my branch back to trunk resolved conflicts and did 'rake spec' - rake 'spec:models' works fine, but when I try running specs for the controllers, I get this error: ./spec/controllers/sessions_controller_spec.rb:13: undefined method `act!' for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) - act! is defined in rspec_on_rails_on_crack, and is being required in spec_helper.rb, but for some reason it isn't loading. I'm guessing that I forgot to commit a file somewhere, but I can't figure it out. - I know this is a pretty general question, but I thought someone might have run it before, so thanks for any help! Here's 'spec_helper.rb'. It's been a bit modified from what was in Beast Forums -------------------------------------------- # This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec' require 'spec/rails' require 'rspec_on_rails_on_crack' #require 'model_stubbing' #require File.dirname(__FILE__) + "/model_stubs" #require 'ruby-debug' #Debugger.start Spec::Runner.configure do |config| include AuthenticatedTestHelper config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/test/fixtures/' def current_site(site = nil) Site.find(:first) || Site.find(site.id) end # Sets the current user in the session from the user fixtures. def login_as(user) controller.stub!(:current_user).and_return(@user = user ? users(user) : nil) end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil end end -- View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22939702.html Sent from the rspec-users mailing list archive at Nabble.com. From danielpennypacker at gmail.com Tue Apr 7 18:40:13 2009 From: danielpennypacker at gmail.com (danielpennypacker) Date: Tue, 7 Apr 2009 15:40:13 -0700 (PDT) Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly Message-ID: <22939702.post@talk.nabble.com> Here's an intro to what I'm working on... - We're adding Beast Forums to our site and we decided to integrate the code instead of have it run in a separate app. - Beast uses rspec, and this was the first time I've been exposed to it, we use boring old unit tests. Beast also uses the rspec_on_rails_on_crack plugin. - I was doing work on a development branch and eventually got all of the specs written for Beast to past after they had been integrated into our site. - I merged my branch back to trunk resolved conflicts and did 'rake spec' - rake 'spec:models' works fine, but when I try running specs for the controllers, I get this error: ./spec/controllers/sessions_controller_spec.rb:13: undefined method `act!' for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) - act! is defined in rspec_on_rails_on_crack, and is being required in spec_helper.rb, but for some reason it isn't loading. I'm guessing that I forgot to commit a file somewhere, but I can't figure it out. - I know this is a pretty general question, but I thought someone might have run it before, so thanks for any help! Here's 'spec_helper.rb'. It's been a bit modified from what was in Beast Forums -------------------------------------------- # This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec' require 'spec/rails' require 'rspec_on_rails_on_crack' #require 'model_stubbing' #require File.dirname(__FILE__) + "/model_stubs" #require 'ruby-debug' #Debugger.start Spec::Runner.configure do |config| include AuthenticatedTestHelper config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/test/fixtures/' def current_site(site = nil) Site.find(:first) || Site.find(site.id) end # Sets the current user in the session from the user fixtures. def login_as(user) controller.stub!(:current_user).and_return(@user = user ? users(user) : nil) end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil end end Full error trace: --------------------------------------------------------- ./spec/controllers/sessions_controller_spec.rb:13: undefined method `act!' for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in `module_eval' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in `subclass' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:55:in `describe' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_factory.rb:29:in `create_example_group' from /Users/pennypacker/Desktop/work/infectious-trunk/vendor/plugins/rspec/lib/spec/extensions/main.rb:27:in `describe' from ./spec/controllers/sessions_controller_spec.rb:3 from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in `load' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in `each' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in `run_examples' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in `run' from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/bin/spec:4 -- View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22939702.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Tue Apr 7 19:03:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 18:03:07 -0500 Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly In-Reply-To: <22939702.post@talk.nabble.com> References: <22939702.post@talk.nabble.com> Message-ID: <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> On Tue, Apr 7, 2009 at 5:40 PM, danielpennypacker wrote: > > Here's an intro to what I'm working on... > > - We're adding Beast Forums to our site and we decided to integrate the code > instead of have it run in a separate app. > > - Beast uses rspec, and this was the first time I've been exposed to it, we > use boring old unit tests. Beast also uses the rspec_on_rails_on_crack > plugin. My understanding is that there is an rspec_on_rails_on_crack branch that is not master that works better w/ the latest rails. Not sure of the details and running out the door shortly, but take a look and see if that can help resolve any issues you're having. Cheers, David > > - I was doing work on a development branch and eventually got all of the > specs written for Beast to past after they had been integrated into our > site. > > - I merged my branch back to trunk resolved conflicts and did 'rake spec' > > - rake 'spec:models' works fine, but when I try running specs for the > controllers, I get this error: > ?./spec/controllers/sessions_controller_spec.rb:13: undefined method `act!' > for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) > > ?- act! is defined in rspec_on_rails_on_crack, and is being required in > spec_helper.rb, but for some reason it isn't loading. I'm guessing that I > forgot to commit a file somewhere, but I can't figure it out. > > - I know this is a pretty general question, but I thought someone might have > run it before, so thanks for any help! > > Here's 'spec_helper.rb'. It's been a bit modified from what was in Beast > Forums > > -------------------------------------------- > > # This file is copied to ~/spec when you run 'ruby script/generate rspec' > # from the project root directory. > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + "/../config/environment") > require 'spec' > require 'spec/rails' > require 'rspec_on_rails_on_crack' > #require 'model_stubbing' > #require File.dirname(__FILE__) + "/model_stubs" > #require 'ruby-debug' > #Debugger.start > > Spec::Runner.configure do |config| > ?include AuthenticatedTestHelper > ?config.use_transactional_fixtures = true > ?config.use_instantiated_fixtures ?= false > ?config.fixture_path = RAILS_ROOT + '/test/fixtures/' > > ?def current_site(site = nil) > ? ?Site.find(:first) || Site.find(site.id) > ?end > > ?# Sets the current user in the session from the user fixtures. > ? def login_as(user) > ? ?controller.stub!(:current_user).and_return(@user = user ? users(user) : > nil) > ?end > > ?def authorize_as(user) > ? ?@request.env["HTTP_AUTHORIZATION"] = user ? "Basic > #{Base64.encode64("#{users(user).login}:test")}" : nil > ?end > end > > Full error trace: > > --------------------------------------------------------- > > ./spec/controllers/sessions_controller_spec.rb:13: undefined method `act!' > for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in > `module_eval' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in > `subclass' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:55:in > `describe' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_factory.rb:29:in > `create_example_group' > ? ? ? ?from > /Users/pennypacker/Desktop/work/infectious-trunk/vendor/plugins/rspec/lib/spec/extensions/main.rb:27:in > `describe' > ? ? ? ?from ./spec/controllers/sessions_controller_spec.rb:3 > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in > `load' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in > `load_files' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in > `each' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in > `run_examples' > ? ? ? ?from > /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in > `run' > ? ? ? ?from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/bin/spec:4 > > > > -- > View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22939702.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Tue Apr 7 19:13:40 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 7 Apr 2009 19:13:40 -0400 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <49DBCB5D.6020805@benmabey.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> <49DBCB5D.6020805@benmabey.com> Message-ID: <85d99afe0904071613u49a3da8cv936985a39fdc531@mail.gmail.com> On Tue, Apr 7, 2009 at 5:53 PM, Ben Mabey wrote: > aslak hellesoy wrote: >> >> Ben Mabey has accepted my invitation to be on the core Cucumber team. >> Ben has been a long time contributor to Cucumber's ecosystem and knows it >> inside out. >> Here is a quote from IRC today: >> >> ?mabes: Yeah but you're the cucumber God. >> >> The core Cucumber team now consists of Joseph Wilk, Ben Mabey and myself. >> Welcome Ben! >> Congrats Ben! >> Aslak > > > Thanks for the welcome! > > Just to be clear.. I did not say that I was the "cucumber God"... someone > said that to me. :) > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From korny at sietsma.com Tue Apr 7 21:01:01 2009 From: korny at sietsma.com (Korny Sietsma) Date: Wed, 8 Apr 2009 11:01:01 +1000 Subject: [rspec-users] [Cucumber] any examples of navigating cucumber parse tree from external script Message-ID: <8e15872b0904071801s8b5adbu987e38f9052bdd66@mail.gmail.com> Hi folks, I'm writing some scripts to integrate our cucumber features with stories stored in a wiki, and I'm hoping to use cucumber's parser to parse the features rather than doing it manually. (I don't really care about the feature contents much, just scenario titles and tags) I've worked out how to parse the features: Cucumber.load_language('en') features = Cucumber::Ast::Features.new parser = Cucumber::Parser::FeatureParser.new feature_files = Dir["#{FEATURE_DIR}/**/*.feature"] feature_files.each do |f| puts "parsing feature file #{f}" features.add_feature(parser.parse_file(f)) end But now I'm digging in to the whole ast visitor thing, and it's getting quite complex to *do* stuff with the features once I've parsed them. I'm sure I can work this out myself, given time, but I was wondering if there are any code examples out there to save me some of the time/effort? Anyone else tried parsing features like this from outside Cucumber itself? Thanks! - Korny -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.zielinski.is at gmail.com Tue Apr 7 19:20:05 2009 From: andrew.zielinski.is at gmail.com (Andrew Zielinski) Date: Tue, 7 Apr 2009 16:20:05 -0700 (PDT) Subject: [rspec-users] superclass mismatch for class ModelExampleGroup (TypeError) Message-ID: <22940271.post@talk.nabble.com> I hope somebody can help me with this. I can't seem to run spec_server with rails 2.3.2 using rspec/rspec-rails 1.2.2. I'm also using mocha 0.9.5 and remarkable 2.3.0. Thanks Andrew Here is the stack trace: --------------------------------- /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example/model_example_group.rb:9: superclass mismatch for class ModelExampleGroup (TypeError) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example.rb:6 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb:19 ... 9 levels... from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `run' from ./script/../config/environment.rb:13 from ./script/spec_server:6:in `require' from ./script/spec_server:6 -- View this message in context: http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22940271.html Sent from the rspec-users mailing list archive at Nabble.com. From andrew.zielinski.is at gmail.com Tue Apr 7 19:21:03 2009 From: andrew.zielinski.is at gmail.com (Andrew Zielinski) Date: Tue, 7 Apr 2009 16:21:03 -0700 (PDT) Subject: [rspec-users] superclass mismatch for class ModelExampleGroup (TypeError) Message-ID: <22940271.post@talk.nabble.com> I hope somebody can help me with this. I can't seem to run spec_server with rails 2.3.2 using rspec/rspec-rails 1.2.2. The funny thing is that autospec seems to work fine. I'm also using mocha 0.9.5 and remarkable 2.3.0. Thanks Andrew Here is the stack trace: --------------------------------- /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example/model_example_group.rb:9: superclass mismatch for class ModelExampleGroup (TypeError) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example.rb:6 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb:19 ... 9 levels... from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `run' from ./script/../config/environment.rb:13 from ./script/spec_server:6:in `require' from ./script/spec_server:6 -- View this message in context: http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22940271.html Sent from the rspec-users mailing list archive at Nabble.com. From danielpennypacker at gmail.com Tue Apr 7 19:55:22 2009 From: danielpennypacker at gmail.com (danielpennypacker) Date: Tue, 7 Apr 2009 16:55:22 -0700 (PDT) Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly In-Reply-To: <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> References: <22939702.post@talk.nabble.com> <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> Message-ID: <22940623.post@talk.nabble.com> We're using Rails 2.1.1 and rspec/rspec_on_rails 1.8.6. It was working okay on a different my dev branch, so I'm not sure if different versions are the problem. Thanks so much for the speedy reply, and I hope knowing my versions helps. My senior dev is gonna help with it tomorrow, so I'll make sure to update our findings. Thanks again! >My understanding is that there is an rspec_on_rails_on_crack branch >that is not master that works better w/ the latest rails. Not sure of >the details and running out the door shortly, but take a look and see >f that can help resolve any issues you're having. >Cheers, >David David Chelimsky-2 wrote: > > On Tue, Apr 7, 2009 at 5:40 PM, danielpennypacker > wrote: >> >> Here's an intro to what I'm working on... >> >> - We're adding Beast Forums to our site and we decided to integrate the >> code >> instead of have it run in a separate app. >> >> - Beast uses rspec, and this was the first time I've been exposed to it, >> we >> use boring old unit tests. Beast also uses the rspec_on_rails_on_crack >> plugin. > > > >> >> - I was doing work on a development branch and eventually got all of the >> specs written for Beast to past after they had been integrated into our >> site. >> >> - I merged my branch back to trunk resolved conflicts and did 'rake spec' >> >> - rake 'spec:models' works fine, but when I try running specs for the >> controllers, I get this error: >> ?./spec/controllers/sessions_controller_spec.rb:13: undefined method >> `act!' >> for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) >> >> ?- act! is defined in rspec_on_rails_on_crack, and is being required in >> spec_helper.rb, but for some reason it isn't loading. I'm guessing that I >> forgot to commit a file somewhere, but I can't figure it out. >> >> - I know this is a pretty general question, but I thought someone might >> have >> run it before, so thanks for any help! >> >> Here's 'spec_helper.rb'. It's been a bit modified from what was in Beast >> Forums >> >> -------------------------------------------- >> >> # This file is copied to ~/spec when you run 'ruby script/generate rspec' >> # from the project root directory. >> ENV["RAILS_ENV"] = "test" >> require File.expand_path(File.dirname(__FILE__) + >> "/../config/environment") >> require 'spec' >> require 'spec/rails' >> require 'rspec_on_rails_on_crack' >> #require 'model_stubbing' >> #require File.dirname(__FILE__) + "/model_stubs" >> #require 'ruby-debug' >> #Debugger.start >> >> Spec::Runner.configure do |config| >> ?include AuthenticatedTestHelper >> ?config.use_transactional_fixtures = true >> ?config.use_instantiated_fixtures ?= false >> ?config.fixture_path = RAILS_ROOT + '/test/fixtures/' >> >> ?def current_site(site = nil) >> ? ?Site.find(:first) || Site.find(site.id) >> ?end >> >> ?# Sets the current user in the session from the user fixtures. >> ? def login_as(user) >> ? ?controller.stub!(:current_user).and_return(@user = user ? users(user) >> : >> nil) >> ?end >> >> ?def authorize_as(user) >> ? ?@request.env["HTTP_AUTHORIZATION"] = user ? "Basic >> #{Base64.encode64("#{users(user).login}:test")}" : nil >> ?end >> end >> >> Full error trace: >> >> --------------------------------------------------------- >> >> ./spec/controllers/sessions_controller_spec.rb:13: undefined method >> `act!' >> for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in >> `module_eval' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in >> `subclass' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:55:in >> `describe' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_factory.rb:29:in >> `create_example_group' >> ? ? ? ?from >> /Users/pennypacker/Desktop/work/infectious-trunk/vendor/plugins/rspec/lib/spec/extensions/main.rb:27:in >> `describe' >> ? ? ? ?from ./spec/controllers/sessions_controller_spec.rb:3 >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >> `load' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >> `load_files' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >> `each' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >> `load_files' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in >> `run_examples' >> ? ? ? ?from >> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in >> `run' >> ? ? ? ?from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/bin/spec:4 >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22939702.html >> Sent from the rspec-users mailing list archive at Nabble.com. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22940623.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Tue Apr 7 21:17:55 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 20:17:55 -0500 Subject: [rspec-users] superclass mismatch for class ModelExampleGroup (TypeError) In-Reply-To: <22940271.post@talk.nabble.com> References: <22940271.post@talk.nabble.com> Message-ID: <57c63afe0904071817s6772e388j9f03f354ef05fba8@mail.gmail.com> On Tue, Apr 7, 2009 at 6:20 PM, Andrew Zielinski wrote: > > I hope somebody can help me with this. > > I can't seem to run spec_server with rails 2.3.2 using rspec/rspec-rails > 1.2.2. I'm also using mocha 0.9.5 and remarkable 2.3.0. The stack trace doesn't show it, but the superclass mismatch suggests that you have a version of rspec pre 1.2 that is being loaded somewhere. The old ModelExampleGroup derived directly from Test::Unit::TestCase, but the 1.2 class derives from ActiveSupport::TestCase. Can you check to see what versions of rspec and rspec-rails you have installed and uninstall all the old ones if you can. HTH, David > > Thanks Andrew > > Here is the stack trace: > > --------------------------------- > > /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example/model_example_group.rb:9: > superclass mismatch for class ModelExampleGroup (TypeError) > > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' > from > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in > `require' > from > /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example.rb:6 > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' > from > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in > `require' > from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb:19 > ?... 9 levels... > from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `run' > from ./script/../config/environment.rb:13 > from ./script/spec_server:6:in `require' > from ./script/spec_server:6 > > > -- > View this message in context: http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22940271.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Apr 7 21:34:30 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Apr 2009 20:34:30 -0500 Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly In-Reply-To: <22940623.post@talk.nabble.com> References: <22939702.post@talk.nabble.com> <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> <22940623.post@talk.nabble.com> Message-ID: <57c63afe0904071834g4ffc53efj70104bcd729e47e0@mail.gmail.com> On Tue, Apr 7, 2009 at 6:55 PM, danielpennypacker wrote: > > We're using Rails 2.1.1 and rspec/rspec_on_rails 1.8.6. 1.8.6 doesn't really exist. The most recent is 1.2.2 :) > It was working okay > on a different my dev branch, so I'm not sure if different versions are the > problem. > > Thanks so much for the speedy reply, and I hope knowing my versions helps. > My senior dev is gonna help with it tomorrow, so I'll make sure to update > our findings. Cool - good luck! > > Thanks again! > >>My understanding is that there is an rspec_on_rails_on_crack branch >>that is not master that works better w/ the latest rails. Not sure of >>the details and running out the door shortly, but take a look and see >>f that can help resolve any issues you're having. > >>Cheers, >>David > > > > > > David Chelimsky-2 wrote: >> >> On Tue, Apr 7, 2009 at 5:40 PM, danielpennypacker >> wrote: >>> >>> Here's an intro to what I'm working on... >>> >>> - We're adding Beast Forums to our site and we decided to integrate the >>> code >>> instead of have it run in a separate app. >>> >>> - Beast uses rspec, and this was the first time I've been exposed to it, >>> we >>> use boring old unit tests. Beast also uses the rspec_on_rails_on_crack >>> plugin. >> >> >> >>> >>> - I was doing work on a development branch and eventually got all of the >>> specs written for Beast to past after they had been integrated into our >>> site. >>> >>> - I merged my branch back to trunk resolved conflicts and did 'rake spec' >>> >>> - rake 'spec:models' works fine, but when I try running specs for the >>> controllers, I get this error: >>> ?./spec/controllers/sessions_controller_spec.rb:13: undefined method >>> `act!' >>> for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) >>> >>> ?- act! is defined in rspec_on_rails_on_crack, and is being required in >>> spec_helper.rb, but for some reason it isn't loading. I'm guessing that I >>> forgot to commit a file somewhere, but I can't figure it out. >>> >>> - I know this is a pretty general question, but I thought someone might >>> have >>> run it before, so thanks for any help! >>> >>> Here's 'spec_helper.rb'. It's been a bit modified from what was in Beast >>> Forums >>> >>> -------------------------------------------- >>> >>> # This file is copied to ~/spec when you run 'ruby script/generate rspec' >>> # from the project root directory. >>> ENV["RAILS_ENV"] = "test" >>> require File.expand_path(File.dirname(__FILE__) + >>> "/../config/environment") >>> require 'spec' >>> require 'spec/rails' >>> require 'rspec_on_rails_on_crack' >>> #require 'model_stubbing' >>> #require File.dirname(__FILE__) + "/model_stubs" >>> #require 'ruby-debug' >>> #Debugger.start >>> >>> Spec::Runner.configure do |config| >>> ?include AuthenticatedTestHelper >>> ?config.use_transactional_fixtures = true >>> ?config.use_instantiated_fixtures ?= false >>> ?config.fixture_path = RAILS_ROOT + '/test/fixtures/' >>> >>> ?def current_site(site = nil) >>> ? ?Site.find(:first) || Site.find(site.id) >>> ?end >>> >>> ?# Sets the current user in the session from the user fixtures. >>> ? def login_as(user) >>> ? ?controller.stub!(:current_user).and_return(@user = user ? users(user) >>> : >>> nil) >>> ?end >>> >>> ?def authorize_as(user) >>> ? ?@request.env["HTTP_AUTHORIZATION"] = user ? "Basic >>> #{Base64.encode64("#{users(user).login}:test")}" : nil >>> ?end >>> end >>> >>> Full error trace: >>> >>> --------------------------------------------------------- >>> >>> ./spec/controllers/sessions_controller_spec.rb:13: undefined method >>> `act!' >>> for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in >>> `module_eval' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in >>> `subclass' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:55:in >>> `describe' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_factory.rb:29:in >>> `create_example_group' >>> ? ? ? ?from >>> /Users/pennypacker/Desktop/work/infectious-trunk/vendor/plugins/rspec/lib/spec/extensions/main.rb:27:in >>> `describe' >>> ? ? ? ?from ./spec/controllers/sessions_controller_spec.rb:3 >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >>> `load' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >>> `load_files' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >>> `each' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >>> `load_files' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in >>> `run_examples' >>> ? ? ? ?from >>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in >>> `run' >>> ? ? ? ?from /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/bin/spec:4 >>> >>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22939702.html >>> Sent from the rspec-users mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > -- > View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22940623.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pat.maddox at gmail.com Tue Apr 7 22:05:10 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Tue, 7 Apr 2009 19:05:10 -0700 Subject: [rspec-users] rake db:test:prepare and pending migrations In-Reply-To: <37264.216.185.71.24.1239125540.squirrel@webmail.harte-lyne.ca> References: <37264.216.185.71.24.1239125540.squirrel@webmail.harte-lyne.ca> Message-ID: <2c7e61990904071905i2654c44j694daf0e49b52ff6@mail.gmail.com> On Tue, Apr 7, 2009 at 10:32 AM, James B. Byrne wrote: > > I have run into a minor glitch and would like to know what others > think. ?I am working on a test/expectation and as part of the > process of debugging I am rolling back db:migrations one step at a > time to discover where the problem was introduced. > > My workflow looks like this: > > $ cucumber ... feature:xx > fail > $ rake db:rollback > $ rake db:test:prepare > ?fail ... you have pending migrations. > > Now, it seems to me that while testing one is interested only in > those migrations that have been applied, not which ones are > available. ?It is nice to be notified that unapplied migrations > exist but I am not sure that one should be constrained to apply them > to conduct tests. > > What do others think? > > > -- > *** ? ? ? ? ?E-Mail is NOT a SECURE channel ? ? ? ? ?*** > James B. Byrne ? ? ? ? ? ? ? ?mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited ? ? ? ? ?http://www.harte-lyne.ca > 9 Brockley Drive ? ? ? ? ? ? ?vox: +1 905 561 1241 > Hamilton, Ontario ? ? ? ? ? ? fax: +1 905 561 0757 > Canada ?L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Scott and Mark have given good input. This is a Rails thing, not an RSpec thing, so if you want the behavior of db:test:prepare changed then you'll have to do it at the Rails end. Pat From f.mischa at gmail.com Wed Apr 8 01:23:50 2009 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 8 Apr 2009 00:23:50 -0500 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <85d99afe0904071613u49a3da8cv936985a39fdc531@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> <49DBCB5D.6020805@benmabey.com> <85d99afe0904071613u49a3da8cv936985a39fdc531@mail.gmail.com> Message-ID: Cool! Congrats Ben. On Tue, Apr 7, 2009 at 6:13 PM, Zach Dennis wrote: > On Tue, Apr 7, 2009 at 5:53 PM, Ben Mabey wrote: > > aslak hellesoy wrote: > >> > >> Ben Mabey has accepted my invitation to be on the core Cucumber team. > >> Ben has been a long time contributor to Cucumber's ecosystem and knows > it > >> inside out. > >> Here is a quote from IRC today: > >> > >> mabes: Yeah but you're the cucumber God. > >> > >> The core Cucumber team now consists of Joseph Wilk, Ben Mabey and > myself. > >> Welcome Ben! > >> > > Congrats Ben! > > >> Aslak > > > > > > Thanks for the welcome! > > > > Just to be clear.. I did not say that I was the "cucumber God"... someone > > said that to me. :) > > > > -Ben > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pat.maddox at gmail.com Wed Apr 8 01:56:21 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Tue, 7 Apr 2009 22:56:21 -0700 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: <2c7e61990904072256j67ef027bxce49126a6f437009@mail.gmail.com> On Tue, Apr 7, 2009 at 2:19 PM, aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the core Cucumber team. > Ben has been a long time contributor to Cucumber's ecosystem and knows it > inside out. > Here is a quote from IRC today: > > ? mabes: Yeah but you're the cucumber God. > > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and myself. > Welcome Ben! > > Aslak > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > You guys are rockin. Thanks. Pat From korny at sietsma.com Wed Apr 8 02:24:15 2009 From: korny at sietsma.com (Korny Sietsma) Date: Wed, 8 Apr 2009 16:24:15 +1000 Subject: [rspec-users] [Cucumber] any examples of navigating cucumber parse tree from external script In-Reply-To: <8e15872b0904071801s8b5adbu987e38f9052bdd66@mail.gmail.com> References: <8e15872b0904071801s8b5adbu987e38f9052bdd66@mail.gmail.com> Message-ID: <8e15872b0904072324u54599f69he6f3dc16c3d95ea3@mail.gmail.com> Hmm - on digging further, I might be better off writing a custom formatter as described at http://wiki.github.com/aslakhellesoy/cucumber/custom-formatters, and just invoking cucumber with --dry-run and my formatter... Though as I want to use the html formatter to format steps for insertion into the wiki, I've still got some work to do :) - korny On Wed, Apr 8, 2009 at 11:01 AM, Korny Sietsma wrote: > Hi folks, > I'm writing some scripts to integrate our cucumber features with stories > stored in a wiki, and I'm hoping to use cucumber's parser to parse the > features rather than doing it manually. (I don't really care about the > feature contents much, just scenario titles and tags) > > I've worked out how to parse the features: > Cucumber.load_language('en') > features = Cucumber::Ast::Features.new > parser = Cucumber::Parser::FeatureParser.new > > feature_files = Dir["#{FEATURE_DIR}/**/*.feature"] > > feature_files.each do |f| > puts "parsing feature file #{f}" > features.add_feature(parser.parse_file(f)) > end > > But now I'm digging in to the whole ast visitor thing, and it's getting > quite complex to *do* stuff with the features once I've parsed them. > > I'm sure I can work this out myself, given time, but I was wondering if > there are any code examples out there to save me some of the time/effort? > Anyone else tried parsing features like this from outside Cucumber itself? > > Thanks! > > - Korny > > -- > Kornelis Sietsma korny at my surname dot com > "Every jumbled pile of person has a thinking part > that wonders what the part that isn't thinking > isn't thinking of" > -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at josephwilk.net Wed Apr 8 03:32:24 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Wed, 08 Apr 2009 08:32:24 +0100 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: <49DC5308.9010208@josephwilk.net> aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the core Cucumber team. > Ben has been a long time contributor to Cucumber's ecosystem and knows > it inside out. > Here is a quote from IRC today: > > mabes: Yeah but you're the cucumber God. > > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and > myself. Welcome Ben! > > Aslak > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Congrats Ben, great to have you on-board. Looks like we will have the first cucumber dev meetup at Railsconf. Team photo definitely required :) -- Joseph Wilk http://blog.josephwilk.net From matt at mattwynne.net Wed Apr 8 04:12:55 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 8 Apr 2009 09:12:55 +0100 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: <4FBF7791-B8EE-417F-AD87-E249FC92EBE4@mattwynne.net> On 7 Apr 2009, at 22:19, aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the core Cucumber team. > Ben has been a long time contributor to Cucumber's ecosystem and > knows it inside out. > Here is a quote from IRC today: > > mabes: Yeah but you're the cucumber God. > > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and > myself. Welcome Ben! > > Aslak Nice one Ben :) Matt Wynne http://blog.mattwynne.net http://www.songkick.com From svoop at delirium.ch Wed Apr 8 05:11:13 2009 From: svoop at delirium.ch (Sven) Date: Wed, 8 Apr 2009 09:11:13 +0000 (UTC) Subject: [rspec-users] Pending expectations Message-ID: I've noticed that pending expectations fail if the before(:each) code is not implemented yet. In other words, taking the example code from Peepcode's rspec series: describe Weather, ".fetch for zipcode" do before(:each) do @weather = Weather.fetch_for_zipcode(98117) end it "should populate zipcode" it "should populate temperature units" it "should populate recorded at" end With rspec-1.2.0 this will result in 3 failing tests (as fetch_for_zipcode is not yet implemented), whereas in the original screencast it caused the three expectations to be reported as pending - which makes more sense to me. How come? -sven From programmer2188 at gmail.com Wed Apr 8 06:25:05 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Wed, 8 Apr 2009 06:25:05 -0400 Subject: [rspec-users] Testing helpers that accept a block Message-ID: <000001c9b834$49fdcdb0$ddf96910$@com> Hi, I am trying to write and test a helper that accepts a block. Right now it goes something like this: module ContactHelper # Wraps a field with div.error if it has an error. def wrap_error_field errors, &block field = capture &block if errors.empty? concat field else concat content_tag(:div, field, :class => 'error') end end # field_error_helper This is my first time writing a helper, so please tell me if I'm wrong. Then, I tried to test it, but couldn't figure it out, since it seems the method won't actually return anything due to the use of concat. The best I could figure out for now was to use eval_erb. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ContactHelper do describe "field_error_helper" do context "when there is an error" do it "should wrap the block in div.error" do assigns[:errors] = [ 'Error' ] output = eval_erb <<-ERB <% wrap_error_field @errors do %>

Block

<% end %> ERB assert_xhtml output do div.error do p 'Block' end end end # it should wrap the block in div.error end # when there is an error end # describe field_error_helper end end Is that the best/only method? I'm not sure how much I really like it. Further, when I run the tests, it always outputs "Block" before the test is executed, and I can't figure out why, and that's slightly annoying. Thanks, Brandon From dchelimsky at gmail.com Wed Apr 8 10:36:01 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 8 Apr 2009 11:36:01 -0300 Subject: [rspec-users] Pending expectations In-Reply-To: References: Message-ID: <57c63afe0904080736s7bb96348yfd365f5f775344e6@mail.gmail.com> On Wed, Apr 8, 2009 at 6:11 AM, Sven wrote: > I've noticed that pending expectations fail if the before(:each) code is not > implemented yet. In other words, taking the example code from Peepcode's rspec > series: > > describe Weather, ".fetch for zipcode" do > > ?before(:each) do > ? ?@weather = Weather.fetch_for_zipcode(98117) > ?end > > ?it "should populate zipcode" > > ?it "should populate temperature units" > > ?it "should populate recorded at" > > end > > With rspec-1.2.0 this will result in 3 failing tests (as fetch_for_zipcode is > not yet implemented), whereas in the original screencast it caused the three > expectations to be reported as pending - which makes more sense to me. > > How come? Please file a bug report at http://rspec.lighthouseapp.com and include the backtrace you're getting. Thanks, David > -sven > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Wed Apr 8 10:59:56 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 8 Apr 2009 07:59:56 -0700 Subject: [rspec-users] Pending expectations In-Reply-To: References: Message-ID: <3c30da400904080759y3e852e7dgb08e8639dba53cd8@mail.gmail.com> On Wed, Apr 8, 2009 at 2:11 AM, Sven wrote: > describe Weather, ".fetch for zipcode" do > > ?before(:each) do > ? ?@weather = Weather.fetch_for_zipcode(98117) > ?end > > ?it "should populate zipcode" > > ?it "should populate temperature units" > > ?it "should populate recorded at" > > end > > With rspec-1.2.0 this will result in 3 failing tests (as fetch_for_zipcode is > not yet implemented), whereas in the original screencast it caused the three > expectations to be reported as pending - which makes more sense to me. No one asked me, but I think the new way is better. If I write code, it should be correct. If I didn't care if the call to fetch_for_zipcode was correct, I'd comment it out, mock it out, or just not write it in the first place. In general, I write before() after I write the examples, since I usually consider it just a DRY refactoring. ///ark From dchelimsky at gmail.com Wed Apr 8 11:06:28 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 8 Apr 2009 12:06:28 -0300 Subject: [rspec-users] Pending expectations In-Reply-To: <3c30da400904080759y3e852e7dgb08e8639dba53cd8@mail.gmail.com> References: <3c30da400904080759y3e852e7dgb08e8639dba53cd8@mail.gmail.com> Message-ID: <57c63afe0904080806w225684cckd96e803ddf14b0ac@mail.gmail.com> On Wed, Apr 8, 2009 at 11:59 AM, Mark Wilden wrote: > On Wed, Apr 8, 2009 at 2:11 AM, Sven wrote: > >> describe Weather, ".fetch for zipcode" do >> >> ?before(:each) do >> ? ?@weather = Weather.fetch_for_zipcode(98117) >> ?end >> >> ?it "should populate zipcode" >> >> ?it "should populate temperature units" >> >> ?it "should populate recorded at" >> >> end >> >> With rspec-1.2.0 this will result in 3 failing tests (as fetch_for_zipcode is >> not yet implemented), whereas in the original screencast it caused the three >> expectations to be reported as pending - which makes more sense to me. > > No one asked me, but I think the new way is better. If I write code, > it should be correct. If I didn't care if the call to > fetch_for_zipcode was correct, I'd comment it out, mock it out, or > just not write it in the first place. In general, I write before() > after I write the examples, since I usually consider it just a DRY > refactoring. No one asked me either, but I think Mark's approach is a valid approach, but not the only approach :) When writing specs with a describe/context structure, like this: describe Thing do context "with no widgets" do before(:each) do @thing = Thing.new end it "acts one way" end context "with one widget" do before(:each) do @thing = Thing.new(:widgets => [Widget.new]) end it "acts a different way" end end It is fairly common to write code to align with the context in the before blocks. My expectation would be, in this case, that the before blocks are not run unless there is at least one non-pending example in the group. FWIW, David > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From svoop at delirium.ch Wed Apr 8 11:07:12 2009 From: svoop at delirium.ch (Sven) Date: Wed, 8 Apr 2009 15:07:12 +0000 (UTC) Subject: [rspec-users] Pending expectations References: <3c30da400904080759y3e852e7dgb08e8639dba53cd8@mail.gmail.com> Message-ID: > In general, I write before() > after I write the examples, since I usually consider it just a DRY > refactoring. Good point. I guess I'll just get used to it then :-) From anja-email1 at web.de Wed Apr 8 11:09:26 2009 From: anja-email1 at web.de (Andrea Jahn) Date: Wed, 08 Apr 2009 17:09:26 +0200 Subject: [rspec-users] possible to stub params hash ? Message-ID: <1338651610@web.de> Hi, I added one line in my controller to extend the params hash. But now I get errors in my controller spec. Controller def update @pl_planning = PlPlanning.find(params[:id]) # the item model version (select box) depends on other select boxes and can be empty # then it is not in the params hash and the attribute would not be updated and validated --> params[:pl_planning]["item_model_version_id"] ||= "" # update planning attributes @pl_planning.attributes = params[:pl_planning] ... Controller Spec error: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] What do I have to add in my spec for that ? I tried: params = {"pl_planning" => {}} controller.stub!(:params).and_return(params) But then I get the following error: undefined method `scope=' for # Thanks in advance Andrea Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele ausl?ndische Netze zum gleichen Preis! https://produkte.web.de/webde_sms/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Wed Apr 8 11:39:36 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 8 Apr 2009 11:39:36 -0400 Subject: [rspec-users] possible to stub params hash ? In-Reply-To: <1338651610@web.de> References: <1338651610@web.de> Message-ID: <5989036C-79E5-481B-AA25-1EF29284592A@railsnewbie.com> On Apr 8, 2009, at 11:09 AM, Andrea Jahn wrote: > > Hi, > > I added one line in my controller to extend the params hash. But now > I get errors > in my controller spec. > > Controller > > def update > @pl_planning = PlPlanning.find(params[:id]) > > # the item model version (select box) depends on other select > boxes and can be empty > # then it is not in the params hash and the attribute would not > be updated and validated > --> params[:pl_planning]["item_model_version_id"] ||= "" > > # update planning attributes > @pl_planning.attributes = params[:pl_planning] > ... > > > Controller Spec error: > > You have a nil object when you didn't expect it! > You might have expected an i nstance of ActiveRecord::Base. > The error occurred while evaluating nil.[] > > > What do I have to add in my spec for that ? > > I tried: > > params = {"pl_planning" => {}} > controller.stub!(:params).and_return(params) > > But then I get the following error: > > undefined method `scope=' for # 0x6aa14cc> > Usually you are will fare better if you pass the params directly in: get :foo, :param1 => "something" Why are you stubbing params? Scott > > Thanks in advance > Andrea > > > > > > Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und > viele > ausl?ndische Netze zum gleichen Preis! > https://produkte.web.de/webde_sms/sms > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielpennypacker at gmail.com Wed Apr 8 13:14:25 2009 From: danielpennypacker at gmail.com (danielpennypacker) Date: Wed, 8 Apr 2009 10:14:25 -0700 (PDT) Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly In-Reply-To: <57c63afe0904071834g4ffc53efj70104bcd729e47e0@mail.gmail.com> References: <22939702.post@talk.nabble.com> <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> <22940623.post@talk.nabble.com> <57c63afe0904071834g4ffc53efj70104bcd729e47e0@mail.gmail.com> Message-ID: <22955408.post@talk.nabble.com> Oops, sotty about that, I got my version of ruby mixed in there. They're both 1.1.8 I followed the instructions here: http://wiki.github.com/dchelimsky/rspec/rails David Chelimsky-2 wrote: > > On Tue, Apr 7, 2009 at 6:55 PM, danielpennypacker > wrote: >> >> We're using Rails 2.1.1 and rspec/rspec_on_rails 1.8.6. > > 1.8.6 doesn't really exist. The most recent is 1.2.2 :) > >> It was working okay >> on a different my dev branch, so I'm not sure if different versions are >> the >> problem. >> >> Thanks so much for the speedy reply, and I hope knowing my versions >> helps. >> My senior dev is gonna help with it tomorrow, so I'll make sure to update >> our findings. > > Cool - good luck! > >> >> Thanks again! >> >>>My understanding is that there is an rspec_on_rails_on_crack branch >>>that is not master that works better w/ the latest rails. Not sure of >>>the details and running out the door shortly, but take a look and see >>>f that can help resolve any issues you're having. >> >>>Cheers, >>>David >> >> >> >> >> >> David Chelimsky-2 wrote: >>> >>> On Tue, Apr 7, 2009 at 5:40 PM, danielpennypacker >>> wrote: >>>> >>>> Here's an intro to what I'm working on... >>>> >>>> - We're adding Beast Forums to our site and we decided to integrate the >>>> code >>>> instead of have it run in a separate app. >>>> >>>> - Beast uses rspec, and this was the first time I've been exposed to >>>> it, >>>> we >>>> use boring old unit tests. Beast also uses the rspec_on_rails_on_crack >>>> plugin. >>> >>> >>> >>>> >>>> - I was doing work on a development branch and eventually got all of >>>> the >>>> specs written for Beast to past after they had been integrated into our >>>> site. >>>> >>>> - I merged my branch back to trunk resolved conflicts and did 'rake >>>> spec' >>>> >>>> - rake 'spec:models' works fine, but when I try running specs for the >>>> controllers, I get this error: >>>> ?./spec/controllers/sessions_controller_spec.rb:13: undefined method >>>> `act!' >>>> for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) >>>> >>>> ?- act! is defined in rspec_on_rails_on_crack, and is being required in >>>> spec_helper.rb, but for some reason it isn't loading. I'm guessing that >>>> I >>>> forgot to commit a file somewhere, but I can't figure it out. >>>> >>>> - I know this is a pretty general question, but I thought someone might >>>> have >>>> run it before, so thanks for any help! >>>> >>>> Here's 'spec_helper.rb'. It's been a bit modified from what was in >>>> Beast >>>> Forums >>>> >>>> -------------------------------------------- >>>> >>>> # This file is copied to ~/spec when you run 'ruby script/generate >>>> rspec' >>>> # from the project root directory. >>>> ENV["RAILS_ENV"] = "test" >>>> require File.expand_path(File.dirname(__FILE__) + >>>> "/../config/environment") >>>> require 'spec' >>>> require 'spec/rails' >>>> require 'rspec_on_rails_on_crack' >>>> #require 'model_stubbing' >>>> #require File.dirname(__FILE__) + "/model_stubs" >>>> #require 'ruby-debug' >>>> #Debugger.start >>>> >>>> Spec::Runner.configure do |config| >>>> ?include AuthenticatedTestHelper >>>> ?config.use_transactional_fixtures = true >>>> ?config.use_instantiated_fixtures ?= false >>>> ?config.fixture_path = RAILS_ROOT + '/test/fixtures/' >>>> >>>> ?def current_site(site = nil) >>>> ? ?Site.find(:first) || Site.find(site.id) >>>> ?end >>>> >>>> ?# Sets the current user in the session from the user fixtures. >>>> ? def login_as(user) >>>> ? ?controller.stub!(:current_user).and_return(@user = user ? >>>> users(user) >>>> : >>>> nil) >>>> ?end >>>> >>>> ?def authorize_as(user) >>>> ? ?@request.env["HTTP_AUTHORIZATION"] = user ? "Basic >>>> #{Base64.encode64("#{users(user).login}:test")}" : nil >>>> ?end >>>> end >>>> >>>> Full error trace: >>>> >>>> --------------------------------------------------------- >>>> >>>> ./spec/controllers/sessions_controller_spec.rb:13: undefined method >>>> `act!' >>>> for ActiveSupport::TestCase::Subclass_1:Class (NoMethodError) >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in >>>> `module_eval' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:177:in >>>> `subclass' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_methods.rb:55:in >>>> `describe' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/example/example_group_factory.rb:29:in >>>> `create_example_group' >>>> ? ? ? ?from >>>> /Users/pennypacker/Desktop/work/infectious-trunk/vendor/plugins/rspec/lib/spec/extensions/main.rb:27:in >>>> `describe' >>>> ? ? ? ?from ./spec/controllers/sessions_controller_spec.rb:3 >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >>>> `load' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >>>> `load_files' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >>>> `each' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >>>> `load_files' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in >>>> `run_examples' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in >>>> `run' >>>> ? ? ? ?from >>>> /Users/pennypacker/.gem/ruby/1.8/gems/rspec-1.2.2/bin/spec:4 >>>> >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22939702.html >>>> Sent from the rspec-users mailing list archive at Nabble.com. >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22940623.html >> Sent from the rspec-users mailing list archive at Nabble.com. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22955408.html Sent from the rspec-users mailing list archive at Nabble.com. From biot023 at gmail.com Wed Apr 8 14:08:15 2009 From: biot023 at gmail.com (doug livesey) Date: Wed, 8 Apr 2009 19:08:15 +0100 Subject: [rspec-users] updated to latest gems, rspec not catching flash.now Message-ID: <50873a360904081108g67f4be76h521b0ff0461e392a@mail.gmail.com> Hi, after an update to all the latest gems, I have a controller spec failing that wasn't previously: flash[:alert].should eql( "Blah blah." )** The flash is being set by "flash.now[:alert] = '...'" in this instance. Can anyone suggest how I can make this work again? Cheers, Doug. -------------- next part -------------- An HTML attachment was scrubbed... URL: From biot023 at gmail.com Wed Apr 8 16:00:20 2009 From: biot023 at gmail.com (doug livesey) Date: Wed, 8 Apr 2009 21:00:20 +0100 Subject: [rspec-users] RSpec-Rails 1.2.2 and Controllers without views - what to do? In-Reply-To: References: Message-ID: <50873a360904081300h564bc7cap7751a3e29ad6184a@mail.gmail.com> Hi. Bira -- just got the same problem myself, and have found that (whilst not a perfect solution) that stubbing out render on the controller in my before block solves it. controller.stub!( :render ) HTH, Doug. 2009/4/1 Bira > I'm trying to upgrade to RSpec 1.2.2 in a Rails app, and reading > Upgrade.rdoc I see that now every controller action must have a > corresponding template for their specs to pass. However, we have a few > controllers which only return XML or JSON as generated by Rails' > to_xml and to_json methods, and so use only render :xml/:json calls > rather than views. With 1.2.2, we get a lot of failing specs in that > section that used to pass with 1.1.12, because of the "missing" > templates. > > What do you recommend I do in this case? Is there any good solution > other than making up templates consisting entirely of a single "<%= > @obj.to_xml %>" line? > > -- > Bira > http://compexplicita.wordpress.com > http://compexplicita.tumblr.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Apr 8 16:32:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 8 Apr 2009 17:32:08 -0300 Subject: [rspec-users] Pending expectations In-Reply-To: References: <3c30da400904080759y3e852e7dgb08e8639dba53cd8@mail.gmail.com> Message-ID: <57c63afe0904081332y47325ed1yedff9f41665232f7@mail.gmail.com> On Wed, Apr 8, 2009 at 12:07 PM, Sven wrote: >> In general, I write before() >> after I write the examples, since I usually consider it just a DRY >> refactoring. > > Good point. I guess I'll just get used to it then :-) No, please don't get used to it. The behaviour you expect is correct, and the behaviour you are seeing is incorrect. Cheers, David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From andrew.zielinski.is at gmail.com Wed Apr 8 16:48:19 2009 From: andrew.zielinski.is at gmail.com (Andrew Zielinski) Date: Wed, 8 Apr 2009 13:48:19 -0700 (PDT) Subject: [rspec-users] superclass mismatch for class ModelExampleGroup (TypeError) In-Reply-To: <57c63afe0904071817s6772e388j9f03f354ef05fba8@mail.gmail.com> References: <22940271.post@talk.nabble.com> <57c63afe0904071817s6772e388j9f03f354ef05fba8@mail.gmail.com> Message-ID: <22959248.post@talk.nabble.com> Thanks David, It seems like remarkable was the culprit. Somebody had posted the same issue to lighthouse. The solution was to specify the lib in environment.rb instead of setting it to false for rspec and rspec-rails. The discussion was in Portuguese so I'm not sure why this works. I don't get the error anymore but now when I run spec_server it hangs. Running it with debug produced the following output: -----------Exception `LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:871 - no such file to load -- rubygems/defaults/operating_system Exception `LoadError' at /Library/Ruby/Site/1.8/rubygems/config_file.rb:35 - no such file to load -- Win32API Exception `TypeError' at (eval):4 - can't modify frozen object Exception `MissingSourceFile' at /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31 - no such file to load -- fast_xs Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:636 - RubyGem version error: rack(0.3.0 not ~> 1.0.0) Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:636 - Could not find RubyGem tmail (~> 1.2.3) Exception `MissingSourceFile' at /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31 - no such file to load -- tmail/tmailscanner Exception `MissingSourceFile' at /Library/Ruby/Site/1.8/rubygems/custom_require.rb:38 - no such file to load -- tmail/tmailscanner Exception `MissingSourceFile' at /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:162 - no such file to load -- tmail/tmailscanner /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: instance variable @reload_plugins not initialized /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: instance variable @reload_plugins not initialized /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: instance variable @reload_plugins not initialized /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: instance variable @reload_plugins not initialized ................... David Chelimsky-2 wrote: > > On Tue, Apr 7, 2009 at 6:20 PM, Andrew Zielinski > wrote: >> >> I hope somebody can help me with this. >> >> I can't seem to run spec_server with rails 2.3.2 using rspec/rspec-rails >> 1.2.2. I'm also using mocha 0.9.5 and remarkable 2.3.0. > > The stack trace doesn't show it, but the superclass mismatch suggests > that you have a version of rspec pre 1.2 that is being loaded > somewhere. The old ModelExampleGroup derived directly from > Test::Unit::TestCase, but the 1.2 class derives from > ActiveSupport::TestCase. Can you check to see what versions of rspec > and rspec-rails you have installed and uninstall all the old ones if > you can. > > HTH, > David > >> >> Thanks Andrew >> >> Here is the stack trace: >> >> --------------------------------- >> >> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example/model_example_group.rb:9: >> superclass mismatch for class ModelExampleGroup (TypeError) >> >> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >> from >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >> `require' >> from >> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example.rb:6 >> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >> from >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >> `require' >> from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb:19 >> ?... 9 levels... >> from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in >> `run' >> from ./script/../config/environment.rb:13 >> from ./script/spec_server:6:in `require' >> from ./script/spec_server:6 >> >> >> -- >> View this message in context: >> http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22940271.html >> Sent from the rspec-users mailing list archive at Nabble.com. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22959248.html Sent from the rspec-users mailing list archive at Nabble.com. From matt at mattwynne.net Wed Apr 8 16:51:29 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 8 Apr 2009 21:51:29 +0100 Subject: [rspec-users] debuggin cucmber script in ruby In-Reply-To: <88634D6B-2927-4257-9CDD-6CF04D15FB25@railsnewbie.com> References: <49DA09EA.1010103@benmabey.com> <427205c9c9f13cacba511275d94cf132@ruby-forum.com> <49DA2C16.6090208@benmabey.com> <85d99afe0904061710y5139100ahbf77028916eee95d@mail.gmail.com> <7ac2300c0904070730q5d19cc25m7b1d9127d5d54fe1@mail.gmail.com> <08ACF3F4-880D-485F-82E8-135B1021341E@benmabey.com> <88634D6B-2927-4257-9CDD-6CF04D15FB25@railsnewbie.com> Message-ID: <11C5C0A8-CA48-4A29-8F00-28E51B1EBAA2@mattwynne.net> On 7 Apr 2009, at 17:23, Scott Taylor wrote: > > On Apr 7, 2009, at 11:54 AM, Ben Mabey wrote: > >> >> On Apr 7, 2009, at 8:30 AM, aidy lewis wrote: >> >>> On 07/04/2009, Zach Dennis wrote: >>>> On Mon, Apr 6, 2009 at 12:21 PM, Ben Mabey >>>> wrote: >>> >>>>> My best >>>>> suggestion would be to set multiple breakpoints and hit "c" to >>>>> continue to >>>>> the next one so you can skip through all of Cucumber's code. >>> >>>> I will sometimes set a global variable to help me flag when to >>>> debug, >>>> if the code in question gets executed multiple times. e.g. >>>> >>>> $c = true if my_condition_is_met >>>> >>>> And then... >>>> >>>> debugger if $c >>> >>> Some useful tips, but I feel the ruby-debug tutorials that exist are >>> lacking. Would it be fitting for me to add a Cucumber and ruby-debug >>> page on the Wiki? >>> >>> Aidy >> >> >> That would be great! Thanks for offering. > > I've been meaning to do a ruby-debug screencast for quite some time. > > Although it won't be specific to cucumber, I'll post it on the wiki > when I get around to it. > > Scott This is really good. It's short and sweet, and makes you realise there's really not much to it at all: http://railscasts.com/episodes/54-debugging-with-ruby-debug Matt Wynne http://blog.mattwynne.net http://www.songkick.com From tbbooher at gmail.com Wed Apr 8 17:18:32 2009 From: tbbooher at gmail.com (TimBooher) Date: Wed, 8 Apr 2009 14:18:32 -0700 (PDT) Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace In-Reply-To: References: Message-ID: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> any takers? am i asking a question that is too hard or too easy and boring? thanks, tim On Apr 7, 7:41?am, Tim Booher wrote: > I am trying to get my workflow down and am confused on several fronts. The > first is how to get my rspec_scaffold tests to run. The problem is that i > generated my scaffold, then moved my controller into a namespace named > :admin. > > So I have the following familiar code. How can i change this to avoid: > > --------------------------------------------- > my error on run > --------------------------------------------- > > /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in > `load_missing_constant': uninitialized constant SponsorsController > (NameError) > ? ? from > /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in > `const_missing' > ? ? from > /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in > `const_missing' > ? ? from > /home/tim/web_apps/lovd_by_fitwit/spec/controllers/sponsors_controller_spec.rb:3 > ? ? from > /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in > `load' > ? ? from > /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in > `load_files' > ? ? from > /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in > `each' > ? ? from > /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in > `load_files' > ? ? from > /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in > `run_examples' > ? ? from > /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in > `run' > ? ? from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 > > --------------------------------------------- > sponsors_controller_spec.rb > --------------------------------------------- > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe SponsorsController do > > ? def mock_sponsor(stubs={}) > ? ? @mock_sponsor ||= mock_model(Sponsor, stubs) > ? end > > ? describe "responding to GET index" do > > ? ? it "should expose all sponsors as @sponsors" do > ? ? ? Sponsor.should_receive(:find).with(:all).and_return([mock_sponsor]) > ? ? ? get :index > ? ? ? assigns[:sponsors].should == [mock_sponsor] > ? ? end > > ? ?. . . . > > end > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Wed Apr 8 17:21:13 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 8 Apr 2009 17:21:13 -0400 Subject: [rspec-users] updated to latest gems, rspec not catching flash.now In-Reply-To: <50873a360904081108g67f4be76h521b0ff0461e392a@mail.gmail.com> References: <50873a360904081108g67f4be76h521b0ff0461e392a@mail.gmail.com> Message-ID: <85d99afe0904081421g482b6e45kaf4fd087fa7490fd@mail.gmail.com> On Wed, Apr 8, 2009 at 2:08 PM, doug livesey wrote: > Hi, after an update to all the latest gems, I have a controller spec failing > that wasn't previously: > ?? flash[:alert].should eql( "Blah blah." ) > > The flash is being set by "flash.now[:alert] = '...'" in this instance. > Can anyone suggest how I can make this work again? I just submitted a patch to ticket #11834 to resolve this issue in rspec-rails: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/98-11834-fake-controller-flash-object#ticket-98-9 In the mean time you can manually patch your local rspec-rails (if you unpack rspec and rspec-rails into vendor/gems or vendor/plugins this should work fine). Or you can do Xavier suggests on that ticket and add a few lines to your spec_helper, until rspec-rails is updated. HTH, > Cheers, > ?? Doug. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From Wesley.Williams at sabre.com Wed Apr 8 05:31:32 2009 From: Wesley.Williams at sabre.com (Williams, Wesley) Date: Wed, 8 Apr 2009 04:31:32 -0500 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> Message-ID: <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> All, I know this is an older post but I have a similar but different set of scenarios I need to handle. I have a set of flight related scheduling features, such as delay, reschedule, and cancel, each with multiple scenarios that have an effect on later flights in the schedule (there are a lot of scenarios actually). What (I think J) I need is a set of flights that I can reuse, in a Background: given section, by all of these features and scenarios, that is defined in a way that is reusable and visible in each of the feature definitions. Is this possible? Is there a better way to do this? Example: Feature: Delay flights with down line adjustments As a flight scheduler I want to delay a flight and have the down line flights adjusted for different periods So I can more quickly update a schedule when events happen Background: Given I have the following flights scheduled: |aircraft | flight number | dept date | dept time | | XX1 | XX0001 | 03Mar2009 | 1000 | | XX1 | XX0002 | 03Mar2009 | 1400 | | XX1 | XX0003 | 03Mar2009 | 2100 | | XX1 | XX0004 | 04Mar2009 | 1000 | Scenario: delay flights with down line adjustments for same dept date as delayed flight When I delay flight XX001 by 5 mins Then XX001 departs at 1005 Then XX002 departs at 1405 Then XX003 departs at 2105 Then XX004 departs at 1000 OR Scenario: delay flights with down line adjustments for same dept date as delayed flight When I delay flight XX001 by 5 mins Then the scheduled flight should be |aircraft | flight number | dept date | dept time | | XX1 | XX0001 | 03Mar2009 | 1005 | | XX1 | XX0002 | 03Mar2009 | 1405 | | XX1 | XX0003 | 03Mar2009 | 2105 | | XX1 | XX0004 | 04Mar2009 | 1000 | There are many more scenarios. Is there a nice way to removed the duplication that is here, especially since I will need a similar set of flights for other scheduling change scenarios? Does anyone see a nice way to simplify the scenarios? Great tool by the way. Thanks, Wes Subject: [rspec-users] Reuse of Cucumber Features +lots :) Generally when we have problems with features its because we are trying to do to much at once. So in your case date entry is being complicated by different contexts, birth and incident. One of the tennents of BDD is to write the simplest thing you can to make you feature pass. I think another one should be "first of all write the simplest scenarios". So taking one of your examples Scenario: Enter Valid Incident When I fill incident correctly I should recieve a confirmation Then your incident step can be something like When /^I fill incident correctly$/ do fill_in("incident[name]", :with => ... ... end If you wanted to specify validation in features you could do a step like When /^I fill incident correctly except$/ do |field| When "I fill in incident correctly" fill_in("incident[#{field}]", :with => '' end now you can create new features like Scenario: Enter Valid Incident with no date When I fill incident correctly except date I should recieve an error With a bit more trickery you could have When I fill incident correctly except date which is xxx Taking this approach you can build incrementally quite complex validation features whilst stll keeping each scenario simple and focused on one thing. Whether you should do this with features or put this detail somewhere else is another question entirely. On another point with dates have you considered international issues. All the dates you've given in your example are valid (technically) there just not in the format you prefer. Also consider that the invalidity of dates might be context dependant e.g. an incident date in the future, an appointment in the past. HTH Andrew 2008/12/14 Pat Maddox > > Hi Steve, > > I likely would only write two scenarios, one for a valid date and one > for an invalid one. Then I would write object-level specs to determine > what a valid date is. Extract this to a validator that you can reuse > throughout your model. > > If it's important that you write features for each potential invalid > date format (because you want to communicate them with the customer) > then I would write a feature file similar to what you show...but it > would be focused only on the date, I wouldn't mention patients or > incidents at all. Date entry seems to be an important concept in your > application, so I would write one feature that specifies how I expect > date entry to work, and then I can just write valid/invalid dates for > patient and incident features. Same idea as the first paragraph, but > using features instead of specs. > > Pat > > > "Steve Molitor" > writes: > > > Thanks -- that gets me closer. Here's an example. Let's say I have two > features, 'Create new patient' and 'Create new incident'. To > > create a new patient you have to enter a valid birth date. To create a > new patient you must enter a valid birth date. To create a new > > incident you must enter a valid incident date. The rules for date entry > are the same: > > > > Feature: Date entry > > > > Scenario: Invalid month > > When I fill in the date value with "13/01/2000" > > I should see "Invalid date..." > > > > Scenario: Invalid year (not 4 digits) > > When I fill in the date value with "13/01/00" > > I should see "Invalid date..." > > > > Scenario: Separate with slashes (ok) > > When I fill in the date value with "01/13/2000" > > I should see "valid date..." > > > > Scenario: Separate with dashes (ok) > > When I fill in the date value with "01-13-2000" > > I should see "valid date..." > > > > .... etc.... > > > > Given the above, how should I write the 'create new patient' and 'create > new incident' features? I don't want to copy and paste all the > > date related scenarios, but I do want to specify (and test) that the > patient birth date and incident date fields conform to the general date > > rules. Here's how the 'create new patient' and 'create new incident' > features would look with some copy and pasting: > > > > Feature: Create new Patient > > > > Scenario: Enter invalid birth date > > Given I fill in "birth date" with "13/01/2000" > > And I fill in "patient name" with "Sam Smith" > > When I press "Save" > > I should see "Invalid birth date '13/01/2000'" > > > > Scenario: Enter valid birth date, valid name > > Given I fill in "birth date" with "01/13/2000" > > And I fill in "patient name" with "Sam Smith" > > When I press "Save" > > I should see "Patient Created Successfully" > > > > Scenario: Enter valid birth date with dashses..... > > ------- > > > > Feature: Create new Incident > > > > Scenario: Enter invalid incident date > > Given I fill in "incident" with "13/01/2000" > > And I fill in "supervisor" with "Sam Smith" > > When I press "Save" > > I should see "Invalid incident date '13/01/2000'" > > > > Scenario: Enter valid incident date, valid supervisor > > Given I fill in "incident date" with "01/13/2000" > > And I fill in "supervisor" with "Sam Smith" > > When I press "Save" > > I should see "Incident Created Successfully" > > > > Scenario: Enter valid incident date with dashes.... > > ----- > > > > Am I making sense? I want to specify the date in the features, as there > may be extra requirements like birth dates can not be in the future > > in addition to the generic date requirements. And I want to validate > that the form checks for valid dates, displays the appropriate error > > message when invalid, and uses the common rules for parsing. But I don't > want to copy and paste those scenarios in every feature. I think > > reusing steps as you mention is probably the solution but I'm stuck on > how to word it and put it together in my case. > > > > Steve > > > > On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne > wrote: > > > > On 13 Dec 2008, at 20:58, Steve Molitor wrote: > > > > What's the best way to handle a requirement that shows up as a > sub-requirement requirement in other features? For example let's say > > users can enter dates in various forms throughout my application. > There is one set of global rules specifying the formats in which > > dates may be entered, and how they are interpreted. I put that > in one feature. In various other features, like 'Create new > > patient', one can enter dates, like the patient's birth date. I > want to do something like 'and the date entry shall follow the > > normal rules' but I'm not sure how to do that in an example > driven way, without copying and pasting from other features. > > > > Does my question make sense? Any suggestions? > > > > Do you know that you can call steps within steps? > > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ > > > > Is that what you're looking for? > > > > Matt Wynne > > http://blog.mattwynne.net > > http://www.songkick.com > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim at saturnflyer.com Wed Apr 8 18:10:55 2009 From: jim at saturnflyer.com (Jim Gay) Date: Wed, 8 Apr 2009 18:10:55 -0400 Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace In-Reply-To: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> References: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> Message-ID: <6A7C432F-6161-4F26-B302-AF0A7506CA1F@saturnflyer.com> Hey Tim, I didn't see the first post. If you've namespaced the controller, you'll need to make that change in the spec. My assumption is that SponsorsController became Admin::SponsorsController So you'll need to make sure that this is reflected in your spec. -Jim On Apr 8, 2009, at 5:18 PM, TimBooher wrote: > any takers? am i asking a question that is too hard or too easy and > boring? > > thanks, > > tim > > On Apr 7, 7:41 am, Tim Booher wrote: >> I am trying to get my workflow down and am confused on several >> fronts. The >> first is how to get my rspec_scaffold tests to run. The problem is >> that i >> generated my scaffold, then moved my controller into a namespace >> named >> :admin. >> >> So I have the following familiar code. How can i change this to >> avoid: >> >> --------------------------------------------- >> my error on run >> --------------------------------------------- >> >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ >> dependencies.rb:445:in >> `load_missing_constant': uninitialized constant SponsorsController >> (NameError) >> from >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ >> dependencies.rb:77:in >> `const_missing' >> from >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ >> dependencies.rb:89:in >> `const_missing' >> from >> /home/tim/web_apps/lovd_by_fitwit/spec/controllers/ >> sponsors_controller_spec.rb:3 >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:15:in >> `load' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:15:in >> `load_files' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:14:in >> `each' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:14:in >> `load_files' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb: >> 97:in >> `run_examples' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> command_line.rb:9:in >> `run' >> from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 >> >> --------------------------------------------- >> sponsors_controller_spec.rb >> --------------------------------------------- >> >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> describe SponsorsController do >> >> def mock_sponsor(stubs={}) >> @mock_sponsor ||= mock_model(Sponsor, stubs) >> end >> >> describe "responding to GET index" do >> >> it "should expose all sponsors as @sponsors" do >> >> Sponsor.should_receive(:find).with(:all).and_return([mock_sponsor]) >> get :index >> assigns[:sponsors].should == [mock_sponsor] >> end >> >> . . . . >> >> end >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Wed Apr 8 18:33:21 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 8 Apr 2009 18:33:21 -0400 Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace In-Reply-To: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> References: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> Message-ID: <85d99afe0904081533w7a96888ajec02d7cea9b13f22@mail.gmail.com> On Wed, Apr 8, 2009 at 5:18 PM, TimBooher wrote: > any takers? am i asking a question that is too hard or too easy and > boring? So your SponsorsController exists inside of a Admin module namespace? If so update your spec: describe Admin::SponsorsController If that's not the issue I'm not quite sure what you're using namespace to refer to, > > thanks, > > tim > > On Apr 7, 7:41?am, Tim Booher wrote: >> I am trying to get my workflow down and am confused on several fronts. The >> first is how to get my rspec_scaffold tests to run. The problem is that i >> generated my scaffold, then moved my controller into a namespace named >> :admin. >> >> So I have the following familiar code. How can i change this to avoid: >> >> --------------------------------------------- >> my error on run >> --------------------------------------------- >> >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in >> `load_missing_constant': uninitialized constant SponsorsController >> (NameError) >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in >> `const_missing' >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in >> `const_missing' >> ? ? from >> /home/tim/web_apps/lovd_by_fitwit/spec/controllers/sponsors_controller_spec.rb:3 >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >> `load' >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:15:in >> `load_files' >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >> `each' >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/example_group_runner.rb:14:in >> `load_files' >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb:97:in >> `run_examples' >> ? ? from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/command_line.rb:9:in >> `run' >> ? ? from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 >> >> --------------------------------------------- >> sponsors_controller_spec.rb >> --------------------------------------------- >> >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> describe SponsorsController do >> >> ? def mock_sponsor(stubs={}) >> ? ? @mock_sponsor ||= mock_model(Sponsor, stubs) >> ? end >> >> ? describe "responding to GET index" do >> >> ? ? it "should expose all sponsors as @sponsors" do >> ? ? ? Sponsor.should_receive(:find).with(:all).and_return([mock_sponsor]) >> ? ? ? get :index >> ? ? ? assigns[:sponsors].should == [mock_sponsor] >> ? ? end >> >> ? ?. . . . >> >> end >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From rspec at nigelthorne.com Wed Apr 8 19:58:35 2009 From: rspec at nigelthorne.com (Nigel Thorne) Date: Thu, 9 Apr 2009 09:58:35 +1000 Subject: [rspec-users] Web-based story runner? In-Reply-To: <49DBCA9F.8020303@benmabey.com> References: <57c63afe0904071440g56511163q494892c24dcae569@mail.gmail.com> <49DBCA9F.8020303@benmabey.com> Message-ID: <5d1f449a0904081658v6e5f2325yb6256f8e43d438d2@mail.gmail.com> I'm starting one of these too... I'll github it when I'm happy with my approach. 2009/4/8 Ben Mabey > David Chelimsky wrote: > >> On Tue, Apr 7, 2009 at 3:26 PM, Sophie (itsme213) >> wrote: >> >> >>> Some time ago I had come across a web-based story editor for scenarios. >>> I'm >>> not sure if it was a full runner, and it was probably before cucumber. >>> >>> Anyone know where I can find it? >>> >>> >> >> It was only a protoype with some javascript to make it look nice - no >> integration to anything real - but, you can find it here: >> >> http://github.com/dchelimsky/rspec-stories/tree/master >> >> Look in the story_server directory. >> >> >> > > Also, take a look at rcumber: > > http://github.com/jgoodsen/rcumber/tree/master > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielpennypacker at gmail.com Wed Apr 8 20:22:33 2009 From: danielpennypacker at gmail.com (danielpennypacker) Date: Wed, 8 Apr 2009 17:22:33 -0700 (PDT) Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly In-Reply-To: <22955408.post@talk.nabble.com> References: <22939702.post@talk.nabble.com> <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> <22940623.post@talk.nabble.com> <57c63afe0904071834g4ffc53efj70104bcd729e47e0@mail.gmail.com> <22955408.post@talk.nabble.com> Message-ID: <22962362.post@talk.nabble.com> So me and the senior dev solved the problem. We tried a number of things, so I'm not sure if my original question is that relevant, but here's what was kinda going on... -This is my first time integrating lots of plugins from another app, so I was going in between installing gems as gems and installing gems as plugins. - Because i wasn't consistent about that, and I wasn't consistent about re-running script/generate rspec, I was getting weird behavior. I guess in the version we're using (I don't know if this is changed later), the files generated are different whether you have rspec installed as a plugin or as a gem. -Hope that helps for anyone, and thanks for the feedback. -- View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22962362.html Sent from the rspec-users mailing list archive at Nabble.com. From dchelimsky at gmail.com Wed Apr 8 20:28:41 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 8 Apr 2009 21:28:41 -0300 Subject: [rspec-users] rspec_on_rails_on_crack not being loaded properly In-Reply-To: <22962362.post@talk.nabble.com> References: <22939702.post@talk.nabble.com> <57c63afe0904071603v72c614f0ue395ebe4579433b@mail.gmail.com> <22940623.post@talk.nabble.com> <57c63afe0904071834g4ffc53efj70104bcd729e47e0@mail.gmail.com> <22955408.post@talk.nabble.com> <22962362.post@talk.nabble.com> Message-ID: <57c63afe0904081728sf3c277j51f341da00501988@mail.gmail.com> On Wed, Apr 8, 2009 at 9:22 PM, danielpennypacker wrote: > > So me and the senior dev solved the problem. We tried a number of things, so > I'm not sure if my original question is that relevant, but here's what was > kinda going on... > > -This is my first time integrating lots of plugins from another app, so I > was going in between installing gems as gems and installing gems as plugins. > > - Because i wasn't consistent about that, and I wasn't consistent about > re-running script/generate rspec, I was getting weird behavior. I guess in > the version we're using (I don't know if this is changed later), the files > generated are different whether you have rspec installed as a plugin or as a > gem. The generated files should be the same either way - but they behave slightly differently depending on where they are installed. > > -Hope that helps for anyone, and thanks for the feedback. > -- > View this message in context: http://www.nabble.com/rspec_on_rails_on_crack-not-being-loaded-properly-tp22939702p22962362.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Wed Apr 8 21:14:50 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Wed, 8 Apr 2009 21:14:50 -0400 Subject: [rspec-users] Testing helpers that accept a block Message-ID: <009a01c9b8b0$95f6bca0$c1e435e0$@com> Hi, Well, I googled some more, and everything I could find used eval_erb. So is this the best method for testing helpers with blocks? And then why is that block displaying when I run the test? Thanks, Brandon > -----Original Message----- > From: Brandon Olivares [mailto:programmer2188 at gmail.com] > Sent: Wednesday, April 08, 2009 6:25 AM > To: 'rspec-users' > Subject: Testing helpers that accept a block > > Hi, > > I am trying to write and test a helper that accepts a block. Right now > it goes something like this: > > module ContactHelper > > # Wraps a field with div.error if it has an error. > def wrap_error_field errors, &block > field = capture &block > if errors.empty? > concat field > else > concat content_tag(:div, field, :class => 'error') > end > end # field_error_helper > > This is my first time writing a helper, so please tell me if I'm wrong. > > Then, I tried to test it, but couldn't figure it out, since it seems > the method won't actually return anything due to the use of concat. The > best I could figure out for now was to use eval_erb. > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe ContactHelper do > > describe "field_error_helper" do > > context "when there is an error" do > > it "should wrap the block in div.error" do > > assigns[:errors] = [ > 'Error' > ] > > output = eval_erb <<-ERB > <% wrap_error_field @errors do %> >

Block

> <% end %> > ERB > > assert_xhtml output do > div.error do > p 'Block' > end > end > > end # it should wrap the block in div.error > > end # when there is an error > > end # describe field_error_helper > > end > end > > Is that the best/only method? I'm not sure how much I really like it. > > Further, when I run the tests, it always outputs "Block" before the > test is executed, and I can't figure out why, and that's slightly > annoying. > > Thanks, > Brandon From phlip2005 at gmail.com Wed Apr 8 23:53:34 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 08 Apr 2009 20:53:34 -0700 Subject: [rspec-users] Testing helpers that accept a block In-Reply-To: <009a01c9b8b0$95f6bca0$c1e435e0$@com> References: <009a01c9b8b0$95f6bca0$c1e435e0$@com> Message-ID: <49DD713E.2030202@gmail.com> > assert_xhtml output do > div.error do > p 'Block' > end > end Nokogiri has some "easter eggs" in its ambitious HTML::Builder system. One of them is only HTML tags not already recognized as methods can get turned into HTML tags. The usual .method_missing() abuse. The fix is: assert_xhtml output do div.error do p! 'Block' end end (Also .be_html_with might work by now... 0.4.9?) Aaron P. is pondering this issue even now in his subconscious, but I only ought to feed him one feature request at a time and a couple others are ahead in the queue, so my ! trick has to work for the near future... From programmer2188 at gmail.com Thu Apr 9 00:52:27 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Thu, 9 Apr 2009 00:52:27 -0400 Subject: [rspec-users] Testing helpers that accept a block In-Reply-To: <49DD713E.2030202@gmail.com> References: <009a01c9b8b0$95f6bca0$c1e435e0$@com> <49DD713E.2030202@gmail.com> Message-ID: <00c801c9b8ce$fc82bcd0$f5883670$@com> Hi, Oh, I should have thought of that. Thanks a lot. I'm growing used to the assert_xhtml syntax, lol, so I've just been using that. Thank you though for fixing the be_html_with syntax. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Wednesday, April 08, 2009 11:54 PM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Testing helpers that accept a block > > > assert_xhtml output do > > div.error do > > p 'Block' > > end > > end > > Nokogiri has some "easter eggs" in its ambitious HTML::Builder system. > One of > them is only HTML tags not already recognized as methods can get turned > into > HTML tags. The usual .method_missing() abuse. > > The fix is: > > assert_xhtml output do > div.error do > p! 'Block' > end > end > > (Also .be_html_with might work by now... 0.4.9?) > > Aaron P. is pondering this issue even now in his subconscious, but I > only ought > to feed him one feature request at a time and a couple others are ahead > in the > queue, so my ! trick has to work for the near future... > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From svoop at delirium.ch Thu Apr 9 03:08:23 2009 From: svoop at delirium.ch (Sven) Date: Thu, 9 Apr 2009 07:08:23 +0000 (UTC) Subject: [rspec-users] Pending expectations References: <3c30da400904080759y3e852e7dgb08e8639dba53cd8@mail.gmail.com> <57c63afe0904081332y47325ed1yedff9f41665232f7@mail.gmail.com> Message-ID: > No, please don't get used to it. The behaviour you expect is correct, > and the behaviour you are seeing is incorrect. Okidoke, I've submitted a ticket on Lighthouse. From matt at mattwynne.net Thu Apr 9 03:48:21 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 9 Apr 2009 08:48:21 +0100 Subject: [rspec-users] [Rspec] Trying to get rspec to test a controller in a namespace In-Reply-To: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> References: <5dd634ef-d037-44e5-9c96-d13f00399027@g20g2000vba.googlegroups.com> Message-ID: Beware of scaffolds - they stop you from thinking which is never good. Anyway my guess at the answer is inline. On 8 Apr 2009, at 22:18, TimBooher wrote: > any takers? am i asking a question that is too hard or too easy and > boring? > > thanks, > > tim > > On Apr 7, 7:41 am, Tim Booher wrote: >> I am trying to get my workflow down and am confused on several >> fronts. The >> first is how to get my rspec_scaffold tests to run. The problem is >> that i >> generated my scaffold, then moved my controller into a namespace >> named >> :admin. >> >> So I have the following familiar code. How can i change this to >> avoid: >> >> --------------------------------------------- >> my error on run >> --------------------------------------------- >> >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ >> dependencies.rb:445:in >> `load_missing_constant': uninitialized constant SponsorsController >> (NameError) >> from >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ >> dependencies.rb:77:in >> `const_missing' >> from >> /home/tim/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/ >> dependencies.rb:89:in >> `const_missing' >> from >> /home/tim/web_apps/lovd_by_fitwit/spec/controllers/ >> sponsors_controller_spec.rb:3 >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:15:in >> `load' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:15:in >> `load_files' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:14:in >> `each' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> example_group_runner.rb:14:in >> `load_files' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/options.rb: >> 97:in >> `run_examples' >> from >> /home/tim/.gem/ruby/1.8/gems/rspec-1.2.2/lib/spec/runner/ >> command_line.rb:9:in >> `run' >> from /home/tim/web_apps/lovd_by_fitwit/script/spec:5 >> >> --------------------------------------------- >> sponsors_controller_spec.rb >> --------------------------------------------- >> >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> module Admin >> describe SponsorsController do >> >> def mock_sponsor(stubs={}) >> @mock_sponsor ||= mock_model(Sponsor, stubs) >> end >> >> describe "responding to GET index" do >> >> it "should expose all sponsors as @sponsors" do >> >> Sponsor.should_receive(:find).with(:all).and_return([mock_sponsor]) >> get :index >> assigns[:sponsors].should == [mock_sponsor] >> end >> >> . . . . >> >> end end >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Thu Apr 9 03:57:47 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 9 Apr 2009 08:57:47 +0100 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> Message-ID: On 8 Apr 2009, at 10:31, Williams, Wesley wrote: > All, > > I know this is an older post but I have a similar but different set > of scenarios I need to handle. I have a set of flight related > scheduling features, such as delay, reschedule, and cancel, each > with multiple scenarios that have an effect on later flights in the > schedule (there are a lot of scenarios actually). What (I think J) > I need is a set of flights that I can reuse, in a Background: given > section, by all of these features and scenarios, that is defined in > a way that is reusable and visible in each of the feature definitions. > > Is this possible? Is there a better way to do this? > > Example: > > Feature: Delay flights with down line adjustments > As a flight scheduler > I want to delay a flight and have the down line flights adjusted > for different periods > So I can more quickly update a schedule when events happen > > Background: > Given I have the following flights scheduled: > |aircraft | flight number | dept date | dept time | > | XX1 | XX0001 | 03Mar2009 | 1000 | > | XX1 | XX0002 | 03Mar2009 | 1400 | > | XX1 | XX0003 | 03Mar2009 | 2100 | > | XX1 | XX0004 | 04Mar2009 | 1000 | > > Scenario: delay flights with down line adjustments for same dept > date as delayed flight > When I delay flight XX001 by 5 mins > Then XX001 departs at 1005 > Then XX002 departs at 1405 > Then XX003 departs at 2105 > Then XX004 departs at 1000 > > OR > > Scenario: delay flights with down line adjustments for same dept > date as delayed flight > When I delay flight XX001 by 5 mins > Then the scheduled flight should be > |aircraft | flight number | dept date | dept time | > | XX1 | XX0001 | 03Mar2009 | 1005 | > | XX1 | XX0002 | 03Mar2009 | 1405 | > | XX1 | XX0003 | 03Mar2009 | 2105 | > | XX1 | XX0004 | 04Mar2009 | 1000 | > > There are many more scenarios. > > Is there a nice way to removed the duplication that is here, > especially since I will need a similar set of flights for other > scheduling change scenarios? Does anyone see a nice way to simplify > the scenarios? > > Great tool by the way. > > Thanks, > Wes Have you seen this? http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ Another way to remove duplication (and noise) from Cucumber steps is the hide the details in the Ruby code that implements the step, and write a much more general step in the feature file like this: Given there are 3 flights departing on the same day And the flights all leave at different times And there is another flight leaving on the following day When the earliest flight is delayed by 5 mins Then the flights on the first day should all be delayed by 5 minutes And the flight on the second day should be unaffected These kind of steps can be clearer to read, but the trade-off is that your underlying step code gets more complex as you start writing logic to deliver these specific scenarios. Still, if you're clever about it, these 'declarative' steps can still be pretty re-usable. HTH, Matt > > Subject: [rspec-users] Reuse of Cucumber Features > > +lots :) > > Generally when we have problems with features its because we are > trying to > do to much at once. So in your case date entry is being complicated by > different contexts, birth and incident. One of the tennents of BDD > is to > write the simplest thing you can to make you feature pass. I think > another > one should be "first of all write the simplest scenarios". So taking > one of > your examples > > Scenario: Enter Valid Incident > When I fill incident correctly > I should recieve a confirmation > > Then your incident step can be something like > > When /^I fill incident correctly$/ do > fill_in("incident[name]", :with => ... > ... > end > > If you wanted to specify validation in features you could do a step > like > > When /^I fill incident correctly except$/ do |field| > When "I fill in incident correctly" > fill_in("incident[#{field}]", :with => '' > end > > now you can create new features like > > Scenario: Enter Valid Incident with no date > When I fill incident correctly except date > I should recieve an error > > With a bit more trickery you could have > > When I fill incident correctly except date which is xxx > > Taking this approach you can build incrementally quite complex > validation > features whilst stll keeping each scenario simple and focused on one > thing. > Whether you should do this with features or put this detail > somewhere else > is another question entirely. > > On another point with dates have you considered international > issues. All > the dates you've given in your example are valid (technically) there > just > not in the format you prefer. Also consider that the invalidity of > dates > might be context dependant e.g. an incident date in the future, an > appointment in the past. > > HTH > > Andrew > > > 2008/12/14 Pat Maddox > > > Hi Steve, > > > > I likely would only write two scenarios, one for a valid date and > one > > for an invalid one. Then I would write object-level specs to > determine > > what a valid date is. Extract this to a validator that you can > reuse > > throughout your model. > > > > If it's important that you write features for each potential invalid > > date format (because you want to communicate them with the customer) > > then I would write a feature file similar to what you show...but it > > would be focused only on the date, I wouldn't mention patients or > > incidents at all. Date entry seems to be an important concept in > your > > application, so I would write one feature that specifies how I > expect > > date entry to work, and then I can just write valid/invalid dates > for > > patient and incident features. Same idea as the first paragraph, > but > > using features instead of specs. > > > > Pat > > > > > > "Steve Molitor" writes: > > > > > Thanks -- that gets me closer. Here's an example. Let's say I > have two > > features, 'Create new patient' and 'Create new incident'. To > > > create a new patient you have to enter a valid birth date. To > create a > > new patient you must enter a valid birth date. To create a new > > > incident you must enter a valid incident date. The rules for > date entry > > are the same: > > > > > > Feature: Date entry > > > > > > Scenario: Invalid month > > > When I fill in the date value with "13/01/2000" > > > I should see "Invalid date..." > > > > > > Scenario: Invalid year (not 4 digits) > > > When I fill in the date value with "13/01/00" > > > I should see "Invalid date..." > > > > > > Scenario: Separate with slashes (ok) > > > When I fill in the date value with "01/13/2000" > > > I should see "valid date..." > > > > > > Scenario: Separate with dashes (ok) > > > When I fill in the date value with "01-13-2000" > > > I should see "valid date..." > > > > > > .... etc.... > > > > > > Given the above, how should I write the 'create new patient' and > 'create > > new incident' features? I don't want to copy and paste all the > > > date related scenarios, but I do want to specify (and test) that > the > > patient birth date and incident date fields conform to the general > date > > > rules. Here's how the 'create new patient' and 'create new > incident' > > features would look with some copy and pasting: > > > > > > Feature: Create new Patient > > > > > > Scenario: Enter invalid birth date > > > Given I fill in "birth date" with "13/01/2000" > > > And I fill in "patient name" with "Sam Smith" > > > When I press "Save" > > > I should see "Invalid birth date '13/01/2000'" > > > > > > Scenario: Enter valid birth date, valid name > > > Given I fill in "birth date" with "01/13/2000" > > > And I fill in "patient name" with "Sam Smith" > > > When I press "Save" > > > I should see "Patient Created Successfully" > > > > > > Scenario: Enter valid birth date with dashses..... > > > ------- > > > > > > Feature: Create new Incident > > > > > > Scenario: Enter invalid incident date > > > Given I fill in "incident" with "13/01/2000" > > > And I fill in "supervisor" with "Sam Smith" > > > When I press "Save" > > > I should see "Invalid incident date '13/01/2000'" > > > > > > Scenario: Enter valid incident date, valid supervisor > > > Given I fill in "incident date" with "01/13/2000" > > > And I fill in "supervisor" with "Sam Smith" > > > When I press "Save" > > > I should see "Incident Created Successfully" > > > > > > Scenario: Enter valid incident date with dashes.... > > > ----- > > > > > > Am I making sense? I want to specify the date in the features, > as there > > may be extra requirements like birth dates can not be in the future > > > in addition to the generic date requirements. And I want to > validate > > that the form checks for valid dates, displays the appropriate error > > > message when invalid, and uses the common rules for parsing. > But I don't > > want to copy and paste those scenarios in every feature. I think > > > reusing steps as you mention is probably the solution but I'm > stuck on > > how to word it and put it together in my case. > > > > > > Steve > > > > > > On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne mattwynne.net> wrote: > > > > > > On 13 Dec 2008, at 20:58, Steve Molitor wrote: > > > > > > What's the best way to handle a requirement that shows > up as a > > sub-requirement requirement in other features? For example let's > say > > > users can enter dates in various forms throughout my > application. > > There is one set of global rules specifying the formats in which > > > dates may be entered, and how they are interpreted. I > put that > > in one feature. In various other features, like 'Create new > > > patient', one can enter dates, like the patient's birth > date. I > > want to do something like 'and the date entry shall follow the > > > normal rules' but I'm not sure how to do that in an > example > > driven way, without copying and pasting from other features. > > > > > > Does my question make sense? Any suggestions? > > > > > > Do you know that you can call steps within steps? > > > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ > > > > > > Is that what you're looking for? > > > > > > Matt Wynne > > > http://blog.mattwynne.net > > > http://www.songkick.com > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Thu Apr 9 08:39:47 2009 From: lists at ruby-forum.com (Fedor Fomenko) Date: Thu, 9 Apr 2009 14:39:47 +0200 Subject: [rspec-users] [Cucumber] Bug? Message-ID: <31822d19b55bb0e594cd344098319141@ruby-forum.com> Hello, I have the following step for checking that a validation message is displayed on screen: Then /^(.+) should be displayed$/ do |error| msg = @browser.ul(:class, 'validation-summary-errors').li(:text, error) #pp msg.text msg.should_not == nil end I run scenario with examples table which contains expected error messages. If I put wrong error message and pp line in step is commented out as shown I get green result from Cucumber, which is wrong. When I uncomment pp line I get exception Unable to locate element, using :text, "BOOOOOOOOOO" (Watir::Exception::UnknownObjectException) ./features/step_definitions/customer_details_steps.rb:47:in `/^(.+) should be displayed$/' features/customer_details_full.feature:40:in `Then should be displayed' And step is shown as Red in Cucumber as it should. Is this a bug in Cucumber or am I missing something? -- Posted via http://www.ruby-forum.com/. From matthew.krom at gmail.com Thu Apr 9 08:43:35 2009 From: matthew.krom at gmail.com (Matthew Krom) Date: Thu, 9 Apr 2009 08:43:35 -0400 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> Message-ID: Two other brainstorms: Brainstorm 1: Given an empty flights database And aircraft XX1 flight number XX0001 departs on 03Mar2009 at 1000 And aircraft XX1 flight number XX0002 departs on 03Mar2009 at 1400 And aircraft XX1 flight number XX0003 departs on 03Mar2009 at 2100 Brainstorm 2: # Sets up all the flights in your scenario Given flight database scenario A In #2, you have to reference separate documentation on what is contained within scenario A. This may or may not be acceptable to your process, but it can work quite well if you are comfortable referring to the separate documentation to keep things straight. Matt Krom >> I know this is an older post but I have a similar but different set of >> scenarios I need to handle. I have a set of flight related scheduling >> features, such as delay, reschedule, and cancel, each with multiple >> scenarios that have an effect on later flights in the schedule (there are a >> lot of scenarios actually). What (I think J) I need is a set of flights >> that I can reuse, in a Background: given section, by all of these features >> and scenarios, that is defined in a way that is reusable and visible in each >> of the feature definitions. >> >> Is this possible? Is there a better way to do this? >> >> Example: >> >> Feature: Delay flights with down line adjustments >> As a flight scheduler >> I want to delay a flight and have the down line flights adjusted for >> different periods >> So I can more quickly update a schedule when events happen >> >> Background: >> Given I have the following flights scheduled: >> |aircraft | flight number | dept date | dept time | >> | XX1 | XX0001 | 03Mar2009 | 1000 | >> | XX1 | XX0002 | 03Mar2009 | 1400 | >> | XX1 | XX0003 | 03Mar2009 | 2100 | >> | XX1 | XX0004 | 04Mar2009 | 1000 | >> >> Scenario: delay flights with down line adjustments for same dept date >> as delayed flight >> When I delay flight XX001 by 5 mins >> Then XX001 departs at 1005 >> Then XX002 departs at 1405 >> Then XX003 departs at 2105 >> Then XX004 departs at 1000 >> >> OR >> >> Scenario: delay flights with down line adjustments for same dept date >> as delayed flight >> When I delay flight XX001 by 5 mins >> Then the scheduled flight should be >> |aircraft | flight number | dept date | dept time | >> | XX1 | XX0001 | 03Mar2009 | 1005 | >> | XX1 | XX0002 | 03Mar2009 | 1405 | >> | XX1 | XX0003 | 03Mar2009 | 2105 | >> | XX1 | XX0004 | 04Mar2009 | 1000 | >> >> There are many more scenarios. >> >> Is there a nice way to removed the duplication that is here, especially >> since I will need a similar set of flights for other scheduling change >> scenarios? Does anyone see a nice way to simplify the scenarios? >> >> Great tool by the way. >> >> Thanks, >> Wes >> > > Have you seen this? > > > http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ > > Another way to remove duplication (and noise) from Cucumber steps is the > hide the details in the Ruby code that implements the step, and write a much > more general step in the feature file like this: > > Given there are 3 flights departing on the same day > And the flights all leave at different times > And there is another flight leaving on the following day > When the earliest flight is delayed by 5 mins > Then the flights on the first day should all be delayed by 5 minutes > And the flight on the second day should be unaffected > > These kind of steps can be clearer to read, but the trade-off is that your > underlying step code gets more complex as you start writing logic to deliver > these specific scenarios. Still, if you're clever about it, these > 'declarative' steps can still be pretty re-usable. > > HTH, > Matt > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Thu Apr 9 09:19:05 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 9 Apr 2009 09:19:05 -0400 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> Message-ID: On Thu, Apr 9, 2009 at 3:57 AM, Matt Wynne wrote: > > > Another way to remove duplication (and noise) from Cucumber steps is the > hide the details in the Ruby code that implements the step, and write a much > more general step in the feature file like this: > > Given there are 3 flights departing on the same day > And the flights all leave at different times > And there is another flight leaving on the following day > When the earliest flight is delayed by 5 mins > Then the flights on the first day should all be delayed by 5 minutes > And the flight on the second day should be unaffected > > These kind of steps can be clearer to read, but the trade-off is that your > underlying step code gets more complex as you start writing logic to deliver > these specific scenarios. Still, if you're clever about it, these > 'declarative' steps can still be pretty re-usable. > > I've gone down a similar road before, albeit with the old story runner rather than Cucumber, and I'm not sure how far I'd push it. That trade-off starts to get onerous. You spend a lot of time debugging your steps to convince yourself that "the flight on the second day" maps to "another flight leaving on the following day" when you reuse the steps in other cases. I found myself wanting to do meta bdd on my story code! -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From Wesley.Williams at sabre.com Thu Apr 9 09:22:20 2009 From: Wesley.Williams at sabre.com (Williams, Wesley) Date: Thu, 9 Apr 2009 08:22:20 -0500 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com><4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> Message-ID: <4BC6E12138FF78458424C4BB5F20EC890BEF4FDD@sgtulmsp06.Global.ad.sabre.com> Matt, I am open to referring to separate documentation/scenario. It would be nice if I can optionally make it appear in the tests but that is a nice to have. Is this just an example/idea or is it possible to do this currently? Thanks, Wes From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Matthew Krom Sent: Thursday, April 09, 2009 2:44 PM To: rspec-users Subject: Re: [rspec-users] Reuse of Cucumber Features Two other brainstorms: Brainstorm 1: Given an empty flights database And aircraft XX1 flight number XX0001 departs on 03Mar2009 at 1000 And aircraft XX1 flight number XX0002 departs on 03Mar2009 at 1400 And aircraft XX1 flight number XX0003 departs on 03Mar2009 at 2100 Brainstorm 2: # Sets up all the flights in your scenario Given flight database scenario A In #2, you have to reference separate documentation on what is contained within scenario A. This may or may not be acceptable to your process, but it can work quite well if you are comfortable referring to the separate documentation to keep things straight. Matt Krom I know this is an older post but I have a similar but different set of scenarios I need to handle. I have a set of flight related scheduling features, such as delay, reschedule, and cancel, each with multiple scenarios that have an effect on later flights in the schedule (there are a lot of scenarios actually). What (I think J) I need is a set of flights that I can reuse, in a Background: given section, by all of these features and scenarios, that is defined in a way that is reusable and visible in each of the feature definitions. Is this possible? Is there a better way to do this? Example: Feature: Delay flights with down line adjustments As a flight scheduler I want to delay a flight and have the down line flights adjusted for different periods So I can more quickly update a schedule when events happen Background: Given I have the following flights scheduled: |aircraft | flight number | dept date | dept time | | XX1 | XX0001 | 03Mar2009 | 1000 | | XX1 | XX0002 | 03Mar2009 | 1400 | | XX1 | XX0003 | 03Mar2009 | 2100 | | XX1 | XX0004 | 04Mar2009 | 1000 | Scenario: delay flights with down line adjustments for same dept date as delayed flight When I delay flight XX001 by 5 mins Then XX001 departs at 1005 Then XX002 departs at 1405 Then XX003 departs at 2105 Then XX004 departs at 1000 OR Scenario: delay flights with down line adjustments for same dept date as delayed flight When I delay flight XX001 by 5 mins Then the scheduled flight should be |aircraft | flight number | dept date | dept time | | XX1 | XX0001 | 03Mar2009 | 1005 | | XX1 | XX0002 | 03Mar2009 | 1405 | | XX1 | XX0003 | 03Mar2009 | 2105 | | XX1 | XX0004 | 04Mar2009 | 1000 | There are many more scenarios. Is there a nice way to removed the duplication that is here, especially since I will need a similar set of flights for other scheduling change scenarios? Does anyone see a nice way to simplify the scenarios? Great tool by the way. Thanks, Wes Have you seen this? http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ Another way to remove duplication (and noise) from Cucumber steps is the hide the details in the Ruby code that implements the step, and write a much more general step in the feature file like this: Given there are 3 flights departing on the same day And the flights all leave at different times And there is another flight leaving on the following day When the earliest flight is delayed by 5 mins Then the flights on the first day should all be delayed by 5 minutes And the flight on the second day should be unaffected These kind of steps can be clearer to read, but the trade-off is that your underlying step code gets more complex as you start writing logic to deliver these specific scenarios. Still, if you're clever about it, these 'declarative' steps can still be pretty re-usable. HTH, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From Wesley.Williams at sabre.com Thu Apr 9 09:29:28 2009 From: Wesley.Williams at sabre.com (Williams, Wesley) Date: Thu, 9 Apr 2009 08:29:28 -0500 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com><4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> Message-ID: <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> Matt, Hmm, I think this is one way to do it. I will need to get my customer to think differently about defining the requirements. They really like the tables. Thanks, Wes -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Matt Wynne Sent: Thursday, April 09, 2009 9:58 AM To: rspec-users Subject: Re: [rspec-users] Reuse of Cucumber Features On 8 Apr 2009, at 10:31, Williams, Wesley wrote: > All, > > I know this is an older post but I have a similar but different set > of scenarios I need to handle. I have a set of flight related > scheduling features, such as delay, reschedule, and cancel, each > with multiple scenarios that have an effect on later flights in the > schedule (there are a lot of scenarios actually). What (I think J) > I need is a set of flights that I can reuse, in a Background: given > section, by all of these features and scenarios, that is defined in > a way that is reusable and visible in each of the feature definitions. > > Is this possible? Is there a better way to do this? > > Example: > > Feature: Delay flights with down line adjustments > As a flight scheduler > I want to delay a flight and have the down line flights adjusted > for different periods > So I can more quickly update a schedule when events happen > > Background: > Given I have the following flights scheduled: > |aircraft | flight number | dept date | dept time | > | XX1 | XX0001 | 03Mar2009 | 1000 | > | XX1 | XX0002 | 03Mar2009 | 1400 | > | XX1 | XX0003 | 03Mar2009 | 2100 | > | XX1 | XX0004 | 04Mar2009 | 1000 | > > Scenario: delay flights with down line adjustments for same dept > date as delayed flight > When I delay flight XX001 by 5 mins > Then XX001 departs at 1005 > Then XX002 departs at 1405 > Then XX003 departs at 2105 > Then XX004 departs at 1000 > > OR > > Scenario: delay flights with down line adjustments for same dept > date as delayed flight > When I delay flight XX001 by 5 mins > Then the scheduled flight should be > |aircraft | flight number | dept date | dept time | > | XX1 | XX0001 | 03Mar2009 | 1005 | > | XX1 | XX0002 | 03Mar2009 | 1405 | > | XX1 | XX0003 | 03Mar2009 | 2105 | > | XX1 | XX0004 | 04Mar2009 | 1000 | > > There are many more scenarios. > > Is there a nice way to removed the duplication that is here, > especially since I will need a similar set of flights for other > scheduling change scenarios? Does anyone see a nice way to simplify > the scenarios? > > Great tool by the way. > > Thanks, > Wes Have you seen this? http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-i n-user-stories/ Another way to remove duplication (and noise) from Cucumber steps is the hide the details in the Ruby code that implements the step, and write a much more general step in the feature file like this: Given there are 3 flights departing on the same day And the flights all leave at different times And there is another flight leaving on the following day When the earliest flight is delayed by 5 mins Then the flights on the first day should all be delayed by 5 minutes And the flight on the second day should be unaffected These kind of steps can be clearer to read, but the trade-off is that your underlying step code gets more complex as you start writing logic to deliver these specific scenarios. Still, if you're clever about it, these 'declarative' steps can still be pretty re-usable. HTH, Matt > > Subject: [rspec-users] Reuse of Cucumber Features > > +lots :) > > Generally when we have problems with features its because we are > trying to > do to much at once. So in your case date entry is being complicated by > different contexts, birth and incident. One of the tennents of BDD > is to > write the simplest thing you can to make you feature pass. I think > another > one should be "first of all write the simplest scenarios". So taking > one of > your examples > > Scenario: Enter Valid Incident > When I fill incident correctly > I should recieve a confirmation > > Then your incident step can be something like > > When /^I fill incident correctly$/ do > fill_in("incident[name]", :with => ... > ... > end > > If you wanted to specify validation in features you could do a step > like > > When /^I fill incident correctly except$/ do |field| > When "I fill in incident correctly" > fill_in("incident[#{field}]", :with => '' > end > > now you can create new features like > > Scenario: Enter Valid Incident with no date > When I fill incident correctly except date > I should recieve an error > > With a bit more trickery you could have > > When I fill incident correctly except date which is xxx > > Taking this approach you can build incrementally quite complex > validation > features whilst stll keeping each scenario simple and focused on one > thing. > Whether you should do this with features or put this detail > somewhere else > is another question entirely. > > On another point with dates have you considered international > issues. All > the dates you've given in your example are valid (technically) there > just > not in the format you prefer. Also consider that the invalidity of > dates > might be context dependant e.g. an incident date in the future, an > appointment in the past. > > HTH > > Andrew > > > 2008/12/14 Pat Maddox > > > Hi Steve, > > > > I likely would only write two scenarios, one for a valid date and > one > > for an invalid one. Then I would write object-level specs to > determine > > what a valid date is. Extract this to a validator that you can > reuse > > throughout your model. > > > > If it's important that you write features for each potential invalid > > date format (because you want to communicate them with the customer) > > then I would write a feature file similar to what you show...but it > > would be focused only on the date, I wouldn't mention patients or > > incidents at all. Date entry seems to be an important concept in > your > > application, so I would write one feature that specifies how I > expect > > date entry to work, and then I can just write valid/invalid dates > for > > patient and incident features. Same idea as the first paragraph, > but > > using features instead of specs. > > > > Pat > > > > > > "Steve Molitor" writes: > > > > > Thanks -- that gets me closer. Here's an example. Let's say I > have two > > features, 'Create new patient' and 'Create new incident'. To > > > create a new patient you have to enter a valid birth date. To > create a > > new patient you must enter a valid birth date. To create a new > > > incident you must enter a valid incident date. The rules for > date entry > > are the same: > > > > > > Feature: Date entry > > > > > > Scenario: Invalid month > > > When I fill in the date value with "13/01/2000" > > > I should see "Invalid date..." > > > > > > Scenario: Invalid year (not 4 digits) > > > When I fill in the date value with "13/01/00" > > > I should see "Invalid date..." > > > > > > Scenario: Separate with slashes (ok) > > > When I fill in the date value with "01/13/2000" > > > I should see "valid date..." > > > > > > Scenario: Separate with dashes (ok) > > > When I fill in the date value with "01-13-2000" > > > I should see "valid date..." > > > > > > .... etc.... > > > > > > Given the above, how should I write the 'create new patient' and > 'create > > new incident' features? I don't want to copy and paste all the > > > date related scenarios, but I do want to specify (and test) that > the > > patient birth date and incident date fields conform to the general > date > > > rules. Here's how the 'create new patient' and 'create new > incident' > > features would look with some copy and pasting: > > > > > > Feature: Create new Patient > > > > > > Scenario: Enter invalid birth date > > > Given I fill in "birth date" with "13/01/2000" > > > And I fill in "patient name" with "Sam Smith" > > > When I press "Save" > > > I should see "Invalid birth date '13/01/2000'" > > > > > > Scenario: Enter valid birth date, valid name > > > Given I fill in "birth date" with "01/13/2000" > > > And I fill in "patient name" with "Sam Smith" > > > When I press "Save" > > > I should see "Patient Created Successfully" > > > > > > Scenario: Enter valid birth date with dashses..... > > > ------- > > > > > > Feature: Create new Incident > > > > > > Scenario: Enter invalid incident date > > > Given I fill in "incident" with "13/01/2000" > > > And I fill in "supervisor" with "Sam Smith" > > > When I press "Save" > > > I should see "Invalid incident date '13/01/2000'" > > > > > > Scenario: Enter valid incident date, valid supervisor > > > Given I fill in "incident date" with "01/13/2000" > > > And I fill in "supervisor" with "Sam Smith" > > > When I press "Save" > > > I should see "Incident Created Successfully" > > > > > > Scenario: Enter valid incident date with dashes.... > > > ----- > > > > > > Am I making sense? I want to specify the date in the features, > as there > > may be extra requirements like birth dates can not be in the future > > > in addition to the generic date requirements. And I want to > validate > > that the form checks for valid dates, displays the appropriate error > > > message when invalid, and uses the common rules for parsing. > But I don't > > want to copy and paste those scenarios in every feature. I think > > > reusing steps as you mention is probably the solution but I'm > stuck on > > how to word it and put it together in my case. > > > > > > Steve > > > > > > On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne mattwynne.net> wrote: > > > > > > On 13 Dec 2008, at 20:58, Steve Molitor wrote: > > > > > > What's the best way to handle a requirement that shows > up as a > > sub-requirement requirement in other features? For example let's > say > > > users can enter dates in various forms throughout my > application. > > There is one set of global rules specifying the formats in which > > > dates may be entered, and how they are interpreted. I > put that > > in one feature. In various other features, like 'Create new > > > patient', one can enter dates, like the patient's birth > date. I > > want to do something like 'and the date entry shall follow the > > > normal rules' but I'm not sure how to do that in an > example > > driven way, without copying and pasting from other features. > > > > > > Does my question make sense? Any suggestions? > > > > > > Do you know that you can call steps within steps? > > > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ > > > > > > Is that what you're looking for? > > > > > > Matt Wynne > > > http://blog.mattwynne.net > > > http://www.songkick.com > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From Wesley.Williams at sabre.com Thu Apr 9 09:42:48 2009 From: Wesley.Williams at sabre.com (Williams, Wesley) Date: Thu, 9 Apr 2009 08:42:48 -0500 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com><4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> Message-ID: <4BC6E12138FF78458424C4BB5F20EC890BEF5027@sgtulmsp06.Global.ad.sabre.com> I have similar concerns. I am coming from a background in Fit/FitNesse so I am use to the table idea but I am not completely convinced it is better. I really appreciate all the feedback I am getting though, great community. I bought 'The Rspec Book' which is what got me started looking at the tool. More chapters please. J I do think being able to use multiple scenarios together would be nice but I do see the issues and danger and dangers of allowing scenario dependencies. Like all dependencies they make change hard. Thanks again for all the feedback and assistance. Wes From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Rick DeNatale Sent: Thursday, April 09, 2009 3:19 PM To: rspec-users Subject: Re: [rspec-users] Reuse of Cucumber Features On Thu, Apr 9, 2009 at 3:57 AM, Matt Wynne wrote: Another way to remove duplication (and noise) from Cucumber steps is the hide the details in the Ruby code that implements the step, and write a much more general step in the feature file like this: Given there are 3 flights departing on the same day And the flights all leave at different times And there is another flight leaving on the following day When the earliest flight is delayed by 5 mins Then the flights on the first day should all be delayed by 5 minutes And the flight on the second day should be unaffected These kind of steps can be clearer to read, but the trade-off is that your underlying step code gets more complex as you start writing logic to deliver these specific scenarios. Still, if you're clever about it, these 'declarative' steps can still be pretty re-usable. I've gone down a similar road before, albeit with the old story runner rather than Cucumber, and I'm not sure how far I'd push it. That trade-off starts to get onerous. You spend a lot of time debugging your steps to convince yourself that "the flight on the second day" maps to "another flight leaving on the following day" when you reuse the steps in other cases. I found myself wanting to do meta bdd on my story code! -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -------------- next part -------------- An HTML attachment was scrubbed... URL: From anja-email1 at web.de Thu Apr 9 09:48:55 2009 From: anja-email1 at web.de (Andrea Jahn) Date: Thu, 09 Apr 2009 15:48:55 +0200 Subject: [rspec-users] possible to stub params hash ? Message-ID: <1340524732@web.de> Hi, I tried to stub the params method of the Controller because I got the error " You have a nil object when you didn't expect it!" for the access to params[:pl_planning]["item_model_version_id"] in the update action. I thought, that the stubbing is not working because of the following error: "undefined method `scope=' for #". But now I found out, that this error has another reason. The put :update does not call the update action, it calls the index action. I will post another email for that problem to the user group. Thanks Andrea *Von:* "Scott Taylor" *Gesendet:* 08.04.09 17:46:31 *An:* rspec-users *Betreff:* Re: [rspec-users] possible to stub params hash ? On Apr 8, 2009, at 11:09 AM, Andrea Jahn wrote: Hi, I added one line in my controller to extend the params hash. But now I get errors in my controller spec. Controller def update @pl_planning = PlPlanning.find(params[:id]) # the item model version (select box) depends on other select boxes and can be empty # then it is not in the params hash and the attribute would not be updated and validated --> params[:pl_planning]["item_model_version_id"] ||= "" # update planning attributes @pl_planning.attributes = params[:pl_planning] ... Controller Spec error: You have a nil object when you didn't expect it! You might have expected an i nstance of ActiveRecord::Base. The error occurred while evaluating nil.[] What do I have to add in my spec for that ? I tried: params = {"pl_planning" => {}} controller.stub!(:params).and_return(params) But then I get the following error: undefined method `scope=' for # Usually you are will fare better if you pass the params directly in: get :foo, :param1 => "something" Why are you stubbing params? Scott Thanks in advance Andrea Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele ausl?ndische Netze zum gleichen Preis! https://produkte.web.de/webde_sms/sms [https://produkte.web.de/webde_sms/sms] _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org [mailto:rspec-users at rubyforge.org] http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________rspec-users mailing listrspec-users at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users GRATIS f?r alle WEB.DE-Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter *http://movieflat.web.de* [http://movieflat.web.de] -------------- next part -------------- An HTML attachment was scrubbed... URL: From anja-email1 at web.de Thu Apr 9 11:58:29 2009 From: anja-email1 at web.de (Andrea Jahn) Date: Thu, 09 Apr 2009 17:58:29 +0200 Subject: [rspec-users] possible to stub params hash ? Message-ID: <1340755697@web.de> The stub for params was the reason, that put :update has called the index action. Now I pass the params directly in and it works fine: put :update, :pl_planning => {"title" => "Project 1"} Scott, thanks a lot for the tip !!! Andrea *Von:* "Andrea Jahn" *Gesendet:* 09.04.09 16:03:53 *An:* rspec-users *Betreff:* Re: [rspec-users] possible to stub params hash ? Hi, I tried to stub the params method of the Controller because I got the error " You have a nil object when you didn't expect it!" for the access to params[:pl_planning]["item_model_version_id"] in the update action. I thought, that the stubbing is not working because of the following error: "undefined method `scope=' for #". But now I found out, that this error has another reason. The put :update does not call the update action, it calls the index action. I will post another email for that problem to the user group. Thanks Andrea *Von:* "Scott Taylor" *Gesendet:* 08.04.09 17:46:31 *An:* rspec-users *Betreff:* Re: [rspec-users] possible to stub params hash ? On Apr 8, 2009, at 11:09 AM, Andrea Jahn wrote: Hi, I added one line in my controller to extend the params hash. But now I get errors in my controller spec. Controller def update @pl_planning = PlPlanning.find(params[:id]) # the item model version (select box) depends on other select boxes and can be empty # then it is not in the params hash and the attribute would not be updated and validated --> params[:pl_planning]["item_model_version_id"] ||= "" # update planning attributes @pl_planning.attributes = params[:pl_planning] ... Controller Spec error: You have a nil object when you didn't expect it! You might have expected an i nstance of ActiveRecord::Base. The error occurred while evaluating nil.[] What do I have to add in my spec for that ? I tried: params = {"pl_planning" => {}} controller.stub!(:params).and_return(params) But then I get the following error: undefined method `scope=' for # Usually you are will fare better if you pass the params directly in: get :foo, :param1 => "something" Why are you stubbing params? Scott Thanks in advance Andrea Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele ausl?ndische Netze zum gleichen Preis! https://produkte.web.de/webde_sms/sms [https://produkte.web.de/webde_sms/sms] _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org [mailto:rspec-users at rubyforge.org] http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________rspec-users mailing listrspec-users at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users GRATIS f?r alle WEB.DE-Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter *http://movieflat.web.de* [http://movieflat.web.de/] _______________________________________________rspec-users mailing listrspec-users at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users GRATIS f?r alle WEB.DE-Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter *http://movieflat.web.de* [http://movieflat.web.de] -------------- next part -------------- An HTML attachment was scrubbed... URL: From phlip2005 at gmail.com Wed Apr 8 23:53:34 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 08 Apr 2009 20:53:34 -0700 Subject: [rspec-users] Testing helpers that accept a block In-Reply-To: <009a01c9b8b0$95f6bca0$c1e435e0$@com> References: <009a01c9b8b0$95f6bca0$c1e435e0$@com> Message-ID: <49DD713E.2030202@gmail.com> > assert_xhtml output do > div.error do > p 'Block' > end > end Nokogiri has some "easter eggs" in its ambitious HTML::Builder system. One of them is only HTML tags not already recognized as methods can get turned into HTML tags. The usual .method_missing() abuse. The fix is: assert_xhtml output do div.error do p! 'Block' end end (Also .be_html_with might work by now... 0.4.9?) Aaron P. is pondering this issue even now in his subconscious, but I only ought to feed him one feature request at a time and a couple others are ahead in the queue, so my ! trick has to work for the near future... From ben at benmabey.com Thu Apr 9 12:43:07 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 09 Apr 2009 10:43:07 -0600 Subject: [rspec-users] [Cucumber] Bug? In-Reply-To: <31822d19b55bb0e594cd344098319141@ruby-forum.com> References: <31822d19b55bb0e594cd344098319141@ruby-forum.com> Message-ID: <49DE259B.4090204@benmabey.com> Fedor Fomenko wrote: > Hello, > > I have the following step for checking that a validation message is > displayed on screen: > > Then /^(.+) should be displayed$/ do |error| > msg = @browser.ul(:class, 'validation-summary-errors').li(:text, > error) > #pp msg.text > msg.should_not == nil > end > > I run scenario with examples table which contains expected error > messages. If I put wrong error message and pp line in step is commented > out as shown I get green result from Cucumber, which is wrong. When I > uncomment pp line I get exception > > Unable to locate element, using :text, "BOOOOOOOOOO" > (Watir::Exception::UnknownObjectException) > ./features/step_definitions/customer_details_steps.rb:47:in `/^(.+) > should be displayed$/' > features/customer_details_full.feature:40:in `Then should be > displayed' > > And step is shown as Red in Cucumber as it should. > > Is this a bug in Cucumber or am I missing something? > I'm not sure if I fully understand the situation... Let me try to summarize. The exception being raised seems to be coming from the first line in the step, is that correct? (So, having the "msg.should_not == nil" seems redundant.) To sum it up, when you have a pp call after you have watir locate the element then no exception appears to be thrown. However, without the pp call the exception is thrown, or at least reported by Cucumber. Is that right? From my current understanding there could be two things going on. A) Watir is not being consistent in when it throws an exception. OR B) Cucumber is not being consistent on how it handles and reports exceptions. Try catching the Watir exception yourself to see if the problem is with Watir not raising an exception. So something like... Then /^(.+) should be displayed$/ do |error| begin msg = @browser.ul(:class, 'validation-summary-errors').li(:text, error) rescue Exception =>e puts "This was raised: #{e.inspect}" raise e end #pp msg.text end If it appears that Cucumber is not handling the exceptions consistently then open up a ticket for it. [1] HTH, Ben 1. https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/new From lists at ruby-forum.com Thu Apr 9 12:46:40 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 9 Apr 2009 18:46:40 +0200 Subject: [rspec-users] [cucumber] Tests pass, application does not. Message-ID: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> This has just cropped up this morning and I have no clue as to what is causing it. Here is the error when running the application through the web browser in development: undefined method `method_exists?' for # /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:255:in `method_missing' /home/byrnejb/Software/Development/Projects/proforma.git/lib/hll_attr_set_by_names.rb:16:in `attr_set_by_names' ... Here is the code: 14 an.each do |f| 15 puts "checking method: #{f}" 16 self.send("#{f}=", "#{param_hash[f]}") if self.method_exists?("#{f}=") 17 end But, when I run the cucumber test for the same controller and view this is what I see: ... And they enter the entity legal name "MyUser LEGAL NAME" # features/app/models/entities/step_definitions/entity_steps.rb:66 entity_common_name entity_legal_name entity_legal_form checking method: entity_common_name checking method: entity_legal_name checking method: entity_legal_form And I press "Create" # features/support/step_definitions/local_webrat_steps.rb:14 Then they should see a save error message # features/app/step_definitions/crud_response_steps.rb:24 12 scenarios 78 passed steps I am lost... Help? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Apr 9 12:47:09 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 9 Apr 2009 12:47:09 -0400 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> Message-ID: <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> On Thu, Apr 9, 2009 at 9:29 AM, Williams, Wesley wrote: > Matt, > > Hmm, I think this is one way to do it. ?I will need to get my customer > to think differently about defining the requirements. ?They really like > the tables. Some times table just work best. I love writing scenarios with natural language, but I've hit many cases where the inputs and outputs are best displayed as a table, and it's easier for the customer to gr0k, then to read a short novel. This kind of re-use that you seem to need sounds like a potential feature for Cucumber. A way to utilize an external file to house a table of data. e.g.: Background Given I have the following set of flights: | foo | bar | baz | ... Would become Background Given I have the following set of flights: FromFile: flights/scheduleA And then you'd have the flights/scheduleA house: | foo | bar | baz | ... Cucumber could dump in the table data it found from the file, and print it out when running the scenarios, and it allows some sets of sample data be re-used easily, in an understandable manner. WDYT? > > Thanks, > Wes > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org > [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Matt Wynne > Sent: Thursday, April 09, 2009 9:58 AM > To: rspec-users > Subject: Re: [rspec-users] Reuse of Cucumber Features > > On 8 Apr 2009, at 10:31, Williams, Wesley wrote: > >> All, >> >> I know this is an older post but I have a similar but different set >> of scenarios I need to handle. ?I have a set of flight related >> scheduling features, such as delay, reschedule, and cancel, each >> with multiple scenarios that have an effect on later flights in the >> schedule (there are a lot of scenarios actually). ?What (I think J) >> I need is a set of flights that I can reuse, in a Background: given >> section, by all of these features and scenarios, that is defined in >> a way that is reusable and visible in each of the feature definitions. >> >> Is this possible? ?Is there a better way to do this? >> >> Example: >> >> Feature: Delay flights with down line adjustments >> ? As a flight scheduler >> ? I want to delay a flight and have the down line flights adjusted >> for different periods >> ? So I can more quickly update a schedule when events happen >> >> ? ? Background: >> ? ? ? Given I have the following flights scheduled: >> ? ? ? ? |aircraft | flight number | dept date | dept time | >> ? ? ? ? | XX1 ? ? ?| ?XX0001 ? ? ? ? ? ? ?| 03Mar2009 | ?1000 ? ? ? ?| >> ? ? ? ? | XX1 ? ? ?| ?XX0002 ? ? ? ? ? ? ?| 03Mar2009 | ?1400 ? ? ? ?| >> ? ? ? ? | XX1 ? ? ?| ?XX0003 ? ? ? ? ? ? ?| 03Mar2009 | ?2100 ? ? ? ?| >> ? ? ? ? | XX1 ? ? ?| ?XX0004 ? ? ? ? ? ? ?| 04Mar2009 | 1000 ? ? ? ? | >> >> ? ?Scenario: ?delay flights with down line adjustments for same dept >> date as delayed flight >> ? ? ? When I delay flight XX001 by 5 mins >> ? ? ? Then XX001 departs at 1005 >> ? ? ? Then XX002 departs at 1405 >> ? ? ? Then XX003 departs at 2105 >> ? ? ? Then XX004 departs at 1000 >> >> OR >> >> ? ?Scenario: ?delay flights with down line adjustments for same dept >> date as delayed flight >> ? ? ? When I delay flight XX001 by 5 mins >> ? ? ? Then the scheduled flight should be >> ? ? ? ? |aircraft | flight number | dept date | dept time | >> ? ? ? ? | XX1 ? ? ?| ?XX0001 ? ? ? ? ? ? ?| 03Mar2009 | ?1005 ? ? ? ?| >> ? ? ? ? | XX1 ? ? ?| ?XX0002 ? ? ? ? ? ? ?| 03Mar2009 | ?1405 ? ? ? ?| >> ? ? ? ? | XX1 ? ? ?| ?XX0003 ? ? ? ? ? ? ?| 03Mar2009 | ?2105 ? ? ? ?| >> ? ? ? ? | XX1 ? ? ?| ?XX0004 ? ? ? ? ? ? ?| 04Mar2009 | 1000 ? ? ? ? | >> >> There are many more scenarios. >> >> Is there a nice way to removed the duplication that is here, >> especially since I will need a similar set of flights for other >> scheduling change scenarios? ?Does anyone see a nice way to simplify >> the scenarios? >> >> Great tool by the way. >> >> Thanks, >> Wes > > Have you seen this? > > http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-i > n-user-stories/ > > Another way to remove duplication (and noise) from Cucumber steps is > the hide the details in the Ruby code that implements the step, and > write a much more general step in the feature file like this: > > ? ? ? ?Given there are 3 flights departing on the same day > ? ? ? ?And the flights all leave at different times > ? ? ? ?And there is another flight leaving on the following day > ? ? ? ?When the earliest flight is delayed by 5 mins > ? ? ? ?Then the flights on the first day should all be delayed by 5 > minutes > ? ? ? ?And the flight on the second day should be unaffected > > These kind of steps can be clearer to read, but the trade-off is that > your underlying step code gets more complex as you start writing logic > to deliver these specific scenarios. Still, if you're clever about it, > these 'declarative' steps can still be pretty re-usable. > > HTH, > Matt > >> >> Subject: [rspec-users] Reuse of Cucumber Features >> >> +lots :) >> >> Generally when we have problems with features its because we are >> trying to >> do to much at once. So in your case date entry is being complicated by >> different contexts, birth and incident. One of the tennents of BDD >> is to >> write the simplest thing you can to make you feature pass. I think >> another >> one should be "first of all write the simplest scenarios". So taking >> one of >> your examples >> >> Scenario: Enter Valid Incident >> ? When I fill incident correctly >> ? I should recieve a confirmation >> >> Then your incident step can be something like >> >> When /^I fill incident correctly$/ do >> ? fill_in("incident[name]", :with => ... >> ? ... >> end >> >> If you wanted to specify validation in features you could do a step >> like >> >> When /^I fill incident correctly except$/ do |field| >> ? When "I fill in incident correctly" >> ? fill_in("incident[#{field}]", :with => '' >> end >> >> now you can create new features like >> >> ?Scenario: Enter Valid Incident with no date >> ? When I fill incident correctly except date >> ? I should recieve an error >> >> With a bit more trickery you could have >> >> ? When I fill incident correctly except date which is xxx >> >> Taking this approach you can build incrementally quite complex >> validation >> features whilst stll keeping each scenario simple and focused on one >> thing. >> Whether you should do this with features or put this detail >> somewhere else >> is another question entirely. >> >> On another point with dates have you considered international >> issues. All >> the dates you've given in your example are valid (technically) there >> just >> not in the format you prefer. ?Also consider that the invalidity of >> dates >> might be context dependant e.g. an incident date in the future, an >> appointment in the past. >> >> HTH >> >> Andrew >> >> >> 2008/12/14 Pat Maddox >> >> > Hi Steve, >> > >> > I likely would only write two scenarios, one for a valid date and >> one >> > for an invalid one. ?Then I would write object-level specs to >> determine >> > what a valid date is. ?Extract this to a validator that you can >> reuse >> > throughout your model. >> > >> > If it's important that you write features for each potential invalid >> > date format (because you want to communicate them with the customer) >> > then I would write a feature file similar to what you show...but it >> > would be focused only on the date, I wouldn't mention patients or >> > incidents at all. ?Date entry seems to be an important concept in >> your >> > application, so I would write one feature that specifies how I >> expect >> > date entry to work, and then I can just write valid/invalid dates >> for >> > patient and incident features. ?Same idea as the first paragraph, >> but >> > using features instead of specs. >> > >> > Pat >> > >> > >> > "Steve Molitor" writes: >> > >> > > Thanks -- that gets me closer. ?Here's an example. ?Let's say I >> have two >> > features, 'Create new patient' and 'Create new incident'. ?To >> > > create a new patient you have to enter a valid birth date. ?To >> create a >> > new patient you must enter a valid birth date. ?To create a new >> > > incident you must enter a valid incident date. ?The rules for >> date entry >> > are the same: >> > > >> > > Feature: ?Date entry >> > > >> > > ? Scenario: Invalid month >> > > ? When I fill in the date value with "13/01/2000" >> > > ? I should see "Invalid date..." >> > > >> > > ? Scenario: Invalid year (not 4 digits) >> > > ? When I fill in the date value with "13/01/00" >> > > ? I should see "Invalid date..." >> > > >> > > ? Scenario: Separate with slashes (ok) >> > > ? When I fill in the date value with "01/13/2000" >> > > ? I should see "valid date..." >> > > >> > > ? Scenario: Separate with dashes (ok) >> > > ? When I fill in the date value with "01-13-2000" >> > > ? I should see "valid date..." >> > > >> > > ? .... etc.... >> > > >> > > Given the above, how should I write the 'create new patient' and >> 'create >> > new incident' features? ?I don't want to copy and paste all the >> > > date related scenarios, but I do want to specify (and test) that >> the >> > patient birth date and incident date fields conform to the general >> date >> > > rules. ?Here's how the 'create new patient' and 'create new >> incident' >> > features would look with some copy and pasting: >> > > >> > > Feature: Create new Patient >> > > >> > > Scenario: ?Enter invalid birth date >> > > ? Given I fill in "birth date" with "13/01/2000" >> > > ? And I fill in "patient name" with "Sam Smith" >> > > ? When I press "Save" >> > > ? I should see "Invalid birth date '13/01/2000'" >> > > >> > > Scenario: ?Enter valid birth date, valid name >> > > ? Given I fill in "birth date" with "01/13/2000" >> > > ? And I fill in "patient name" with "Sam Smith" >> > > ? When I press "Save" >> > > ? I should see "Patient Created Successfully" >> > > >> > > Scenario: ?Enter valid birth date with dashses..... >> > > ------- >> > > >> > > Feature: Create new Incident >> > > >> > > Scenario: ?Enter invalid incident date >> > > ? Given I fill in "incident" with "13/01/2000" >> > > ? And I fill in "supervisor" with "Sam Smith" >> > > ? When I press "Save" >> > > ? I should see "Invalid incident date '13/01/2000'" >> > > >> > > Scenario: ?Enter valid incident date, valid supervisor >> > > ? Given I fill in "incident date" with "01/13/2000" >> > > ? And I fill in "supervisor" with "Sam Smith" >> > > ? When I press "Save" >> > > ? I should see "Incident Created Successfully" >> > > >> > > Scenario: ?Enter valid incident date with dashes.... >> > > ----- >> > > >> > > Am I making sense? ?I want to specify the date in the features, >> as there >> > may be extra requirements like birth dates can not be in the future >> > > in addition to the generic date requirements. ?And I want to >> validate >> > that the form checks for valid dates, displays the appropriate error >> > > message when invalid, and uses the common rules for parsing. >> But I don't >> > want to copy and paste those scenarios in every feature. ?I think >> > > reusing steps as you mention is probably the solution but I'm >> stuck on >> > how to word it and put it together in my case. >> > > >> > > Steve >> > > >> > > On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne > mattwynne.net> wrote: >> > > >> > > ? ? On 13 Dec 2008, at 20:58, Steve Molitor wrote: >> > > >> > > ? ? ? ? What's the best way to handle a requirement that shows >> up as a >> > sub-requirement requirement in other features? ?For example let's >> say >> > > ? ? ? ? users can enter dates in various forms throughout my >> application. >> > ? There is one set of global rules specifying the formats in which >> > > ? ? ? ? dates may be entered, and how they are interpreted. ?I >> put that >> > in one feature. ?In various other features, like 'Create new >> > > ? ? ? ? patient', one can enter dates, like the patient's birth >> date. ?I >> > want to do something like 'and the date entry shall follow the >> > > ? ? ? ? normal rules' but I'm not sure how to do that in an >> example >> > driven way, without copying and pasting from other features. >> > > >> > > ? ? ? ? Does my question make sense? ?Any suggestions? >> > > >> > > ? ? Do you know that you can call steps within steps? >> > > > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ >> > > >> > > ? ? Is that what you're looking for? >> > > >> > > ? ? Matt Wynne >> > > ? ? http://blog.mattwynne.net >> > > ? ? http://www.songkick.com >> > > >> > > ? ? _______________________________________________ >> > > ? ? rspec-users mailing list >> > > ? ? rspec-users at rubyforge.org >> > > ? ? http://rubyforge.org/mailman/listinfo/rspec-users >> > > >> > > _______________________________________________ >> > > rspec-users mailing list >> > > rspec-users at rubyforge.org >> > > http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From walketim at gmail.com Thu Apr 9 12:53:30 2009 From: walketim at gmail.com (Tim Walker) Date: Thu, 9 Apr 2009 10:53:30 -0600 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <4FBF7791-B8EE-417F-AD87-E249FC92EBE4@mattwynne.net> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> <4FBF7791-B8EE-417F-AD87-E249FC92EBE4@mattwynne.net> Message-ID: <1ebf5a4d0904090953h6092ed2ey918ff3ddfab26877@mail.gmail.com> Three Cucumberists! You're just an onion short of a salad! Best regards, and congratulations Ben! Tim On Apr 8, 2009 3:14 AM, "Matt Wynne" wrote: On 7 Apr 2009, at 22:19, aslak hellesoy wrote: > Ben Mabey has accepted my invitation to be on the... Nice one Ben :) Matt Wynne http://blog.mattwynne.net http://www.songkick.com _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org... -------------- next part -------------- An HTML attachment was scrubbed... URL: From pat.maddox at gmail.com Thu Apr 9 12:55:46 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 9 Apr 2009 09:55:46 -0700 Subject: [rspec-users] [cucumber] Tests pass, application does not. In-Reply-To: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> References: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> Message-ID: <2c7e61990904090955ia6a15d4x8c198b0d80020f12@mail.gmail.com> On Thu, Apr 9, 2009 at 9:46 AM, James Byrne wrote: > This has just cropped up this morning and I have no clue as to what is > causing it. > > Here is the error when running the application through the web browser > in development: > > ?undefined method `method_exists?' for # > > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:255:in > `method_missing' > /home/byrnejb/Software/Development/Projects/proforma.git/lib/hll_attr_set_by_names.rb:16:in > `attr_set_by_names' > ... > > Here is the code: > > 14 ?an.each do |f| > 15 ? ? puts "checking method: #{f}" > 16 ? ?self.send("#{f}=", "#{param_hash[f]}") if > self.method_exists?("#{f}=") > 17 ?end > > But, when I run the cucumber test for the same controller and view this > is what I see: > ... > ? ?And they enter the entity legal name "MyUser ?LEGAL ?NAME" > ? ? ? # > features/app/models/entities/step_definitions/entity_steps.rb:66 > entity_common_name > entity_legal_name > entity_legal_form > checking method: entity_common_name > checking method: entity_legal_name > checking method: entity_legal_form > ? ?And I press "Create" > ? ? ? # features/support/step_definitions/local_webrat_steps.rb:14 > ? ?Then they should see a save error message > ? ? ? # features/app/step_definitions/crud_response_steps.rb:24 > > 12 scenarios > 78 passed steps > > I am lost... ?Help? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I just did a github search and the only place I found method_exists? referenced was in mocha. So my guess is that in test mode, mocha is being loaded and so it's passing for you. Try using respond_to? instead of method_exists? I've never even heard of method_exists? until just now. Pat From biot023 at gmail.com Thu Apr 9 12:53:41 2009 From: biot023 at gmail.com (doug livesey) Date: Thu, 9 Apr 2009 17:53:41 +0100 Subject: [rspec-users] updated to latest gems, rspec not catching flash.now In-Reply-To: <85d99afe0904081421g482b6e45kaf4fd087fa7490fd@mail.gmail.com> References: <50873a360904081108g67f4be76h521b0ff0461e392a@mail.gmail.com> <85d99afe0904081421g482b6e45kaf4fd087fa7490fd@mail.gmail.com> Message-ID: <50873a360904090953u5866c718j7e9388bcb6392a2@mail.gmail.com> Didn't spot this when you replied earlier -- cheers for that! Doug. 2009/4/8 Zach Dennis > On Wed, Apr 8, 2009 at 2:08 PM, doug livesey wrote: > > Hi, after an update to all the latest gems, I have a controller spec > failing > > that wasn't previously: > > flash[:alert].should eql( "Blah blah." ) > > > > The flash is being set by "flash.now[:alert] = '...'" in this instance. > > Can anyone suggest how I can make this work again? > > I just submitted a patch to ticket #11834 to resolve this issue in > rspec-rails: > > > https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/98-11834-fake-controller-flash-object#ticket-98-9 > > In the mean time you can manually patch your local rspec-rails (if you > unpack rspec and rspec-rails into vendor/gems or vendor/plugins this > should work fine). Or you can do Xavier suggests on that ticket and > add a few lines to your spec_helper, until rspec-rails is updated. > > HTH, > > > > Cheers, > > Doug. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Apr 9 13:04:25 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 9 Apr 2009 19:04:25 +0200 Subject: [rspec-users] [cucumber] Tests pass, application does not. In-Reply-To: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> References: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> Message-ID: <46602cfc7171034ba7676f961711c78c@ruby-forum.com> James Byrne wrote: > This has just cropped up this morning and I have no clue as to what is > causing it. > > Here is the error when running the application through the web browser > in development: > > undefined method `method_exists?' for # I put in a print self.methods.sort.to_yaml and, sure enough, when I do this through the browser this is what I see: ... - mark_for_destruction - marked_for_destruction? - metaclass - method - method_missing - methods - new_record? - nil? - object_id ... I put the same check in the controller @entity = Entity.new print @entity.methods.sort.to_yaml and it is missing there as well. No method_exists?, So, where is it going? However, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 9 13:44:21 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 9 Apr 2009 19:44:21 +0200 Subject: [rspec-users] [cucumber] Tests pass, application does not. In-Reply-To: <2c7e61990904090955ia6a15d4x8c198b0d80020f12@mail.gmail.com> References: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> <2c7e61990904090955ia6a15d4x8c198b0d80020f12@mail.gmail.com> Message-ID: Pat Maddox wrote: > > > I just did a github search and the only place I found method_exists? > referenced was in mocha. So my guess is that in test mode, mocha is > being loaded and so it's passing for you. Try using respond_to? > instead of method_exists? I've never even heard of method_exists? > until just now. > > Pat Ahh, thanks. That fixed things. Most disconcerting to have ones tests pass and the application die. -- Posted via http://www.ruby-forum.com/. From joe at josephwilk.net Thu Apr 9 13:48:32 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Thu, 09 Apr 2009 18:48:32 +0100 Subject: [rspec-users] [cucumber] Tests pass, application does not. In-Reply-To: <46602cfc7171034ba7676f961711c78c@ruby-forum.com> References: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> <46602cfc7171034ba7676f961711c78c@ruby-forum.com> Message-ID: <49DE34F0.9000904@josephwilk.net> James Byrne wrote: > James Byrne wrote: > >> This has just cropped up this morning and I have no clue as to what is >> causing it. >> >> Here is the error when running the application through the web browser >> in development: >> >> undefined method `method_exists?' for # >> > > I put in a print self.methods.sort.to_yaml and, sure enough, when I do > this through the browser this is what I see: > > ... > - mark_for_destruction > - marked_for_destruction? > - metaclass > - method > - method_missing > - methods > - new_record? > - nil? > - object_id > ... > > I put the same check in the controller > @entity = Entity.new > print @entity.methods.sort.to_yaml > > and it is missing there as well. > > > > No method_exists?, So, where is it going? > > Could be completely off track, Pats mention of Mocha reminded me that Rails 2.3 tests have lots of 'require mocha' dotted around the place: David raised a ticket on this: https://rails.lighthouseapp.com/projects/8994/tickets/2240-let-users-decide-what-mock-framework-to-use Could this be causing some conflict? -- Joseph Wilk http://blog.josephwilk.net > However, > From dchelimsky at gmail.com Thu Apr 9 13:51:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 9 Apr 2009 14:51:29 -0300 Subject: [rspec-users] [cucumber] Tests pass, application does not. In-Reply-To: <2c7e61990904090955ia6a15d4x8c198b0d80020f12@mail.gmail.com> References: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> <2c7e61990904090955ia6a15d4x8c198b0d80020f12@mail.gmail.com> Message-ID: <57c63afe0904091051x5a3e0ce2w673e9f037c86673d@mail.gmail.com> On Thu, Apr 9, 2009 at 1:55 PM, Pat Maddox wrote: > On Thu, Apr 9, 2009 at 9:46 AM, James Byrne wrote: >> This has just cropped up this morning and I have no clue as to what is >> causing it. >> >> Here is the error when running the application through the web browser >> in development: >> >> ?undefined method `method_exists?' for # >> >> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:255:in >> `method_missing' >> /home/byrnejb/Software/Development/Projects/proforma.git/lib/hll_attr_set_by_names.rb:16:in >> `attr_set_by_names' >> ... >> >> Here is the code: >> >> 14 ?an.each do |f| >> 15 ? ? puts "checking method: #{f}" >> 16 ? ?self.send("#{f}=", "#{param_hash[f]}") if >> self.method_exists?("#{f}=") >> 17 ?end >> >> But, when I run the cucumber test for the same controller and view this >> is what I see: >> ... >> ? ?And they enter the entity legal name "MyUser ?LEGAL ?NAME" >> ? ? ? # >> features/app/models/entities/step_definitions/entity_steps.rb:66 >> entity_common_name >> entity_legal_name >> entity_legal_form >> checking method: entity_common_name >> checking method: entity_legal_name >> checking method: entity_legal_form >> ? ?And I press "Create" >> ? ? ? # features/support/step_definitions/local_webrat_steps.rb:14 >> ? ?Then they should see a save error message >> ? ? ? # features/app/step_definitions/crud_response_steps.rb:24 >> >> 12 scenarios >> 78 passed steps >> >> I am lost... ?Help? >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > I just did a github search and the only place I found method_exists? > referenced was in mocha. ?So my guess is that in test mode, mocha is > being loaded and so it's passing for you. ?Try using respond_to? > instead of method_exists? ?I've never even heard of method_exists? > until just now. Yes - Rails now requires 'mocha' in ActiveSupport::TestCase if you have it on your system. I've filed a ticket about this here: https://rails.lighthouseapp.com/projects/8994/tickets/2240 Cheers, David > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 9 14:12:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 9 Apr 2009 15:12:04 -0300 Subject: [rspec-users] [cucumber] Tests pass, application does not. In-Reply-To: <49DE34F0.9000904@josephwilk.net> References: <617cc821fe98bb7776e4cdcc5ba88ad2@ruby-forum.com> <46602cfc7171034ba7676f961711c78c@ruby-forum.com> <49DE34F0.9000904@josephwilk.net> Message-ID: <57c63afe0904091112m2004a57ej27ab1688060c9361@mail.gmail.com> On Thu, Apr 9, 2009 at 2:48 PM, Joseph Wilk wrote: > > James Byrne wrote: >> >> James Byrne wrote: >> >>> >>> This has just cropped up this morning and I have no clue as to what is >>> causing it. >>> >>> Here is the error when running the application through the web browser >>> in development: >>> >>> ?undefined method `method_exists?' for # >>> >> >> I put in a print self.methods.sort.to_yaml and, sure enough, when I do >> this through the browser this is what I see: >> >> ... >> - mark_for_destruction >> - marked_for_destruction? >> - metaclass >> - method >> - method_missing >> - methods >> - new_record? >> - nil? >> - object_id >> ... >> >> I put the same check in the controller >> ?@entity = Entity.new >> ?print @entity.methods.sort.to_yaml >> >> and it is missing there as well. >> >> >> >> No method_exists?, So, where is it going? >> >> > > Could be completely off track, Pats mention of Mocha reminded me that Rails > 2.3 tests have lots of 'require mocha' dotted around the place: It's not just in Rails' own tests. It's actually in ActiveSupport::TestCase, which means that if you have mocha installed, it's getting loaded whether you use it or not. http://github.com/rails/rails/blob/660fc93942697b74a8093d4d5338d1ced25cbe7f/activesupport/lib/active_support/test_case.rb Generally speaking, this should really not be a problem. But there are those odd cases where a conflict may arise because both rspec-mocks and mocha add methods to object to support partial mocking/stubbing on any object. It happens that they use different method names. But, for example, if we wanted to alias :should_receive with :expects in RSpec to give it more of mocha's flavor, we'd be definitely be risking some unpleasant behaviour. Cheers, David > > David raised a ticket on this: > > https://rails.lighthouseapp.com/projects/8994/tickets/2240-let-users-decide-what-mock-framework-to-use > > Could this be causing some conflict? > > -- > Joseph Wilk > http://blog.josephwilk.net > >> However, >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jgoodsen at radsoft.com Thu Apr 9 14:19:59 2009 From: jgoodsen at radsoft.com (John Goodsen) Date: Thu, 9 Apr 2009 14:19:59 -0400 Subject: [rspec-users] [cucumber, jruby] Same steps are being added multiple times? Message-ID: Hi all, I'm not quite sure I understand how env.rb is loaded in the cucumber/jruby world. I have a directory structure like this: stories/fulfillment_status_tracking stories/fulfillment_status_tracking/main_success.feature stories/fulfillment_status_tracking/test.feature stories/regular_billme_single_title_subscription stories/regular_billme_single_title_subscription/form_validation.feature stories/regular_billme_single_title_subscription/main_success.feature stories/support stories/support/env.rb My env.rb file simply loads my Java step class and adds it, here's what it looks like: ----------- env.rb ----------- require 'cucumber/java' import 'com.timeinc.ecommerce.storytests.cucumber.NavigationSteps' register_steps(NavigationSteps) SeleniumController.markStepsLoaded() ----------- but when I run my tests with: jruby -S cucumber -r stories/support/env.rb I am getting Ambiguous match of my steps - but I only have a single class of steps, NavigationSteps. any ideas what's going on? -- John Goodsen RADSoft / Better Software Faster jgoodsen at radsoft.com Lean/Agile/XP/Scrum Coaching and Training http://www.radsoft.com Ruby on Rails and Java Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Apr 9 14:52:31 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 9 Apr 2009 20:52:31 +0200 Subject: [rspec-users] [cucumber, jruby] Same steps are being added multiple times? In-Reply-To: References: Message-ID: <34a9ed7e3d347b88a6f9afa00908acd6@ruby-forum.com> John Goodsen wrote: > > but when I run my tests with: jruby -S cucumber -r > stories/support/env.rb > > I am getting Ambiguous match of my steps - but I only have a single > class of steps, NavigationSteps. > > any ideas what's going on? You have two (or more) step matchers that match a single clause in a scenario. The error message usually tells you exactly which steps in which files collide, for the MRI anyway -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 9 14:55:11 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 9 Apr 2009 20:55:11 +0200 Subject: [rspec-users] Testing page layouts Message-ID: <052e82cd0f59100cac4eec1054f6cf55@ruby-forum.com> This is a question of technique. To what degree do projects generally test page/report layouts? Do you just check to see if the expected data is present or do you also check that the layout is presentable? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Thu Apr 9 14:56:05 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 9 Apr 2009 19:56:05 +0100 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> Message-ID: <029F8324-DDCF-4D62-886A-6332F72D384B@mattwynne.net> On 9 Apr 2009, at 17:47, Zach Dennis wrote: > On Thu, Apr 9, 2009 at 9:29 AM, Williams, Wesley > wrote: >> Matt, >> >> Hmm, I think this is one way to do it. I will need to get my >> customer >> to think differently about defining the requirements. They really >> like >> the tables. > > Some times table just work best. I love writing scenarios with natural > language, but I've hit many cases where the inputs and outputs are > best displayed as a table, and it's easier for the customer to gr0k, > then to read a short novel. > > This kind of re-use that you seem to need sounds like a potential > feature for Cucumber. A way to utilize an external file to house a > table of data. e.g.: > > Background > Given I have the following set of flights: > | foo | bar | baz | > ... > > Would become > > Background > Given I have the following set of flights: > FromFile: flights/scheduleA > > And then you'd have the flights/scheduleA house: > > | foo | bar | baz | > ... > > Cucumber could dump in the table data it found from the file, and > print it out when running the scenarios, and it allows some sets of > sample data be re-used easily, in an understandable manner. > > WDYT? This is a good idea - people do this with Fit (as opposed to Fitnesse) and go straight to a spreadsheet for the examples. I don't see why it needs a new Cucumber feature though - you could easily (and more flexibly) write a custom step yourself to load in the data from an external file, right? Matt Wynne http://blog.mattwynne.net http://beta.songkick.com From zach.dennis at gmail.com Thu Apr 9 15:30:23 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 9 Apr 2009 15:30:23 -0400 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <029F8324-DDCF-4D62-886A-6332F72D384B@mattwynne.net> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> <029F8324-DDCF-4D62-886A-6332F72D384B@mattwynne.net> Message-ID: <85d99afe0904091230m2ead6a62k870175768b1f2a00@mail.gmail.com> On Thu, Apr 9, 2009 at 2:56 PM, Matt Wynne wrote: > > On 9 Apr 2009, at 17:47, Zach Dennis wrote: > >> On Thu, Apr 9, 2009 at 9:29 AM, Williams, Wesley >> wrote: >>> >>> Matt, >>> >>> Hmm, I think this is one way to do it. ?I will need to get my customer >>> to think differently about defining the requirements. ?They really like >>> the tables. >> >> Some times table just work best. I love writing scenarios with natural >> language, but I've hit many cases where the inputs and outputs are >> best displayed as a table, and it's easier for the customer to gr0k, >> then to read a short novel. >> >> This kind of re-use that you seem to need sounds like a potential >> feature for Cucumber. A way to utilize an external file to house a >> table of data. e.g.: >> >> Background >> ?Given I have the following set of flights: >> ? ? | foo | bar | baz | >> ? ? ... >> >> Would become >> >> Background >> ? Given I have the following set of flights: >> ? FromFile: flights/scheduleA >> >> And then you'd have the flights/scheduleA house: >> >> ? ? | foo | bar | baz | >> ? ? ... >> >> Cucumber could dump in the table data it found from the file, and >> print it out when running the scenarios, and it allows some sets of >> sample data be re-used easily, in an understandable manner. >> >> WDYT? > > > This is a good idea - people do this with Fit (as opposed to Fitnesse) and > go straight to a spreadsheet for the examples. > > I don't see why it needs a new Cucumber feature though - you could easily > (and more flexibly) write a custom step yourself to load in the data from an > external file, right? That's true, but why does everyone need to write their file loading step/code? It seems like something where flexibility really doesn't benefit anyone, unless you are doing something unique and special, which I think is different than simply being able to store example tables in an external file. > > Matt Wynne > http://blog.mattwynne.net > http://beta.songkick.com > > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Thu Apr 9 15:34:04 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 9 Apr 2009 15:34:04 -0400 Subject: [rspec-users] Testing page layouts In-Reply-To: <052e82cd0f59100cac4eec1054f6cf55@ruby-forum.com> References: <052e82cd0f59100cac4eec1054f6cf55@ruby-forum.com> Message-ID: <85d99afe0904091234w75110abbk9102ce224d0a9eb7@mail.gmail.com> On Thu, Apr 9, 2009 at 2:55 PM, James Byrne wrote: > This is a question of technique. ?To what degree do projects generally > test page/report layouts? ?Do you just check to see if the expected data > is present or do you also check that the layout is presentable? We use humans to check layout and presentation since it's visual and not something that can be determined correct by a program in a reasonably maintainable way (at least IMO). We use scenarios and specs to ensure that the application is providing the right display of information from the system, and the proper form/inputs that people should be able to access through the app. We find the combination gives us a good flexibility to change the UI while being confident that the app is still doing everything it should be, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From scottnj at gmail.com Thu Apr 9 13:33:44 2009 From: scottnj at gmail.com (scott) Date: Thu, 9 Apr 2009 10:33:44 -0700 (PDT) Subject: [rspec-users] [cucumber][rails] trouble with authlogic tests Message-ID: <9598815a-1cd4-4ec5-be63-8d8fe7f31df6@r36g2000vbr.googlegroups.com> i am trying to learn testing for rails apps. i followed the two authlogic tutorials (basic authlogic setup and password reset) and now i am trying to add some integration tests with cucumber (i know you are supposed to do the tests 1st, but i am just trying to figure out how things work). i found this app http://github.com/hectoregm/rails-templates/tree/master with a bunch of cucumber/webrat tests setup for authlogic so i started applying them to my app. the app works fine when i do everything in the web browser, but i can not figure out why it doesn't work with the tests. when it creates a user account it should go to the show account page and flash "account registered", but instead it is creating a user in the database (good), going to my home page(bad), and the flash is "logout successful"(bad). anyone have any guidance on what might be going wrong or how to troubleshoot this? # from my feature file Scenario: Allow an anonymous user to create account Given "hector" is an anonymous user When I go to the registration form And I fill in "login" with "hector" And I fill in "email" with "hec... at example.com" And I fill in "password" with "secret" And I fill in "password confirmation" with "secret" And I press "Register" Then I should have a successful registration # the relevent steps Given /"(.*)" is an anonymous user/ do |name| # registration_steps.rb visit '/logout' visit '/' end When /^I go to (.+)$/ do |page_name| # webrat_steps.rb visit path_to(page_name) end when /the registration form/ # paths.rb new_account_path When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| # webrat_steps.rb fill_in(field, :with => value) end When /^I press "([^\"]*)"$/ do |button| # webrat_steps.rb click_button(button) end Then /^I should have a successful registration$/ do # registration_steps.rb When 'I should see "Account registered!"' end Then /^I should see "([^\"]*)"$/ do |text| # webrat_steps.rb response.should contain(text) end # output from running "cucumber features" Feature: Registration As a anonymous user I want be able to register So that can be productive and be cool Scenario: Allow an anonymous user to create account # features/ registration.feature:13 Given "hector" is an anonymous user # features/ step_definitions/registration_steps.rb:1 When I go to the registration form # features/ step_definitions/webrat_steps.rb:10 And I fill in "login" with "hector" # features/ step_definitions/webrat_steps.rb:22 And I fill in "email" with "hec... at example.com" # features/ step_definitions/webrat_steps.rb:22 And I fill in "password" with "secret" # features/ step_definitions/webrat_steps.rb:22 And I fill in "password confirmation" with "secret" # features/ step_definitions/webrat_steps.rb:22 And I press "Register" # features/ step_definitions/webrat_steps.rb:14 Then I should have a successful registration # features/ step_definitions/registration_steps.rb:54 expected the following element's content to include "Account registered!": home: index Authlogic Example App 1 user currently logged in Register | Log In | Forgot password Logout successful! Home Page (Spec::Expectations::ExpectationNotMetError) ./features/step_definitions/webrat_steps.rb:94:in `/^I should see "([^\"]*)"$/' features/registration.feature:21:in `Then I should have a successful registration' 1 scenario 1 failed step 7 passed steps From zach.dennis at gmail.com Thu Apr 9 15:36:49 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 9 Apr 2009 15:36:49 -0400 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <85d99afe0904091230m2ead6a62k870175768b1f2a00@mail.gmail.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> <029F8324-DDCF-4D62-886A-6332F72D384B@mattwynne.net> <85d99afe0904091230m2ead6a62k870175768b1f2a00@mail.gmail.com> Message-ID: <85d99afe0904091236v468506fat77a0abe2b0e4a8c8@mail.gmail.com> On Thu, Apr 9, 2009 at 3:30 PM, Zach Dennis wrote: > On Thu, Apr 9, 2009 at 2:56 PM, Matt Wynne wrote: >> >> On 9 Apr 2009, at 17:47, Zach Dennis wrote: >> >>> On Thu, Apr 9, 2009 at 9:29 AM, Williams, Wesley >>> wrote: >>>> >>>> Matt, >>>> >>>> Hmm, I think this is one way to do it. ?I will need to get my customer >>>> to think differently about defining the requirements. ?They really like >>>> the tables. >>> >>> Some times table just work best. I love writing scenarios with natural >>> language, but I've hit many cases where the inputs and outputs are >>> best displayed as a table, and it's easier for the customer to gr0k, >>> then to read a short novel. >>> >>> This kind of re-use that you seem to need sounds like a potential >>> feature for Cucumber. A way to utilize an external file to house a >>> table of data. e.g.: >>> >>> Background >>> ?Given I have the following set of flights: >>> ? ? | foo | bar | baz | >>> ? ? ... >>> >>> Would become >>> >>> Background >>> ? Given I have the following set of flights: >>> ? FromFile: flights/scheduleA >>> >>> And then you'd have the flights/scheduleA house: >>> >>> ? ? | foo | bar | baz | >>> ? ? ... >>> >>> Cucumber could dump in the table data it found from the file, and >>> print it out when running the scenarios, and it allows some sets of >>> sample data be re-used easily, in an understandable manner. >>> >>> WDYT? >> >> >> This is a good idea - people do this with Fit (as opposed to Fitnesse) and >> go straight to a spreadsheet for the examples. >> >> I don't see why it needs a new Cucumber feature though - you could easily >> (and more flexibly) write a custom step yourself to load in the data from an >> external file, right? > > That's true, but why does everyone need to write their file loading > step/code? It seems like something where flexibility really doesn't > benefit anyone, unless you are doing something unique and special, > which I think is different than simply being able to store example > tables in an external file. One more though, how would you process your example table from a file within a step? Would you do a giant "eval" after reading the contents? Or would you reach into the guts of Cucumber to programmatically build the right thing? Is there another way? I've never done it, so just asking how you would approach this by writing your own step, > > >> >> Matt Wynne >> http://blog.mattwynne.net >> http://beta.songkick.com >> >> > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From jgoodsen at radsoft.com Thu Apr 9 16:09:47 2009 From: jgoodsen at radsoft.com (John Goodsen) Date: Thu, 9 Apr 2009 16:09:47 -0400 Subject: [rspec-users] [cucumber, jruby] Same steps are being added multiple times? In-Reply-To: <34a9ed7e3d347b88a6f9afa00908acd6@ruby-forum.com> References: <34a9ed7e3d347b88a6f9afa00908acd6@ruby-forum.com> Message-ID: I understand how this happens when I *really do* have ambiguous steps, but in my simple case, I don't. I only have a single class which contains steps (attached below). I can run a single scenario just fin, but when I try to run multiple scenarios in one run, I get Ambiguous step errors. It's like the steps are getting added again before each scenario runs - I've got to be missing something really basic here. thanks in advance, John PS: Here's the one, and only one, step class that I'm using (implementation removed for shortness): package com.timeinc.ecommerce.storytests.cucumber; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.thoughtworks.selenium.Selenium; import com.timeinc.ecommerce.KickOffFulfillment; import com.timeinc.ecommerce.domain.FulfillmentTransaction; import com.timeinc.ecommerce.domain.Order; import com.timeinc.ecommerce.domain.PersistenceService; import com.timeinc.ecommerce.storytests.StoryTestProperties; import com.timeinc.ecommerce.storytests.checkers.OrderChecker; import com.timeinc.ecommerce.storytests.selenium.Page; import com.timeinc.ecommerce.storytests.selenium.ReceiptPage; import com.timeinc.ecommerce.storytests.selenium.SeleniumController; import cucumber.Given; import cucumber.Table; import cucumber.Then; import cucumber.When; public class NavigationSteps { @Given("the microsite with") public void givenTheMicrosite(Table table) { } @When("I navigate to the microsite") public void whenTheUserNavigatesToTheMicrosite() { } @When("I submit the form with") } @Then("I see a receipt page") public void theUserIsPresentedWithAReceiptPage() { } @Then("a new order is created with") public void aNewOrderIsCreatedWith(Table table) { } @Then("the following error messages are displayed") public void theFollowingErrorsShouldBeDisplayed(Table table) { Page.ensureErrorsAreDisplayed(selenium, table); } @When("fulfillment runs") public void fulfillmentRuns() throws Exception { } @Given("an order exists in the system") public void anOrderExistsInTheSystem() { } @When("the user navigates to the status tracking page for the order") public void navigatesToStatusTrackingPage() { } @Then("the transaction is displayed as succeeded") public void theTransactionIsDisplayedAsSucceeded() { } } On Thu, Apr 9, 2009 at 2:52 PM, James Byrne wrote: > John Goodsen wrote: > > > > > but when I run my tests with: jruby -S cucumber -r > > stories/support/env.rb > > > > I am getting Ambiguous match of my steps - but I only have a single > > class of steps, NavigationSteps. > > > > any ideas what's going on? > > You have two (or more) step matchers that match a single clause in a > scenario. The error message usually tells you exactly which steps in > which files collide, for the MRI anyway > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- John Goodsen RADSoft / Better Software Faster jgoodsen at radsoft.com Lean/Agile/XP/Scrum Coaching and Training http://www.radsoft.com Ruby on Rails and Java Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Thu Apr 9 17:25:36 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 9 Apr 2009 22:25:36 +0100 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <85d99afe0904091236v468506fat77a0abe2b0e4a8c8@mail.gmail.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> <029F8324-DDCF-4D62-886A-6332F72D384B@mattwynne.net> <85d99afe0904091230m2ead6a62k870175768b1f2a00@mail.gmail.com> <85d99afe0904091236v468506fat77a0abe2b0e4a8c8@mail.gmail.com> Message-ID: <561459BB-D403-4DBA-A8C9-1AD2DCCA3214@mattwynne.net> On 9 Apr 2009, at 20:36, Zach Dennis wrote: > On Thu, Apr 9, 2009 at 3:30 PM, Zach Dennis > wrote: >> On Thu, Apr 9, 2009 at 2:56 PM, Matt Wynne >> wrote: >>> >>> On 9 Apr 2009, at 17:47, Zach Dennis wrote: >>> >>>> On Thu, Apr 9, 2009 at 9:29 AM, Williams, Wesley >>>> wrote: >>>>> >>>>> Matt, >>>>> >>>>> Hmm, I think this is one way to do it. I will need to get my >>>>> customer >>>>> to think differently about defining the requirements. They >>>>> really like >>>>> the tables. >>>> >>>> Some times table just work best. I love writing scenarios with >>>> natural >>>> language, but I've hit many cases where the inputs and outputs are >>>> best displayed as a table, and it's easier for the customer to >>>> gr0k, >>>> then to read a short novel. >>>> >>>> This kind of re-use that you seem to need sounds like a potential >>>> feature for Cucumber. A way to utilize an external file to house a >>>> table of data. e.g.: >>>> >>>> Background >>>> Given I have the following set of flights: >>>> | foo | bar | baz | >>>> ... >>>> >>>> Would become >>>> >>>> Background >>>> Given I have the following set of flights: >>>> FromFile: flights/scheduleA >>>> >>>> And then you'd have the flights/scheduleA house: >>>> >>>> | foo | bar | baz | >>>> ... >>>> >>>> Cucumber could dump in the table data it found from the file, and >>>> print it out when running the scenarios, and it allows some sets of >>>> sample data be re-used easily, in an understandable manner. >>>> >>>> WDYT? >>> >>> >>> This is a good idea - people do this with Fit (as opposed to >>> Fitnesse) and >>> go straight to a spreadsheet for the examples. >>> >>> I don't see why it needs a new Cucumber feature though - you could >>> easily >>> (and more flexibly) write a custom step yourself to load in the >>> data from an >>> external file, right? >> >> That's true, but why does everyone need to write their file loading >> step/code? It seems like something where flexibility really doesn't >> benefit anyone, unless you are doing something unique and special, >> which I think is different than simply being able to store example >> tables in an external file. > > One more though, how would you process your example table from a file > within a step? Would you do a giant "eval" after reading the contents? > Or would you reach into the guts of Cucumber to programmatically build > the right thing? Is there another way? I've never done it, so just > asking how you would approach this by writing your own step, Not sure - I've not needed to do it yet, which is why I would balk at generalising it into the Cucumber framework - seems a bit premature :) I guess I would replace this: Given I have the following set of flights: | foo | bar | baz | With this: Given I have the set of flights specified in "test_data/foo.xls" Then in that step matcher I'd open the spreadsheet, loop through the rows and just do the same as I would with the hashes I'd normally get from Cucumber I suppose. Obviously you couldn't do this for scenario outline tables without extending Cucumber, but that's another issue entirely. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From luke at lukemelia.com Thu Apr 9 17:45:43 2009 From: luke at lukemelia.com (Luke Melia) Date: Thu, 9 Apr 2009 17:45:43 -0400 Subject: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team In-Reply-To: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> References: <8d961d900904071419m39d7afffyca122f322f54505a@mail.gmail.com> Message-ID: On Apr 7, 2009, at 5:19 PM, aslak hellesoy wrote: > The core Cucumber team now consists of Joseph Wilk, Ben Mabey and > myself. Welcome Ben! Great choice, great team. Thanks for all your hard work, gentlemen. -- Luke Melia luke at lukemelia.com http://www.lukemelia.com/ From lists at ruby-forum.com Thu Apr 9 18:37:38 2009 From: lists at ruby-forum.com (Tadatoshi Takahashi) Date: Fri, 10 Apr 2009 00:37:38 +0200 Subject: [rspec-users] [cucumber] Cucumber and restful_authentication Message-ID: Hi, I have just started to use Cucumber. I'm struggling to use Cucumber on the feature that is available only to the logged in user. Could anybody provide the codes that need to be added? The sites I found by Google search don't give clear information about what to do. The ones I found are: http://stackoverflow.com/questions/679928?sort=newest#sort-top http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen http://blog.andrew.premdas.org/articles/2008/10/12/cucumber-webrat-and-debugging-features The step I added is: Given /^I am logged in$/ do User.create!( :first_name => 'quire', :last_name => 'smith', :login => 'quire', :email => 'quire at example.com', :password => 'test', :password_confirmation => 'test' ) post "/login", :login => 'quire', :password => 'test' end By the way, in routes.rb, I'm setting the following as described in restful_authentication: map.login '/login', :controller => 'sessions', :action => 'new' Without login_required and the step above, the Cucumber scenario was successfully run. But after I put login_required and the step above, Cucumber cannot locate a field (its value is filled in text field). Thank you in advance. Tadatoshi -- Posted via http://www.ruby-forum.com/. From tadatoshi.mailinglist at gmail.com Thu Apr 9 18:46:34 2009 From: tadatoshi.mailinglist at gmail.com (Tadatoshi Takahashi) Date: Thu, 9 Apr 2009 18:46:34 -0400 Subject: [rspec-users] [cucumber] Cucumber and restful_authentication Message-ID: <96708edb0904091546g77964216s83168151122686ed@mail.gmail.com> Hi, I have just started to use Cucumber. I'm struggling to use Cucumber on the feature that is available only to the logged in user. Could anybody provide the codes that need to be added? The sites I found by Google search don't give clear information about what to do. The ones I found are: http://stackoverflow.com/questions/679928?sort=newest#sort-top http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen http://blog.andrew.premdas.org/articles/2008/10/12/cucumber-webrat-and-debugging-features The step I added is: Given /^I am logged in$/ do User.create!( :first_name => 'quire', :last_name => 'smith', :login => 'quire', :email => 'quire at example.com', :password => 'test', :password_confirmation => 'test' ) post "/login", :login => 'quire', :password => 'test' end By the way, in routes.rb, I'm setting the following as described in restful_authentication: map.login '/login', :controller => 'sessions', :action => 'new' Without login_required and the step above, the Cucumber scenario was successfully run. But after I put login_required and the step above, Cucumber cannot locate a field (its value is filled in text field). Thank you in advance. Tadatoshi -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Thu Apr 9 21:12:37 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 10 Apr 2009 02:12:37 +0100 Subject: [rspec-users] Cucover: coverage-aware 'lazy' cucumber runs Message-ID: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> Hi Folks, This is an idea I've been playing with for some time, and I think I've finally it into a shape where it might be useful to other people. Cucover is a thin wrapper for Cucumber which makes it lazy. What does it mean for Cucumber to be lazy? It will only run a feature if it needs to. How does it decide whether it needs to run a feature? Every time you run a feature using Cucover, it watches the code in your application that is executed, and remembers. The next time you run Cucover, it skips a feature if the source files (or the feature itself) have not been changed since it was last run. If this sounds useful to you, please take a look, try it out, and let me know what you think. http://github.com/mattwynne/cucover/tree/master cheers, Matt Wynne http://blog.mattwynne.net http://beta.songkick.com From lists at ruby-forum.com Thu Apr 9 23:14:08 2009 From: lists at ruby-forum.com (Gavin Hughes) Date: Fri, 10 Apr 2009 05:14:08 +0200 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit Message-ID: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> "Then I should be on /users/3/posts/8/comments/2/edit" What's the solution for parsing out and matching and arbitrarily deep nested route? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 9 23:27:33 2009 From: lists at ruby-forum.com (Gavin Hughes) Date: Fri, 10 Apr 2009 05:27:33 +0200 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> Message-ID: <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> The problem is actually this: And I fill in ... And I press "Create Comment" Then I should be on [the correct page, ie. /users/3/posts/8/comments/2/edit] How do you write a step for that? -- Posted via http://www.ruby-forum.com/. From programmer2188 at gmail.com Fri Apr 10 00:14:24 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 10 Apr 2009 00:14:24 -0400 Subject: [rspec-users] Eliminating duplication from tests Message-ID: <00f701c9b992$d6042750$820c75f0$@com> Hi, Lately I've found myself trying to reduce typing as much as possible, so when I have a lot of tests that only differ in a few variables, I tend to abstract them to reduce typing. For instance, I have an assert_form_errors method that I call within a describe block to ensure the proper errors are displaying. I have an assert_form_fields method to validate that the fields that have errors are wrapped in div.error, and the ones that don't are not (that method should probably be renamed now that I think of it, but I'm not sure to what). That one is especially useful because it can test all of the fields in one go. So is this necessarily bad? I've heard it's not always good to reduce duplication in tests, but it just seems much preferable than copy/paste. Also, I fear it is becoming more test-like than behavior, but that's the way my testing is progressing. Brandon From pat.maddox at gmail.com Fri Apr 10 00:25:39 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 9 Apr 2009 21:25:39 -0700 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> Message-ID: <2c7e61990904092125v6bb45fbbrba9f1cc369cbd848@mail.gmail.com> I'm not sure, cause I've never tried to write a step like that. I would rather do Then I should see "Editing 'My sweet comment'" Even better would be to actually edit the comment and make sure that it changed. So maybe When I edit the comment to be "My new comment" Then I should see "My new comment" And I should not see "My old comment" This way you're testing the feature itself, rather than some implementation detail such as the current url. Pat On Thu, Apr 9, 2009 at 8:27 PM, Gavin Hughes wrote: > The problem is actually this: > > And I fill in ... > And I press "Create Comment" > Then I should be on [the correct page, ie. > /users/3/posts/8/comments/2/edit] > > How do you write a step for that? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Fri Apr 10 00:51:37 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 09 Apr 2009 22:51:37 -0600 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> Message-ID: <49DED059.1030407@benmabey.com> Gavin Hughes wrote: > "Then I should be on /users/3/posts/8/comments/2/edit" > > What's the solution for parsing out and matching and arbitrarily deep > nested route? > Hi Gavin, Let me try to answer your question without actually answering it. :) I generally don't test my URLs. IMO, for the majority of cases the URL is merely an implementation detail of the application. For example I could easily see the URL in your example (/users/3/posts/8/comments/2/edit) as being "/posts/8/comments/2/edit" or "/comments/2/edit" or "/posts/the-name/comments/2/edit". The user would be fine with all of these cases, they really don't care one way or the other. Instead of focusing on an implementation detail of the application scenarios should be focused on the behaviour that the user would like to see. In your particular case what the user really cares about is being able to edit a comment, correct? So, instead of just verifying that the user is on the right page after clicking on "Edit Comment", you should have the user actually fill out the form to edit the comment. Then verify that the comment is actually updated on the post's page after they submit the comment editing form. Off the top of my head something like this may work: Scenario: edit comment Given a post exists named "big news" And I have made a comment "bad post!" on the "big news" post And I am viewing the "big news" post When I change my "bad post!" comment to "Great post!" And press "Update Comment" Then I should see "Great Post!" With this you are just testing the behaviour of the application. (BTW, you could write the scenario above number of ways and still be testing the same thing- I'm not sure if I love the way I wrote it....) You could change your URL naming scheme and this would still pass because the behaviour hasn't changed. By embedding the URL in the scenario your URL scheme is now coupled to your features unnecessarily. Sorry, for not really answering your question but I think you will thank me later if you take this approach. :) -Ben From ben at benmabey.com Fri Apr 10 00:56:27 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 09 Apr 2009 22:56:27 -0600 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> Message-ID: <49DED17B.5060506@benmabey.com> Gavin Hughes wrote: > The problem is actually this: > > And I fill in ... > And I press "Create Comment" > Then I should be on [the correct page, ie. > /users/3/posts/8/comments/2/edit] > > How do you write a step for that? > I just saw this second message.. My assumption about what you were testing was off, but the principle remains the same. You should verify that the application is correct by looking at what the user actually sees in the response body- not what they see in the URL/address bar. So, instead of saying "Then I should be on..." can you say something like "Then I should see..."? Again, does the user really care what the URL is, or what is actually on the page? -Ben From joshknowles at gmail.com Fri Apr 10 00:58:07 2009 From: joshknowles at gmail.com (Josh Knowles) Date: Fri, 10 Apr 2009 00:58:07 -0400 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> Message-ID: On Thu, Apr 9, 2009 at 11:27 PM, Gavin Hughes wrote: > The problem is actually this: > > And I fill in ... > And I press "Create Comment" > Then I should be on [the correct page, ie. > /users/3/posts/8/comments/2/edit] > > How do you write a step for that? Personally I try and stay away from step-matchers based on URLs. Do you really care about what page you're on? I would instead check the response for the "Thank you for posting" or whatever message that you're probably showing. If however you want to check the page, do something like response.url.should == "/blah" -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com From programmer2188 at gmail.com Fri Apr 10 01:08:23 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 10 Apr 2009 01:08:23 -0400 Subject: [rspec-users] route_for testing multiple request methods Message-ID: <00fc01c9b99a$60879450$2196bcf0$@com> Hi, I'm trying to use route_for to test my routes. I have two routes that have the same path, but different request methods. map.with_options :controller => 'contact' do |c| c.contact 'contact.html', :action => 'index', :conditions => {:method => :get} c.process_contact_form 'contact.html', :action => 'process_form', :conditions => {:method => :post} End My test is: it "should map {:controller => 'contact', :action => 'process_form'} to /contact.html" do route_for(:controller => 'contact', :action => 'process_form').should == '/contact.html' end # it should map {:controller => 'contact', :action => 'process_form'} to /contact.html The error: Test::Unit::AssertionFailedError in 'ContactController route generation should map {:controller => 'contact', :action => 'process_form'} to /contact.html' The recognized options <{"action"=>"index", "controller"=>"contact"}> did not match <{"action"=>"process_form", "controller"=>"contact"}>, difference: <{"action"=>"process_form"}> Is this a bug, or am I doing something wrong? It works when I use assert_generates, so I think the routes are correct. Brandon From lists at ruby-forum.com Fri Apr 10 01:32:15 2009 From: lists at ruby-forum.com (Gavin Hughes) Date: Fri, 10 Apr 2009 07:32:15 +0200 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <1a083600a35de11209d4e43f85852cf9@ruby-forum.com> Message-ID: <11e7469949ce9b842906c012f499c5d3@ruby-forum.com> Ben, Josh Makes perfect sense. The user won't be looking at the URL. He'll expect some result on the page, thus we test for that. Thanks! Gavin -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Apr 10 02:49:41 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 03:49:41 -0300 Subject: [rspec-users] route_for testing multiple request methods In-Reply-To: <00fc01c9b99a$60879450$2196bcf0$@com> References: <00fc01c9b99a$60879450$2196bcf0$@com> Message-ID: <57c63afe0904092349s5fffe872nf559c4300f5b7e1a@mail.gmail.com> On Fri, Apr 10, 2009 at 2:08 AM, Brandon Olivares wrote: > Hi, > > I'm trying to use route_for to test my routes. I have two routes that have > the same path, but different request methods. > > map.with_options :controller => 'contact' do |c| > ?c.contact 'contact.html', :action => 'index', > ?:conditions => {:method => :get} > ?c.process_contact_form 'contact.html', :action => 'process_form', > ?:conditions => {:method => :post} > End > > My test is: > > ? ?it "should map ?{:controller => 'contact', :action => 'process_form'} to > /contact.html" do > ? ? ?route_for(:controller => 'contact', :action => 'process_form').should > == > ? ? ?'/contact.html' > ? ?end # it should map ?{:controller => 'contact', :action => > 'process_form'} to /contact.html > > The error: > > Test::Unit::AssertionFailedError in 'ContactController route generation > should map ?{:controller => 'contact', :action => 'process_form'} to > /contact.html' > The recognized options <{"action"=>"index", "controller"=>"contact"}> did > not match <{"action"=>"process_form", "controller"=>"contact"}>, difference: > <{"action"=>"process_form"}> > > Is this a bug, or am I doing something wrong? It works when I use > assert_generates, so I think the routes are correct. assert_recognizes, however, will fail in the same way :) Try: route_for(:controller => 'contact', :action => 'index') .should == {:path => '/contact.html', :method => :get} route_for(:controller => 'contact', :action => 'process_form') .should == {:path => '/contact.html', :method => :post} The default is :method => :get, so the first doesn't require the :method in the hash: route_for(:controller => 'contact', :action => 'index') .should == :method => :get > > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 10 03:09:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 04:09:58 -0300 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <00f701c9b992$d6042750$820c75f0$@com> References: <00f701c9b992$d6042750$820c75f0$@com> Message-ID: <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> On Fri, Apr 10, 2009 at 1:14 AM, Brandon Olivares wrote: > Hi, > > Lately I've found myself trying to reduce typing as much as possible, so > when I have a lot of tests that only differ in a few variables, I tend to > abstract them to reduce typing. abstract or extract? I think you mean extract. > For instance, I have an assert_form_errors method that I call within a > describe block to ensure the proper errors are displaying. I have an > assert_form_fields method to validate that the fields that have errors are > wrapped in div.error, and the ones that don't are not (that method should > probably be renamed now that I think of it, but I'm not sure to what). That > one is especially useful because it can test all of the fields in one go. > > So is this necessarily bad? I've heard it's not always good to reduce > duplication in tests, but it just seems much preferable than copy/paste. If it's not always good, then it's probably not always bad :) It really varies from situation to situation. You need to understand the risks involved. Can you please post specific examples of the use of these so we don't have to talk in generalities? > Also, I fear it is becoming more test-like than behavior, but that's the way > my testing is progressing. Of course your "testing" is progressing towards something more "test-like." You're calling it "testing" so you're probably thinking of it as "testing." You're using words like "ensure" instead of "specify" and you've even named your expectations "assert_xxx" instead of "expect_xxx." TDD is *not a testing practice*. It is a design practice. The whole reason BDD was created was to help get that point across, and you are fighting it every step of the way in your example. Don't feel bad about this. If it was easy, we wouldn't need to talk about it. It is *very* subtle stuff. And it's confusing because the very nature of a code example changes as soon as the code it specifies gets written. Consider: 1. Write an example. There is no code, so the example is a specification for code that doesn't exist. 2. Write code to pass the example. The example is now, in *addition* to being a specification for that code, documentation of existing code and a regression test for that code. During step 2 the example itself does not change, yet it transforms in its meaning. The example *is* a test, but not until after the code to pass it is written. And that's even more confusing because we use the terms pass and fail. I have no idea if this is helpful :) Regardless, that is the intent. Cheers, David > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 10 03:14:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 04:14:59 -0300 Subject: [rspec-users] [cucumber] Cucumber and restful_authentication In-Reply-To: References: Message-ID: <57c63afe0904100014h4eddc662r6ab4a2bf4213c9bc@mail.gmail.com> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi wrote: > Hi, > > I have just started to use Cucumber. > I'm struggling to use Cucumber on the feature that is available only to > the logged in user. > > Could anybody provide the codes that need to be added? > > > The sites I found by Google search don't give clear information about > what to do. > The ones I found are: > > http://stackoverflow.com/questions/679928?sort=newest#sort-top > http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen > http://blog.andrew.premdas.org/articles/2008/10/12/cucumber-webrat-and-debugging-features > > > The step I added is: > > Given /^I am logged in$/ do > ?User.create!( :first_name => 'quire', > ? ? ? ? ? ? ? ?:last_name => 'smith', > ? ? ? ? ? ? ? ?:login => 'quire', > ? ? ? ? ? ? ? ?:email => 'quire at example.com', > ? ? ? ? ? ? ? ?:password => 'test', > ? ? ? ? ? ? ? ?:password_confirmation => 'test' ) > ?post "/login", :login => 'quire', :password => 'test' > end > > By the way, in routes.rb, I'm setting the following as described in > restful_authentication: > > map.login '/login', :controller => 'sessions', :action => 'new' > > Without login_required and the step above, the Cucumber scenario was > successfully run. But after I put login_required and the step above, > Cucumber cannot locate a field (its value is filled in text field). Where are you putting login_required? > > Thank you in advance. > > Tadatoshi > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Fri Apr 10 03:38:06 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 10 Apr 2009 03:38:06 -0400 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> References: <00f701c9b992$d6042750$820c75f0$@com> <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> Message-ID: <000001c9b9af$4b189f50$e149ddf0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Friday, April 10, 2009 3:10 AM > To: rspec-users > Subject: Re: [rspec-users] Eliminating duplication from tests > > Can you please post specific examples of the use of these so we don't > have to talk in generalities? Sure, here is something I just wrote. def assert_route_recognition path, controller, methods describe "route recognition" do [:get, :post, :put, :delete].each do |method| if methods.include? method it "should generate the params" + " {:controller => '#{controller}', :action => '#{methods[method]}'}" + " when the request method is #{method.to_s.upcase}" do params_from(method, path).should == { :controller => controller, :action => methods[method] } end else it "should not accept the #{method} method" do lambda { params_from(method, path) }.should raise_error(ActionController::MethodNotAllowed) end end end end end # assert_route_recognition > Of course your "testing" is progressing towards something more > "test-like." You're calling it "testing" so you're probably thinking > of it as "testing." You're using words like "ensure" instead of > "specify" and you've even named your expectations "assert_xxx" instead > of "expect_xxx." Interesting. I'm just used to thinking that way I guess. What is wrong with ensure instead of specify? And I've never seen that convention with the expect prefix. Can you provide an example? Thank you very much for the help. Brandon From dchelimsky at gmail.com Fri Apr 10 03:57:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 04:57:29 -0300 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <000001c9b9af$4b189f50$e149ddf0$@com> References: <00f701c9b992$d6042750$820c75f0$@com> <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> <000001c9b9af$4b189f50$e149ddf0$@com> Message-ID: <57c63afe0904100057v100a020fg9671f75145e3b1ca@mail.gmail.com> On Fri, Apr 10, 2009 at 4:38 AM, Brandon Olivares wrote: > > >> -----Original Message----- >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> bounces at rubyforge.org] On Behalf Of David Chelimsky >> Sent: Friday, April 10, 2009 3:10 AM >> To: rspec-users >> Subject: Re: [rspec-users] Eliminating duplication from tests >> >> Can you please post specific examples of the use of these so we don't >> have to talk in generalities? > > Sure, here is something I just wrote. > > ? ?def assert_route_recognition path, controller, methods > ? ? ?describe "route recognition" do > ? ? ? ?[:get, :post, :put, :delete].each do |method| > ? ? ? ? ?if methods.include? method > ? ? ? ? ? ?it "should generate the params" + > ? ? ? ? ? ?" {:controller => '#{controller}', :action => > '#{methods[method]}'}" + > ? ? ? ? ? ?" when the request method is #{method.to_s.upcase}" do > ? ? ? ? ? ? ?params_from(method, path).should == { > ? ? ? ? ? ? ?:controller => controller, > ? ? ? ? ? ? ?:action => methods[method] > ? ? ? ? ? ?} > ? ? ? ? ? ?end > ? ? ? ? ?else > ? ? ? ? ? ?it "should not accept the #{method} method" do > ? ? ? ? ? ? ?lambda { > ? ? ? ? ? ? ? ?params_from(method, path) > ? ? ? ? ? ? ?}.should raise_error(ActionController::MethodNotAllowed) > ? ? ? ? ? ?end > ? ? ? ? ?end > ? ? ? ?end > ? ? ?end > ? ?end # assert_route_recognition I meant where it's used, not how it works :) But now that you've shown the implementation, I can see that this is a macro that generates examples. So when you're using it it probably looks like this: describe WidgetsController do assert_route_recognition "/widgets/", :widgets, [:get, :post] end In this case, I'd change the name to something like recognizes_routes_for: describe WidgetsController do recognizes_routes_for "/widgets/", :widgets, [:get, :post] end But even that is a bit of a challenge to understand what all the arguments mean. Another option might be: describe WidgetsController do recognizes_routes_for :get, :post, "/widgets/" end The controller can be inferred from WidgetsController in the macro, which you can access from the described_class method: :controller => described_class.to_s.sub(/Controller/,'').underscore.to_sym >> Of course your "testing" is progressing towards something more >> "test-like." You're calling it "testing" so you're probably thinking >> of it as "testing." You're using words like "ensure" instead of >> "specify" and you've even named your expectations "assert_xxx" instead >> of "expect_xxx." > > Interesting. I'm just used to thinking that way I guess. What is wrong with > ensure instead of specify? > > And I've never seen that convention with the expect prefix. Can you provide > an example? I don't have any examples :) I was just making a suggestion because part of the BDD nomenclature is "expectation" instead of "assertion." An expectation is about something in the future. An assertion is about something that already exists. In this case, since it's a macro, I'd go with what I suggested above (recognizes_routes_for). HTH, David > Thank you very much for the help. > > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 10 04:12:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 05:12:16 -0300 Subject: [rspec-users] superclass mismatch for class ModelExampleGroup (TypeError) In-Reply-To: <22959248.post@talk.nabble.com> References: <22940271.post@talk.nabble.com> <57c63afe0904071817s6772e388j9f03f354ef05fba8@mail.gmail.com> <22959248.post@talk.nabble.com> Message-ID: <57c63afe0904100112w142c0289wfc4b7d9bd444b0f3@mail.gmail.com> On Wed, Apr 8, 2009 at 5:48 PM, Andrew Zielinski wrote: > > Thanks David, > > It seems like remarkable was the culprit. Somebody had posted the same issue > to lighthouse. Do you mean rspec's lighthouse account? If so, which ticket? > The solution was to specify the lib in environment.rb instead of setting it > to false for rspec and rspec-rails. The discussion was in Portuguese so I'm > not sure why this works. > > I don't get the error anymore but now when I run spec_server it hangs. > Running it with debug produced the following output: > > -----------Exception `LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:871 - > no such file to load -- rubygems/defaults/operating_system > Exception `LoadError' at /Library/Ruby/Site/1.8/rubygems/config_file.rb:35 - > no such file to load -- Win32API Win32API??? No idea why that is being loaded (or trying to be). > Exception `TypeError' at (eval):4 - can't modify frozen object > Exception `MissingSourceFile' at > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31 - no such file to load > -- fast_xs > Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:636 - > RubyGem version error: rack(0.3.0 not ~> 1.0.0) > > Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:636 - Could > not find RubyGem tmail (~> 1.2.3) > > Exception `MissingSourceFile' at > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31 - no such file to load > -- tmail/tmailscanner > Exception `MissingSourceFile' at > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:38 - no such file to load > -- tmail/tmailscanner > Exception `MissingSourceFile' at > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:162 > - no such file to load -- tmail/tmailscanner > /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: > instance variable @reload_plugins not initialized > /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: > instance variable @reload_plugins not initialized > /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: > instance variable @reload_plugins not initialized > /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: > instance variable @reload_plugins not initialized There's not that much help in this backtrace (for me). Anybody else paying attention and getting some idea about this problem? > > ................... > > > > David Chelimsky-2 wrote: >> >> On Tue, Apr 7, 2009 at 6:20 PM, Andrew Zielinski >> wrote: >>> >>> I hope somebody can help me with this. >>> >>> I can't seem to run spec_server with rails 2.3.2 using rspec/rspec-rails >>> 1.2.2. I'm also using mocha 0.9.5 and remarkable 2.3.0. >> >> The stack trace doesn't show it, but the superclass mismatch suggests >> that you have a version of rspec pre 1.2 that is being loaded >> somewhere. The old ModelExampleGroup derived directly from >> Test::Unit::TestCase, but the 1.2 class derives from >> ActiveSupport::TestCase. Can you check to see what versions of rspec >> and rspec-rails you have installed and uninstall all the old ones if >> you can. >> >> HTH, >> David >> >>> >>> Thanks Andrew >>> >>> Here is the stack trace: >>> >>> --------------------------------- >>> >>> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example/model_example_group.rb:9: >>> superclass mismatch for class ModelExampleGroup (TypeError) >>> >>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >>> `gem_original_require' >>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >>> from >>> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >>> `require' >>> from >>> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example.rb:6 >>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >>> `gem_original_require' >>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >>> from >>> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >>> `require' >>> from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb:19 >>> ?... 9 levels... >>> from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in >>> `run' >>> from ./script/../config/environment.rb:13 >>> from ./script/spec_server:6:in `require' >>> from ./script/spec_server:6 >>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22940271.html >>> Sent from the rspec-users mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > -- > View this message in context: http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22959248.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Apr 10 05:43:03 2009 From: lists at ruby-forum.com (Fedor Fomenko) Date: Fri, 10 Apr 2009 11:43:03 +0200 Subject: [rspec-users] [Cucumber] Bug? In-Reply-To: <49DE259B.4090204@benmabey.com> References: <31822d19b55bb0e594cd344098319141@ruby-forum.com> <49DE259B.4090204@benmabey.com> Message-ID: <4d9c1d42435f0d4d04fc2525f3c18ca0@ruby-forum.com> Thank you for your help. I found the problem. My assertion was wrong. I should have used msg.exists?.should == true since msg.should_not == nil is allways true. Watir always returns an object which might or might nor have text field. -- Posted via http://www.ruby-forum.com/. From programmer2188 at gmail.com Fri Apr 10 08:16:56 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 10 Apr 2009 08:16:56 -0400 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <57c63afe0904100057v100a020fg9671f75145e3b1ca@mail.gmail.com> References: <00f701c9b992$d6042750$820c75f0$@com> <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> <000001c9b9af$4b189f50$e149ddf0$@com> <57c63afe0904100057v100a020fg9671f75145e3b1ca@mail.gmail.com> Message-ID: <001501c9b9d6$3ec57e40$bc507ac0$@com> David, Thank you very much. Most of my methods that are generating examples are similar to that, and I hadn't thought to call them macros. Anyway I like the name you suggest. I'll go through my macros and try to come up with more appropriate names for them. Oh, and that described_class trick is great; thanks for showing me that. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Friday, April 10, 2009 3:57 AM > To: rspec-users > Subject: Re: [rspec-users] Eliminating duplication from tests > > On Fri, Apr 10, 2009 at 4:38 AM, Brandon Olivares > wrote: > > > > > >> -----Original Message----- > >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > >> bounces at rubyforge.org] On Behalf Of David Chelimsky > >> Sent: Friday, April 10, 2009 3:10 AM > >> To: rspec-users > >> Subject: Re: [rspec-users] Eliminating duplication from tests > >> > >> Can you please post specific examples of the use of these so we > don't > >> have to talk in generalities? > > > > Sure, here is something I just wrote. > > > > ? ?def assert_route_recognition path, controller, methods > > ? ? ?describe "route recognition" do > > ? ? ? ?[:get, :post, :put, :delete].each do |method| > > ? ? ? ? ?if methods.include? method > > ? ? ? ? ? ?it "should generate the params" + > > ? ? ? ? ? ?" {:controller => '#{controller}', :action => > > '#{methods[method]}'}" + > > ? ? ? ? ? ?" when the request method is #{method.to_s.upcase}" do > > ? ? ? ? ? ? ?params_from(method, path).should == { > > ? ? ? ? ? ? ?:controller => controller, > > ? ? ? ? ? ? ?:action => methods[method] > > ? ? ? ? ? ?} > > ? ? ? ? ? ?end > > ? ? ? ? ?else > > ? ? ? ? ? ?it "should not accept the #{method} method" do > > ? ? ? ? ? ? ?lambda { > > ? ? ? ? ? ? ? ?params_from(method, path) > > ? ? ? ? ? ? ?}.should raise_error(ActionController::MethodNotAllowed) > > ? ? ? ? ? ?end > > ? ? ? ? ?end > > ? ? ? ?end > > ? ? ?end > > ? ?end # assert_route_recognition > > I meant where it's used, not how it works :) But now that you've shown > the implementation, I can see that this is a macro that generates > examples. So when you're using it it probably looks like this: > > describe WidgetsController do > assert_route_recognition "/widgets/", :widgets, [:get, :post] > end > > In this case, I'd change the name to something like > recognizes_routes_for: > > describe WidgetsController do > recognizes_routes_for "/widgets/", :widgets, [:get, :post] > end > > But even that is a bit of a challenge to understand what all the > arguments mean. Another option might be: > > describe WidgetsController do > recognizes_routes_for :get, :post, "/widgets/" > end > > The controller can be inferred from WidgetsController in the macro, > which you can access from the described_class method: > > :controller => > described_class.to_s.sub(/Controller/,'').underscore.to_sym > > >> Of course your "testing" is progressing towards something more > >> "test-like." You're calling it "testing" so you're probably thinking > >> of it as "testing." You're using words like "ensure" instead of > >> "specify" and you've even named your expectations "assert_xxx" > instead > >> of "expect_xxx." > > > > Interesting. I'm just used to thinking that way I guess. What is > wrong with > > ensure instead of specify? > > > > And I've never seen that convention with the expect prefix. Can you > provide > > an example? > > I don't have any examples :) I was just making a suggestion because > part of the BDD nomenclature is "expectation" instead of "assertion." > An expectation is about something in the future. An assertion is about > something that already exists. > > In this case, since it's a macro, I'd go with what I suggested above > (recognizes_routes_for). > > HTH, > David > > > Thank you very much for the help. > > > > Brandon > > > > _______________________________________________ > > 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 phlip2005 at gmail.com Fri Apr 10 08:38:35 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 10 Apr 2009 05:38:35 -0700 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <00f701c9b992$d6042750$820c75f0$@com> References: <00f701c9b992$d6042750$820c75f0$@com> Message-ID: Brandon Olivares wrote: > So is this necessarily bad? I've heard it's not always good to reduce > duplication in tests, but it just seems much preferable than copy/paste. Refactor production code (while passing the tests after each edit) to make it as DRY as possible. This _typically_ means duplicate the behavior you need to change, make the new method pass the new test, and only then merge the new behavior back in with the old code. Merge following the rule "refactor low hanging fruit". Don't jam two big methods back together; use Extract Method Refactor on the smallest common lines within them, until only the differences are left. This implies clone-and-modify is part of the process. In test code, the best way to write a new test is clone the best example and change the assertions in the clone. (Ripping all the old assertions out, and changing the sample data on principle, are both best practices here.) Refactor test code with two further constraints: Unlike production code, each test case should tell a little story. And squeezing that last bit of duplication out of the test cases is not likely to improve the tests' designs. New tests should always be easy to write. If you get that, then the refactoring is working. From phlip2005 at gmail.com Fri Apr 10 09:04:16 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 10 Apr 2009 06:04:16 -0700 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <001501c9b9d6$3ec57e40$bc507ac0$@com> References: <00f701c9b992$d6042750$820c75f0$@com> <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> <000001c9b9af$4b189f50$e149ddf0$@com> <57c63afe0904100057v100a020fg9671f75145e3b1ca@mail.gmail.com> <001501c9b9d6$3ec57e40$bc507ac0$@com> Message-ID: Brandon Olivares wrote: > Oh, and that described_class trick is great; thanks for showing me that. http://c2.com/cgi/wiki?AbstractTest ? From manderson at drillinginfo.com Fri Apr 10 09:03:22 2009 From: manderson at drillinginfo.com (Mark Anderson) Date: Fri, 10 Apr 2009 08:03:22 -0500 Subject: [rspec-users] [Cucumber] Bug? In-Reply-To: <4d9c1d42435f0d4d04fc2525f3c18ca0@ruby-forum.com> References: <31822d19b55bb0e594cd344098319141@ruby-forum.com><49DE259B.4090204@benmabey.com> <4d9c1d42435f0d4d04fc2525f3c18ca0@ruby-forum.com> Message-ID: I prefer to use the form 'msg.should exist' because I feel that it reads better. The error message is a little wordy, but still more communicative than expected true and got false. /\/\ark > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Fedor Fomenko > Sent: Friday, April 10, 2009 4:43 AM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] [Cucumber] Bug? > > Thank you for your help. > > I found the problem. My assertion was wrong. I should have used > msg.exists?.should == true since msg.should_not == nil is allways true. > Watir always returns an object which might or might nor have text field. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > __________ Information from ESET NOD32 Antivirus, version of virus > signature database 3998 (20090409) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > __________ Information from ESET NOD32 Antivirus, version of virus signature database 3999 (20090410) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com From programmer2188 at gmail.com Fri Apr 10 09:15:11 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 10 Apr 2009 09:15:11 -0400 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: <57c63afe0904100057v100a020fg9671f75145e3b1ca@mail.gmail.com> References: <00f701c9b992$d6042750$820c75f0$@com> <57c63afe0904100009w70f4646di5289f6d20faf19ad@mail.gmail.com> <000001c9b9af$4b189f50$e149ddf0$@com> <57c63afe0904100057v100a020fg9671f75145e3b1ca@mail.gmail.com> Message-ID: <002001c9b9de$6212fe60$2638fb20$@com> David, I wanted to ask about another macro I have. I have something currently called assert_form_fields, that is called like: Assert_form_fields :field1, :field2, ... What it does is sets an error for each field, and specifies that the field should be wrapped in a div with class 'error', and that the other fields are not wrapped by such a div. It does it by calling other methods. For each field I have assert_[field]_has_errors and assert_[field]_does_not_have_errors. So now that I'm trying to rename these, I'm just not sure what to name this. What should I keep in mind when trying to write appropriate names for such things? Thanks, Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Friday, April 10, 2009 3:57 AM > To: rspec-users > Subject: Re: [rspec-users] Eliminating duplication from tests > > On Fri, Apr 10, 2009 at 4:38 AM, Brandon Olivares > wrote: > > > > > >> -----Original Message----- > >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > >> bounces at rubyforge.org] On Behalf Of David Chelimsky > >> Sent: Friday, April 10, 2009 3:10 AM > >> To: rspec-users > >> Subject: Re: [rspec-users] Eliminating duplication from tests > >> > >> Can you please post specific examples of the use of these so we > don't > >> have to talk in generalities? > > > > Sure, here is something I just wrote. > > > > ? ?def assert_route_recognition path, controller, methods > > ? ? ?describe "route recognition" do > > ? ? ? ?[:get, :post, :put, :delete].each do |method| > > ? ? ? ? ?if methods.include? method > > ? ? ? ? ? ?it "should generate the params" + > > ? ? ? ? ? ?" {:controller => '#{controller}', :action => > > '#{methods[method]}'}" + > > ? ? ? ? ? ?" when the request method is #{method.to_s.upcase}" do > > ? ? ? ? ? ? ?params_from(method, path).should == { > > ? ? ? ? ? ? ?:controller => controller, > > ? ? ? ? ? ? ?:action => methods[method] > > ? ? ? ? ? ?} > > ? ? ? ? ? ?end > > ? ? ? ? ?else > > ? ? ? ? ? ?it "should not accept the #{method} method" do > > ? ? ? ? ? ? ?lambda { > > ? ? ? ? ? ? ? ?params_from(method, path) > > ? ? ? ? ? ? ?}.should raise_error(ActionController::MethodNotAllowed) > > ? ? ? ? ? ?end > > ? ? ? ? ?end > > ? ? ? ?end > > ? ? ?end > > ? ?end # assert_route_recognition > > I meant where it's used, not how it works :) But now that you've shown > the implementation, I can see that this is a macro that generates > examples. So when you're using it it probably looks like this: > > describe WidgetsController do > assert_route_recognition "/widgets/", :widgets, [:get, :post] > end > > In this case, I'd change the name to something like > recognizes_routes_for: > > describe WidgetsController do > recognizes_routes_for "/widgets/", :widgets, [:get, :post] > end > > But even that is a bit of a challenge to understand what all the > arguments mean. Another option might be: > > describe WidgetsController do > recognizes_routes_for :get, :post, "/widgets/" > end > > The controller can be inferred from WidgetsController in the macro, > which you can access from the described_class method: > > :controller => > described_class.to_s.sub(/Controller/,'').underscore.to_sym > > >> Of course your "testing" is progressing towards something more > >> "test-like." You're calling it "testing" so you're probably thinking > >> of it as "testing." You're using words like "ensure" instead of > >> "specify" and you've even named your expectations "assert_xxx" > instead > >> of "expect_xxx." > > > > Interesting. I'm just used to thinking that way I guess. What is > wrong with > > ensure instead of specify? > > > > And I've never seen that convention with the expect prefix. Can you > provide > > an example? > > I don't have any examples :) I was just making a suggestion because > part of the BDD nomenclature is "expectation" instead of "assertion." > An expectation is about something in the future. An assertion is about > something that already exists. > > In this case, since it's a macro, I'd go with what I suggested above > (recognizes_routes_for). > > HTH, > David > > > Thank you very much for the help. > > > > Brandon > > > > _______________________________________________ > > 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 programmer2188 at gmail.com Fri Apr 10 10:25:21 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Fri, 10 Apr 2009 10:25:21 -0400 Subject: [rspec-users] Eliminating duplication from tests In-Reply-To: References: <00f701c9b992$d6042750$820c75f0$@com> Message-ID: <005701c9b9e8$2f4ee2a0$8deca7e0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Friday, April 10, 2009 8:39 AM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] Eliminating duplication from tests > > Refactor production code (while passing the tests after each edit) to > make it as > DRY as possible. This _typically_ means duplicate the behavior you need > to > change, make the new method pass the new test, and only then merge the > new > behavior back in with the old code. Merge following the rule "refactor > low > hanging fruit". Don't jam two big methods back together; use Extract > Method > Refactor on the smallest common lines within them, until only the > differences > are left. I already factor when I see duplication in the code, but I haven't ever seen what you are saying about duplicating the behavior in a new method. Usually I just change the existing method. Can you explain this a bit further? > > This implies clone-and-modify is part of the process. In test code, the > best way > to write a new test is clone the best example and change the assertions > in the > clone. (Ripping all the old assertions out, and changing the sample > data on > principle, are both best practices here.) > > Refactor test code with two further constraints: Unlike production > code, each > test case should tell a little story. And squeezing that last bit of > duplication > out of the test cases is not likely to improve the tests' designs. > > New tests should always be easy to write. If you get that, then the > refactoring > is working. Thank you. That helps a lot. Brandon From lenny at aps.org Fri Apr 10 11:49:28 2009 From: lenny at aps.org (Lenny Marks) Date: Fri, 10 Apr 2009 11:49:28 -0400 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <49DED059.1030407@benmabey.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <49DED059.1030407@benmabey.com> Message-ID: On Apr 10, 2009, at 12:51 AM, Ben Mabey wrote: > Gavin Hughes wrote: >> "Then I should be on /users/3/posts/8/comments/2/edit" >> >> What's the solution for parsing out and matching and arbitrarily deep >> nested route? >> > Hi Gavin, > Let me try to answer your question without actually answering it. :) > > I generally don't test my URLs. IMO, for the majority of cases the > URL is merely an implementation detail of the application. For > example I could easily see the URL in your example (/users/3/posts/8/ > comments/2/edit) as being "/posts/8/comments/2/edit" or "/comments/2/ > edit" or "/posts/the-name/comments/2/edit". The user would be fine > with all of these cases, they really don't care one way or the > other. Instead of focusing on an implementation detail of the > application scenarios should be focused on the behaviour that the > user would like to see. In your particular case what the user > really cares about is being able to edit a comment, correct? So, > instead of just verifying that the user is on the right page after > clicking on "Edit Comment", you should have the user actually fill > out the form to edit the comment. Then verify that the comment is > actually updated on the post's page after they submit the comment > editing form. One place I've actually been interested in testing URLs was to verify that the app actually redirected after a form submission. The user facing reason for this is to verify that the app works as expected(e.g. doesn't repost a comment or something) when the user refreshes to get fresh data. Of course, sticking to what the user cares about, it would probably be best to have this tested in a separate scenario for 'user refreshes page after posting comment' . -lenny > Off the top of my head something like this may work: > > Scenario: edit comment > Given a post exists named "big news" > And I have made a comment "bad post!" on the "big news" post > And I am viewing the "big news" post > > When I change my "bad post!" comment to "Great post!" > And press "Update Comment" > > Then I should see "Great Post!" > > With this you are just testing the behaviour of the application. > (BTW, you could write the scenario above number of ways and still be > testing the same thing- I'm not sure if I love the way I wrote > it....) You could change your URL naming scheme and this would still > pass because the behaviour hasn't changed. By embedding the URL in > the scenario your URL scheme is now coupled to your features > unnecessarily. > > Sorry, for not really answering your question but I think you will > thank me later if you take this approach. :) > > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From phlip2005 at gmail.com Fri Apr 10 10:56:32 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 10 Apr 2009 07:56:32 -0700 Subject: [rspec-users] where's an example of an RSpec'd Rails or Merb site with RJS calls? Message-ID: RSpeckers: The time has come to plug assert_rjs_ into a matcher providing a grammar like "should generate_js_to :replace_html...". Does anyone have a lite website that uses Ajax and RSpec, for a reference implementation? I need non-trivial challenges... -- Phlip From pat.maddox at gmail.com Fri Apr 10 12:40:09 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Fri, 10 Apr 2009 09:40:09 -0700 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <49DED059.1030407@benmabey.com> Message-ID: <2c7e61990904100940n51f1d7aax89462692562582f9@mail.gmail.com> On Fri, Apr 10, 2009 at 8:49 AM, Lenny Marks wrote: > > On Apr 10, 2009, at 12:51 AM, Ben Mabey wrote: > >> Gavin Hughes wrote: >>> >>> "Then I should be on /users/3/posts/8/comments/2/edit" >>> >>> What's the solution for parsing out and matching and arbitrarily deep >>> nested route? >>> >> Hi Gavin, >> Let me try to answer your question without actually answering it. :) >> >> I generally don't test my URLs. ?IMO, for the majority of cases the URL is >> merely an implementation detail of the application. ?For example I could >> easily see the URL in your example (/users/3/posts/8/comments/2/edit) as >> being "/posts/8/comments/2/edit" or "/comments/2/edit" or >> "/posts/the-name/comments/2/edit". ?The user would be fine with all of these >> cases, they really don't care one way or the other. ?Instead of focusing on >> an implementation detail of the application scenarios should be focused on >> the behaviour that the user would like to see. ?In your particular case what >> the user really cares about is being able to edit a comment, correct? ?So, >> instead of just verifying that the user is on the right page after clicking >> on "Edit Comment", you should have the user actually fill out the form to >> edit the comment. ?Then verify that the comment is actually updated on the >> post's page after they submit the comment editing form. > > One place I've actually been interested in testing URLs was to verify that > the app actually redirected after a form submission. The user facing reason > for this is to verify that the app works as expected(e.g. doesn't repost a > comment or something) when the user refreshes to get fresh data. Of course, > sticking to what the user cares about, it would probably be best to have > this tested in a separate scenario for 'user refreshes page after posting > comment' . I would just test that at the controller level it "should redirect to the comment's article" do post :create, :article_id => @article.to_param, :comment => {:body => "wooo"} response.should redirect_to(@article) end Pat From pat.maddox at gmail.com Fri Apr 10 12:41:05 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Fri, 10 Apr 2009 09:41:05 -0700 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: <2c7e61990904100940n51f1d7aax89462692562582f9@mail.gmail.com> References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <49DED059.1030407@benmabey.com> <2c7e61990904100940n51f1d7aax89462692562582f9@mail.gmail.com> Message-ID: <2c7e61990904100941t1e192647tcf8d85352e248ecf@mail.gmail.com> On Fri, Apr 10, 2009 at 9:40 AM, Pat Maddox wrote: > I would just test that at the controller level I would _specify_ that at the controller level. BAD BDD evangelist :P From ashley.moran at patchspace.co.uk Fri Apr 10 13:34:44 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 10 Apr 2009 18:34:44 +0100 Subject: [rspec-users] Cucover: coverage-aware 'lazy' cucumber runs In-Reply-To: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> Message-ID: <00740092-BD8D-48D5-B872-872B625FFF78@patchspace.co.uk> On 10 Apr 2009, at 02:12, Matt Wynne wrote: > If this sounds useful to you, please take a look, try it out, and > let me know what you think. Hi Matt Cucover sounds *very* interesting! However I fell at the first hurdle: "Anything that runs out of process will not be covered, and therefore cannot trigger a re-run, so if you use Cucumber to drive Selenium, for example, you're out of luck." As I use Cucumber with Celerity in a separate JRuby process, I can't use Cucover. Is it feasible to make it work cross-process? Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From matt at mattwynne.net Fri Apr 10 14:39:40 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 10 Apr 2009 19:39:40 +0100 Subject: [rspec-users] Cucover: coverage-aware 'lazy' cucumber runs In-Reply-To: <00740092-BD8D-48D5-B872-872B625FFF78@patchspace.co.uk> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <00740092-BD8D-48D5-B872-872B625FFF78@patchspace.co.uk> Message-ID: On 10 Apr 2009, at 18:34, Ashley Moran wrote: > On 10 Apr 2009, at 02:12, Matt Wynne wrote: >> If this sounds useful to you, please take a look, try it out, and >> let me know what you think. > > > Hi Matt > > Cucover sounds *very* interesting! However I fell at the first > hurdle: > > "Anything that runs out of process will not be covered, and > therefore cannot trigger a re-run, so if you use Cucumber to drive > Selenium, for example, you're out of luck." > > As I use Cucumber with Celerity in a separate JRuby process, I can't > use Cucover. Is it feasible to make it work cross-process? It's feasible I think, and something I'd definitely like to add for my own purposes eventually. I think RCov works with JRuby too, though I've not tried it myself. To be honest though, the next feature in my queue is probably to make more granular re-runs that work per scenario rather than per feature, as it currently does. The code is really pretty simple so if you want to pull it down and take a look maybe we can have a chat directly about it would work. I think the problem would be around how the external process gets started (and it's coverage observed) but your situation should be much easier than a selenium setup where the process could be on a remote box. Just to be clear, are you calling Ruby to call Cucumber to call JRuby to call Celerity, as you seem to be suggesting? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Fri Apr 10 16:40:08 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 10 Apr 2009 21:40:08 +0100 Subject: [rspec-users] message expectations without explicit receiver In-Reply-To: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> References: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> Message-ID: On 10 Apr 2009, at 19:43, Barun Singh wrote: > A model I'm trying to spec looks something like this > > class MyClass > def methodA > do some stuff > methodB > end > > def methodB > do some stuff > end > end > > my spec looks something like this: > > x = MyClass.new > x.should_receive(:methodB) > lambda{ x.methodA } > > In the situation outlined above, the spec fails. But, if I change > the definition of methodA to be as follows the spec passes (note the > addition of "self" as the receiver): > > def methodA > do some stuff > self.methodB > end > > > The code doesn't actually need for me to identify "self" as the > receiver on order for it to work. But rSpec seems to require this. > Is there an alternative way to write the spec so that it passes in > the original case (where I call methodB without an explicit receiver)? You're going into some pretty messy territory here, trying to insert a mocking layer between two methods of the same class. Since most people who use RSpec wouldn't want to do this, you've found that's it not possible. I also suspect it would be quite difficult to write the mocking code, but that's a different issue. I could write more about this, and I suspect others will, but for now I would suggest that you listen to your test and try to test the behaviour of the whole class, only mocking out collaborating objects. This will ensure there's as little coupling as possible between the tests and the code, making that code easier to change. Here are a couple of things you could read up to see what I mean: http://www.jmock.org/oopsla2004.pdf http://www.patmaddox.com/blog/2008/10/27/testing-protected-and-private-methods-in-ruby Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Fri Apr 10 17:39:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 18:39:08 -0300 Subject: [rspec-users] message expectations without explicit receiver In-Reply-To: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> References: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> Message-ID: <57c63afe0904101439u34b0d62cp8a693d1b497d5c7d@mail.gmail.com> On Fri, Apr 10, 2009 at 3:43 PM, Barun Singh wrote: > A model I'm trying to spec looks something like this > > class MyClass > ? def methodA > ??? do some stuff > ??? methodB > ? end > > ? def methodB > ??? do some stuff > ? end > end > > my spec looks something like this: > > x = MyClass.new > x.should_receive(:methodB) > lambda{ x.methodA } Why the lambda? Is it ever called? The following works as expected: class Foo def bar baz end def baz end end describe "a message expectation on the same object" do it "works just fine" do foo = Foo.new foo.should_receive(:baz) foo.bar end end - David > > In the situation outlined above, the spec fails.? But, if I change the > definition of methodA to be as follows the spec passes (note the addition of > "self" as the receiver): > > def methodA > ? do some stuff > ? self.methodB > end > > > The code doesn't actually need for me to identify "self" as the receiver on > order for it to work.? But rSpec seems to require this.? Is there an > alternative way to write the spec so that it passes in the original case > (where I call methodB without an explicit receiver)? Something > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Apr 10 17:52:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 18:52:04 -0300 Subject: [rspec-users] message expectations without explicit receiver In-Reply-To: <83e853830904101427x2f4ef631q31634cbd5a5b176d@mail.gmail.com> References: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> <5d1f449a0904101342q24d211e7nd2f68ac89c3da745@mail.gmail.com> <83e853830904101427x2f4ef631q31634cbd5a5b176d@mail.gmail.com> Message-ID: <57c63afe0904101452i4d06cba4q5261e58998ab57cd@mail.gmail.com> On Fri, Apr 10, 2009 at 6:27 PM, Barun Singh wrote: > Ok, well it seems that the answer to my direct question is that no, there's > no way to test message expectations without an explicit receiver; thanks for > the responses. > > I suppose I should respond to the comments re: more general issue of testing > strategy [hopefully this doesn't ignite too long of a thread]: > > I completely agree that the goal should be to disconnect testing from > implementation as much as possible.? In general, this requires finding the > simples set of N inputs to a method that cover all the basic behavior you > want to test for, and making sure that the appropriate output is generated > for all of those cases. > > This may work for the majority of methods you encounter; but it's not always > practical.? Sometimes a method is complex enough that the N inputs you would > need to describe all behavior can be too large to be practical.? We want to > test thoroughly and to test in a way that's easy to maintain.? Overall it is > easier to maintain tests that don't rely at all on implementation, but it is > also easier to maintain a smaller number of tests than a very large number > of tests.? These two things have to be balanced. > > So, I do agree with the general rule, but it doesn't apply in every > situation.? And, to be clear, this has nothing to do with testing protected > methods, which of course shouldn't be done.? Here's an example to illustrate > my point: > > Suppose methodA does the following: > ? * parse a data file uploaded by the user > ? * reformat the parsed data to deal with a variety of different allowable > configurations > ? * perform calculations on the collected data > > In the implementation, I might refactor the functionality into three smaller > methods (one for each bullet), and just call those three smaller methods > from within methodA.? Those other methods will also be public (they might > need to be called from elsewhere), and I test each of them separately.? So, > having tested all of the functionality described by those three bullets > separately, all I really care about in testing methodA is that it is > actually calling those three methods.? Otherwise, re-testing all that > functionality is not at all DRY. > > Even if I wanted to re-test all of the functionality, it can be next to > impossible.? Suppose I write 20 tests to fully spec out each of the three > methods called from within methodA (because there are 20 distinct sets of > behaviors that describe all the possible behaviors of each of those > methods).? In this case, if I wanted to test methodA without referencing any > internal logic at all, I might be required to write 20^3 = 8,000 tests to > fully cover all of the logic described by the 60 tests used to cover the > three subroutines. I responded to your initial post - I think we're chasing a red herring here because what you want to be able to do *should* work. That said, the traditional view of what you're describing now is to extract behaviour to separate objects, not just a separate methods, and then use mock objects in the examples. That solves the explosion of examples to cover edge cases without the risks associated with modifying the object being specified. Not to say this is law, nor that I never violate it myself. But pretty much the only time I do so is when a framework I'm using pushes me to do so. If the class being spec'd is a PORO, and all my code, I generally follow this guideline. HTH, David > > > > On Fri, Apr 10, 2009 at 4:42 PM, Nigel Thorne wrote: >> >> Hi Barun, >> Here is my take on this... >> Why are you mocking methods on the object under test? The aim of BDD is to >> specify the behaviour of the class. When you are mocking, the intention is >> to spec one object in?isolation. When you define expectations between >> objects you are specifying object interaction. >> Mocking method on the object under test ties your spec to your >> implementation. If you decided to implement 'methodA' in some other way that >> lead to the same behaviour, then your specs shuould still pass. In your case >> they would not. >> Cheers >> Nigel >> >> 2009/4/11 Barun Singh >>> >>> A model I'm trying to spec looks something like this >>> >>> class MyClass >>> ? def methodA >>> ??? do some stuff >>> ??? methodB >>> ? end >>> >>> ? def methodB >>> ??? do some stuff >>> ? end >>> end >>> >>> my spec looks something like this: >>> >>> x = MyClass.new >>> x.should_receive(:methodB) >>> lambda{ x.methodA } >>> >>> In the situation outlined above, the spec fails.? But, if I change the >>> definition of methodA to be as follows the spec passes (note the addition of >>> "self" as the receiver): >>> >>> def methodA >>> ? do some stuff >>> ? self.methodB >>> end >>> >>> >>> The code doesn't actually need for me to identify "self" as the receiver >>> on order for it to work.? But rSpec seems to require this.? Is there an >>> alternative way to write the spec so that it passes in the original case >>> (where I call methodB without an explicit receiver)? >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ashley.moran at patchspace.co.uk Fri Apr 10 17:55:52 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 10 Apr 2009 22:55:52 +0100 Subject: [rspec-users] message expectations without explicit receiver In-Reply-To: <83e853830904101427x2f4ef631q31634cbd5a5b176d@mail.gmail.com> References: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> <5d1f449a0904101342q24d211e7nd2f68ac89c3da745@mail.gmail.com> <83e853830904101427x2f4ef631q31634cbd5a5b176d@mail.gmail.com> Message-ID: On 10 Apr 2009, at 22:27, Barun Singh wrote: > This may work for the majority of methods you encounter; but it's > not always practical. Sometimes a method is complex enough that the > N inputs you would need to describe all behavior can be too large to > be practical. We want to test thoroughly and to test in a way > that's easy to maintain. Overall it is easier to maintain tests > that don't rely at all on implementation, but it is also easier to > maintain a smaller number of tests than a very large number of > tests. These two things have to be balanced. > > So, I do agree with the general rule, but it doesn't apply in every > situation. And, to be clear, this has nothing to do with testing > protected methods, which of course shouldn't be done. Here's an > example to illustrate my point: > > Suppose methodA does the following: > * parse a data file uploaded by the user > * reformat the parsed data to deal with a variety of different > allowable configurations > * perform calculations on the collected data Hi Barun The situation you describe is a violation of the Single Responsibility principle. Your *class*, never mind your method, is doing too much. > Even if I wanted to re-test all of the functionality, it can be next > to impossible. Suppose I write 20 tests to fully spec out each of > the three methods called from within methodA (because there are 20 > distinct sets of behaviors that describe all the possible behaviors > of each of those methods). In this case, if I wanted to test > methodA without referencing any internal logic at all, I might be > required to write 20^3 = 8,000 tests to fully cover all of the logic > described by the 60 tests used to cover the three subroutines. What you need to do is figure out how you can isolate parts of the algorithm and spec them as separate objects. That way you can mock out the other bits, and cut down the permutations you need to cover to prove the app still works. Excessive build-up of logic branches is something I struggled with for a long time, and it still bit me recently. But, in my experience, it's always just a code/spec smell. As soon as the specs get too complex to understand, find a simpler way of expressing you problem. This can be either by refactoring with standard OO techniques, or - if that fails to reduce the complexity - fundamentally re-modelling the problem. HTH Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From dchelimsky at gmail.com Fri Apr 10 17:57:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 10 Apr 2009 18:57:48 -0300 Subject: [rspec-users] message expectations without explicit receiver In-Reply-To: References: <83e853830904101143x355c997cq58bf43d271b12263@mail.gmail.com> <5d1f449a0904101342q24d211e7nd2f68ac89c3da745@mail.gmail.com> <83e853830904101427x2f4ef631q31634cbd5a5b176d@mail.gmail.com> Message-ID: <57c63afe0904101457j432c6987u71ded0b3df33a2ba@mail.gmail.com> On Fri, Apr 10, 2009 at 6:55 PM, Ashley Moran wrote: > On 10 Apr 2009, at 22:27, Barun Singh wrote: >> >> This may work for the majority of methods you encounter; but it's not >> always practical. ?Sometimes a method is complex enough that the N inputs >> you would need to describe all behavior can be too large to be practical. >> ?We want to test thoroughly and to test in a way that's easy to maintain. >> ?Overall it is easier to maintain tests that don't rely at all on >> implementation, but it is also easier to maintain a smaller number of tests >> than a very large number of tests. ?These two things have to be balanced. >> >> So, I do agree with the general rule, but it doesn't apply in every >> situation. ?And, to be clear, this has nothing to do with testing protected >> methods, which of course shouldn't be done. ?Here's an example to illustrate >> my point: >> >> Suppose methodA does the following: >> ?* parse a data file uploaded by the user >> ?* reformat the parsed data to deal with a variety of different allowable >> configurations >> ?* perform calculations on the collected data > > Hi Barun > > The situation you describe is a violation of the Single Responsibility > principle. ?Your *class*, never mind your method, is doing too much. Agreed. FWIW. > >> Even if I wanted to re-test all of the functionality, it can be next to >> impossible. ?Suppose I write 20 tests to fully spec out each of the three >> methods called from within methodA (because there are 20 distinct sets of >> behaviors that describe all the possible behaviors of each of those >> methods). ?In this case, if I wanted to test methodA without referencing any >> internal logic at all, I might be required to write 20^3 = 8,000 tests to >> fully cover all of the logic described by the 60 tests used to cover the >> three subroutines. > > > What you need to do is figure out how you can isolate parts of the algorithm > and spec them as separate objects. ?That way you can mock out the other > bits, and cut down the permutations you need to cover to prove the app still > works. > > Excessive build-up of logic branches is something I struggled with for a > long time, and it still bit me recently. ?But, in my experience, it's always > just a code/spec smell. ?As soon as the specs get too complex to understand, > find a simpler way of expressing you problem. ?This can be either by > refactoring with standard OO techniques, or - if that fails to reduce the > complexity - fundamentally re-modelling the problem. > > HTH > > Ashley > > -- > http://www.patchspace.co.uk/ > http://www.linkedin.com/in/ashleymoran > http://aviewfromafar.net/ > http://twitter.com/ashleymoran > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ashley.moran at patchspace.co.uk Fri Apr 10 18:40:42 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 10 Apr 2009 23:40:42 +0100 Subject: [rspec-users] Cucover: coverage-aware 'lazy' cucumber runs In-Reply-To: References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <00740092-BD8D-48D5-B872-872B625FFF78@patchspace.co.uk> Message-ID: <23B67A83-FF78-462D-876C-FCD59B3FC1AB@patchspace.co.uk> On 10 Apr 2009, at 19:39, Matt Wynne wrote: > It's feasible I think, and something I'd definitely like to add for > my own purposes eventually. I think RCov works with JRuby too, > though I've not tried it myself. Hmmm - the JRuby process is just running Cucumber, where my Merb code is all in MRI. It's the MRI process that needs to run RCov, right? (I've never used it beyond inspecting its coverage reports.) > To be honest though, the next feature in my queue is probably to > make more granular re-runs that work per scenario rather than per > feature, as it currently does. Sounds like a good idea! > The code is really pretty simple so if you want to pull it down and > take a look maybe we can have a chat directly about it would work. I > think the problem would be around how the external process gets > started (and it's coverage observed) but your situation should be > much easier than a selenium setup where the process could be on a > remote box. > > Just to be clear, are you calling Ruby to call Cucumber to call > JRuby to call Celerity, as you seem to be suggesting? Currently what I've got is a rake file running in MRI, that calls jrake, that runs the Cucumber task in the JRuby process. The indirection there just so I can type `rake features`, as Merb won't (currently) start up in JRuby, which prevents me from typing `jrake features`. Part of my env.rb involves some code I wrote that wraps daemon_controller to start my webapps. I have a separate "features" environment that is started on demand, so it's only available when Cucumber is running. Cheers Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From phlip2005 at gmail.com Fri Apr 10 19:28:18 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 10 Apr 2009 16:28:18 -0700 Subject: [rspec-users] where's an example of an RSpec'd Rails or Merb site with RJS calls? In-Reply-To: References: Message-ID: > The time has come to plug assert_rjs_ into a matcher providing a grammar > like "should generate_js_to :replace_html...". > > Does anyone have a lite website that uses Ajax and RSpec, for a > reference implementation? I need non-trivial challenges... Whoa - this'n sure hit the spot! http://github.com/spot-us/spot-us/tree/master Ajax vs Cucumber! From lists at ruby-forum.com Fri Apr 10 20:07:48 2009 From: lists at ruby-forum.com (James Byrne) Date: Sat, 11 Apr 2009 02:07:48 +0200 Subject: [rspec-users] Cucumber - Recommended viewing. Message-ID: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html -- Posted via http://www.ruby-forum.com/. From hectoregm at gmail.com Fri Apr 10 21:08:11 2009 From: hectoregm at gmail.com (Hector Gomez) Date: Fri, 10 Apr 2009 18:08:11 -0700 (PDT) Subject: [rspec-users] [cucumber][rails] trouble with authlogic tests In-Reply-To: <9598815a-1cd4-4ec5-be63-8d8fe7f31df6@r36g2000vbr.googlegroups.com> References: <9598815a-1cd4-4ec5-be63-8d8fe7f31df6@r36g2000vbr.googlegroups.com> Message-ID: Hi: I am the author of the rails template you linked, If you are only using the features and specs from the template your problem is that my features differ in the behavior when a succesful registration is taking place. In my features it is expected a redirection to the homepage and a flash with a successful message and a message indicating the user to check his email. The email has a confirmation link so the user has to confirm before it can be logged in. While in the tutorial the user is logged in and is redirected to his account page. Hector On Apr 9, 12:33?pm, scott wrote: > i am trying to learn testing for rails apps. > i followed the two authlogic tutorials (basic authlogic setup and > password reset) and now i am trying to add some integration tests with > cucumber (i know you are supposed to do the tests 1st, but i am just > trying to figure out how things work). > > i found this apphttp://github.com/hectoregm/rails-templates/tree/master > with a bunch of cucumber/webrat tests setup for authlogic so i started > applying them to my app. > > the app works fine when i do everything in the web browser, but i can > not figure out why it doesn't work with the tests. when it creates a > user account it should go to the show account page and flash "account > registered", but instead it is creating a user in the database (good), > going to my home page(bad), and the flash is "logout > successful"(bad). > > anyone have any guidance on what might be going wrong or how to > troubleshoot this? > > # from my feature file > Scenario: Allow an anonymous user to create account > ? Given "hector" is an anonymous user > ? When I go to the registration form > ? And I fill in "login" with "hector" > ? And I fill in "email" with "hec... at example.com" > ? And I fill in "password" with "secret" > ? And I fill in "password confirmation" with "secret" > ? And I press "Register" > ? Then I should have a successful registration > > # the relevent steps > Given /"(.*)" is an anonymous user/ do |name| # registration_steps.rb > ? visit '/logout' > ? visit '/' > end > When /^I go to (.+)$/ do |page_name| # webrat_steps.rb > ? visit path_to(page_name) > end > when /the registration form/ # paths.rb > ? new_account_path > When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| # > webrat_steps.rb > ? fill_in(field, :with => value) > end > When /^I press "([^\"]*)"$/ do |button| # webrat_steps.rb > ? click_button(button) > end > Then /^I should have a successful registration$/ do # > registration_steps.rb > ? When 'I should see "Account registered!"' > end > Then /^I should see "([^\"]*)"$/ do |text| # webrat_steps.rb > ? response.should contain(text) > end > # output from running "cucumber features" > Feature: Registration > ? As a anonymous user > ? I want be able to register > ? So that can be productive and be cool > ? Scenario: Allow an anonymous user to create account ? # features/ > registration.feature:13 > ? ? Given "hector" is an anonymous user ? ? ? ? ? ? ? ? # features/ > step_definitions/registration_steps.rb:1 > ? ? When I go to the registration form ? ? ? ? ? ? ? ? ?# features/ > step_definitions/webrat_steps.rb:10 > ? ? And I fill in "login" with "hector" ? ? ? ? ? ? ? ? # features/ > step_definitions/webrat_steps.rb:22 > ? ? And I fill in "email" with "hec... at example.com" ? ? # features/ > step_definitions/webrat_steps.rb:22 > ? ? And I fill in "password" with "secret" ? ? ? ? ? ? ?# features/ > step_definitions/webrat_steps.rb:22 > ? ? And I fill in "password confirmation" with "secret" # features/ > step_definitions/webrat_steps.rb:22 > ? ? And I press "Register" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# features/ > step_definitions/webrat_steps.rb:14 > ? ? Then I should have a successful registration ? ? ? ?# features/ > step_definitions/registration_steps.rb:54 > ? ? ? expected the following element's content to include "Account > registered!": > ? ? ? home: index > ? ? ? Authlogic Example App > ? ? ? 1 user currently logged in > ? ? ? Register | Log In | Forgot password > ? ? ? Logout successful! > ? ? ? Home Page > ? ? ? ?(Spec::Expectations::ExpectationNotMetError) > ? ? ? ./features/step_definitions/webrat_steps.rb:94:in `/^I should > see "([^\"]*)"$/' > ? ? ? features/registration.feature:21:in `Then I should have a > successful registration' > 1 scenario > 1 failed step > 7 passed steps > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Fri Apr 10 23:07:30 2009 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 11 Apr 2009 00:07:30 -0300 Subject: [rspec-users] Cucumber stripping the letter "a" on windows In-Reply-To: <5A95EAE4A3FE1645992FAF868AD6DCDC09AEB25C@DEN-EXM-06.corp.ebay.com> References: <5A95EAE4A3FE1645992FAF868AD6DCDC09AEB25C@DEN-EXM-06.corp.ebay.com> Message-ID: <71166b3b0904102007j52278256w323c70588042b79@mail.gmail.com> On Fri, Apr 10, 2009 at 9:19 PM, Colfer, Brian wrote: > > It looks like cucumber is having the problem with the letter "a" again ? a > problem with handling the angstrom character and windows: > Who stole my a's ? :-D I'm working in a new version of win32console that will handle much better UTF and other encodings. Once I've that released (in the upcoming days if I hit the Iconv jackpot), Cucumber can be updated to feed it with the proper encoding (UTF8) Since I'm looking targe 1.9 functionality too, will be tricky get yours a's back today :-) -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From sfeley at gmail.com Fri Apr 10 23:08:43 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 10 Apr 2009 23:08:43 -0400 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> Message-ID: <1fb4df0904102008i9d60975r762087761bf0933a@mail.gmail.com> On Fri, Apr 10, 2009 at 8:07 PM, James Byrne wrote: > http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html Strongly agreed. I've been watching all of the Mountain West RubyConf presentations, and came close to skipping the BDD one, thinking "I've been working with this stuff for a few months now, do I really need to spend time on one more Cucumber tutorial?" But as it happened, I learned quite a bit -- both in fundamental philosophy, and a few syntax tricks I'd never picked up on. Great job, Ben! -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Fri Apr 10 23:48:31 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 10 Apr 2009 23:48:31 -0400 Subject: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit In-Reply-To: References: <251f578fc296cfdbc6fa04db8207a990@ruby-forum.com> <49DED059.1030407@benmabey.com> Message-ID: <1fb4df0904102048w1b40922eu258eb2632fcb3f22@mail.gmail.com> On Fri, Apr 10, 2009 at 11:49 AM, Lenny Marks wrote: > > One place I've actually been interested in testing URLs was to verify that > the app actually redirected after a form submission. I can agree with this, and I had a similar need just the other day. I had an action that redirected to different places depending on whether a certain box was checked. But I didn't spec it by checking the literal text of URL itself. Instead I worked with the paths functionality that was already in Cucumber's support directory, and made it a bit more flexible. Here was my situation: Scenario: Has an Enclosure Given I am a contributor When I go to the create episode page And I fill in [...blah blah, submitting the form...] Then I should have an episode titled "Any title" And I should be on the create enclosure page for that episode ...I wanted that "I should be on (foo) for that (bar)" to be general, so in my application_steps.rb: Then /^I should be on (.*page) for that (.*)$/ do |page, element| current_url.should == path_to(page, instance_variable_get("@#{element}")) end ...And finally, I rewrote the path_to method in paths.rb a bit: def path_to(page_name, parent_object = nil) case page_name [ . . . ] when /the create enclosure page/i new_episode_enclosure_url(parent_object) This all worked, and it worked well. Though of course, going through the work of specing and building a separate enclosure model made me decide that it would really work better as a simple Paperclip attribute inside episode, so I threw all that away... But c'est la vie. >8-> -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From ben at benmabey.com Sat Apr 11 01:35:45 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 10 Apr 2009 23:35:45 -0600 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <1fb4df0904102008i9d60975r762087761bf0933a@mail.gmail.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> <1fb4df0904102008i9d60975r762087761bf0933a@mail.gmail.com> Message-ID: <49E02C31.5090808@benmabey.com> Stephen Eley wrote: > On Fri, Apr 10, 2009 at 8:07 PM, James Byrne wrote: > >> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >> > > Strongly agreed. I've been watching all of the Mountain West RubyConf > presentations, and came close to skipping the BDD one, thinking "I've > been working with this stuff for a few months now, do I really need to > spend time on one more Cucumber tutorial?" But as it happened, I > learned quite a bit -- both in fundamental philosophy, and a few > syntax tricks I'd never picked up on. > > Great job, Ben! > > Thanks! I also recommend reading/viewing is Joesph's presentation from SoR: http://blog.josephwilk.net/ruby/outside-in-development-with-cucumber-and-rspec.html I have been eagerly awaiting the video but I don't think it is online yet. However, there are recorded code demos (minus the sound) in it you can watch right now. -Ben From kero at chello.nl Sat Apr 11 07:29:59 2009 From: kero at chello.nl (Kero van Gelder) Date: Sat, 11 Apr 2009 13:29:59 +0200 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <85d99afe0904091230m2ead6a62k870175768b1f2a00@mail.gmail.com> References: <4BC6E12138FF78458424C4BB5F20EC890BEA20BA@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEA20C3@sgtulmsp06.Global.ad.sabre.com> <4BC6E12138FF78458424C4BB5F20EC890BEF4FF4@sgtulmsp06.Global.ad.sabre.com> <85d99afe0904090947l5e161c43jf6a4fee5be183ab9@mail.gmail.com> <029F8324-DDCF-4D62-886A-6332F72D384B@mattwynne.net> <85d99afe0904091230m2ead6a62k870175768b1f2a00@mail.gmail.com> Message-ID: <20090411112958.GD32729@bumblebee.m38c.nl> > >> Cucumber could dump in the table data it found from the file, and > >> print it out when running the scenarios, and it allows some sets of > >> sample data be re-used easily, in an understandable manner. If the file is used to unclutter the examples, does printing-when-running help? > > This is a good idea - people do this with Fit (as opposed to Fitnesse) and > > go straight to a spreadsheet for the examples. > > > > I don't see why it needs a new Cucumber feature though - you could easily > > (and more flexibly) write a custom step yourself to load in the data from an > > external file, right? > > That's true, but why does everyone need to write their file loading > step/code? It seems like something where flexibility really doesn't > benefit anyone, unless you are doing something unique and special, > which I think is different than simply being able to store example > tables in an external file. Moreover, reading your own stuff is always possible in normal steps. Nevertheless, adding something like FromFile: should give real benefits, and I'm not sure that's the case here. Reading and writing files is easy enough (yaml, marshal, comma separated files, ...) without special features. Providing data can be done with Given("Scenario Morning rush hour") { Given flight 1234 leaving 08:30 And flight 2345 leaving 08:32 And flight 2346 leaving 08:34 } in a separate (step definition) file already, no? Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From andrew.zielinski.is at gmail.com Sat Apr 11 09:01:22 2009 From: andrew.zielinski.is at gmail.com (Andrew Zielinski) Date: Sat, 11 Apr 2009 06:01:22 -0700 (PDT) Subject: [rspec-users] superclass mismatch for class ModelExampleGroup (TypeError) In-Reply-To: <57c63afe0904100112w142c0289wfc4b7d9bd444b0f3@mail.gmail.com> References: <22940271.post@talk.nabble.com> <57c63afe0904071817s6772e388j9f03f354ef05fba8@mail.gmail.com> <22959248.post@talk.nabble.com> <57c63afe0904100112w142c0289wfc4b7d9bd444b0f3@mail.gmail.com> Message-ID: <23000951.post@talk.nabble.com> It was on remarkable's lighthouse account. David Chelimsky-2 wrote: > > On Wed, Apr 8, 2009 at 5:48 PM, Andrew Zielinski > wrote: >> >> Thanks David, >> >> It seems like remarkable was the culprit. Somebody had posted the same >> issue >> to lighthouse. > > Do you mean rspec's lighthouse account? If so, which ticket? > >> The solution was to specify the lib in environment.rb instead of setting >> it >> to false for rspec and rspec-rails. The discussion was in Portuguese so >> I'm >> not sure why this works. >> >> I don't get the error anymore but now when I run spec_server it hangs. >> Running it with debug produced the following output: >> >> -----------Exception `LoadError' at >> /Library/Ruby/Site/1.8/rubygems.rb:871 - >> no such file to load -- rubygems/defaults/operating_system >> Exception `LoadError' at >> /Library/Ruby/Site/1.8/rubygems/config_file.rb:35 - >> no such file to load -- Win32API > > Win32API??? No idea why that is being loaded (or trying to be). > >> Exception `TypeError' at (eval):4 - can't modify frozen object >> Exception `MissingSourceFile' at >> /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31 - no such file to >> load >> -- fast_xs >> Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:636 - >> RubyGem version error: rack(0.3.0 not ~> 1.0.0) >> >> Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:636 - >> Could >> not find RubyGem tmail (~> 1.2.3) >> >> Exception `MissingSourceFile' at >> /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31 - no such file to >> load >> -- tmail/tmailscanner >> Exception `MissingSourceFile' at >> /Library/Ruby/Site/1.8/rubygems/custom_require.rb:38 - no such file to >> load >> -- tmail/tmailscanner >> Exception `MissingSourceFile' at >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:162 >> - no such file to load -- tmail/tmailscanner >> /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: >> instance variable @reload_plugins not initialized >> /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: >> instance variable @reload_plugins not initialized >> /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: >> instance variable @reload_plugins not initialized >> /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:756: warning: >> instance variable @reload_plugins not initialized > > There's not that much help in this backtrace (for me). Anybody else > paying attention and getting some idea about this problem? > >> >> ................... >> >> >> >> David Chelimsky-2 wrote: >>> >>> On Tue, Apr 7, 2009 at 6:20 PM, Andrew Zielinski >>> wrote: >>>> >>>> I hope somebody can help me with this. >>>> >>>> I can't seem to run spec_server with rails 2.3.2 using >>>> rspec/rspec-rails >>>> 1.2.2. I'm also using mocha 0.9.5 and remarkable 2.3.0. >>> >>> The stack trace doesn't show it, but the superclass mismatch suggests >>> that you have a version of rspec pre 1.2 that is being loaded >>> somewhere. The old ModelExampleGroup derived directly from >>> Test::Unit::TestCase, but the 1.2 class derives from >>> ActiveSupport::TestCase. Can you check to see what versions of rspec >>> and rspec-rails you have installed and uninstall all the old ones if >>> you can. >>> >>> HTH, >>> David >>> >>>> >>>> Thanks Andrew >>>> >>>> Here is the stack trace: >>>> >>>> --------------------------------- >>>> >>>> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example/model_example_group.rb:9: >>>> superclass mismatch for class ModelExampleGroup (TypeError) >>>> >>>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >>>> `gem_original_require' >>>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >>>> from >>>> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >>>> `require' >>>> from >>>> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails/example.rb:6 >>>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in >>>> `gem_original_require' >>>> from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' >>>> from >>>> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in >>>> `require' >>>> from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb:19 >>>> ?... 9 levels... >>>> from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in >>>> `run' >>>> from ./script/../config/environment.rb:13 >>>> from ./script/spec_server:6:in `require' >>>> from ./script/spec_server:6 >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22940271.html >>>> Sent from the rspec-users mailing list archive at Nabble.com. >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p22959248.html >> Sent from the rspec-users mailing list archive at Nabble.com. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -- View this message in context: http://www.nabble.com/superclass-mismatch-for-class-ModelExampleGroup-%28TypeError%29-tp22940271p23000951.html Sent from the rspec-users mailing list archive at Nabble.com. From ashley.moran at patchspace.co.uk Sat Apr 11 14:02:01 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sat, 11 Apr 2009 19:02:01 +0100 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> Message-ID: <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> On 10 Apr 2009, at 02:12, Matt Wynne wrote: > What does it mean for Cucumber to be lazy? It will only run a > feature if it needs to. While I have yet to do more than skim the full articles, I wondered if you'd seen "Integration Tests Are A Scam" on InfoQ[1]? It was the following that caught my attention: > the hypothetical programmers with the integration-based test suite > choose to worry only about "the most important [x]% of the tests" Towards the end of the second article he seems to say it's more excessive integration testing that is the problem. (Even if he does end with "Stop writing them.") Strikes as me as rather along the lines of, albeit in the opposite direction to, "we don't mock because it makes the tests fragile". I was just idly thinking, could a code-coverage based system could be combined with some sort of failure (fragility) history to balance the time cost of heavy feature runs with the benefits of having something run end-to-end? We've had reverse-modification-time spec ordering for ages which is a useful start. On a more ranty note - I have very little time for these "XXX BDD/ development technique is always bad, don't do it" articles. (But hey, maybe I was guilty of this myself and have forgotten since...) Pretty much every technique I've seen has some benefit - if you use it selectively. I wish people would stop writing these inflammatory articles, and (a) figure out how to use these techniques like razors not shotguns and (b) go and improve the tools that apply them. Otherwise they're just making everyone's life harder. Gah!!! Ashley [1] http://www.infoq.com/news/2009/04/jbrains-integration-test-scam -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From hectoregm at gmail.com Sat Apr 11 16:57:50 2009 From: hectoregm at gmail.com (Hector Gomez) Date: Sat, 11 Apr 2009 13:57:50 -0700 (PDT) Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <49E02C31.5090808@benmabey.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> <1fb4df0904102008i9d60975r762087761bf0933a@mail.gmail.com> <49E02C31.5090808@benmabey.com> Message-ID: Nice presentation Ben, very good coverage of the process in so limited time. Like Stephen I picked some syntax tips that I didn't know. Hector On Apr 11, 12:35?am, Ben Mabey wrote: > Stephen Eley wrote: > > On Fri, Apr 10, 2009 at 8:07 PM, James Byrne wrote: > > >>http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben... > > > Strongly agreed. ?I've been watching all of the Mountain West RubyConf > > presentations, and came close to skipping the BDD one, thinking "I've > > been working with this stuff for a few months now, do I really need to > > spend time on one more Cucumber tutorial?" ?But as it happened, I > > learned quite a bit -- both in fundamental philosophy, and a few > > syntax tricks I'd never picked up on. > > > Great job, Ben! > > Thanks! > > I also recommend reading/viewing is Joesph's presentation from SoR: > > http://blog.josephwilk.net/ruby/outside-in-development-with-cucumber-... > > I have been eagerly awaiting the video but I don't think it is online > yet. ?However, there are recorded code demos (minus the sound) in it you > can watch right now. > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From aidy.lewis at googlemail.com Sat Apr 11 17:49:53 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Sat, 11 Apr 2009 22:49:53 +0100 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> Message-ID: <7ac2300c0904111449j70632ab1v53abeeaf79b785ba@mail.gmail.com> Maybe not as clear as Ben's http://skillsmatter.com/podcast/ajax-ria/cucumber-celerity-firewatir Aidy 2009/4/11 James Byrne : > http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Sat Apr 11 18:59:38 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 11 Apr 2009 18:59:38 -0400 Subject: [rspec-users] Mocking: brittle specs and tight coupling? Message-ID: <000301c9baf9$31ec69d0$95c53d70$@com> Hi, I've read of complaints that mocking can make the specs very brittle, in that if the method is changed at all, it will break the specs, even if the behavior remains the same. Do you find this to be the case? How do you deal with this if so? Also, when I used to do TDD in PHP, well there wasn't the ability to modify the class on the fly like in Ruby, so you actually had to do dependency injection, but people generally looked at this as a good thing, for loose coupling. So if a controller method for instance used a User model, then it would be preferred to get that instance from somewhere, either passing it to the method itself or calling another method to instantiate it. I notice this isn't a concern in RSpec or in Ruby in general. Do you view this differently, or what is the preferred way to deal with dependencies? Is it fine just to do: User.should_receive(:new).and_return(User.new) Just as a very simple example? Thanks, Brandon Brandon From lists at ruby-forum.com Sat Apr 11 19:04:25 2009 From: lists at ruby-forum.com (Tadatoshi Takahashi) Date: Sun, 12 Apr 2009 01:04:25 +0200 Subject: [rspec-users] [cucumber] Cucumber and restful_authentication In-Reply-To: <57c63afe0904100014h4eddc662r6ab4a2bf4213c9bc@mail.gmail.com> References: <57c63afe0904100014h4eddc662r6ab4a2bf4213c9bc@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi > wrote: >> what to do. >> ?User.create!( :first_name => 'quire', >> >> map.login '/login', :controller => 'sessions', :action => 'new' >> >> Without login_required and the step above, the Cucumber scenario was >> successfully run. But after I put login_required and the step above, >> Cucumber cannot locate a field (its value is filled in text field). > > Where are you putting login_required? Hi, David. I am sorry for the late reply. The login_required I put is actually before_filter in the controller, e.g. before_filter :login_required. Basically, if I disabled restful_authentication by commenting it out, all the steps in Cucumber passed. But when I enabled it (putting the before_filter above), Cucumber failed at one step. I don't necessary have a time to dig into the codes inside Cucumber and RSpec. So if there is a code that works, I would like to just use it and continue with Behaviour-Driven Development. Thank you. Tadatoshi -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sat Apr 11 19:13:22 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 11 Apr 2009 16:13:22 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <000301c9baf9$31ec69d0$95c53d70$@com> References: <000301c9baf9$31ec69d0$95c53d70$@com> Message-ID: <3c30da400904111613g63409e52p138d1f5569c41a38@mail.gmail.com> On Sat, Apr 11, 2009 at 3:59 PM, Brandon Olivares wrote: > I've read of complaints that mocking can make the specs very brittle, in > that if the method is changed at all, it will break the specs, even if the > behavior remains the same. Do you find this to be the case? How do you deal > with this if so? I change the spec. In theory, this may sound onerous, but I haven't found it to be so in practice. Testing in general can introduce dependencies, just as testing can introduce bugs. The idea however is that tests are simpler than the code they're testing, so the bugs in them are easier to fix and the dependencies fairly mechanical to deal with. ///ark From pat.maddox at gmail.com Sat Apr 11 19:24:50 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Sat, 11 Apr 2009 16:24:50 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <000301c9baf9$31ec69d0$95c53d70$@com> References: <000301c9baf9$31ec69d0$95c53d70$@com> Message-ID: <2c7e61990904111624g455596d0ye78af0ba4a555b30@mail.gmail.com> On Sat, Apr 11, 2009 at 3:59 PM, Brandon Olivares wrote: > Hi, > > I've read of complaints that mocking can make the specs very brittle, in > that if the method is changed at all, it will break the specs, even if the > behavior remains the same. Do you find this to be the case? How do you deal > with this if so? http://patmaddox.com/blog/you-probably-dont-get-mocks > Also, when I used to do TDD in PHP, well there wasn't the ability to modify > the class on the fly like in Ruby, so you actually had to do dependency > injection, but people generally looked at this as a good thing, for loose > coupling. So if a controller method for instance used a User model, then it > would be preferred to get that instance from somewhere, either passing it to > the method itself or calling another method to instantiate it. > > I notice this isn't a concern in RSpec or in Ruby in general. Do you view > this differently, or what is the preferred way to deal with dependencies? Is > it fine just to do: > > User.should_receive(:new).and_return(User.new) > > Just as a very simple example? I have an example of this in my Legacy Rails talk and say it's the sort of thing that would make a Java programmer run for the fucking hills. That's not entirely true because there are a couple mock frameworks that do let you do that, but in general they prefer to avoid it because it requires bytecode manipulation. Ruby is much more flexible and gives us a couple ways of injecting dependencies. You've got traditional DI: class Order def calculate_tax(calculator) calculator.calculate total, us_state end end You've got traditional DI + default args class Order def calculate_tax(calculator=TaxCalculator.new) calculator.calculate total, us_state end end You can partially mock on the target object: class Order def calculate_tax calculator.calculate total, us_state end def calculator TaxCalculator end end order = Order.new order.stub!(:calculator).and_return(mock('calculator', :calculate => 1.25)) or you can use partial mocks somewhere inside of the target object, like you showed. The pattern you showed is popular because often you won't ever want to pass in a different object. In your UsersController you're only ever going to deal with the User class as a repository, and if you change it then it's a fairly big change and you don't mind updating your tests. I find that you can use mocks to express the intent of the class well. Don't use constructor/setter/method dependency injection if you don't need it...accept a bit tighter coupling and use partial mocking if all you're trying to do is isolate behaviors. Pat From programmer2188 at gmail.com Sat Apr 11 19:57:56 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 11 Apr 2009 19:57:56 -0400 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <2c7e61990904111624g455596d0ye78af0ba4a555b30@mail.gmail.com> References: <000301c9baf9$31ec69d0$95c53d70$@com> <2c7e61990904111624g455596d0ye78af0ba4a555b30@mail.gmail.com> Message-ID: <000001c9bb01$573c2290$05b467b0$@com> Pat, Thank you very much for the link, and dependency injection explanation. That helps a lot. I like your blog, too. Brandon > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Pat Maddox > Sent: Saturday, April 11, 2009 7:25 PM > To: rspec-users > Subject: Re: [rspec-users] Mocking: brittle specs and tight coupling? > > On Sat, Apr 11, 2009 at 3:59 PM, Brandon Olivares > wrote: > > Hi, > > > > I've read of complaints that mocking can make the specs very brittle, > in > > that if the method is changed at all, it will break the specs, even > if the > > behavior remains the same. Do you find this to be the case? How do > you deal > > with this if so? > > http://patmaddox.com/blog/you-probably-dont-get-mocks > > > > Also, when I used to do TDD in PHP, well there wasn't the ability to > modify > > the class on the fly like in Ruby, so you actually had to do > dependency > > injection, but people generally looked at this as a good thing, for > loose > > coupling. So if a controller method for instance used a User model, > then it > > would be preferred to get that instance from somewhere, either > passing it to > > the method itself or calling another method to instantiate it. > > > > I notice this isn't a concern in RSpec or in Ruby in general. Do you > view > > this differently, or what is the preferred way to deal with > dependencies? Is > > it fine just to do: > > > > User.should_receive(:new).and_return(User.new) > > > > Just as a very simple example? > > I have an example of this in my Legacy Rails talk and say it's the > sort of thing that would make a Java programmer run for the fucking > hills. That's not entirely true because there are a couple mock > frameworks that do let you do that, but in general they prefer to > avoid it because it requires bytecode manipulation. > > Ruby is much more flexible and gives us a couple ways of injecting > dependencies. You've got traditional DI: > > class Order > def calculate_tax(calculator) > calculator.calculate total, us_state > end > end > > You've got traditional DI + default args > > class Order > def calculate_tax(calculator=TaxCalculator.new) > calculator.calculate total, us_state > end > end > > You can partially mock on the target object: > > class Order > def calculate_tax > calculator.calculate total, us_state > end > > def calculator > TaxCalculator > end > end > > order = Order.new > order.stub!(:calculator).and_return(mock('calculator', :calculate => > 1.25)) > > or you can use partial mocks somewhere inside of the target object, > like you showed. > > The pattern you showed is popular because often you won't ever want to > pass in a different object. In your UsersController you're only ever > going to deal with the User class as a repository, and if you change > it then it's a fairly big change and you don't mind updating your > tests. > > I find that you can use mocks to express the intent of the class well. > Don't use constructor/setter/method dependency injection if you don't > need it...accept a bit tighter coupling and use partial mocking if all > you're trying to do is isolate behaviors. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ashley.moran at patchspace.co.uk Sat Apr 11 21:39:36 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 12 Apr 2009 02:39:36 +0100 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <000301c9baf9$31ec69d0$95c53d70$@com> References: <000301c9baf9$31ec69d0$95c53d70$@com> Message-ID: <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> On 11 Apr 2009, at 23:59, Brandon Olivares wrote: > I've read of complaints that mocking can make the specs very > brittle, in > that if the method is changed at all, it will break the specs, even > if the > behavior remains the same. Do you find this to be the case? How do > you deal > with this if so? I've found the opposite more often - changing the specs of one side of an interaction leaves them passing, but the code no longer joins up. You should, after all, usually be changing the specs first. Recently, I've been leaning towards limiting mocks to points in the code where either the number of logic branches starts to explode (read - you've got `if` statements), or the interactions are more important than the implementation (ie - you're more likely to change how the other object works than what it/its interface is). Basically, I use them when it makes life easier*. These are rules of thumb to me right now, so I probably couldn't explain well what I mean, although I'm sure I should try. I like to view it as a sliding scale... Pure mock specs Pure integration specs |--------------------------------------------------------------| Lead more directly to good OOP Allow rapid hack-solutions Force you to think things through Encourage experimentation Fragile Sturdy Fast to run Slow to run Localised failure errors Vague failure errors High risk of false positives High risk of whack-a-mole debugging Or at least those are how I find them. I think I need to sit down some time and think through more formal strategies to choose when to use mocks. Right now I'd say, use mocks aggressively, work through the problems you find (which tend to highlight poor OO design), learn the design/ refactoring tricks, then take a step back. But make sure you've got some layer of integration spec (maybe Cucumber) above mocked specs, and make sure you don't give up *before* you feel like you've tamed mocks. Ignoring either of those could leave you thinking they are a bad tool that cause brittle specs, when actually they are a very powerful tool, just hard to use at first*. Ashley * some things that eventually make like easier seem to make it harder initially -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From phlip2005 at gmail.com Sun Apr 12 00:19:55 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 11 Apr 2009 21:19:55 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> Message-ID: Ashley Moran wrote: > I like to view it as a sliding scale... > > Pure mock specs Pure integration specs > |--------------------------------------------------------------| > Lead more directly to good OOP Allow rapid hack-solutions > I think I need to sit down some time and think through more formal > strategies to choose when to use mocks. There's a third alternative: Your sliding scale is really a pyramid with a peak. The third alternative is you never _need_ to mock, yet both your tests and target code are highly decoupled. _That_ is the goal. Under TDD, you get that by avoiding a design smell called "expensive setup". Your scale assumes that something actually must be set up - either mocks, or end-to-end class models. The best tests only need a few stubbed objects, each easy to construct. You avoid the design smell by writing the simplest new test you can think of, and writing simple code to pass the test. And if you don't want that code to be so simplistic, you practice "triangulation". Triangulation occurs when you have a big bowl of spaghetti, a meatball under it, and two chopsticks. You want to lift the meatball out, so you probe with one chopstick until you feel it, then you probe with the other until you can seize it. The two chopsticks now form a triangle, locating the meatball. The spaghetti is the design you don't want. The meatball is the design you want. Each chopstick is a simple test, and the angle between the chopsticks represents the _difference_ between the two tests. If each test is simple yet is set up differently, then the simplest code which can pass both simple tests approaches the most elegant design. Mock abuse just enables runaway dependencies. -- Phlip From sfeley at gmail.com Sun Apr 12 00:47:39 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sun, 12 Apr 2009 00:47:39 -0400 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> Message-ID: <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> On Sat, Apr 11, 2009 at 2:02 PM, Ashley Moran wrote: > > I was just idly thinking, could a code-coverage based system could be > combined with some sort of failure (fragility) history to balance the time > cost of heavy feature runs with the benefits of having something run > end-to-end? ?We've had reverse-modification-time spec ordering for ages > which is a useful start. I've had it in my head for a while now that someday (yes, that mythical 'someday') I want to write a better autotest. Maybe this is heresy, but I am a huge fan of the _idea_ behind autotest and totally annoyed by its implementation. It's extensible only in strange ways (hence wrappers like autospec), and its fundamental strategy is too static. I once lost most of a day trying to fix merb_cucumber so the features would run when they should, and was ready to hurl cats when I realized autotest's idea of context chaining was to make you list them all in the classname in alphabetical order. Look at the files in the Cucumber gem's 'lib/autotest' directory and you'll see what I mean. A proper design would let you plug in your own file-change discovery strategy, plug in multiple runners (RSpec, Cucumber, yadda yadda) with true modularity, specify lists of observers on directories or files, and allow different output views. An _ideal_ design would also let you set priority rules like you're describing here, so you get instant feedback only on the stuff you're working with, and do end-to-end runs in the background. Right now this is just a pipe dream, but I don't think it would be _hard._ It's just finding the time to do it vs. actual public-facing applications that's the challenge. If anybody wants to have a conversation about this, maybe get some collaboration going, feel free to drop me a line. > On a more ranty note - I have very little time for these "XXX > BDD/development technique is always bad, don't do it" articles. ?(But hey, > maybe I was guilty of this myself and have forgotten since...) "Declaring absolutes is always bad, don't do it?" >8-> Oh -- one other thought I had from reflecting upon your e-mail. This is totally unrelated to the above, but since we're being Big Thinkers I might as well write it down before I forget. You mentioned fragility/failure history, in relation to coverage, and I started thinking... I wonder if everyone's going about test coverage from the wrong direction, simply trying to _anticipate_ failure? What if we extended something like exception_notifier or Hoptoad as well, and brought real exceptions from the application's staging and production environments into our test tools? We know from the stack traces where failures occur, so it'd be pretty straightforward to write an RCov-like utility that nagged you: "You dingbat, your specs totally fail to cover line 119 of hamburgers.rb. It threw a MeatNotFound exception last Tuesday. Gonna test for that? Ever?" What do you think? Decent idea? Or does something like this already exist and I don't know about it? -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From matt at mattwynne.net Sun Apr 12 08:39:54 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 12 Apr 2009 13:39:54 +0100 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> Message-ID: <078980A3-849B-49B1-884F-2D91F77829ED@mattwynne.net> On 11 Apr 2009, at 01:07, James Byrne wrote: > http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html Great job with the talk Ben, it's a really good intro to Cucumber and I will be pointing anyone who asks towards it. One question about the kitten-killing. I was surprised that defining methods in your env / step_definition files adds methods to *every instance* of Object. I thought it just added those methods to the particular instance of Object that's used to create the World. Did I misunderstand the you in the talk, or misunderstand the code in Cucumber? cheers, Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From phlip2005 at gmail.com Sun Apr 12 11:32:11 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 12 Apr 2009 08:32:11 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> Message-ID: > The third alternative is you never _need_ to mock, yet both your tests > and target code are highly decoupled. _That_ is the goal. Another tip: To TDD a new feature, don't clone a high-level test which calls code which calls code which calls the code you need to change. Start by cloning the lowest level test possible. If there is none, write one. And if the test still wouldn't be low level enough, start by refactoring the line you need to change, to pull it out into a method you can test directly. From ben at benmabey.com Sun Apr 12 11:35:05 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 12 Apr 2009 09:35:05 -0600 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <078980A3-849B-49B1-884F-2D91F77829ED@mattwynne.net> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> <078980A3-849B-49B1-884F-2D91F77829ED@mattwynne.net> Message-ID: <49E20A29.6000805@benmabey.com> Matt Wynne wrote: > > On 11 Apr 2009, at 01:07, James Byrne wrote: > >> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >> > > Great job with the talk Ben, it's a really good intro to Cucumber and > I will be pointing anyone who asks towards it. > > One question about the kitten-killing. I was surprised that defining > methods in your env / step_definition files adds methods to *every > instance* of Object. I thought it just added those methods to the > particular instance of Object that's used to create the World. > > Did I misunderstand the you in the talk, or misunderstand the code in > Cucumber? > Well, the step definitions themselves don't add themselves to every instance. The Given, When, and Then methods have actually killed some kittens and already live on Object (sometimes it is okay). The step methods will register the passed in blocks to the StepMother-- not onto Object. So if that is what you are referring to you are correct. However, if you want to create a ruby helper method then you will need to wrap it in a module to prevent to from being added to every object instance. In my example I had something like: def login_as(user) visit '/login' fill_in 'Email', :with => user.email fill_in 'Password', :with => 'password' click_button end If you place that method in the top-level in either your env.rb or any step files it is going to be living on Object since Cucumber will load up these files as any other ruby file. So you could call #login_as on an Array or any other object! Definitely not what we want. So, you need to wrap it in a module and use the World hook to make the helper methods available only in your World (which you get a new one for every scenario). With the new World syntax (as of 0.2.3 I believe) it would be: module UserHelpers def login_as(user) visit '/login' fill_in 'Email', :with => user.email fill_in 'Password', :with => 'password' click_button end end World(UserHelpers) I feel like I may of just repeated what I said in the presentation... so you still may be just as confused. :/ Let me know if that helps to clarify things or what part of it is confusing. -Ben From matt at mattwynne.net Sun Apr 12 12:14:09 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 12 Apr 2009 17:14:09 +0100 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <49E20A29.6000805@benmabey.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> <078980A3-849B-49B1-884F-2D91F77829ED@mattwynne.net> <49E20A29.6000805@benmabey.com> Message-ID: On 12 Apr 2009, at 16:35, Ben Mabey wrote: > Matt Wynne wrote: >> >> On 11 Apr 2009, at 01:07, James Byrne wrote: >> >>> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >> >> Great job with the talk Ben, it's a really good intro to Cucumber >> and I will be pointing anyone who asks towards it. >> >> One question about the kitten-killing. I was surprised that >> defining methods in your env / step_definition files adds methods >> to *every instance* of Object. I thought it just added those >> methods to the particular instance of Object that's used to create >> the World. >> >> Did I misunderstand the you in the talk, or misunderstand the code >> in Cucumber? >> > Well, the step definitions themselves don't add themselves to every > instance. The Given, When, and Then methods have actually killed > some kittens and already live on Object (sometimes it is okay). The > step methods will register the passed in blocks to the StepMother-- > not onto Object. So if that is what you are referring to you are > correct. > > However, if you want to create a ruby helper method then you will > need to wrap it in a module to prevent to from being added to every > object instance. In my example I had something like: > > def login_as(user) > visit '/login' > fill_in 'Email', :with => user.email > fill_in 'Password', :with => 'password' > click_button > end > > If you place that method in the top-level in either your env.rb or > any step files it is going to be living on Object since Cucumber > will load up these files as any other ruby file. So you could call > #login_as on an Array or any other object! Definitely not what we > want. So, you need to wrap it in a module and use the World hook to > make the helper methods available only in your World (which you get > a new one for every scenario). With the new World syntax (as of > 0.2.3 I believe) it would be: > > module UserHelpers > def login_as(user) > visit '/login' > fill_in 'Email', :with => user.email > fill_in 'Password', :with => 'password' > click_button > end > end > > World(UserHelpers) > > I feel like I may of just repeated what I said in the > presentation... so you still may be just as confused. :/ Let me > know if that helps to clarify things or what part of it is confusing. Yeah you did, but I think you've made me realise something obvious: there's a difference between the ruby you write in the env and step matchers, and the ruby you write *inside* the step matchers. It's the later that gets evaluated in the context of the World instance, the former that gets evaluated in the root namespace. Right? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Sun Apr 12 12:27:58 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 12 Apr 2009 17:27:58 +0100 Subject: [rspec-users] Cucover: coverage-aware 'lazy' cucumber runs In-Reply-To: <23B67A83-FF78-462D-876C-FCD59B3FC1AB@patchspace.co.uk> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <00740092-BD8D-48D5-B872-872B625FFF78@patchspace.co.uk> <23B67A83-FF78-462D-876C-FCD59B3FC1AB@patchspace.co.uk> Message-ID: On 10 Apr 2009, at 23:40, Ashley Moran wrote: > On 10 Apr 2009, at 19:39, Matt Wynne wrote: >> It's feasible I think, and something I'd definitely like to add for >> my own purposes eventually. I think RCov works with JRuby too, >> though I've not tried it myself. > > Hmmm - the JRuby process is just running Cucumber, where my Merb > code is all in MRI. It's the MRI process that needs to run RCov, > right? (I've never used it beyond inspecting its coverage reports.) Ah right, OK, that might make things a little simpler then :) After a few iterations, I settled on Cucover using Rcov as a library[1], slipping in a call to Rcov::CallSiteAnalyzer#run_hooked into the Cucumber AST. This makes it easy for me to pull out just the data I need from the Rcov result objects, rather than trying to parse the Rcov binary's output. >> The code is really pretty simple so if you want to pull it down and >> take a look maybe we can have a chat directly about it would work. >> I think the problem would be around how the external process gets >> started (and it's coverage observed) but your situation should be >> much easier than a selenium setup where the process could be on a >> remote box. >> >> Just to be clear, are you calling Ruby to call Cucumber to call >> JRuby to call Celerity, as you seem to be suggesting? > > Currently what I've got is a rake file running in MRI, that calls > jrake, that runs the Cucumber task in the JRuby process. The > indirection there just so I can type `rake features`, as Merb won't > (currently) start up in JRuby, which prevents me from typing `jrake > features`. > > Part of my env.rb involves some code I wrote that wraps > daemon_controller to start my webapps. I have a separate "features" > environment that is started on demand, so it's only available when > Cucumber is running. So it sounds like what would need to happen is for those daemon_controller spawned webapps to be run with coverage, and that coverage passed back to Cucover, right? This sounds like an interesting challenge :D [1]http://manalang.com/bdoc/rdoc/rcov-0.8.1.2.0/rdoc/classes/Rcov/CallSiteAnalyzer.html Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From cwdinfo at gmail.com Sun Apr 12 15:24:51 2009 From: cwdinfo at gmail.com (s.ross) Date: Sun, 12 Apr 2009 12:24:51 -0700 Subject: [rspec-users] How to Spec a Web Services Client Message-ID: I put a pastie out at http://pastie.org/444424, which is an implementation (short) of an XML-RPC client. I'm getting wrapped around an axle trying to figure out how to spec this without actually hitting the remote server. Is the best way to do this stubbing out the xml-rpc :call method to return known good or bad results to get the network out of the mix? Any thoughts are much appreciated! Thanks. From sfeley at gmail.com Sun Apr 12 16:03:50 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sun, 12 Apr 2009 16:03:50 -0400 Subject: [rspec-users] How to Spec a Web Services Client In-Reply-To: References: Message-ID: <1fb4df0904121303l6f16a9d2tfbce4e45382244ad@mail.gmail.com> On Sun, Apr 12, 2009 at 3:24 PM, s.ross wrote: > I put a pastie out at http://pastie.org/444424, which is an implementation > (short) of an XML-RPC client. I'm getting wrapped around an axle trying to > figure out how to spec this without actually hitting the remote server. I just had the same challenge with a SOAP client I'm building that hits a fairly complicated service. My solution was to generate a dummy SOAP server that accepts the right calls and returns the right kinds of dummy answers. Since I used the wsdl2ruby script (part of the soap4r gem) to create a client skeleton from the WSDL file, creating a server skeleton was just another command line. I added a few lines to spec_helper.rb to start the server and override the client code's service URL, and now I just fill out the return values from the server methods as part of writing my specs for each feature. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Sun Apr 12 16:23:40 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sun, 12 Apr 2009 16:23:40 -0400 Subject: [rspec-users] How to Spec a Web Services Client In-Reply-To: <1fb4df0904121303l6f16a9d2tfbce4e45382244ad@mail.gmail.com> References: <1fb4df0904121303l6f16a9d2tfbce4e45382244ad@mail.gmail.com> Message-ID: <1fb4df0904121323h73a620byf2e6c1d1d04e2b01@mail.gmail.com> On Sun, Apr 12, 2009 at 4:03 PM, Stephen Eley wrote: > > I just had the same challenge with a SOAP client I'm building that > hits a fairly complicated service. ?My solution was to generate a > dummy SOAP server that accepts the right calls and returns the right > kinds of dummy answers. Oh -- I forgot to mention. I haven't done this yet, but part of my plan is also to build a switch into my Cucumber env.rb file so that I can flip between using my dummy server and the real remote Web service for feature runs. Hitting their API constantly with tests during my development cycle is an unfriendly act, but if I never run my integration tests against it at all, I'm not proving what actually matters. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From cwdinfo at gmail.com Sun Apr 12 16:43:50 2009 From: cwdinfo at gmail.com (s.ross) Date: Sun, 12 Apr 2009 13:43:50 -0700 Subject: [rspec-users] [rspec] How to Spec a Web Services Client In-Reply-To: <1fb4df0904121303l6f16a9d2tfbce4e45382244ad@mail.gmail.com> References: <1fb4df0904121303l6f16a9d2tfbce4e45382244ad@mail.gmail.com> Message-ID: Thanks. I think instead of a server, I'll need to dive into replacing the results of XmlRpc::Client#call unless there's some ultra-cool way I haven't thought of. Steve On Apr 12, 2009, at 1:03 PM, Stephen Eley wrote: > On Sun, Apr 12, 2009 at 3:24 PM, s.ross wrote: >> I put a pastie out at http://pastie.org/444424, which is an >> implementation >> (short) of an XML-RPC client. I'm getting wrapped around an axle >> trying to >> figure out how to spec this without actually hitting the remote >> server. > > I just had the same challenge with a SOAP client I'm building that > hits a fairly complicated service. My solution was to generate a > dummy SOAP server that accepts the right calls and returns the right > kinds of dummy answers. Since I used the wsdl2ruby script (part of > the soap4r gem) to create a client skeleton from the WSDL file, > creating a server skeleton was just another command line. I added a > few lines to spec_helper.rb to start the server and override the > client code's service URL, and now I just fill out the return values > from the server methods as part of writing my specs for each feature. From dchelimsky at gmail.com Sun Apr 12 17:20:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 12 Apr 2009 18:20:11 -0300 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> Message-ID: <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> On Sun, Apr 12, 2009 at 12:32 PM, Phlip wrote: >> The third alternative is you never _need_ to mock, yet both your tests and >> target code are highly decoupled. _That_ is the goal. > > Another tip: To TDD a new feature, don't clone a high-level test which calls > code which calls code which calls the code you need to change. FWIW, what you propose is the exact opposite of BDD, which suggests we start at the highest levels and work our way in. How can you know what the lowest level code is supposed to do before you have higher level code invoking it? You can certainly make good guesses, and they might end up being good choices in the end, but they tend to bind you to a pre-determined design. Your recommendation also starts with cloning a pre-existing example, so I'm assuming this is a very specific sort of situation, where you have a certain amount of code in place. What about when you are starting a project for the first time? David > Start by cloning the lowest level test possible. If there is none, write > one. And if the test still wouldn't be low level enough, start by > refactoring the line you need to change, to pull it out into a method you > can test directly. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Apr 12 17:36:56 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 12 Apr 2009 18:36:56 -0300 Subject: [rspec-users] [cucumber] Cucumber and restful_authentication In-Reply-To: References: <57c63afe0904100014h4eddc662r6ab4a2bf4213c9bc@mail.gmail.com> Message-ID: <57c63afe0904121436w5cd0958bo8f10cc5d67473bec@mail.gmail.com> On Sat, Apr 11, 2009 at 8:04 PM, Tadatoshi Takahashi wrote: > David Chelimsky wrote: >> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi >> wrote: >>> what to do. >>> ?User.create!( :first_name => 'quire', >>> >>> map.login '/login', :controller => 'sessions', :action => 'new' >>> >>> Without login_required and the step above, the Cucumber scenario was >>> successfully run. But after I put login_required and the step above, >>> Cucumber cannot locate a field (its value is filled in text field). >> >> Where are you putting login_required? > > Hi, David. > > I am sorry for the late reply. > > The login_required I put is actually before_filter in the controller, > e.g. > before_filter :login_required. > Basically, if I disabled restful_authentication by commenting it out, > all the steps in Cucumber passed. But when I enabled it (putting the > before_filter above), Cucumber failed at one step. > > I don't necessary have a time to dig into the codes inside Cucumber and > RSpec. So if there is a code that works, I would like to just use it and > continue with Behaviour-Driven Development. I haven't personally set up any apps with restful_authentication and Cucumber. Is there anybody else on this who has who can help Tadatoshi out? > > Thank you. > > Tadatoshi > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Sun Apr 12 18:17:37 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 12 Apr 2009 16:17:37 -0600 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> <078980A3-849B-49B1-884F-2D91F77829ED@mattwynne.net> <49E20A29.6000805@benmabey.com> Message-ID: <49E26881.4090508@benmabey.com> Matt Wynne wrote: > > On 12 Apr 2009, at 16:35, Ben Mabey wrote: > >> Matt Wynne wrote: >>> >>> On 11 Apr 2009, at 01:07, James Byrne wrote: >>> >>>> http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html >>>> >>> >>> Great job with the talk Ben, it's a really good intro to Cucumber >>> and I will be pointing anyone who asks towards it. >>> >>> One question about the kitten-killing. I was surprised that defining >>> methods in your env / step_definition files adds methods to *every >>> instance* of Object. I thought it just added those methods to the >>> particular instance of Object that's used to create the World. >>> >>> Did I misunderstand the you in the talk, or misunderstand the code >>> in Cucumber? >>> >> Well, the step definitions themselves don't add themselves to every >> instance. The Given, When, and Then methods have actually killed >> some kittens and already live on Object (sometimes it is okay). The >> step methods will register the passed in blocks to the StepMother-- >> not onto Object. So if that is what you are referring to you are >> correct. >> >> However, if you want to create a ruby helper method then you will >> need to wrap it in a module to prevent to from being added to every >> object instance. In my example I had something like: >> >> def login_as(user) >> visit '/login' >> fill_in 'Email', :with => user.email >> fill_in 'Password', :with => 'password' >> click_button >> end >> >> If you place that method in the top-level in either your env.rb or >> any step files it is going to be living on Object since Cucumber will >> load up these files as any other ruby file. So you could call >> #login_as on an Array or any other object! Definitely not what we >> want. So, you need to wrap it in a module and use the World hook to >> make the helper methods available only in your World (which you get a >> new one for every scenario). With the new World syntax (as of 0.2.3 >> I believe) it would be: >> >> module UserHelpers >> def login_as(user) >> visit '/login' >> fill_in 'Email', :with => user.email >> fill_in 'Password', :with => 'password' >> click_button >> end >> end >> >> World(UserHelpers) >> >> I feel like I may of just repeated what I said in the presentation... >> so you still may be just as confused. :/ Let me know if that helps >> to clarify things or what part of it is confusing. > > Yeah you did, but I think you've made me realise something obvious: > there's a difference between the ruby you write in the env and step > matchers, and the ruby you write *inside* the step matchers. It's the > later that gets evaluated in the context of the World instance, the > former that gets evaluated in the root namespace. > > Right? Correct. -Ben From ben at benmabey.com Sun Apr 12 18:21:02 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 12 Apr 2009 16:21:02 -0600 Subject: [rspec-users] [cucumber] Cucumber and restful_authentication In-Reply-To: <57c63afe0904121436w5cd0958bo8f10cc5d67473bec@mail.gmail.com> References: <57c63afe0904100014h4eddc662r6ab4a2bf4213c9bc@mail.gmail.com> <57c63afe0904121436w5cd0958bo8f10cc5d67473bec@mail.gmail.com> Message-ID: <49E2694E.30106@benmabey.com> David Chelimsky wrote: > On Sat, Apr 11, 2009 at 8:04 PM, Tadatoshi Takahashi > wrote: > >> David Chelimsky wrote: >> >>> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi >>> wrote: >>> >>>> what to do. >>>> ?User.create!( :first_name => 'quire', >>>> >>>> map.login '/login', :controller => 'sessions', :action => 'new' >>>> >>>> Without login_required and the step above, the Cucumber scenario was >>>> successfully run. But after I put login_required and the step above, >>>> Cucumber cannot locate a field (its value is filled in text field). >>>> >>> Where are you putting login_required? >>> >> Hi, David. >> >> I am sorry for the late reply. >> >> The login_required I put is actually before_filter in the controller, >> e.g. >> before_filter :login_required. >> Basically, if I disabled restful_authentication by commenting it out, >> all the steps in Cucumber passed. But when I enabled it (putting the >> before_filter above), Cucumber failed at one step. >> >> I don't necessary have a time to dig into the codes inside Cucumber and >> RSpec. So if there is a code that works, I would like to just use it and >> continue with Behaviour-Driven Development. >> > > I haven't personally set up any apps with restful_authentication and > Cucumber. Is there anybody else on this who has who can help Tadatoshi > out? > > I have not used Cucumber with restful_auth. However, on the 'Related Tools' page[1] on the wiki there are several links to projects that deal with Cucumber and authentication. One of them is a sample app, by Andrew Premdas, using cucumber with restful_auth: http://github.com/diabolo/fbrp/tree/master You might learn something by looking at that codebase. HTH, Ben 1. http://wiki.github.com/aslakhellesoy/cucumber/related-tools From ben at benmabey.com Sun Apr 12 18:51:50 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 12 Apr 2009 16:51:50 -0600 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> Message-ID: <49E27086.5000208@benmabey.com> Stephen Eley wrote: > On Sat, Apr 11, 2009 at 2:02 PM, Ashley Moran > wrote: > >> I was just idly thinking, could a code-coverage based system could be >> combined with some sort of failure (fragility) history to balance the time >> cost of heavy feature runs with the benefits of having something run >> end-to-end? We've had reverse-modification-time spec ordering for ages >> which is a useful start. >> > > I've had it in my head for a while now that someday (yes, that > mythical 'someday') I want to write a better autotest. Maybe this is > heresy, but I am a huge fan of the _idea_ behind autotest and totally > annoyed by its implementation. It's extensible only in strange ways > (hence wrappers like autospec), and its fundamental strategy is too > static. I once lost most of a day trying to fix merb_cucumber so the > features would run when they should, and was ready to hurl cats when I > realized autotest's idea of context chaining was to make you list them > all in the classname in alphabetical order. Look at the files in the > Cucumber gem's 'lib/autotest' directory and you'll see what I mean. > > A proper design would let you plug in your own file-change discovery > strategy, plug in multiple runners (RSpec, Cucumber, yadda yadda) with > true modularity, specify lists of observers on directories or files, > and allow different output views. An _ideal_ design would also let > you set priority rules like you're describing here, so you get instant > feedback only on the stuff you're working with, and do end-to-end runs > in the background. > That would be very cool, you have lots of good ideas there. Being able to plug in your own file-change strategy would be killer. Another cool idea I ran across the other idea is being able to specify in your examples that which ones are "focussed". Meaning, autotest will only run the focussed ones and not bother running the entire suite. Once you have solved the problem at hand you remove the focussed tag and the whole suite is then ran. This idea, *which is already implemented*, comes from Micronaut[1]. The idea is very similar to Cucumber's and RSpec's[2] tagging feature (yet to come for rspec). The cool thing about micronaunt is that they have tied it into autotest. Ideally, we could be able to tell autotest, or whatever program, to only run tests that are tagged a certain way-- and then you could override that with the "focused" tag. So, we can add that to our list of cool things to have. :) -Ben 1. http://blog.thinkrelevance.com/2009/3/26/introducing-micronaut-a-lightweight-bdd-framework 2. https://rspec.lighthouseapp.com/projects/5645/tickets/682-conditional-exclusion-of-example-groups From phlip2005 at gmail.com Sun Apr 12 20:23:45 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 12 Apr 2009 17:23:45 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> Message-ID: David Chelimsky wrote: >> Another tip: To TDD a new feature, don't clone a high-level test which calls >> code which calls code which calls the code you need to change. > > FWIW, what you propose is the exact opposite of BDD, which suggests we > start at the highest levels and work our way in. My current day-job's most important project has a test suite that suffered from abuse of that concept. The original team, without enough refactoring, were cloning and modifying very-high-level tests, making them longer, and using them to TDD new features into the bottom of the models layer. Don't do that. > How can you know what the lowest level code is supposed to do before > you have higher level code invoking it? You can certainly make good > guesses, and they might end up being good choices in the end, but they > tend to bind you to a pre-determined design. That sounds like James Kanze's over-educated arguments against TDD: > Phlip wrote: >> James Kanze wrote: >> > In particular, you can't >> > write a single line of code (unit test or implementation) before >> > you know what the function should do, > >> I didn't bring up TDD, but if you are curious enough about it >> to keep asking these entry-level FAQs, > > I'm not asking anything. I'm simply stating an easily > established fact, which wishful thinking seems to cause some > people to ignore. Tests definitly have their role, but until > you know what the code should do, you can't begin to write them. > And until you've written something down in black and white, you > don't know it. From there, he'll wander off into "too smart to just try it" bullshit... > Your recommendation also starts with cloning a pre-existing example, > so I'm assuming this is a very specific sort of situation, where you > have a certain amount of code in place. What about when you are > starting a project for the first time? Programming bottom-up gives you decoupled lower layers. Top-down gives you a way to tunnel from a new View feature into the code that supports it. The goal is you _could_ start a new feature either way, and you get the benefits of both techniques. I thought of describing that specific tip while adding "any!" to assert_xhtml. It would have been too easy to start with the high-level tests: def test_anybang_is_magic assert_xhtml SAMPLE_LIST do ul.kalika do any! 'Billings report' end end assert_xhtml_flunk SAMPLE_LIST do without! do any! 'Billings report' end end end Some of my features indeed started there, and some of them indeed do not yet have low-level tests. But the entire call stack below that also at least has tests on each layer - except the actual code which converts a tag like select! into the fragment of XPath which matches //select[]. Oh, and that code around it had grown a little long. So in this case, I started there, and refactored out the single line that needed the change: def translate_tag(element) element.name.sub(/\!$/, '') end Then I can TDD translate_tag directly: def test_any_element bhw = assemble_BeHtmlWith{ any :attribute => 'whatever' } element = bhw.builder.doc.root assert{ bhw.translate_tag(element) == 'any' } bhw = assemble_BeHtmlWith{ any! :attribute => 'whatever' } element = bhw.builder.doc.root assert{ bhw.translate_tag(element) == '*' } end ... def translate_tag(element) if element.name == 'any!' '*' else element.name.sub(/\!$/, '') end end Only then I wrote the high-level tests, and they passed. Note that RSpec requires the constructor to BeHtmlWith to be a little ... fruity, so I wrapped it and its Builder stuff up into assemble_BeHtmlWith... -- Phlip From programmer2188 at gmail.com Sun Apr 12 21:15:21 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 12 Apr 2009 21:15:21 -0400 Subject: [rspec-users] Custom matcher, use other helpers and matchers from rspec-rails Message-ID: <000001c9bbd5$520c8470$f6258d50$@com> Hi, I am creating an improved version of route_for that is more intuitive to me. However, I keep getting NoMethodError exceptions, so am trying to find all the includes I have to put into my class. What's the best way to import the necessary classes to use rspec-rails assertions and helpers? Brandon From dchelimsky at gmail.com Sun Apr 12 21:27:26 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 12 Apr 2009 22:27:26 -0300 Subject: [rspec-users] Custom matcher, use other helpers and matchers from rspec-rails In-Reply-To: <000001c9bbd5$520c8470$f6258d50$@com> References: <000001c9bbd5$520c8470$f6258d50$@com> Message-ID: <57c63afe0904121827kc5353c0s3db534053667c887@mail.gmail.com> On Sun, Apr 12, 2009 at 10:15 PM, Brandon Olivares wrote: > Hi, > > I am creating an improved version of route_for that is more intuitive to me. > However, I keep getting NoMethodError exceptions, so am trying to find all > the includes I have to put into my class. > > What's the best way to import the necessary classes to use rspec-rails > assertions and helpers? There's not really a single mechanism for that at this point because rspec-rails isn't really designed to be the basis for extensions of itself. Can you be more specific about which methods are not being found? Are they all from rspec-rails? Are some from rails directly? > > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Sun Apr 12 21:35:21 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 12 Apr 2009 21:35:21 -0400 Subject: [rspec-users] Custom matcher, use other helpers and matchers from rspec-rails In-Reply-To: <57c63afe0904121827kc5353c0s3db534053667c887@mail.gmail.com> References: <000001c9bbd5$520c8470$f6258d50$@com> <57c63afe0904121827kc5353c0s3db534053667c887@mail.gmail.com> Message-ID: <000001c9bbd8$1d844eb0$588cec10$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Sunday, April 12, 2009 9:27 PM > To: rspec-users > Subject: Re: [rspec-users] Custom matcher, use other helpers and > matchers from rspec-rails > > There's not really a single mechanism for that at this point because > rspec-rails isn't really designed to be the basis for extensions of > itself. > > Can you be more specific about which methods are not being found? Are > they all from rspec-rails? Are some from rails directly? > I can't remember everything, but first was route_for, so I included Spec::Rails::Example::RoutingHelpers. Then assert_recognizes, and I can't remember exactly what I included for that at first. Then clean_backtrace, and I found the module for that, then build_message. Then I gave up, and was trying to find a parent module that would just include all of that, because it doesn't make sense I'd have to include so many different things to make it work. Brandon > > > > Brandon > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Apr 12 22:05:18 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 12 Apr 2009 23:05:18 -0300 Subject: [rspec-users] Custom matcher, use other helpers and matchers from rspec-rails In-Reply-To: <000001c9bbd8$1d844eb0$588cec10$@com> References: <000001c9bbd5$520c8470$f6258d50$@com> <57c63afe0904121827kc5353c0s3db534053667c887@mail.gmail.com> <000001c9bbd8$1d844eb0$588cec10$@com> Message-ID: <57c63afe0904121905v37d8f630ya33d6bf913ddc244@mail.gmail.com> On Sun, Apr 12, 2009 at 10:35 PM, Brandon Olivares wrote: > > >> -----Original Message----- >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> bounces at rubyforge.org] On Behalf Of David Chelimsky >> Sent: Sunday, April 12, 2009 9:27 PM >> To: rspec-users >> Subject: Re: [rspec-users] Custom matcher, use other helpers and >> matchers from rspec-rails >> >> There's not really a single mechanism for that at this point because >> rspec-rails isn't really designed to be the basis for extensions of >> itself. >> >> Can you be more specific about which methods are not being found? Are >> they all from rspec-rails? Are some from rails directly? >> > > I can't remember everything, but first was route_for, so I included > Spec::Rails::Example::RoutingHelpers. Then assert_recognizes, and I can't > remember exactly what I included for that at first. Then clean_backtrace, > and I found the module for that, then build_message. > > Then I gave up, and was trying to find a parent module that would just > include all of that, because it doesn't make sense I'd have to include so > many different things to make it work. Yeah - unfortunately, you're kinda stuck with that for the moment cuz there is no parent module. :( > > Brandon > >> > >> > Brandon >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Apr 12 22:10:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 12 Apr 2009 23:10:49 -0300 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> Message-ID: <57c63afe0904121910t79baf60ata15b8b1d82bd4622@mail.gmail.com> On Sun, Apr 12, 2009 at 9:23 PM, Phlip wrote: > David Chelimsky wrote: > >>> Another tip: To TDD a new feature, don't clone a high-level test which >>> calls >>> code which calls code which calls the code you need to change. >> >> FWIW, what you propose is the exact opposite of BDD, which suggests we >> start at the highest levels and work our way in. > > My current day-job's most important project has a test suite that suffered > from abuse of that concept. Any concept can be abused. No reason to ignore its merits. Similarly, ideas that work well in one situation shouldn't be assumed to work well in all situations. It cuts both ways. > The original team, without enough refactoring, "without enough refactoring" suggests that the problem was the team, not the concept. No? > were cloning and modifying very-high-level tests, making them longer, and > using them to TDD new features into the bottom of the models layer. Don't do > that. > >> How can you know what the lowest level code is supposed to do before >> you have higher level code invoking it? You can certainly make good >> guesses, and they might end up being good choices in the end, but they >> tend to bind you to a pre-determined design. > > That sounds like James Kanze's over-educated arguments against TDD: > >> Phlip wrote: >>> >>> James Kanze wrote: >>> > In particular, you can't >>> > write a single line of code (unit test or implementation) before >>> > you know what the function should do, >> >>> I didn't bring up TDD, but if you are curious enough about it >>> to keep asking these entry-level FAQs, >> >> I'm not asking anything. ?I'm simply stating an easily >> established fact, which wishful thinking seems to cause some >> people to ignore. ?Tests definitly have their role, but until >> you know what the code should do, you can't begin to write them. >> And until you've written something down in black and white, you >> don't know it. > > From there, he'll wander off into "too smart to just try it" bullshit... > >> Your recommendation also starts with cloning a pre-existing example, >> so I'm assuming this is a very specific sort of situation, where you >> have a certain amount of code in place. What about when you are >> starting a project for the first time? > > Programming bottom-up gives you decoupled lower layers. Top-down gives you a > way to tunnel from a new View feature into the code that supports it. I don't think these are mutually exclusive. You can develop decoupled layers driving from the outside-in. And when you do, the inner layers, which serve the needs of the outer layers, tend to be more focused on that responsibility than if you start with the inner layers because you're not guessing what you'll need, you're satisfying an existing need. > The > goal is you _could_ start a new feature either way, and you get the benefits > of both techniques. > > I thought of describing that specific tip while adding "any!" to > assert_xhtml. It would have been too easy to start with the high-level > tests: > > ?def test_anybang_is_magic > ? ?assert_xhtml SAMPLE_LIST do > ? ? ?ul.kalika do > ? ? ? ?any! 'Billings report' > ? ? ?end > ? ?end > > ? ?assert_xhtml_flunk SAMPLE_LIST do > ? ? ?without! do > ? ? ? ?any! 'Billings report' > ? ? ?end > ? ?end > ?end > > Some of my features indeed started there, and some of them indeed do not yet > have low-level tests. > > But the entire call stack below that also at least has tests on each layer - > except the actual code which converts a tag like select! into the fragment > of XPath which matches //select[]. Oh, and that code around it had grown a > little long. So in this case, I started there, and refactored out the single > line that needed the change: > > ?def translate_tag(element) > ? ?element.name.sub(/\!$/, '') > ?end > > Then I can TDD translate_tag directly: > > ?def test_any_element > ? ?bhw = assemble_BeHtmlWith{ any :attribute => 'whatever' } > ? ?element = bhw.builder.doc.root > ? ?assert{ bhw.translate_tag(element) == 'any' } > ? ?bhw = assemble_BeHtmlWith{ any! :attribute => 'whatever' } > ? ?element = bhw.builder.doc.root > ? ?assert{ bhw.translate_tag(element) == '*' } > ?end > > ... > > ?def translate_tag(element) > ? ?if element.name == 'any!' > ? ? ?'*' > ? ?else > ? ? ?element.name.sub(/\!$/, '') > ? ?end > ?end > > Only then I wrote the high-level tests, and they passed. >From what I'm reading, this seems like a very specific situation you're describing in which you did, in fact, start from the outside-in. The lower level test you added was the result of refactoring, which seems perfectly reasonable to me. But I'm not seeing how this applies as a general all-purpose guideline. What am I missing? > > Note that RSpec requires the constructor to BeHtmlWith to be a little ... > fruity Huh? RSpec does not construct matcher instances for you, so how is it enforcing any constructor restrictions, fruity or otherwise? > so I wrapped it and its Builder stuff up into assemble_BeHtmlWith... > > -- > ?Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Sun Apr 12 22:36:50 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 12 Apr 2009 22:36:50 -0400 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> Message-ID: <85d99afe0904121936v193d9f8ew633b45188229ee84@mail.gmail.com> On Sun, Apr 12, 2009 at 8:23 PM, Phlip wrote: > David Chelimsky wrote: > >>> Another tip: To TDD a new feature, don't clone a high-level test which >>> calls >>> code which calls code which calls the code you need to change. >> >> FWIW, what you propose is the exact opposite of BDD, which suggests we >> start at the highest levels and work our way in. > > My current day-job's most important project has a test suite that suffered > from abuse of that concept. The original team, without enough refactoring, > were cloning and modifying very-high-level tests, making them longer, and > using them to TDD new features into the bottom of the models layer. Don't do > that. This sounds like an issue with the team. > >> How can you know what the lowest level code is supposed to do before >> you have higher level code invoking it? You can certainly make good >> guesses, and they might end up being good choices in the end, but they >> tend to bind you to a pre-determined design. > > That sounds like James Kanze's over-educated arguments against TDD: > >> Phlip wrote: >>> >>> James Kanze wrote: >>> > In particular, you can't >>> > write a single line of code (unit test or implementation) before >>> > you know what the function should do, >> >>> I didn't bring up TDD, but if you are curious enough about it >>> to keep asking these entry-level FAQs, >> >> I'm not asking anything. ?I'm simply stating an easily >> established fact, which wishful thinking seems to cause some >> people to ignore. ?Tests definitly have their role, but until >> you know what the code should do, you can't begin to write them. >> And until you've written something down in black and white, you >> don't know it. > > From there, he'll wander off into "too smart to just try it" bullshit... > >> Your recommendation also starts with cloning a pre-existing example, >> so I'm assuming this is a very specific sort of situation, where you >> have a certain amount of code in place. What about when you are >> starting a project for the first time? > > Programming bottom-up gives you decoupled lower layers. Top-down gives you a > way to tunnel from a new View feature into the code that supports it. The > goal is you _could_ start a new feature either way, and you get the benefits > of both techniques. Having done both for a few years each, in my experience I've found that outside-in gives me better decoupled layers, where each layer is more focused on its responsibility. Inside-out usually leaked a lot of things into outer layers, because as I was building out I was making assumptions on what I was going to need. Individually, each thing that leaked was small and manageable, but a few weeks, and months later, all of those little manageable oddities now may the code base hell to work with, slowing down progress and making it much harder for new devs to get ramped up. I have worked bottom-up with Java and Ruby, and I've shipped those apps. Not all of them were webapps either. IME, the bottom up approach works. But after sharpening my outside-in skills, I have found it to be all around much better development approach for the apps that I deliver. > > I thought of describing that specific tip while adding "any!" to > assert_xhtml. It would have been too easy to start with the high-level > tests: > > ?def test_anybang_is_magic > ? ?assert_xhtml SAMPLE_LIST do > ? ? ?ul.kalika do > ? ? ? ?any! 'Billings report' > ? ? ?end > ? ?end > > ? ?assert_xhtml_flunk SAMPLE_LIST do > ? ? ?without! do > ? ? ? ?any! 'Billings report' > ? ? ?end > ? ?end > ?end > > Some of my features indeed started there, and some of them indeed do not yet > have low-level tests. > > But the entire call stack below that also at least has tests on each layer - > except the actual code which converts a tag like select! into the fragment > of XPath which matches //select[]. Oh, and that code around it had grown a > little long. So in this case, I started there, and refactored out the single > line that needed the change: > > ?def translate_tag(element) > ? ?element.name.sub(/\!$/, '') > ?end > > Then I can TDD translate_tag directly: > > ?def test_any_element > ? ?bhw = assemble_BeHtmlWith{ any :attribute => 'whatever' } > ? ?element = bhw.builder.doc.root > ? ?assert{ bhw.translate_tag(element) == 'any' } > ? ?bhw = assemble_BeHtmlWith{ any! :attribute => 'whatever' } > ? ?element = bhw.builder.doc.root > ? ?assert{ bhw.translate_tag(element) == '*' } > ?end > > ... > > ?def translate_tag(element) > ? ?if element.name == 'any!' > ? ? ?'*' > ? ?else > ? ? ?element.name.sub(/\!$/, '') > ? ?end > ?end > > Only then I wrote the high-level tests, and they passed. > > Note that RSpec requires the constructor to BeHtmlWith to be a little ... > fruity, so I wrapped it and its Builder stuff up into assemble_BeHtmlWith... > > -- > ?Phlip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From sfeley at gmail.com Sun Apr 12 23:25:51 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sun, 12 Apr 2009 23:25:51 -0400 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <3e21ad60904121547m564ea84bqace0834773e8e6ed@mail.gmail.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <3e21ad60904121547m564ea84bqace0834773e8e6ed@mail.gmail.com> Message-ID: <1fb4df0904122025h6a0f0f8ay3d3304e7f261234c@mail.gmail.com> On Sun, Apr 12, 2009 at 6:47 PM, Steve Molitor wrote: > Regarding the exception nagger, ?would a simple script that grepped the log > file for exceptions and produced a list of failing lines in your code be a > start? Hi Steve, I think so. If it said which class-or-module and method they were defined in (almost always determinable by backwards regexing) even better. Then a dimwit like me could just glance at it and say "Oh, duh! I forgot to spec Planet.destroy!" Also I must confess: after I sent that last e-mail, it occurred to me why a past-exception-based coverage tool wouldn't work very well in the long term. It'd be fine for immediate use, but if you didn't do the specs right away, the code would evolve and the line numbers of those old exceptions would slowly go out of sync with current reality. Since the only reasonable answer to that is "When something breaks, write a test for it _immediately_ to catch it next time" I'd say the simpler script you're talking about is probably close to ideal. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From phlip2005 at gmail.com Sun Apr 12 23:27:56 2009 From: phlip2005 at gmail.com (Phlip) Date: Sun, 12 Apr 2009 20:27:56 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: <85d99afe0904121936v193d9f8ew633b45188229ee84@mail.gmail.com> References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> <85d99afe0904121936v193d9f8ew633b45188229ee84@mail.gmail.com> Message-ID: Zach Dennis wrote: >> My current day-job's most important project has a test suite that suffered >> from abuse of that concept. The original team, without enough refactoring, >> were cloning and modifying very-high-level tests, making them longer, and >> using them to TDD new features into the bottom of the models layer. Don't do >> that. > > This sounds like an issue with the team. And yet they didn't abuse mocks. (-: From pat.maddox at gmail.com Mon Apr 13 00:56:48 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Sun, 12 Apr 2009 21:56:48 -0700 Subject: [rspec-users] Mocking: brittle specs and tight coupling? In-Reply-To: References: <000301c9baf9$31ec69d0$95c53d70$@com> <51DA7D4D-87CB-448A-8E61-29C7FF0AFE6D@patchspace.co.uk> <57c63afe0904121420k460be963v699acec77b68d06c@mail.gmail.com> <85d99afe0904121936v193d9f8ew633b45188229ee84@mail.gmail.com> Message-ID: <2c7e61990904122156v6c39be03y865b88c668763397@mail.gmail.com> On Sun, Apr 12, 2009 at 8:27 PM, Phlip wrote: > My current day-job's most important project has a test suite that suffered from abuse of that concept. The original team, without enough refactoring Would you have called it abuse were the tests well-factored? I don't think it was abuse of acceptance tdd, or outside-in, or mocks, or any other concept that caused them suffering. You're always going to end up fucking yourself if you don't refactor. Pat From ben at benmabey.com Mon Apr 13 02:31:36 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 13 Apr 2009 00:31:36 -0600 Subject: [rspec-users] Cucumber - Recommended viewing. In-Reply-To: <8d961d900904122256o56a0b76cj32b96306e8bb8016@mail.gmail.com> References: <218f7b0ace2c0f651cd4db4f0f311491@ruby-forum.com> <078980A3-849B-49B1-884F-2D91F77829ED@mattwynne.net> <49E20A29.6000805@benmabey.com> <8d961d900904122256o56a0b76cj32b96306e8bb8016@mail.gmail.com> Message-ID: <49E2DC48.9080405@benmabey.com> aslak hellesoy wrote: > > > On Sun, Apr 12, 2009 at 5:35 PM, Ben Mabey > wrote: > > Matt Wynne wrote: > > > On 11 Apr 2009, at 01:07, James Byrne wrote: > > http://mwrc2009.confreaks.com/14-mar-2009-15-00-bdd-with-cucumber-ben-mabey.html > > > > Great job with the talk Ben, it's a really good intro to > Cucumber and I will be pointing anyone who asks towards it. > > One question about the kitten-killing. I was surprised that > defining methods in your env / step_definition files adds > methods to *every instance* of Object. I thought it just added > those methods to the particular instance of Object that's used > to create the World. > > Did I misunderstand the you in the talk, or misunderstand the > code in Cucumber? > > Well, the step definitions themselves don't add themselves to > every instance. The Given, When, and Then methods have actually > killed some kittens and already live on Object (sometimes it is > okay). The step methods will register the passed in blocks to the > StepMother-- not onto Object. So if that is what you are > referring to you are correct. > > > This isn't exactly how it works. The Given, When, Then methods (and a > few others) are defined in the Cucumber::StepMother module. This > module is extended by the Ruby top level object, which is a single > instance. Object is not altered. Here is an interesting discussion > about it: > http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/7b023b23385241c7?pli=1 Interesting.. I knew that the methods started out in Cucumber::StepMother but I thought they had to be added to every instance of Object to exhibit the behaviour that they do. That makes even more sense now-- and it is a very nice technique to know about! Thanks for clearing up that misunderstanding. -Ben > > > > > However, if you want to create a ruby helper method then you will > need to wrap it in a module to prevent to from being added to > every object instance. In my example I had something like: > > def login_as(user) > visit '/login' > fill_in 'Email', :with => user.email > fill_in 'Password', :with => 'password' > click_button > end > > If you place that method in the top-level in either your env.rb or > any step files it is going to be living on Object since Cucumber > will load up these files as any other ruby file. So you could > call #login_as on an Array or any other object! Definitely not > what we want. So, you need to wrap it in a module and use the > World hook to make the helper methods available only in your World > (which you get a new one for every scenario). With the new World > syntax (as of 0.2.3 I believe) it would be: > > module UserHelpers > def login_as(user) > visit '/login' > fill_in 'Email', :with => user.email > fill_in 'Password', :with => 'password' > click_button > end > end > > World(UserHelpers) > > I feel like I may of just repeated what I said in the > presentation... so you still may be just as confused. :/ Let me > know if that helps to clarify things or what part of it is confusing. > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From programmer2188 at gmail.com Mon Apr 13 03:19:21 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Mon, 13 Apr 2009 03:19:21 -0400 Subject: [rspec-users] Passing self to matchers Message-ID: <000001c9bc08$2bbaea40$8330bec0$@com> Hi, I've noticed in several matchers that the matcher method passes self to the constructor of the class. Then that's used to call several of the methods used. For instance, in RouteFor, self is passed, and it is used to call assert_recognizes. I'm just curious why this is, and when this is required. Brandon From kero at chello.nl Mon Apr 13 05:31:39 2009 From: kero at chello.nl (Kero van Gelder) Date: Mon, 13 Apr 2009 11:31:39 +0200 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <49E27086.5000208@benmabey.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <49E27086.5000208@benmabey.com> Message-ID: <20090413093139.GA5586@bumblebee.m38c.nl> > That would be very cool, you have lots of good ideas there. Being able > to plug in your own file-change strategy would be killer. Another cool > idea I ran across the other idea is being able to specify in your > examples that which ones are "focussed". Meaning, autotest will only > run the focussed ones and not bother running the entire suite. Once you > have solved the problem at hand you remove the focussed tag and the > whole suite is then ran. This idea, *which is already implemented*, > comes from Micronaut[1]. The idea is very similar to Cucumber's and > RSpec's[2] tagging feature (yet to come for rspec). The cool thing > about micronaunt is that they have tied it into autotest. Ideally, we > could be able to tell autotest, or whatever program, to only run tests > that are tagged a certain way-- and then you could override that with > the "focused" tag. So, we can add that to our list of cool things to > have. :) Are you saying you want multiple tags and let autotest do logic on them? - run everything "focus and current_feature" - run everything "current_feature or related_to_it" Or are you saying you should explicitely specified which test went wrong (would it be nice if autotest just ran all your recently failed features first and the rest later; compared to the last failure only, as it is supposed to do now, afaik; perhaps after running previously failed features, it can run newest features first, finally followed by the other features). Or are you saying it's going to be separate from tags completely? I'm feeling my first idea will run out of hand (adding complexity, while not solving a specific need), the third sounds bad from a technical Point of view. The second one comes from the observation that "focussing" is a process, not a property. You state "you remove the focussed tag" yourself. "important" could be a property, if you don't remove it. Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From dchelimsky at gmail.com Mon Apr 13 06:39:18 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 07:39:18 -0300 Subject: [rspec-users] Passing self to matchers In-Reply-To: <000001c9bc08$2bbaea40$8330bec0$@com> References: <000001c9bc08$2bbaea40$8330bec0$@com> Message-ID: <57c63afe0904130339q6d7066d0ia159722d7583f627@mail.gmail.com> On Mon, Apr 13, 2009 at 4:19 AM, Brandon Olivares wrote: > Hi, > > I've noticed in several matchers that the matcher method passes self to the > constructor of the class. Then that's used to call several of the methods > used. For instance, in RouteFor, self is passed, and it is used to call > assert_recognizes. > > I'm just curious why this is, and when this is required. Because assert_recognizes is defined in the context of the example, not inside the scope of the matcher. This is only necessary in such cases that helper methods are outside the matcher itself. HTH, David > > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Apr 13 11:06:47 2009 From: lists at ruby-forum.com (Salil Gaikwad) Date: Mon, 13 Apr 2009 17:06:47 +0200 Subject: [rspec-users] how to write a spec for an actionmailer method Message-ID: <6791588240fb9a0a46f6ea0d76728573@ruby-forum.com> how to write a spec for an actionmailer method. following is the method of action controller. class Notifier < ActionMailer::Base def conta(username ,adresseemail,code) @subject = 'Admin Confirmation Mail' @recipients = adresseemail @body["Username"]= username @body["adresseemail"]= adresseemail @body[:url] = "http://192.168.1.58:3002/login/activate/#{code}" @from ='anubhaw at cipher-tech.com' @sent_on = Time.now end end Regards Salil -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Apr 13 11:09:45 2009 From: lists at ruby-forum.com (Salil Gaikwad) Date: Mon, 13 Apr 2009 17:09:45 +0200 Subject: [rspec-users] How to write a spec file for a helper Message-ID: How to write a spec file for a following helper module ArtistsHelper def round_to(x) (self * 10**x).round.to_f / 10**x end end Regards salil -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Apr 13 11:14:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 12:14:37 -0300 Subject: [rspec-users] how to write a spec for an actionmailer method In-Reply-To: <6791588240fb9a0a46f6ea0d76728573@ruby-forum.com> References: <6791588240fb9a0a46f6ea0d76728573@ruby-forum.com> Message-ID: <57c63afe0904130814n3c818859i7c970a1049c444fe@mail.gmail.com> On Mon, Apr 13, 2009 at 12:06 PM, Salil Gaikwad wrote: > how to write a spec for an actionmailer method. Check out http://github.com/bmabey/email-spec/ Cheers, David > > following is the method of action controller. > > class Notifier < ActionMailer::Base > > ?def conta(username ,adresseemail,code) > ? ?@subject ?= 'Admin Confirmation Mail' > ? ?@recipients ?= adresseemail > ? ?@body["Username"]= username > ? ?@body["adresseemail"]= adresseemail > ? ?@body[:url] ?= "http://192.168.1.58:3002/login/activate/#{code}" > ? ?@from ? ? ? ? ? ? ?='anubhaw at cipher-tech.com' > ? ?@sent_on ? ? ? ? = ?Time.now > ?end > > end > > Regards > > Salil > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Apr 13 11:17:39 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 12:17:39 -0300 Subject: [rspec-users] How to write a spec file for a helper In-Reply-To: References: Message-ID: <57c63afe0904130817y762b405dkc9a5c72efb8b6068@mail.gmail.com> On Mon, Apr 13, 2009 at 12:09 PM, Salil Gaikwad wrote: > How to write a spec file for a following helper > > module ArtistsHelper > > def round_to(x) > ? ?(self * 10**x).round.to_f / 10**x > end > > end in spec/helpers/artists_helper_spec.rb: describe AristsHelper do it "rounds to ...." do helper.round_to(xxx).should == yyy end end Cheers, David > > Regards > > salil > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Mon Apr 13 11:21:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 13 Apr 2009 09:21:14 -0600 Subject: [rspec-users] how to write a spec for an actionmailer method In-Reply-To: <57c63afe0904130814n3c818859i7c970a1049c444fe@mail.gmail.com> References: <6791588240fb9a0a46f6ea0d76728573@ruby-forum.com> <57c63afe0904130814n3c818859i7c970a1049c444fe@mail.gmail.com> Message-ID: <49E3586A.4030202@benmabey.com> David Chelimsky wrote: > On Mon, Apr 13, 2009 at 12:06 PM, Salil Gaikwad wrote: > >> how to write a spec for an actionmailer method. >> > > Check out http://github.com/bmabey/email-spec/ > > Cheers, > David > Specifically, look at this example for an idea on how to use it with RSpec: http://github.com/bmabey/email-spec/blob/cdf3eeda4d28ef8b35bbce8af9ca7c493528332d/examples/rails_root/spec/models/user_mailer_spec.rb -Ben > >> following is the method of action controller. >> >> class Notifier < ActionMailer::Base >> >> def conta(username ,adresseemail,code) >> @subject = 'Admin Confirmation Mail' >> @recipients = adresseemail >> @body["Username"]= username >> @body["adresseemail"]= adresseemail >> @body[:url] = "http://192.168.1.58:3002/login/activate/#{code}" >> @from ='anubhaw at cipher-tech.com' >> @sent_on = Time.now >> end >> >> end >> >> Regards >> >> Salil >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pat.maddox at gmail.com Mon Apr 13 11:26:27 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Mon, 13 Apr 2009 08:26:27 -0700 Subject: [rspec-users] How to write a spec file for a helper In-Reply-To: <57c63afe0904130817y762b405dkc9a5c72efb8b6068@mail.gmail.com> References: <57c63afe0904130817y762b405dkc9a5c72efb8b6068@mail.gmail.com> Message-ID: <2c7e61990904130826q7c9bd345yeab704c6240fe257@mail.gmail.com> On Mon, Apr 13, 2009 at 8:17 AM, David Chelimsky wrote: > On Mon, Apr 13, 2009 at 12:09 PM, Salil Gaikwad wrote: >> How to write a spec file for a following helper >> >> module ArtistsHelper >> >> def round_to(x) >> ? ?(self * 10**x).round.to_f / 10**x >> end >> >> end > > in spec/helpers/artists_helper_spec.rb: > > describe AristsHelper do > ?it "rounds to ...." do > ? ?helper.round_to(xxx).should == yyy > ?end > end That's what I was going to say, but I'm not sure that it's a Rails helper...the calculation rounds self. So I'm a bit confused. If this is a module that you're using to extend the behavior of Numeric classes, just mix it in somewhere and write examples for the class that got the mixin. Pat From ben at benmabey.com Mon Apr 13 11:39:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 13 Apr 2009 09:39:14 -0600 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <20090413093139.GA5586@bumblebee.m38c.nl> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <49E27086.5000208@benmabey.com> <20090413093139.GA5586@bumblebee.m38c.nl> Message-ID: <49E35CA2.60107@benmabey.com> Kero van Gelder wrote: >> That would be very cool, you have lots of good ideas there. Being able >> to plug in your own file-change strategy would be killer. Another cool >> idea I ran across the other idea is being able to specify in your >> examples that which ones are "focussed". Meaning, autotest will only >> run the focussed ones and not bother running the entire suite. Once you >> have solved the problem at hand you remove the focussed tag and the >> whole suite is then ran. This idea, *which is already implemented*, >> comes from Micronaut[1]. The idea is very similar to Cucumber's and >> RSpec's[2] tagging feature (yet to come for rspec). The cool thing >> about micronaunt is that they have tied it into autotest. Ideally, we >> could be able to tell autotest, or whatever program, to only run tests >> that are tagged a certain way-- and then you could override that with >> the "focused" tag. So, we can add that to our list of cool things to >> have. :) >> > > Are you saying you want multiple tags and let autotest do logic on them? > - run everything "focus and current_feature" > - run everything "current_feature or related_to_it" > > Or are you saying you should explicitely specified which test went wrong > (would it be nice if autotest just ran all your recently failed features > first and the rest later; compared to the last failure only, as it is > supposed to do now, afaik; perhaps after running previously failed > features, it can run newest features first, finally followed by the other > features). > > The way micronaut currently works is that when you tag an example or example group as "focussed" autotest will only run those. So you are overriding it's default behaviour and not running the entire suite. > Or are you saying it's going to be separate from tags completely? > > I'm feeling my first idea will run out of hand (adding complexity, > while not solving a specific need), the third sounds bad from a > technical Point of view. The second one comes from the observation > that "focussing" is a process, not a property. You state > "you remove the focussed tag" > yourself. "important" could be a property, if you don't remove it. > Yeah, it is a process and that is what I like about it. When working on a large suite it is impractical to run the entire suite in conjunction with autotest. So, you end up running them by hand. I really like using autotest though and so by providing this feature one can still use autotest in there workflow/process when working on new functionality in a large project. I haven't used it too much, but it seems like a really useful thing to have. Having autotest act on multiple tags may get too complicated, but I think the "focussed" tag is pretty straightforward. -Ben > Bye, > Kero. > ___ > How can I change the world if I can't even change myself? > -- Faithless, Salva Mea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Apr 13 12:33:06 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Mon, 13 Apr 2009 18:33:06 +0200 Subject: [rspec-users] App can't start on production server due to RSpec missing In-Reply-To: <57c63afe0901161305x94c7075y14c4e94d16000bfb@mail.gmail.com> References: <1f1ae1ba8c8e53b634b138baa4dd0f66@ruby-forum.com> <57c63afe0901161305x94c7075y14c4e94d16000bfb@mail.gmail.com> Message-ID: <3c9a0846822af4a15bc9a9cd6df28b4a@ruby-forum.com> >> A quick fix is to install rspec and rspec-rails gems on production >> server, but I don't get why the app wants them installed. > > This is a tricky business. > > We put that in there in response to a user who works on a team. One > team member had pulled code and tried t run specs and got an error he > didn't understand, so this is intended to help that developer know he > needs to install rspec. > > So now this creates a new problem for you, which is that this means > you have to have rspec installed everywhere you want to run rake > tasks. I haven't followed the ML latety, but it seems that now I don't have to install rspec and its friends on the production server anymore. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Apr 13 14:14:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 15:14:17 -0300 Subject: [rspec-users] Problem seeing and accessing RSpec gems In-Reply-To: <44821e060904131022p3b86ae8aoa97afbf0121a37fd@mail.gmail.com> References: <44821e060904131022p3b86ae8aoa97afbf0121a37fd@mail.gmail.com> Message-ID: <57c63afe0904131114i34f75fb6mc038db879cca7bb1@mail.gmail.com> On Mon, Apr 13, 2009 at 2:22 PM, Sarah Gray wrote: > Hello RSpec-list: > I'm having trouble getting rspec and rspec-rails correctly installed on my > system. (I had to uninstall, unfortunately).The upshot is that even when > they are installed -- i.e. when I can see them on my system -- they don't > appear known to gem which which and, more importantly, they are not > accessible to my application. ?I've tried options such as installing with > --no-rdoc, cleaning out all files manually from ~/.gem (and cache, doc, > etc), installing via rake gems:install from w/in the app and installing > versus gem install and sudo gem install outside the app... > Are there any steps that, if done wrong once, could have permanently hosed > the system? For instance, if at some point I answered "Y", which I believe > that I did to > Remove executables: > autospec, spec > Would that cause this type of issue? If so, is there any way I can reset? A > clean uninstall doesn't do it. > I've put a fairly detailed log of what I've been doing and system responses > if it's helpful. ?It seems like it boils down to the first issue: that even > though the gems show up via gem list, gem which doesn't turn them up. ?The > rest just confirms this. Any thoughts helpful. ?Thanks. > > *************************************************************** > # Are they there? > $ gem list rspec > *** LOCAL GEMS *** > rspec (1.2.2) > rspec-rails (1.2.2) > > # OK, where are they? > $ gem which rspec > Can't find ruby library file or shared library rspec > $ gem which rspec-rails > Can't find ruby library file or shared library rspec-rails > # Let's do this manually > $cd?/usr/local/lib/ruby/gems/1.8/gems > $ls | grep rspec > rspec-1.2.2 > rspec-rails-1.2.2 > # Let's try to unpack them, then > $ sudo rake vendor gems:unpack RAILS_ENV=test > (in /Users/sarah/Sites/site-name) > no such file to load -- rspec > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > .... massive stack trace here > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > These gems that this application depends on are missing: > ?- rspec > ?- rspec-rails > Run "rake gems:install" to install them. > no such file to load -- rspec > # Doesn't sound promising, but OK, I'll try again > $ rake gems:install RAILS_ENV=test > (in /Users/sarah/Sites/site-name) > no such file to load -- rspec > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > .... massive stack trace here; same as above > However, at the end of the stack track, it installs the gems anyway, to > ~/.gem > gem install rspec --version ">= 1.2.0" > WARNING: ?Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and > ?/usr/local/bin aren't both writable. > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > ************************************************** > ??Thank you for installing rspec-1.2.2 > ??Please be sure to read History.rdoc and Upgrade.rdoc > ??for useful information about this release. > ************************************************** > Successfully installed rspec-1.2.2 > 1 gem installed > Installing ri documentation for rspec-1.2.2... > Installing RDoc documentation for rspec-1.2.2... > gem install rspec-rails --version ">= 1.2.0" > WARNING: ?Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and > ?/usr/local/bin aren't both writable. > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > ************************************************** > ??Thank you for installing rspec-rails-1.2.2 > ??If you are upgrading, do this in each of your rails apps > ??that you want to upgrade: > ?? ?$ ruby script/generate rspec > ??Please be sure to read History.rdoc and Upgrade.rdoc > ??for useful information about this release. > ************************************************** > Successfully installed rspec-rails-1.2.2 > 1 gem installed > Installing ri documentation for rspec-rails-1.2.2... > Installing RDoc documentation for rspec-rails-1.2.2... > # Just for fun, try to unpack, again: > $ sudo rake gems:unpack RAILS_ENV=test > Password: > (in /Users/sarah/Sites/radio-info) > no such file to load -- rspec > ... stack trace > # OK, I will uninstall and try again > $ sudo gem uninstall rspec > Remove executables: > autospec, spec > in addition to the gem? [Yn] ?n > Executables and scripts will remain installed. > You have requested to uninstall the gem: > rspec-1.2.2 > rspec-rails-1.2.2 depends on [rspec (= 1.2.2)] > If you remove this gems, one or more dependencies will not be met. > Continue with Uninstall? [Yn] ?y > Successfully uninstalled rspec-1.2.2 > sarah-grays-computer:radio-info sarah$ sudo gem uninstall rspec-rails > Successfully uninstalled rspec-rails-1.2.2 > # Still there? > $ gem list rspec > *** LOCAL GEMS *** > rspec (1.2.2) > rspec-rails (1.2.2) > $ gem uninstall rspec > ERROR: ?While executing gem ... (Gem::InstallError) > ?? ?Unknown gem rspec >= 0 > #OK, now I will manually remove the gem from > $cd /Users/sarah/.gem/ruby/1.8/gems; $sudo rm -rf rspec* > $cd?/Users/sarah/.gem/ruby/1.8/cache; $sudo rm -rf rspec* > $cd?/Users/sarah/.gem/ruby/1.8/doc; $sudo rm -rf rspec* > $cd?/Users/sarah/.gem/ruby/1.8/specifications; $sudo rm -rf rspec* > # Check gone. > $ gem list rspec > *** LOCAL GEMS *** > # OK, confirmed gone, start from scratch > $ sudo gem install rspec > ************************************************** > ??Thank you for installing rspec-1.2.2 > ??Please be sure to read History.rdoc and Upgrade.rdoc > ??for useful information about this release. > ************************************************** > Successfully installed rspec-1.2.2 > 1 gem installed > Installing ri documentation for rspec-1.2.2... > Installing RDoc documentation for rspec-1.2.2... > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > Could not find main page README.rdoc > sarah-grays-computer:~ sarah$ gem which rspec > Can't find ruby library file or shared library rspec > sarah-grays-computer:~ sarah$ gem list rspec > *** LOCAL GEMS *** > rspec (1.2.2) > # See if the gem is accessible from w/in the application: > $ ruby script/generate rspec > :0:Warning: Gem::SourceIndex#search support for Regexp patterns is > deprecated > Couldn't find 'rspec' generator > sarah-grays-computer:site-name sarah$ > > > ************** > Any thoughts? I'm not familiar with a gemwhich - sounds crunchy - but .... $ gem which spec (checking gem rspec-1.2.3 for spec) /Library/Ruby/Gems/1.8/gems/rspec-1.2.3/lib/spec.rb $ gem which spec/rails (checking gem rspec-rails-1.2.3 for spec/rails) /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.3/lib/spec/rails.rb Of course, 1.2.3 isn't released yet, but I have special privileges ;) So it appears that "gem which" looks for files, not gems or executables. HTH, David > Thanks, > Sarah > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Apr 13 15:29:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 16:29:07 -0300 Subject: [rspec-users] Problem seeing and accessing RSpec gems In-Reply-To: <44821e060904131136i434b85a7r3691615e2116972a@mail.gmail.com> References: <44821e060904131022p3b86ae8aoa97afbf0121a37fd@mail.gmail.com> <57c63afe0904131114i34f75fb6mc038db879cca7bb1@mail.gmail.com> <44821e060904131136i434b85a7r3691615e2116972a@mail.gmail.com> Message-ID: <57c63afe0904131229y2a263629q2eb032b765fdaa95@mail.gmail.com> On Mon, Apr 13, 2009 at 3:36 PM, Sarah Gray wrote: > David, thanks, that does appear to be true, which is helpful to know, > thanks. But the "gem which" problem was really the canary in the coal mine > for the fact that the gems aren't being recognized when I am attempting to > configure them: > $ gem which spec > (checking gem rspec-1.2.2 for spec) > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.2/lib/spec.rb > $ gem which spec/rails > (checking gem rspec-rails-1.2.2 for spec/rails) > /usr/local/lib/ruby/gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb > This is what I have in environment/test.rb > config.gem "rspec", :lib => false, :version => ">= 1.2.0" > config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0" > but when I check the configuration by running > $?rake gems RAILS_ENV=test I get this (with rspec + rspec-rails + factory girl configured in test.rb): $ rake gems RAILS_ENV=test (in /Users/david/projects/ruby/tmp/foo) - [I] rspec >= 1.2.0 - [ ] rspec-rails >= 1.2.0 - [I] thoughtbot-factory_girl I = Installed F = Frozen R = Framework (loaded before rails starts) What version of rails are you using? > > I get this massive stack trace that ends in this: > These gems that this application depends on are missing: > ?- rspec > ?- rspec-rails > Run "rake gems:install" to install them. > no such file to load -- rspec > I'm missing something here and it's not obvious to me... I'm hoping it is > obvious to s/o else... thanks. > This then ends up in me not being able to successful run ruby > script/generate rspec > Stack trace below: > (in /Users/sarah/Sites/site-name) > no such file to load -- rspec > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `__send__' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `to_proc' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `each' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `load_gems' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:142:in > `process' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in > `send' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in > `run' > /Users/sarah/Sites/site-name/config/environment.rb:13 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/lib/tasks/maintenance.rake:1 > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7:in > `each' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/Rakefile:9 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in `load' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in > `raw_load_rakefile' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1993:in > `load_rakefile' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1992:in > `load_rakefile' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1976:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > no such file to load -- rspec-rails > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `__send__' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `to_proc' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `each' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `load_gems' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:142:in > `process' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in > `send' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in > `run' > /Users/sarah/Sites/site-name/config/environment.rb:13 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/lib/tasks/maintenance.rake:1 > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7:in > `each' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/Rakefile:9 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in `load' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in > `raw_load_rakefile' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1993:in > `load_rakefile' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1992:in > `load_rakefile' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1976:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > These gems that this application depends on are missing: > ?- rspec > ?- rspec-rails > Run "rake gems:install" to install them. > no such file to load -- rspec > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `__send__' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `to_proc' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `each' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `load_gems' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:142:in > `process' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in > `send' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in > `run' > /Users/sarah/Sites/site-name/config/environment.rb:13 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/misc.rake:3 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/gems.rake:15 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:588:in > `invoke_prerequisites' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in > `invoke_prerequisites' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:577:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in > `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > no such file to load -- rspec-rails > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in > `load' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `__send__' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in > `to_proc' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `each' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in > `load_gems' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:142:in > `process' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in > `send' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in > `run' > /Users/sarah/Sites/site-name/config/environment.rb:13 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in > `new_constants_in' > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in > `require' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/misc.rake:3 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/gems.rake:15 > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:588:in > `invoke_prerequisites' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in > `invoke_prerequisites' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:577:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in > `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > > [F] thoughtbot-factory_girl > [ ] rspec >= 1.2.0 > [ ] rspec-rails >= 1.2.0 > I = Installed > F = Frozen > > These gems that this application depends on are missing: > ?- rspec > ?- rspec-rails > > On Mon, Apr 13, 2009 at 1:14 PM, David Chelimsky > wrote: >> >> On Mon, Apr 13, 2009 at 2:22 PM, Sarah Gray wrote: >> > Hello RSpec-list: >> > I'm having trouble getting rspec and rspec-rails correctly installed on >> > my >> > system. (I had to uninstall, unfortunately).The upshot is that even when >> > they are installed -- i.e. when I can see them on my system -- they >> > don't >> > appear known to gem which which and, more importantly, they are not >> > accessible to my application. ?I've tried options such as installing >> > with >> > --no-rdoc, cleaning out all files manually from ~/.gem (and cache, doc, >> > etc), installing via rake gems:install from w/in the app and installing >> > versus gem install and sudo gem install outside the app... >> > Are there any steps that, if done wrong once, could have permanently >> > hosed >> > the system? For instance, if at some point I answered "Y", which I >> > believe >> > that I did to >> > Remove executables: >> > autospec, spec >> > Would that cause this type of issue? If so, is there any way I can >> > reset? A >> > clean uninstall doesn't do it. >> > I've put a fairly detailed log of what I've been doing and system >> > responses >> > if it's helpful. ?It seems like it boils down to the first issue: that >> > even >> > though the gems show up via gem list, gem which doesn't turn them up. >> > ?The >> > rest just confirms this. Any thoughts helpful. ?Thanks. >> > >> > *************************************************************** >> > # Are they there? >> > $ gem list rspec >> > *** LOCAL GEMS *** >> > rspec (1.2.2) >> > rspec-rails (1.2.2) >> > >> > # OK, where are they? >> > $ gem which rspec >> > Can't find ruby library file or shared library rspec >> > $ gem which rspec-rails >> > Can't find ruby library file or shared library rspec-rails >> > # Let's do this manually >> > $cd?/usr/local/lib/ruby/gems/1.8/gems >> > $ls | grep rspec >> > rspec-1.2.2 >> > rspec-rails-1.2.2 >> > # Let's try to unpack them, then >> > $ sudo rake vendor gems:unpack RAILS_ENV=test >> > (in /Users/sarah/Sites/site-name) >> > no such file to load -- rspec >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > .... massive stack trace here >> > /usr/local/bin/rake:19:in `load' >> > /usr/local/bin/rake:19 >> > These gems that this application depends on are missing: >> > ?- rspec >> > ?- rspec-rails >> > Run "rake gems:install" to install them. >> > no such file to load -- rspec >> > # Doesn't sound promising, but OK, I'll try again >> > $ rake gems:install RAILS_ENV=test >> > (in /Users/sarah/Sites/site-name) >> > no such file to load -- rspec >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > .... massive stack trace here; same as above >> > However, at the end of the stack track, it installs the gems anyway, to >> > ~/.gem >> > gem install rspec --version ">= 1.2.0" >> > WARNING: ?Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and >> > ?/usr/local/bin aren't both writable. >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > ************************************************** >> > ??Thank you for installing rspec-1.2.2 >> > ??Please be sure to read History.rdoc and Upgrade.rdoc >> > ??for useful information about this release. >> > ************************************************** >> > Successfully installed rspec-1.2.2 >> > 1 gem installed >> > Installing ri documentation for rspec-1.2.2... >> > Installing RDoc documentation for rspec-1.2.2... >> > gem install rspec-rails --version ">= 1.2.0" >> > WARNING: ?Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and >> > ?/usr/local/bin aren't both writable. >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > ************************************************** >> > ??Thank you for installing rspec-rails-1.2.2 >> > ??If you are upgrading, do this in each of your rails apps >> > ??that you want to upgrade: >> > ?? ?$ ruby script/generate rspec >> > ??Please be sure to read History.rdoc and Upgrade.rdoc >> > ??for useful information about this release. >> > ************************************************** >> > Successfully installed rspec-rails-1.2.2 >> > 1 gem installed >> > Installing ri documentation for rspec-rails-1.2.2... >> > Installing RDoc documentation for rspec-rails-1.2.2... >> > # Just for fun, try to unpack, again: >> > $ sudo rake gems:unpack RAILS_ENV=test >> > Password: >> > (in /Users/sarah/Sites/radio-info) >> > no such file to load -- rspec >> > ... stack trace >> > # OK, I will uninstall and try again >> > $ sudo gem uninstall rspec >> > Remove executables: >> > autospec, spec >> > in addition to the gem? [Yn] ?n >> > Executables and scripts will remain installed. >> > You have requested to uninstall the gem: >> > rspec-1.2.2 >> > rspec-rails-1.2.2 depends on [rspec (= 1.2.2)] >> > If you remove this gems, one or more dependencies will not be met. >> > Continue with Uninstall? [Yn] ?y >> > Successfully uninstalled rspec-1.2.2 >> > sarah-grays-computer:radio-info sarah$ sudo gem uninstall rspec-rails >> > Successfully uninstalled rspec-rails-1.2.2 >> > # Still there? >> > $ gem list rspec >> > *** LOCAL GEMS *** >> > rspec (1.2.2) >> > rspec-rails (1.2.2) >> > $ gem uninstall rspec >> > ERROR: ?While executing gem ... (Gem::InstallError) >> > ?? ?Unknown gem rspec >= 0 >> > #OK, now I will manually remove the gem from >> > $cd /Users/sarah/.gem/ruby/1.8/gems; $sudo rm -rf rspec* >> > $cd?/Users/sarah/.gem/ruby/1.8/cache; $sudo rm -rf rspec* >> > $cd?/Users/sarah/.gem/ruby/1.8/doc; $sudo rm -rf rspec* >> > $cd?/Users/sarah/.gem/ruby/1.8/specifications; $sudo rm -rf rspec* >> > # Check gone. >> > $ gem list rspec >> > *** LOCAL GEMS *** >> > # OK, confirmed gone, start from scratch >> > $ sudo gem install rspec >> > ************************************************** >> > ??Thank you for installing rspec-1.2.2 >> > ??Please be sure to read History.rdoc and Upgrade.rdoc >> > ??for useful information about this release. >> > ************************************************** >> > Successfully installed rspec-1.2.2 >> > 1 gem installed >> > Installing ri documentation for rspec-1.2.2... >> > Installing RDoc documentation for rspec-1.2.2... >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > Could not find main page README.rdoc >> > sarah-grays-computer:~ sarah$ gem which rspec >> > Can't find ruby library file or shared library rspec >> > sarah-grays-computer:~ sarah$ gem list rspec >> > *** LOCAL GEMS *** >> > rspec (1.2.2) >> > # See if the gem is accessible from w/in the application: >> > $ ruby script/generate rspec >> > :0:Warning: Gem::SourceIndex#search support for Regexp patterns is >> > deprecated >> > Couldn't find 'rspec' generator >> > sarah-grays-computer:site-name sarah$ >> > >> > >> > ************** >> > Any thoughts? >> >> I'm not familiar with a gemwhich - sounds crunchy - but .... >> >> $ gem which spec >> (checking gem rspec-1.2.3 for spec) >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.3/lib/spec.rb >> $ gem which spec/rails >> (checking gem rspec-rails-1.2.3 for spec/rails) >> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.3/lib/spec/rails.rb >> >> Of course, 1.2.3 isn't released yet, but I have special privileges ;) >> >> So it appears that "gem which" looks for files, not gems or executables. >> >> HTH, >> David >> >> > Thanks, >> > Sarah >> > >> > >> > >> > _______________________________________________ >> > 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.fabled.net/blog/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Apr 13 15:53:35 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 13 Apr 2009 20:53:35 +0100 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> Message-ID: On 11 Apr 2009, at 19:02, Ashley Moran wrote: > I was just idly thinking, could a code-coverage based system could > be combined with some sort of failure (fragility) history to balance > the time cost of heavy feature runs with the benefits of having > something run end-to-end? We've had reverse-modification-time spec > ordering for ages which is a useful start. I believe this is roughly what Kent Beck's new venture, JUnit Max, does. I think it's pretty much essential to start thinking about doing this - dumbly running all the tests just doesn't make sense and won't scale on a bigger project. Cucover is my first attempt to dip my toe into this water. I blogged about this the other day: http://blog.mattwynne.net/2009/04/06/the-future-of-automated-acceptance-testing/ Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Mon Apr 13 15:48:19 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 16:48:19 -0300 Subject: [rspec-users] Problem seeing and accessing RSpec gems In-Reply-To: <44821e060904131234o7ab56a33w293ab4cae4ab2534@mail.gmail.com> References: <44821e060904131022p3b86ae8aoa97afbf0121a37fd@mail.gmail.com> <57c63afe0904131114i34f75fb6mc038db879cca7bb1@mail.gmail.com> <44821e060904131136i434b85a7r3691615e2116972a@mail.gmail.com> <57c63afe0904131229y2a263629q2eb032b765fdaa95@mail.gmail.com> <44821e060904131234o7ab56a33w293ab4cae4ab2534@mail.gmail.com> Message-ID: <57c63afe0904131248x6a79d198kc4458936070bdf07@mail.gmail.com> On Mon, Apr 13, 2009 at 4:34 PM, Sarah Gray wrote: > rails -v > 2.3.2 Me too. Not sure what to tell you. Anybody else? > (Sorry about that long stack trace in the last message!) > > On Mon, Apr 13, 2009 at 2:29 PM, David Chelimsky > wrote: >> >> On Mon, Apr 13, 2009 at 3:36 PM, Sarah Gray wrote: >> > David, thanks, that does appear to be true, which is helpful to know, >> > thanks. But the "gem which" problem was really the canary in the coal >> > mine >> > for the fact that the gems aren't being recognized when I am attempting >> > to >> > configure them: >> > $ gem which spec >> > (checking gem rspec-1.2.2 for spec) >> > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.2/lib/spec.rb >> > $ gem which spec/rails >> > (checking gem rspec-rails-1.2.2 for spec/rails) >> > /usr/local/lib/ruby/gems/1.8/gems/rspec-rails-1.2.2/lib/spec/rails.rb >> > This is what I have in environment/test.rb >> > config.gem "rspec", :lib => false, :version => ">= 1.2.0" >> > config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0" >> > but when I check the configuration by running >> > $?rake gems RAILS_ENV=test >> >> I get this (with rspec + rspec-rails + factory girl configured in >> test.rb): >> >> $ rake gems RAILS_ENV=test >> (in /Users/david/projects/ruby/tmp/foo) >> ?- [I] rspec >= 1.2.0 >> ?- [ ] rspec-rails ?>= 1.2.0 >> ?- [I] thoughtbot-factory_girl >> >> I = Installed >> F = Frozen >> R = Framework (loaded before rails starts) >> >> What version of rails are you using? >> >> >> > >> > I get this massive stack trace that ends in this: >> > These gems that this application depends on are missing: >> > ?- rspec >> > ?- rspec-rails >> > Run "rake gems:install" to install them. >> > no such file to load -- rspec >> > I'm missing something here and it's not obvious to me... I'm hoping it >> > is >> > obvious to s/o else... thanks. >> > This then ends up in me not being able to successful run ruby >> > script/generate rspec >> > Stack trace below: >> > (in /Users/sarah/Sites/site-name) >> > no such file to load -- rspec >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `__send__' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `to_proc' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `each' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `load_gems' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:142:in >> > `process' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in >> > `send' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in >> > `run' >> > /Users/sarah/Sites/site-name/config/environment.rb:13 >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > /Users/sarah/Sites/site-name/lib/tasks/maintenance.rake:1 >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in >> > `load' >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7:in >> > `each' >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > /Users/sarah/Sites/site-name/Rakefile:9 >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in `load' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in >> > `raw_load_rakefile' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1993:in >> > `load_rakefile' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1992:in >> > `load_rakefile' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1976:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 >> > /usr/local/bin/rake:19:in `load' >> > /usr/local/bin/rake:19 >> > no such file to load -- rspec-rails >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `__send__' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `to_proc' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `each' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `load_gems' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:142:in >> > `process' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in >> > `send' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/initializer.rb:93:in >> > `run' >> > /Users/sarah/Sites/site-name/config/environment.rb:13 >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > /Users/sarah/Sites/site-name/lib/tasks/maintenance.rake:1 >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in >> > `load' >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7:in >> > `each' >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/rails.rb:7 >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > /Users/sarah/Sites/site-name/Rakefile:9 >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in `load' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in >> > `raw_load_rakefile' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1993:in >> > `load_rakefile' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1992:in >> > `load_rakefile' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1976:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 >> > /usr/local/bin/rake:19:in `load' >> > /usr/local/bin/rake:19 >> > These gems that this application depends on are missing: >> > ?- rspec >> > ?- rspec-rails >> > Run "rake gems:install" to install them. >> > no such file to load -- rspec >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `__send__' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `to_proc' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `each' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `load_gems' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:142:in >> > `process' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in >> > `send' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in >> > `run' >> > /Users/sarah/Sites/site-name/config/environment.rb:13 >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/misc.rake:3 >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/gems.rake:15 >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:588:in >> > `invoke_prerequisites' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in >> > `invoke_prerequisites' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:577:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >> > `invoke_task' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in >> > `top_level' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in >> > `top_level' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in >> > `top_level' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 >> > /usr/local/bin/rake:19:in `load' >> > /usr/local/bin/rake:19 >> > no such file to load -- rspec-rails >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in >> > `load' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `__send__' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb:11:in >> > `to_proc' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `each' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:246:in >> > `load_gems' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:142:in >> > `process' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in >> > `send' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/initializer.rb:93:in >> > `run' >> > /Users/sarah/Sites/site-name/config/environment.rb:13 >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `gem_original_require' >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in >> > `new_constants_in' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> > `require' >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/misc.rake:3 >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >> > >> > /Users/sarah/Sites/site-name/vendor/rails/railties/lib/tasks/gems.rake:15 >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in >> > `execute' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:588:in >> > `invoke_prerequisites' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in >> > `invoke_prerequisites' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:577:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/1.8/monitor.rb:238:in `synchronize' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> > `invoke_with_call_chain' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >> > `invoke_task' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in >> > `top_level' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in >> > `top_level' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in >> > `top_level' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> > `standard_exception_handling' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >> > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 >> > /usr/local/bin/rake:19:in `load' >> > /usr/local/bin/rake:19 >> > >> > [F] thoughtbot-factory_girl >> > [ ] rspec >= 1.2.0 >> > [ ] rspec-rails >= 1.2.0 >> > I = Installed >> > F = Frozen >> > >> > These gems that this application depends on are missing: >> > ?- rspec >> > ?- rspec-rails >> > >> > On Mon, Apr 13, 2009 at 1:14 PM, David Chelimsky >> > wrote: >> >> >> >> On Mon, Apr 13, 2009 at 2:22 PM, Sarah Gray >> >> wrote: >> >> > Hello RSpec-list: >> >> > I'm having trouble getting rspec and rspec-rails correctly installed >> >> > on >> >> > my >> >> > system. (I had to uninstall, unfortunately).The upshot is that even >> >> > when >> >> > they are installed -- i.e. when I can see them on my system -- they >> >> > don't >> >> > appear known to gem which which and, more importantly, they are not >> >> > accessible to my application. ?I've tried options such as installing >> >> > with >> >> > --no-rdoc, cleaning out all files manually from ~/.gem (and cache, >> >> > doc, >> >> > etc), installing via rake gems:install from w/in the app and >> >> > installing >> >> > versus gem install and sudo gem install outside the app... >> >> > Are there any steps that, if done wrong once, could have permanently >> >> > hosed >> >> > the system? For instance, if at some point I answered "Y", which I >> >> > believe >> >> > that I did to >> >> > Remove executables: >> >> > autospec, spec >> >> > Would that cause this type of issue? If so, is there any way I can >> >> > reset? A >> >> > clean uninstall doesn't do it. >> >> > I've put a fairly detailed log of what I've been doing and system >> >> > responses >> >> > if it's helpful. ?It seems like it boils down to the first issue: >> >> > that >> >> > even >> >> > though the gems show up via gem list, gem which doesn't turn them up. >> >> > ?The >> >> > rest just confirms this. Any thoughts helpful. ?Thanks. >> >> > >> >> > *************************************************************** >> >> > # Are they there? >> >> > $ gem list rspec >> >> > *** LOCAL GEMS *** >> >> > rspec (1.2.2) >> >> > rspec-rails (1.2.2) >> >> > >> >> > # OK, where are they? >> >> > $ gem which rspec >> >> > Can't find ruby library file or shared library rspec >> >> > $ gem which rspec-rails >> >> > Can't find ruby library file or shared library rspec-rails >> >> > # Let's do this manually >> >> > $cd?/usr/local/lib/ruby/gems/1.8/gems >> >> > $ls | grep rspec >> >> > rspec-1.2.2 >> >> > rspec-rails-1.2.2 >> >> > # Let's try to unpack them, then >> >> > $ sudo rake vendor gems:unpack RAILS_ENV=test >> >> > (in /Users/sarah/Sites/site-name) >> >> > no such file to load -- rspec >> >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> >> > `gem_original_require' >> >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> >> > `require' >> >> > >> >> > >> >> > /Users/sarah/Sites/site-name/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in >> >> > `require' >> >> > .... massive stack trace here >> >> > /usr/local/bin/rake:19:in `load' >> >> > /usr/local/bin/rake:19 >> >> > These gems that this application depends on are missing: >> >> > ?- rspec >> >> > ?- rspec-rails >> >> > Run "rake gems:install" to install them. >> >> > no such file to load -- rspec >> >> > # Doesn't sound promising, but OK, I'll try again >> >> > $ rake gems:install RAILS_ENV=test >> >> > (in /Users/sarah/Sites/site-name) >> >> > no such file to load -- rspec >> >> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> >> > `gem_original_require' >> >> > .... massive stack trace here; same as above >> >> > However, at the end of the stack track, it installs the gems anyway, >> >> > to >> >> > ~/.gem >> >> > gem install rspec --version ">= 1.2.0" >> >> > WARNING: ?Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and >> >> > ?/usr/local/bin aren't both writable. >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > ************************************************** >> >> > ??Thank you for installing rspec-1.2.2 >> >> > ??Please be sure to read History.rdoc and Upgrade.rdoc >> >> > ??for useful information about this release. >> >> > ************************************************** >> >> > Successfully installed rspec-1.2.2 >> >> > 1 gem installed >> >> > Installing ri documentation for rspec-1.2.2... >> >> > Installing RDoc documentation for rspec-1.2.2... >> >> > gem install rspec-rails --version ">= 1.2.0" >> >> > WARNING: ?Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and >> >> > ?/usr/local/bin aren't both writable. >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > ************************************************** >> >> > ??Thank you for installing rspec-rails-1.2.2 >> >> > ??If you are upgrading, do this in each of your rails apps >> >> > ??that you want to upgrade: >> >> > ?? ?$ ruby script/generate rspec >> >> > ??Please be sure to read History.rdoc and Upgrade.rdoc >> >> > ??for useful information about this release. >> >> > ************************************************** >> >> > Successfully installed rspec-rails-1.2.2 >> >> > 1 gem installed >> >> > Installing ri documentation for rspec-rails-1.2.2... >> >> > Installing RDoc documentation for rspec-rails-1.2.2... >> >> > # Just for fun, try to unpack, again: >> >> > $ sudo rake gems:unpack RAILS_ENV=test >> >> > Password: >> >> > (in /Users/sarah/Sites/radio-info) >> >> > no such file to load -- rspec >> >> > ... stack trace >> >> > # OK, I will uninstall and try again >> >> > $ sudo gem uninstall rspec >> >> > Remove executables: >> >> > autospec, spec >> >> > in addition to the gem? [Yn] ?n >> >> > Executables and scripts will remain installed. >> >> > You have requested to uninstall the gem: >> >> > rspec-1.2.2 >> >> > rspec-rails-1.2.2 depends on [rspec (= 1.2.2)] >> >> > If you remove this gems, one or more dependencies will not be met. >> >> > Continue with Uninstall? [Yn] ?y >> >> > Successfully uninstalled rspec-1.2.2 >> >> > sarah-grays-computer:radio-info sarah$ sudo gem uninstall rspec-rails >> >> > Successfully uninstalled rspec-rails-1.2.2 >> >> > # Still there? >> >> > $ gem list rspec >> >> > *** LOCAL GEMS *** >> >> > rspec (1.2.2) >> >> > rspec-rails (1.2.2) >> >> > $ gem uninstall rspec >> >> > ERROR: ?While executing gem ... (Gem::InstallError) >> >> > ?? ?Unknown gem rspec >= 0 >> >> > #OK, now I will manually remove the gem from >> >> > $cd /Users/sarah/.gem/ruby/1.8/gems; $sudo rm -rf rspec* >> >> > $cd?/Users/sarah/.gem/ruby/1.8/cache; $sudo rm -rf rspec* >> >> > $cd?/Users/sarah/.gem/ruby/1.8/doc; $sudo rm -rf rspec* >> >> > $cd?/Users/sarah/.gem/ruby/1.8/specifications; $sudo rm -rf rspec* >> >> > # Check gone. >> >> > $ gem list rspec >> >> > *** LOCAL GEMS *** >> >> > # OK, confirmed gone, start from scratch >> >> > $ sudo gem install rspec >> >> > ************************************************** >> >> > ??Thank you for installing rspec-1.2.2 >> >> > ??Please be sure to read History.rdoc and Upgrade.rdoc >> >> > ??for useful information about this release. >> >> > ************************************************** >> >> > Successfully installed rspec-1.2.2 >> >> > 1 gem installed >> >> > Installing ri documentation for rspec-1.2.2... >> >> > Installing RDoc documentation for rspec-1.2.2... >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > Could not find main page README.rdoc >> >> > sarah-grays-computer:~ sarah$ gem which rspec >> >> > Can't find ruby library file or shared library rspec >> >> > sarah-grays-computer:~ sarah$ gem list rspec >> >> > *** LOCAL GEMS *** >> >> > rspec (1.2.2) >> >> > # See if the gem is accessible from w/in the application: >> >> > $ ruby script/generate rspec >> >> > :0:Warning: Gem::SourceIndex#search support for Regexp patterns is >> >> > deprecated >> >> > Couldn't find 'rspec' generator >> >> > sarah-grays-computer:site-name sarah$ >> >> > >> >> > >> >> > ************** >> >> > Any thoughts? >> >> >> >> I'm not familiar with a gemwhich - sounds crunchy - but .... >> >> >> >> $ gem which spec >> >> (checking gem rspec-1.2.3 for spec) >> >> /Library/Ruby/Gems/1.8/gems/rspec-1.2.3/lib/spec.rb >> >> $ gem which spec/rails >> >> (checking gem rspec-rails-1.2.3 for spec/rails) >> >> /Library/Ruby/Gems/1.8/gems/rspec-rails-1.2.3/lib/spec/rails.rb >> >> >> >> Of course, 1.2.3 isn't released yet, but I have special privileges ;) >> >> >> >> So it appears that "gem which" looks for files, not gems or >> >> executables. >> >> >> >> HTH, >> >> David >> >> >> >> > Thanks, >> >> > Sarah >> >> > >> >> > >> >> > >> >> > _______________________________________________ >> >> > 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.fabled.net/blog/ >> > >> > _______________________________________________ >> > 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.fabled.net/blog/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Apr 13 16:02:00 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 13 Apr 2009 21:02:00 +0100 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <49E27086.5000208@benmabey.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <49E27086.5000208@benmabey.com> Message-ID: <495C1B92-ADD0-4D25-BD5D-5704C8218375@mattwynne.net> On 12 Apr 2009, at 23:51, Ben Mabey wrote: > Stephen Eley wrote: >> On Sat, Apr 11, 2009 at 2:02 PM, Ashley Moran >> wrote: >> >>> I was just idly thinking, could a code-coverage based system could >>> be >>> combined with some sort of failure (fragility) history to balance >>> the time >>> cost of heavy feature runs with the benefits of having something run >>> end-to-end? We've had reverse-modification-time spec ordering for >>> ages >>> which is a useful start. >>> >> >> I've had it in my head for a while now that someday (yes, that >> mythical 'someday') I want to write a better autotest. Maybe this is >> heresy, but I am a huge fan of the _idea_ behind autotest and totally >> annoyed by its implementation. It's extensible only in strange ways >> (hence wrappers like autospec), and its fundamental strategy is too >> static. I once lost most of a day trying to fix merb_cucumber so the >> features would run when they should, and was ready to hurl cats >> when I >> realized autotest's idea of context chaining was to make you list >> them >> all in the classname in alphabetical order. Look at the files in the >> Cucumber gem's 'lib/autotest' directory and you'll see what I mean. >> >> A proper design would let you plug in your own file-change discovery >> strategy, plug in multiple runners (RSpec, Cucumber, yadda yadda) >> with >> true modularity, specify lists of observers on directories or files, >> and allow different output views. An _ideal_ design would also let >> you set priority rules like you're describing here, so you get >> instant >> feedback only on the stuff you're working with, and do end-to-end >> runs >> in the background. +1 to this Stephen, I am with you 100%. A direct email about the pipe-dream is on it's way. >> >> > That would be very cool, you have lots of good ideas there. Being > able to plug in your own file-change strategy would be killer. > Another cool idea I ran across the other idea is being able to > specify in your examples that which ones are "focussed". Meaning, > autotest will only run the focussed ones and not bother running the > entire suite. Once you have solved the problem at hand you remove > the focussed tag and the whole suite is then ran. This idea, *which > is already implemented*, comes from Micronaut[1]. The idea is very > similar to Cucumber's and RSpec's[2] tagging feature (yet to come > for rspec). The cool thing about micronaunt is that they have tied > it into autotest. Ideally, we could be able to tell autotest, or > whatever program, to only run tests that are tagged a certain way-- > and then you could override that with the "focused" tag. So, we can > add that to our list of cool things to have. :) I actually don't think it should be necessary to tell the tool where to focus. As long as it understands the relationship between your tests and your source code, and you're making changes test-first, the tool should be able to know which parts of your code are unstable and likely to need re-testing after a change. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Mon Apr 13 16:09:07 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 13 Apr 2009 21:09:07 +0100 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <8d961d900904130446u13f1539bhc8122ef6ab87dbed@mail.gmail.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <8d961d900904130446u13f1539bhc8122ef6ab87dbed@mail.gmail.com> Message-ID: <6883A46F-365C-495F-B98C-E85A173ECD60@mattwynne.net> On 13 Apr 2009, at 12:46, aslak hellesoy wrote: > A couple of years ago I was on a project that had fallen into the > trap of too many integration tests (exactly the horror scenario that > J.B. Rainsberger describes: http://www.jbrains.ca/permalink/239). > The whole suite had hundreds of slow watir tests and took several > hours to run. If there was a failure, it was usually just in a > coupel of them. > > We ended up improving this a lot with a homegrown distributed RSpec > runner (based on Drb) and employing techniques from pairwise testing > (http://www.pairwise.org/). > > At the time I also explored a third technique that we never put in > use: Heuristics. > > If we could establish relationships between arbitrary files and > failing tests over time, then we would be able to calulate the > probablilty that a certain commit would break certain tests. We > could then choose to run the tests that had a high probablilty of > breakage, and exclude the others. A neural network could potentially > be used to implement this. The input neurons would be files in the > codebase (on if it's changed, off if not) and the output neurons > would be the tests to run. > > So if someone develops a better AutoTest with a plugin architecture, > and that doesn't have to run as a long/lived process, then I'd be > very interested in writing the neural network part - possibly backed > by FANN (http://leenissen.dk/fann/) > > It's so crazy it has to be tried! > > Aslak Aslak as usual you have stepped it up another seventy levels! I'm really keen to write a generic test runner that works on both RSpec and Cucumber examples alike (and could extend for other testing libraries). Allowing for pluggable strategies for test selection as Stephen has described is a terrific idea. Aslak do you have any ideas in the pipeline for building a fancier test runner for Cucumber? I know there was some brain-storming on the list a while back about a 'thick client'. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From dchelimsky at gmail.com Mon Apr 13 16:19:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Apr 2009 17:19:48 -0300 Subject: [rspec-users] Problem seeing and accessing RSpec gems In-Reply-To: <44821e060904131304j33ecbafdsd5848d835d01eb19@mail.gmail.com> References: <44821e060904131022p3b86ae8aoa97afbf0121a37fd@mail.gmail.com> <57c63afe0904131114i34f75fb6mc038db879cca7bb1@mail.gmail.com> <44821e060904131136i434b85a7r3691615e2116972a@mail.gmail.com> <57c63afe0904131229y2a263629q2eb032b765fdaa95@mail.gmail.com> <44821e060904131234o7ab56a33w293ab4cae4ab2534@mail.gmail.com> <57c63afe0904131248x6a79d198kc4458936070bdf07@mail.gmail.com> <44821e060904131304j33ecbafdsd5848d835d01eb19@mail.gmail.com> Message-ID: <57c63afe0904131319i57efe2ecpdcd02be8df314fa9@mail.gmail.com> On Mon, Apr 13, 2009 at 5:04 PM, Sarah Gray wrote: > When uninstalling rspec, should you: > Remove executables: > autospec, spec > in addition to the gem? [Yn] > And, is there possible fallout from doing this step wrong? As long as you're going to reinstall it, then there should not be any fallout. > > > On Mon, Apr 13, 2009 at 2:48 PM, David Chelimsky > wrote: >> >> On Mon, Apr 13, 2009 at 4:34 PM, Sarah Gray wrote: >> > rails -v >> > 2.3.2 >> >> Me too. Not sure what to tell you. >> >> Anybody else? >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Apr 13 17:03:36 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 13 Apr 2009 23:03:36 +0200 Subject: [rspec-users] Cucumber features for RSS feeds Message-ID: I am moving into yet another area that I possess absolutely no experience with. In this case the realm of RSS feeds and Rails as the consumer. My first feature/scenario looks like this and, given the effort I had to make to grasp the basics of features and scenarios in the crud world, I thought it best to ask for comments before I get too far in. Feature: Automatically Retrieve and Store Foreign Currency Exchange Rates In order to set foreign currency exchange rates daily The automated system Should automatically retrieve and store central bank exchange rates To Reduce Costs and Protect Revenue Scenario: Retrieve Exchange Rates from the Bank of Canada RSS feed Given an RSS feed "http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml" When I access the RSS feed between Monday to Friday after "17:15UTC" Then I should see "Bank of Canada: Noon Foreign Exchange Rates" And I should see today's date in "yyyy-mm-dd" format Basically, all this is doing is seeing if I can get the feed. I suppose that I could implement this as a direct controller call to the URL but there is probably a better way of which I am presently unaware. The other thing for which I wish guidance is the proper method to parse the feed. I gather this is a case where I should be parsing the xml in order to feed it to (ActiveResource?) and thence into the currency_exchange_rates model. Is there a recommended/preferred gem to handle this requirement? -- Posted via http://www.ruby-forum.com/. From sfeley at gmail.com Mon Apr 13 22:43:58 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 13 Apr 2009 22:43:58 -0400 Subject: [rspec-users] Problem seeing and accessing RSpec gems In-Reply-To: <44821e060904131346n24691037y7bc8b42ee6d9e8d1@mail.gmail.com> References: <44821e060904131022p3b86ae8aoa97afbf0121a37fd@mail.gmail.com> <57c63afe0904131114i34f75fb6mc038db879cca7bb1@mail.gmail.com> <44821e060904131136i434b85a7r3691615e2116972a@mail.gmail.com> <57c63afe0904131229y2a263629q2eb032b765fdaa95@mail.gmail.com> <44821e060904131234o7ab56a33w293ab4cae4ab2534@mail.gmail.com> <57c63afe0904131248x6a79d198kc4458936070bdf07@mail.gmail.com> <44821e060904131304j33ecbafdsd5848d835d01eb19@mail.gmail.com> <69f72d390904131319k30e8c7b7xfaf28aa45e005fef@mail.gmail.com> <44821e060904131346n24691037y7bc8b42ee6d9e8d1@mail.gmail.com> Message-ID: <1fb4df0904131943n645531c5q6a064a41af215052@mail.gmail.com> On Mon, Apr 13, 2009 at 4:46 PM, Sarah Gray wrote: > Jeff, ?always a good idea -- it didn't work in this case, but I've seen it > before. ?I ended up uninstalling my rails gem (and the action* gems) and > reinstalling; then, reinstalling rspec and rspec-rails. ?After that, rspec > worked without the issues I'd seen before. Don't know why. I didn't read this in time, but my first thought was going to be to suggest a "gem env" to find out your gem loading paths. You never mentioned what OS you're using, but from the use of /Users for your homedir and /usr/local/lib/ruby for the gempath, I'm guessing it's a Mac where you recompiled Ruby yourself. It's great the Leopard came with 1.8.6, but the gem environment is a pretty big mess, and adding your own stuff on top of it (even as innocuously as with a "sudo gem update --system") can sometimes leave a strange path state. That's just a fly-by observation based on ways I've set myself on fire in the past. If you got it working, you got it working, so it may not matter until next time. >8-> -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Mon Apr 13 23:56:41 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 13 Apr 2009 23:56:41 -0400 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <8d961d900904130446u13f1539bhc8122ef6ab87dbed@mail.gmail.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <8d961d900904130446u13f1539bhc8122ef6ab87dbed@mail.gmail.com> Message-ID: <1fb4df0904132056r403b4344ld86a31ac1ea2e6f5@mail.gmail.com> On Mon, Apr 13, 2009 at 7:46 AM, aslak hellesoy wrote: > > So if someone develops a better AutoTest with a plugin architecture, and > that doesn't have to run as a long/lived process, then I'd be very > interested in writing?the neural network part - possibly backed by FANN > (http://leenissen.dk/fann/) In the immortal words of Socrates, "That rocks." The nice thing about separating concerns like this -- the reason why design patterns appeal so much to me -- is that pieces can rather easily be built up incrementally. As Matt said, thinking 'neural networks' with this is way beyond the level of anything I'd had in my head. But it's a damn cool idea. I can think of a few ways to handle this particular chunk, with levels of complexity that would scale up: 1.) DUMB REACTION: Just re-run the tests that failed in this run cycle. Then, periodically, run tests that succeeded in the background as a regression check. (This isn't much beyond what Autotest does now.) 2.) OBSERVERS: Allow handlers to register themselves against certain files, so that when a file is changed, that handlers gets run. Multiple handlers can observe any given file, and a handler can declare multiple rules, including directories or pattern matches. (Again, Autotest has something _sort of_ like this, but not nearly as flexible.) 3.) PERSISTENCE: Track the history of tests and the times they were created, edited, last run, and last failed. Also track file modification times. When a file changes, run the tests first that are either new or have failed since the last time the file was changed. Then run the tests that went from failing to passing in that time. (This could certainly be improved -- I haven't sat down to figure out the actual rule set -- but you get the gist. Know when things changed and set priorities accordingly.) 4.) INTELLIGENCE: Aslak's neural network. Let the system figure out which tests matter to which files, and run what it thinks it ought to run. Maybe use code coverage analysis. It can 'learn' and improve when the full suite is run and it discovers new failures. In all four of these cases, I still think it's imperative to run the full suite. None of these methods are foolproof, and code is tricky and makes weird things happen in weird crevices. That's _why_ testing must be done. But running the suite doesn't have to be a 'blocking' activity, like it is with Autotest now. It can happen in bits and pieces, when nothing else is going on, and it can be configured to only grab your attention when something failed unexpectedly. (That's one of the prime reasons for the 'multiple output views' feature, by the way. When I said output views I wasn't just thinking of the console or a window. I'm also thinking Dashboard widgets, or gauges in the toolbar, or RSS feeds, or dynamic wallpaper, or whatever else anyone can think of. Stuff that stays out of your way until it either needs you or you choose to look at it.) Still making sense? This is starting to sound pretty big and pretty complex -- but I don't think it strictly needs to be. #1 and #2 above are pretty easy. The others don't have to be built before releasing something. And, of course, you wouldn't have to pick just one selection module. You could run or disable all of these depending on your project's needs, or come up with your own system involving Tarot cards and Linux running on a dead badger.(*) I just want to build a core that detects changes in stuff, tells other stuff about it, and passes on what that stuff says about it to a third set of stuff. The rest is implementation-specific details. >8-> (* http://www.strangehorizons.com/2004/20040405/badger.shtml ) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lists at ruby-forum.com Tue Apr 14 02:24:35 2009 From: lists at ruby-forum.com (Salil Gaikwad) Date: Tue, 14 Apr 2009 08:24:35 +0200 Subject: [rspec-users] undefined local variable or method `params' for # following is the method of the helper module ApplicationHelper def tab_class(tab) 'class="active"' if tab == params[:controller] end end i write the spec method as follows describe ApplicationHelper do it "should be active if controller is same" do tab_class('royalty_statement').should include('active') end end it gives me following error undefined local variable or method `params' for # Regards Salil -- Posted via http://www.ruby-forum.com/. From andre.x.pretorius at gmail.com Tue Apr 14 05:00:50 2009 From: andre.x.pretorius at gmail.com (AndreXP) Date: Tue, 14 Apr 2009 02:00:50 -0700 (PDT) Subject: [rspec-users] (MissingSourceFile) no such file to load -- spec/expectations/differs/default Message-ID: <23035747.post@talk.nabble.com> Hi All, This morning I did a "gem update" which installed "rspec-1.2.4" and when I run my cucumber "rake features" command I got the following: c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:142:in `activate': can't activate rspec (= 1.2.2, runtime), already activated rspec-1.2.4 (Gem::Exception) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' from c:/ruby/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:92:in `enable_diffing' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:35:in `execute!' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 rake aborted! Command failed with status (1): [c:/ruby/bin/ruby -I "c:/ruby/lib/ruby/gems...] Then I run the "Gem clean" command which removed all old gems... and when I run my cucumber "rake features" command I got the following: c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- spec/expectations/differs/default (MissingSourceFile) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `polyglot_original_require' from c:/ruby/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:92:in `enable_diffing' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:35:in `execute!' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 rake aborted! Command failed with status (1): [c:/ruby/bin/ruby -I "c:/ruby/lib/ruby/gems...] Any thoughts on fixing this as ?gem install spec? gives me : ?ERROR: could not find gem spec locally or in a repository?, Andre -- View this message in context: http://www.nabble.com/%28MissingSourceFile%29-no-such-file-to-load----spec-expectations-differs-default-tp23035747p23035747.html Sent from the rspec-users mailing list archive at Nabble.com. From andre.x.pretorius at gmail.com Tue Apr 14 05:40:02 2009 From: andre.x.pretorius at gmail.com (AndreXP) Date: Tue, 14 Apr 2009 02:40:02 -0700 (PDT) Subject: [rspec-users] (MissingSourceFile) no such file to load -- spec/expectations/differs/default In-Reply-To: <8d961d900904140208q1b2b886bmf0b778eae524542b@mail.gmail.com> References: <23035747.post@talk.nabble.com> <8d961d900904140208q1b2b886bmf0b778eae524542b@mail.gmail.com> Message-ID: <23036301.post@talk.nabble.com> Fixed :) I should have looked in lighthouseapp for this ticket..!! Thanks for the speedy reply. Andre Aslak Hellesoy wrote: > > On Tue, Apr 14, 2009 at 11:00 AM, AndreXP > wrote: > >> >> Hi All, >> >> This morning I did a "gem update" which installed "rspec-1.2.4" and when >> I >> run my cucumber "rake features" command I got the following: >> > > Try the latest Cucumber code (aslakhellesoy-cucumber gem). This was fixed > yesterday: > https://rspec.lighthouseapp.com/projects/16211/tickets/291-dependency-on-internal-files-in-rspec-breaks-cucumber-w-rspec-124#ticket-291-2 > > Aslak > > >> >> c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:142:in `activate': can't >> activate >> rspec (= 1.2.2, runtime), already activated rspec-1.2.4 >> (Gem::Exception) >> from >> c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `polyglot_original_require' >> from >> c:/ruby/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `require' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in >> `require' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in >> `new_constants_in' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in >> `require' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:92:in >> `enable_diffing' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:35:in >> `execute!' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in >> `execute' >> from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 >> rake aborted! >> Command failed with status (1): [c:/ruby/bin/ruby -I >> "c:/ruby/lib/ruby/gems...] >> >> Then I run the "Gem clean" command which removed all old gems... and when >> I >> run my cucumber "rake features" command I got the following: >> >> c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in >> `gem_original_require': no such file to load -- >> spec/expectations/differs/default (MissingSourceFile) >> from >> c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in >> `polyglot_original_require' >> from >> c:/ruby/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `require' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in >> `require' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in >> `new_constants_in' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in >> `require' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:92:in >> `enable_diffing' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:35:in >> `execute!' >> from >> >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in >> `execute' >> from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 >> rake aborted! >> Command failed with status (1): [c:/ruby/bin/ruby -I >> "c:/ruby/lib/ruby/gems...] >> >> >> Any thoughts on fixing this as ?gem install spec? gives me : ?ERROR: >> could >> not find gem spec locally or in a repository?, >> >> Andre >> >> -- >> View this message in context: >> http://www.nabble.com/%28MissingSourceFile%29-no-such-file-to-load----spec-expectations-differs-default-tp23035747p23035747.html >> Sent from the rspec-users mailing list archive at Nabble.com. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- View this message in context: http://www.nabble.com/%28MissingSourceFile%29-no-such-file-to-load----spec-expectations-differs-default-tp23035747p23036301.html Sent from the rspec-users mailing list archive at Nabble.com. From jeremiah.heller at gmail.com Tue Apr 14 07:32:53 2009 From: jeremiah.heller at gmail.com (Jeremiah Heller) Date: Tue, 14 Apr 2009 04:32:53 -0700 Subject: [rspec-users] various results from same test Message-ID: Hi, I've read on the 'Cucumber Backgrounder' page that running cuc via rake, command line and autotest could give different results but I seem to get different results depending on the path I pass cucumber and am not sure what's going on. I would be grateful for any help or insight. There's a fresh rails app with features/admin_management/ {crud_admins.feature,crud_admins_steps.rb} and the other default files. webrat, rspec(-rails) and cucumber are installed as plugins from their respective master branches (as of a couple hours ago) - I had them installed as gems initially but now gems are all uninstalled and only plugins reside. crud_admins.feature; just has a single step: Scenario: Create an admin user Given I can see the form to create an admin user crud_admins_steps.rb; just has a single step-def: Given "I can see the form to $action a(n)? $controller $domain" do | action, _, controller, domain| visit path_to("#{action} #{controller} #{domain}") end If I run `script/cucumber features/admin_management/ crud_admins.feature`; I see: undefined method `visit' for If I run `script/cucumber features`; I see: No route matches "/admin/users/create" which is what I expect. There are no migrations yet; could that be an/the issue? - Jeremiah From lists at ruby-forum.com Tue Apr 14 08:01:26 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Tue, 14 Apr 2009 14:01:26 +0200 Subject: [rspec-users] undefined local variable or method `params' for # References: Message-ID: <5a7105e9d4df55a9fc36081e16d7bd7a@ruby-forum.com> > it gives me following error > > undefined local variable or method `params' for That's normal. Remember that params exists because there is an http request issued. In your spec, you don't tell Rspec anything about any request. So you could create a mock for params. If I recall correctly you would have to do something like this: describe ApplicationHelper do it "should be active if controller is same" do controller.params = {:controller => 'whatever_value'} tab_class('royalty_statement').should include('active') end end -- Posted via http://www.ruby-forum.com/. From aidy.lewis at googlemail.com Tue Apr 14 08:19:55 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 14 Apr 2009 13:19:55 +0100 Subject: [rspec-users] [Cucumber] attribute readers in World? Message-ID: <7ac2300c0904140519l64e7192dya45301c07166e419@mail.gmail.com> Hi, #env.rb class ProjectWorld include Spec::Matchers def browser @browser ||= Browser.new end end World do ProjectWorld.new end Instead of using explicit getters here, can I not use attribute readers? Aidy From lists at ruby-forum.com Tue Apr 14 08:23:45 2009 From: lists at ruby-forum.com (Salil Gaikwad) Date: Tue, 14 Apr 2009 14:23:45 +0200 Subject: [rspec-users] undefined local variable or method `params' for # References: <5a7105e9d4df55a9fc36081e16d7bd7a@ruby-forum.com> Message-ID: Fernando Perez wrote: >> it gives me following error >> >> undefined local variable or method `params' for > > That's normal. Remember that params exists because there is an http > request issued. In your spec, you don't tell Rspec anything about any > request. So you could create a mock for params. If I recall correctly > you would have to do something like this: Thanx fernando i try the following it "should be active if controller is same" do params = {:controller => 'royalty_statement'} tab_class('royalty_statement').should include('active') end but it doesn't work out. it gives me same error as previus. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 14 09:01:50 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Tue, 14 Apr 2009 15:01:50 +0200 Subject: [rspec-users] undefined local variable or method `params' for # References: <5a7105e9d4df55a9fc36081e16d7bd7a@ruby-forum.com> Message-ID: <119ac056026d4734808fe19e77ec250a@ruby-forum.com> > it "should be active if controller is same" do > params = {:controller => 'royalty_statement'} > tab_class('royalty_statement').should include('active') > end > > but it doesn't work out. it gives me same error as previous. Nah it doesn't work that way, because remember that RSpec is just Ruby code. 'it' is just a method, "should be active ..." is just an argument, and then you specify a block of code. So when you define params = ..., you are actually defining a local variable, but that variable is not available inside the controller when the spec is run. That's why I find controllers so painful to spec. I prefer to use cucumber and webrat for that purpose. Anyway, I thought that setting controller.params would do the trick but no. Maybe you'll have to force a get request then? so it would be: get :action_name We need to wait for rspec-rails experts advice. By the way the same problem applies to session, so you might be luckier looking for info about simulating session in rspec and then apply the same technique to params. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 14 09:04:29 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Tue, 14 Apr 2009 15:04:29 +0200 Subject: [rspec-users] undefined local variable or method `params' for # References: <5a7105e9d4df55a9fc36081e16d7bd7a@ruby-forum.com> <119ac056026d4734808fe19e77ec250a@ruby-forum.com> Message-ID: Try with that: controller.stub!(:params).and_return({:controller => 'your_controller_name'}) -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 14 10:00:39 2009 From: lists at ruby-forum.com (Salil Gaikwad) Date: Tue, 14 Apr 2009 16:00:39 +0200 Subject: [rspec-users] undefined local variable or method `params' for # References: <5a7105e9d4df55a9fc36081e16d7bd7a@ruby-forum.com> <119ac056026d4734808fe19e77ec250a@ruby-forum.com> Message-ID: <1681160a947360df6a683ac6bb9d8173@ruby-forum.com> > Try with that: > > controller.stub!(:params).and_return({:controller => > 'your_controller_name'}) Nah it doesn't work out,gives same error. neways thanx for the info. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 14 10:11:22 2009 From: lists at ruby-forum.com (Salil Gaikwad) Date: Tue, 14 Apr 2009 16:11:22 +0200 Subject: [rspec-users] how to write a spec for an actionmailer method In-Reply-To: <49E3586A.4030202@benmabey.com> References: <6791588240fb9a0a46f6ea0d76728573@ruby-forum.com> <57c63afe0904130814n3c818859i7c970a1049c444fe@mail.gmail.com> <49E3586A.4030202@benmabey.com> Message-ID: <7f542c37297ce47752bbe07765fbd459@ruby-forum.com> > http://github.com/bmabey/email-spec/blob/cdf3eeda4d28ef8b35bbce8af9ca7c493528332d/examples/rails_root/spec/models/user_mailer_spec.rb > > -Ben I try following and it works. i don't know how but it pass the test gives me 100% coverage and also i receive a test email. describe ApplicationHelper do it "should use ActionMailer to send a confirmation email" do ActionMailer::Base.deliveries=[] Notifier.deliver_conta('Salil','salil at cipher-tech.com', 123456) end end -- Posted via http://www.ruby-forum.com/. From brandtkurowski at gmail.com Tue Apr 14 11:14:05 2009 From: brandtkurowski at gmail.com (Brandt Kurowski) Date: Tue, 14 Apr 2009 08:14:05 -0700 (PDT) Subject: [rspec-users] How to write a spec file for a helper In-Reply-To: <2c7e61990904130826q7c9bd345yeab704c6240fe257@mail.gmail.com> References: <57c63afe0904130817y762b405dkc9a5c72efb8b6068@mail.gmail.com> <2c7e61990904130826q7c9bd345yeab704c6240fe257@mail.gmail.com> Message-ID: <78ffa712-a0ac-41fd-bafc-4f59f6671af8@q9g2000yqc.googlegroups.com> On Apr 13, 11:26?am, Pat Maddox wrote: > If this is a module that you're using to extend the behavior of > Numeric classes, just mix it in somewhere and write examples for the > class that got the mixin. I prefer to test modules in isolation by mixing them into a stub in the spec, in order to make it explicit that we're describing the module itself (not some other class), and to avoid dependencies on that other class. For example: describe ArtistsHelper do before do @artist = 123.456 class << @artist include ArtistsHelper end end it "should round stuff" do @artist.round_to(1).should == 123.5 end end Granted, it looks a little awkward here since it looks like the module is meant to be used with a Numeric, but in general I find this approach to be pretty clean. -- Brandt From programmer2188 at gmail.com Tue Apr 14 11:30:49 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Tue, 14 Apr 2009 11:30:49 -0400 Subject: [rspec-users] OT: RSpec support in rails.vim Message-ID: <000c01c9bd15$fe5388a0$fafa99e0$@com> Hi, The rails plugin for vim has limited RSpec support, and it mentions how to add extra commands such as speccontroller, etc, with Rcommand. Has anyone done this? I'm not very good with the syntax of .vimrc, so I don't know how to enter these. I think it said I need to use autocmd, but everything I try just isn't working. I'd also be interested in anything else you're doing to make it work better with RSpec. Brandon From walketim at gmail.com Tue Apr 14 13:19:23 2009 From: walketim at gmail.com (Tim Walker) Date: Tue, 14 Apr 2009 11:19:23 -0600 Subject: [rspec-users] [Cucumber] features.txt Message-ID: <1ebf5a4d0904141019y7bc4166bgb771a0adc5a0275e@mail.gmail.com> Hi Guys, My nightly tests stopped working suddenly over the weekend. Not sure why yet. It's wierd because they just look like the exited without a clue mid-test. Nothing in the logs is a smoking gun. Here's my question: It seems like the contents of features.txt do not get written until the tests are done. In my current case this file is 0 length at the end of the run. Any way to affect this behavior and force the output to be written as the tests run. Many thanks guys. Sincerely, Tim From walketim at gmail.com Tue Apr 14 15:41:47 2009 From: walketim at gmail.com (Tim Walker) Date: Tue, 14 Apr 2009 13:41:47 -0600 Subject: [rspec-users] [Cucumber] features.txt In-Reply-To: <8d961d900904141126h2aca4d2dw7656061d34c8da93@mail.gmail.com> References: <1ebf5a4d0904141019y7bc4166bgb771a0adc5a0275e@mail.gmail.com> <8d961d900904141126h2aca4d2dw7656061d34c8da93@mail.gmail.com> Message-ID: <1ebf5a4d0904141241i1dbbf4d0t84d5a344c7f20ba8@mail.gmail.com> Sorry. This is running from cruisecontrol rb: --- Cucumber::Rake::Task.new(:cruise) do |t| t.cucumber_opts = "-r features/cucumber_env --format pretty --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.txt --format html --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.html" t.rcov = true t.rcov_opts = ["#{RCOV_COMMON_OPTS} -o #{ENV['CC_BUILD_ARTIFACTS']}/features_rcov"] t.feature_pattern = ["features/control*/*.feature"] end --- Thanks, Tim On Tue, Apr 14, 2009 at 12:26 PM, aslak hellesoy wrote: > > > On Tue, Apr 14, 2009 at 7:19 PM, Tim Walker wrote: >> >> Hi Guys, >> >> My nightly tests stopped working suddenly over the weekend. Not sure >> why yet. It's wierd because they just look like the exited without a >> clue mid-test. Nothing in the logs is a smoking gun. >> >> Here's my question: It seems like the contents of features.txt do not > > What's features.txt? > >> >> get written until the tests are done. In my current case this file is >> 0 length at the end of the run. Any way to affect this behavior and >> force the output to be written as the tests run. >> >> Many thanks guys. >> >> Sincerely, >> >> 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 > From jeremiah.heller at gmail.com Tue Apr 14 16:06:59 2009 From: jeremiah.heller at gmail.com (Jeremiah Heller) Date: Tue, 14 Apr 2009 13:06:59 -0700 Subject: [rspec-users] various results from same test In-Reply-To: <8d961d900904140541t3bd8de42n6f4cf44e85df131d@mail.gmail.com> References: <8d961d900904140541t3bd8de42n6f4cf44e85df131d@mail.gmail.com> Message-ID: <82D8D31C-AB3B-472C-815E-007B59EF6929@gmail.com> On 14 Apr 2009, at 05:41, aslak hellesoy wrote: > crud_admins.feature; just has a single step: > Scenario: Create an admin user > Given I can see the form to create an admin user > > crud_admins_steps.rb; just has a single step-def: > Given "I can see the form to $action a(n)? $controller > $domain" do |action, _, controller, domain| > visit path_to("#{action} #{controller} #{domain}") > end > > If I run `script/cucumber features/admin_management/ > crud_admins.feature`; I see: > undefined method `visit' for > > If I run `script/cucumber features`; I see: > No route matches "/admin/users/create" > > which is what I expect. > > There are no migrations yet; could that be an/the issue? > > Can you post the full backtrace in addition to the error message? Here it is. Thanks for taking a look. undefined method `visit' for # (NoMethodError) ./features/admin_management/crud_admins_steps.rb:5:in `__instance_exec0' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/core_ext/instance_exec.rb:60:in `send' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/core_ext/instance_exec.rb:60:in `instance_exec' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/core_ext/instance_exec.rb:20:in `cucumber_instance_exec' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/core_ext/instance_exec.rb:38:in `cucumber_run_with_backtrace_filtering' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/core_ext/instance_exec.rb:10:in `cucumber_instance_exec' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/step_definition.rb:102:in `invoke' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/step_match.rb:13:in `invoke' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/step_invocation.rb:32:in `invoke' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/step_invocation.rb:22:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/visitor.rb:74:in `visit_step' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/formatter/pretty.rb:120:in `visit_step' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/step_collection.rb:14:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/step_collection.rb:13:in `each' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/step_collection.rb:13:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/visitor.rb:70:in `visit_steps' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/scenario.rb:33:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/step_mother.rb:201:in `before_and_after' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/scenario.rb:32:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/visitor.rb:45:in `visit_feature_element' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/formatter/pretty.rb:79:in `visit_feature_element' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/feature.rb:22:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/feature.rb:21:in `each' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/feature.rb:21:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/visitor.rb:23:in `visit_feature' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/formatter/pretty.rb:41:in `visit_feature' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/features.rb:21:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/features.rb:20:in `each' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/features.rb:20:in `accept' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/ast/visitor.rb:19:in `visit_features' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/formatter/pretty.rb:26:in `visit_features' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/broadcaster.rb:9:in `__send__' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/broadcaster.rb:9:in `method_missing' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/broadcaster.rb:8:in `map' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/broadcaster.rb:8:in `method_missing' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/cli/main.rb:41:in `execute!' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/../lib/ cucumber/cli/main.rb:20:in `execute' /Users/jf/Sites/tarbis/vendor/plugins/cucumber/bin/cucumber:6 script/cucumber:3:in `load' script/cucumber:3 features/admin_management/crud_admins.feature:7:in `Given I can see the form to create an admin user' From lists at ruby-forum.com Tue Apr 14 19:39:26 2009 From: lists at ruby-forum.com (Wolfram Arnold) Date: Wed, 15 Apr 2009 01:39:26 +0200 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? Message-ID: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> We're trying to verify XML REST API's and would like to write Cucumber specs of the following type: Scenario: Create a phrase Given I have an authenticated session for user with login "steve" When I send a POST to /phrases with parameters: locale=ca and post body " 060e985b-0307-4c8f-b43f-c16f0e45196d Fake Catalan Source ca " Then I get a 201 (created) status result And I a phrase object with UUID=060e985b-0307-4c8f-b43f-c16f0e45196d exists on the server In other words, we're trying to pass a multi-line value to the parser. We've found this reference: https://rspec.lighthouseapp.com/projects/16211/tickets/4-add-multiline-step-support It's marked as resolved, but we can't seem to get it to work with the "..." syntax. The parser statement is: When /^I send a (GET|POST|PUT|DELETE) to ([\/\w]+)(?: with parameters: )?(.*) and post body (.*)$/m do |method, path, params, body| send(method.downcase.to_sym, path, params) end The error: $ cucumber features/phrases_xml.feature -n /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/parser/treetop_ext.rb:42:in `parse_or_fail': features/phrases_xml.feature:9:6: Parse error, expected one of "|", "\n", "\r", "\"\"\"", "#", "Given", "When", "Then", "And", "But", "@", "Scenario", "Scenario Outline". (Cucumber::Parser::SyntaxError) from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/parser/treetop_ext.rb:28:in `parse_file' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/parser/treetop_ext.rb:33:in `open' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/parser/treetop_ext.rb:33:in `parse_file' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:55:in `load_plain_text_features' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:54:in `each' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:54:in `load_plain_text_features' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:37:in `execute!' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 from /usr/bin/cucumber:19:in `load' from /usr/bin/cucumber:19 -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 14 19:40:46 2009 From: lists at ruby-forum.com (Wolfram Arnold) Date: Wed, 15 Apr 2009 01:40:46 +0200 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> Message-ID: <0c4134cb04f1d6bec09a09bc2e836f6d@ruby-forum.com> Copy & paste mistake: We did escape the quotes inside the XML stanza, result is the same. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Tue Apr 14 20:37:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 14 Apr 2009 18:37:14 -0600 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> Message-ID: <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> On Apr 14, 2009, at 5:39 PM, Wolfram Arnold wrote: > We're trying to verify XML REST API's and would like to write Cucumber > specs of the following type: > > Scenario: Create a phrase > Given I have an authenticated session for user with login "steve" > When I send a POST to /phrases with parameters: locale=ca and post > body > " > > 060e985b-0307-4c8f-b43f-c16f0e45196d > Fake Catalan Source > ca > " > Then I get a 201 (created) status result > And I a phrase object with UUID=060e985b-0307-4c8f-b43f- > c16f0e45196d > exists on the server > > In other words, we're trying to pass a multi-line value to the parser. Have you tried the pystring syntax? Given I want to have multiple lines """ I can pass them in with three quotes... """ -Ben From ben at benmabey.com Tue Apr 14 21:31:22 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 14 Apr 2009 19:31:22 -0600 Subject: [rspec-users] [Cucumber] features.txt In-Reply-To: <1ebf5a4d0904141241i1dbbf4d0t84d5a344c7f20ba8@mail.gmail.com> References: <1ebf5a4d0904141019y7bc4166bgb771a0adc5a0275e@mail.gmail.com> <8d961d900904141126h2aca4d2dw7656061d34c8da93@mail.gmail.com> <1ebf5a4d0904141241i1dbbf4d0t84d5a344c7f20ba8@mail.gmail.com> Message-ID: <9E1B094C-142D-45E4-8CA3-062A080CB78F@benmabey.com> On Apr 14, 2009, at 1:41 PM, Tim Walker wrote: > Sorry. This is running from cruisecontrol rb: > > --- > Cucumber::Rake::Task.new(:cruise) do |t| > t.cucumber_opts = "-r features/cucumber_env --format pretty > --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.txt --format html > --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.html" > t.rcov = true > t.rcov_opts = ["#{RCOV_COMMON_OPTS} -o > #{ENV['CC_BUILD_ARTIFACTS']}/features_rcov"] > t.feature_pattern = ["features/control*/*.feature"] > end > --- > > Thanks, > > Tim What happens when you run the features from the command line on the build server? What output do you get then? -Ben > > > On Tue, Apr 14, 2009 at 12:26 PM, aslak hellesoy > wrote: >> >> >> On Tue, Apr 14, 2009 at 7:19 PM, Tim Walker >> wrote: >>> >>> Hi Guys, >>> >>> My nightly tests stopped working suddenly over the weekend. Not sure >>> why yet. It's wierd because they just look like the exited without a >>> clue mid-test. Nothing in the logs is a smoking gun. >>> >>> Here's my question: It seems like the contents of features.txt do >>> not >> >> What's features.txt? >> >>> >>> get written until the tests are done. In my current case this file >>> is >>> 0 length at the end of the run. Any way to affect this behavior and >>> force the output to be written as the tests run. >>> >>> Many thanks guys. >>> >>> Sincerely, >>> >>> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From sfeley at gmail.com Tue Apr 14 22:37:09 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 14 Apr 2009 22:37:09 -0400 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> Message-ID: <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> On Tue, Apr 14, 2009 at 8:37 PM, Ben Mabey wrote: > > Have you tried the pystring syntax? > > Given I want to have multiple lines > """ > I can pass them > in with three quotes... > """ How does that parse into a step definition? Would it be: Given /^I want to have multiple lines\n(.*)$/m do |text| ...or would it be something else? Is the newline character necessary? Are the quotes included? And does this imply that multiline text must always be separated from from steps in lines of its own? Sorry if I'm asking dumb questions, but I was trying to look this up a few weeks ago myself to represent some example Markdown data, and eventually gave up. This isn't documented anywhere that I could find. I've also never heard of pystring syntax -- I just tried to Google that too, but all I got were references to Java libraries and no simple syntax reference. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From zach.dennis at gmail.com Tue Apr 14 22:53:50 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 14 Apr 2009 22:53:50 -0400 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> Message-ID: <85d99afe0904141953s113c982fr2cb09244518b790a@mail.gmail.com> On Tue, Apr 14, 2009 at 10:37 PM, Stephen Eley wrote: > On Tue, Apr 14, 2009 at 8:37 PM, Ben Mabey wrote: >> >> Have you tried the pystring syntax? >> >> Given I want to have multiple lines >> """ >> I can pass them >> in with three quotes... >> """ > > How does that parse into a step definition? ?Would it be: > > Given /^I want to have multiple lines\n(.*)$/m do |text| Given /^I want to have multiple lines$/m do |text| Cucumber parses it and appends it to the blocks argument list---so it will always be the last argument. e.g. Given /^(\w+) want to have multiple lines$/m do |who, text| It is a cucumber PyString object, but you can treat it like a normal string. > > ...or would it be something else? ?Is the newline character necessary? > ?Are the quotes included? ?And does this imply that multiline text > must always be separated from from steps in lines of its own? > > Sorry if I'm asking dumb questions, but I was trying to look this up a > few weeks ago myself to represent some example Markdown data, and > eventually gave up. ?This isn't documented anywhere that I could find. > ?I've also never heard of pystring syntax -- I just tried to Google > that too, but all I got were references to Java libraries and no > simple syntax reference. > > > -- > Have Fun, > ? Steve Eley (sfeley at gmail.com) > ? ESCAPE POD - The Science Fiction Podcast Magazine > ? http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From sfeley at gmail.com Tue Apr 14 23:03:40 2009 From: sfeley at gmail.com (Stephen Eley) Date: Tue, 14 Apr 2009 23:03:40 -0400 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> Message-ID: <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> On Tue, Apr 14, 2009 at 10:37 PM, Stephen Eley wrote: > > Sorry if I'm asking dumb questions, but I was trying to look this up a > few weeks ago myself to represent some example Markdown data, and > eventually gave up. ?This isn't documented anywhere that I could find. > ?I've also never heard of pystring syntax -- I just tried to Google > that too, but all I got were references to Java libraries and no > simple syntax reference. All right, never mind. Having been given enough clues that the feature exists and what it generally might look like, I prowled through Cucumber's specs and examples until I got a clearer picture. Then, to keep my 'There ain't no documentation!' whining privileges, I went and added what I learned to the wiki: http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments I'd call it my minor good deed for the day, but really I was using it to procrastinate on my podcasting work for another half hour, so overall it was morally neutral. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From phlip2005 at gmail.com Tue Apr 14 23:22:16 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 14 Apr 2009 20:22:16 -0700 Subject: [rspec-users] How to write a feature that calls for a prompt? In-Reply-To: <5A95EAE4A3FE1645992FAF868AD6DCDC09B48C9C@DEN-EXM-06.corp.ebay.com> References: <5A95EAE4A3FE1645992FAF868AD6DCDC09B48C9C@DEN-EXM-06.corp.ebay.com> Message-ID: Colfer, Brian wrote: > I am writing a feature that will test an LDAP protected site. I need to > login as my self with my real password. When unit testing, thou shalt not hit the wire. Mock anything that goes further than your database. Put another way, you are not going to refactor LDAP itself, or add features to it, so mocks should set the boundaries to what you do expect to refactor. From ben at benmabey.com Wed Apr 15 00:34:22 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 14 Apr 2009 22:34:22 -0600 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> Message-ID: <49E563CE.40409@benmabey.com> Stephen Eley wrote: > On Tue, Apr 14, 2009 at 10:37 PM, Stephen Eley wrote: > >> Sorry if I'm asking dumb questions, but I was trying to look this up a >> few weeks ago myself to represent some example Markdown data, and >> eventually gave up. This isn't documented anywhere that I could find. >> I've also never heard of pystring syntax -- I just tried to Google >> that too, but all I got were references to Java libraries and no >> simple syntax reference. >> > > All right, never mind. Having been given enough clues that the > feature exists and what it generally might look like, I prowled > through Cucumber's specs and examples until I got a clearer picture. > Then, to keep my 'There ain't no documentation!' whining privileges, I > went and added what I learned to the wiki: > > http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments > > I'd call it my minor good deed for the day, but really I was using it > to procrastinate on my podcasting work for another half hour, so > overall it was morally neutral. > > > lol.. Sorry for not explaining the syntax better... What you wrote on the wiki is great and doesn't really need further explanation by Ben Mabey or anyone else IMO. ;) I'll go ahead and elaborate on it though. Thanks for adding the page. -Ben From aslak.hellesoy at gmail.com Wed Apr 15 01:12:47 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Wed, 15 Apr 2009 07:12:47 +0200 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> Message-ID: <5AA9D81A-C696-4FEF-999D-A58FD5E69F92@gmail.com> > On Tue, Apr 14, 2009 at 10:37 PM, Stephen Eley > wrote: >> >> Sorry if I'm asking dumb questions, but I was trying to look this >> up a >> few weeks ago myself to represent some example Markdown data, and >> eventually gave up. This isn't documented anywhere that I could >> find. >> I've also never heard of pystring syntax -- I just tried to Google >> that too, but all I got were references to Java libraries and no >> simple syntax reference. > > All right, never mind. Having been given enough clues that the > feature exists and what it generally might look like, I prowled > through Cucumber's specs and examples until I got a clearer picture. > Then, to keep my 'There ain't no documentation!' whining privileges, I > went and added what I learned to the wiki: > > http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments > > I'd call it my minor good deed for the day, but really I was using it > to procrastinate on my podcasting work for another half hour, so > overall it was morally neutral. > Allright allright. You *will* be allowed into Cucumber heaven :-) Aslak > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From sfeley at gmail.com Wed Apr 15 01:30:17 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 15 Apr 2009 01:30:17 -0400 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <5AA9D81A-C696-4FEF-999D-A58FD5E69F92@gmail.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> <5AA9D81A-C696-4FEF-999D-A58FD5E69F92@gmail.com> Message-ID: <1fb4df0904142230y5399bb52r254bd2e0f6e47003@mail.gmail.com> On Wed, Apr 15, 2009 at 1:12 AM, Aslak Helles?y wrote: > > Allright allright. You *will* be allowed into Cucumber heaven :-) Woohoo! That makes me so happy that I won't share any of the dirty jokes that sentence evokes. >8-> -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From bcolfer at shopping.com Wed Apr 15 02:46:06 2009 From: bcolfer at shopping.com (Colfer, Brian) Date: Wed, 15 Apr 2009 00:46:06 -0600 Subject: [rspec-users] How to write a feature that calls for a prompt? In-Reply-To: References: <5A95EAE4A3FE1645992FAF868AD6DCDC09B48C9C@DEN-EXM-06.corp.ebay.com> Message-ID: <5A95EAE4A3FE1645992FAF868AD6DCDC09B48E5A@DEN-EXM-06.corp.ebay.com> Phlip, Ah, but I am not unit testing ... I am writing an acceptance test. I am QA, not the developer and using cucumber to automate the functional and acceptance tests. Brian -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Phlip Sent: Tuesday, April 14, 2009 8:22 PM To: rspec-users at rubyforge.org Subject: Re: [rspec-users] How to write a feature that calls for a prompt? Colfer, Brian wrote: > I am writing a feature that will test an LDAP protected site. I need > to login as my self with my real password. When unit testing, thou shalt not hit the wire. Mock anything that goes further than your database. Put another way, you are not going to refactor LDAP itself, or add features to it, so mocks should set the boundaries to what you do expect to refactor. _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Wed Apr 15 04:14:03 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 15 Apr 2009 09:14:03 +0100 Subject: [rspec-users] Spec run heuristics (Re: Cucover: coverage-aware 'lazy' cucumber runs) In-Reply-To: <88fd8ddc0904141313r123b28bbv870b2bc98a5743ff@mail.gmail.com> References: <5128FD4F-E996-4C30-8BA6-0F82AEE659E6@mattwynne.net> <40F67B27-3699-4387-A3D8-77AE361D238B@patchspace.co.uk> <1fb4df0904112147x2d7cda39v7f97efb25c3ba6ad@mail.gmail.com> <8d961d900904130446u13f1539bhc8122ef6ab87dbed@mail.gmail.com> <1fb4df0904132056r403b4344ld86a31ac1ea2e6f5@mail.gmail.com> <88fd8ddc0904141313r123b28bbv870b2bc98a5743ff@mail.gmail.com> Message-ID: <946B9C6D-462A-406E-BE82-27711F38539A@mattwynne.net> Yeah this is all good stuff. We're basically talking about 'personal CI' here I think[1]. Nothing wrong with that, but we must remember some of this can be deferred until check-in. [1]http://silkandspinach.net/2009/01/18/a-different-use-for-cruisecontrol/ On 14 Apr 2009, at 21:13, Andrew Premdas wrote: > One simple thing I asked about the other day was running multiple > instances of autotest to do different things. Currently I'd like to > run one for my specs and one for my features, but you could easily > extend this idea. Creating several profiles that run at the same > time, with the long running ones having a low priority would give a > range of feedback that eventually would be fairly complete (on a big > project it might fully catch up overnight, or at the weekend) whilst > providing sufficient feedback to be able to iterate quickly with > reasonable confidence > > 2009/4/14 Stephen Eley > On Mon, Apr 13, 2009 at 7:46 AM, aslak hellesoy > wrote: > > > > So if someone develops a better AutoTest with a plugin > architecture, and > > that doesn't have to run as a long/lived process, then I'd be very > > interested in writing the neural network part - possibly backed by > FANN > > (http://leenissen.dk/fann/) > > In the immortal words of Socrates, "That rocks." > > The nice thing about separating concerns like this -- the reason why > design patterns appeal so much to me -- is that pieces can rather > easily be built up incrementally. As Matt said, thinking 'neural > networks' with this is way beyond the level of anything I'd had in my > head. But it's a damn cool idea. > > I can think of a few ways to handle this particular chunk, with levels > of complexity that would scale up: > > 1.) DUMB REACTION: Just re-run the tests that failed in this run > cycle. Then, periodically, run tests that succeeded in the background > as a regression check. (This isn't much beyond what Autotest does > now.) > > 2.) OBSERVERS: Allow handlers to register themselves against certain > files, so that when a file is changed, that handlers gets run. > Multiple handlers can observe any given file, and a handler can > declare multiple rules, including directories or pattern matches. > (Again, Autotest has something _sort of_ like this, but not nearly as > flexible.) > > 3.) PERSISTENCE: Track the history of tests and the times they were > created, edited, last run, and last failed. Also track file > modification times. When a file changes, run the tests first that are > either new or have failed since the last time the file was changed. > Then run the tests that went from failing to passing in that time. > (This could certainly be improved -- I haven't sat down to figure out > the actual rule set -- but you get the gist. Know when things changed > and set priorities accordingly.) > > 4.) INTELLIGENCE: Aslak's neural network. Let the system figure out > which tests matter to which files, and run what it thinks it ought to > run. Maybe use code coverage analysis. It can 'learn' and improve > when the full suite is run and it discovers new failures. > > In all four of these cases, I still think it's imperative to run the > full suite. None of these methods are foolproof, and code is tricky > and makes weird things happen in weird crevices. That's _why_ testing > must be done. But running the suite doesn't have to be a 'blocking' > activity, like it is with Autotest now. It can happen in bits and > pieces, when nothing else is going on, and it can be configured to > only grab your attention when something failed unexpectedly. > > (That's one of the prime reasons for the 'multiple output views' > feature, by the way. When I said output views I wasn't just thinking > of the console or a window. I'm also thinking Dashboard widgets, or > gauges in the toolbar, or RSS feeds, or dynamic wallpaper, or whatever > else anyone can think of. Stuff that stays out of your way until it > either needs you or you choose to look at it.) > > Still making sense? This is starting to sound pretty big and pretty > complex -- but I don't think it strictly needs to be. #1 and #2 above > are pretty easy. The others don't have to be built before releasing > something. And, of course, you wouldn't have to pick just one > selection module. You could run or disable all of these depending on > your project's needs, or come up with your own system involving Tarot > cards and Linux running on a dead badger.(*) > > I just want to build a core that detects changes in stuff, tells other > stuff about it, and passes on what that stuff says about it to a third > set of stuff. The rest is implementation-specific details. >8-> > > (* http://www.strangehorizons.com/2004/20040405/badger.shtml ) > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > 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 Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From matt at mattwynne.net Wed Apr 15 04:19:41 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 15 Apr 2009 09:19:41 +0100 Subject: [rspec-users] How to write a spec file for a helper In-Reply-To: <78ffa712-a0ac-41fd-bafc-4f59f6671af8@q9g2000yqc.googlegroups.com> References: <57c63afe0904130817y762b405dkc9a5c72efb8b6068@mail.gmail.com> <2c7e61990904130826q7c9bd345yeab704c6240fe257@mail.gmail.com> <78ffa712-a0ac-41fd-bafc-4f59f6671af8@q9g2000yqc.googlegroups.com> Message-ID: <693785E5-6AD5-43ED-AB09-5C45C5245928@mattwynne.net> On 14 Apr 2009, at 16:14, Brandt Kurowski wrote: > On Apr 13, 11:26 am, Pat Maddox wrote: >> If this is a module that you're using to extend the behavior of >> Numeric classes, just mix it in somewhere and write examples for the >> class that got the mixin. > > I prefer to test modules in isolation by mixing them into a stub in > the spec, in order to make it explicit that we're describing the > module itself (not some other class), and to avoid dependencies on > that other class. For example: > > describe ArtistsHelper do > before do > @artist = 123.456 > class << @artist > include ArtistsHelper > end > end > > it "should round stuff" do > @artist.round_to(1).should == 123.5 > end > end > > Granted, it looks a little awkward here since it looks like the module > is meant to be used with a Numeric Isn't it? That's probably what I would infer if I read this code. Is there any reason why you don't do this? @artist = Object.new.extend(ArtistHelper) Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From lists at ruby-forum.com Wed Apr 15 09:04:16 2009 From: lists at ruby-forum.com (Neema Cheriyath) Date: Wed, 15 Apr 2009 15:04:16 +0200 Subject: [rspec-users] Ambigous error while running cucumber features Message-ID: Hello, I was just trying out a cucumber-java example with selenium integrated. My feature file has two scenarios and while executing the command "cucumber features", It is executing the first scenario succesfully, but for the second scenario I am getting the ambiguity error (Cucumber::Ambiguous): Scenario: Find what I'm looking for in yahoo # features/login.feature:11 Given I am on the yahoo search page # features/login.feature:12 Ambiguous match of "I am on the yahoo search page": public void main.java.selenium.orbitz.SearchFeature.givenOnHome(java.lang.String) throws java.lang.Exception:in `/I am on the (Google|yahoo) search page/' public void main.java.selenium.orbitz.SearchFeature.givenOnHome(java.lang.String) throws java.lang.Exception:in `/I am on the (Google|yahoo) search page/' You can run again with --guess to make Cucumber be more smart about it (Cucumber::Ambiguous) /opt/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/step_mother.rb:122:in `step_match' /opt/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/ast/step_invocation.rb:50:in `find_step_match!' Infact I am getting the same error whenver I try to run more than one scenario in a feature file with java step definitions. But running the same via ruby step definitions is working fine. Could anyone please explain how to solve this ambiguity? Is it not possible to run more than one scenario of cucumber features using cucumber-java ? I have attached the contents of env.rb, search.feature and the java file for which this issue is occurring herewith. Thanks, Neema Attachments: http://www.ruby-forum.com/attachment/3577/searchfiles.txt -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Apr 15 10:19:45 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Wed, 15 Apr 2009 16:19:45 +0200 Subject: [rspec-users] How to test/spec an ActiveRecord find that uses :include Message-ID: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> Hi, I was refactoring my model specs so that they don't hit the database, but how to handle a custom find that uses :joins or :include with some important :conditions? I can't see a way to not hit the database. Should that spec actually belong to an integration spec? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Apr 15 10:18:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 15 Apr 2009 11:18:46 -0300 Subject: [rspec-users] [ANN] rspec 1.2.4 Released Message-ID: <57c63afe0904150718m42345029v61575df42617a31b@mail.gmail.com> rspec version 1.2.4 has been released! Be sure to check History.rdoc and Updgrade.rdoc at http://rspec.rubyforge.org/rspec/1.2.4/ before upgrading. * * * * Behaviour Driven Development for Ruby. Changes: ### Version 1.2.4 * bug fix * just one - update the manifest ### Version 1.2.3 * enhancements * support for specifying single examples with colon syntax. Closes #712. (Ben Mabey) * you can now say "spec some_spec.rb:12" in addition to "spec some_spec.rb --line 12" * run specs locally with --drb if no drb server is running. Closes #780. * still prints "No server running" to stderr * bug fixes * support expectations on DelegateClass (Clifford T. Matthews). Closes #48. * Fixed match_array blows up if elements can't be sorted (Jeff Dean). Closes #779. * deprecations * BaseFormatter#add_example_group (use #example_group_started instead) * ExampleGroupProxy#backtrace (use #location instead) * ExampleProxy#backtrace (use #location instead) * BaseFormatter#example_pending now expects two arguments. The third argument is deprecated. * ExampleGroupProxy#filtered_description. This was only used in one place internally, and was a confusing solution to the problem. If you've got a custom formatter that uses it, you can just use ExampleGroupProxy#description and modify it directly. * predicate_matchers (use the new Matcher DSL instead) * Spec::Matchers.create (use Spec::Matchers.define instead) * * * * From phlip2005 at gmail.com Wed Apr 15 10:30:43 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 15 Apr 2009 07:30:43 -0700 Subject: [rspec-users] How to test/spec an ActiveRecord find that uses :include In-Reply-To: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> References: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> Message-ID: Fernando Perez wrote: > I was refactoring my model specs so that they don't hit the database, > but how to handle a custom find that uses :joins or :include with some > important :conditions? I can't see a way to not hit the database. What's wrong with hitting the database? When high-end consultants like Mike Feathers tell you not to hit the database, what they are really saying is that programmers using big iron languages like C++ or Java should start decoupling by any means necessary. It's just a mind-game. At the other extreme, systems like Rails and its test fixtures have illustrated how you can leverage the database for a pool of stub objects. It doesn't lead to bad design, or slow tests down. -- Phlip From programmer2188 at gmail.com Wed Apr 15 10:52:15 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Wed, 15 Apr 2009 10:52:15 -0400 Subject: [rspec-users] Specs for RSpec Matchers and Helpers Message-ID: <001801c9bdd9$c57a4f90$506eeeb0$@com> Hi, I've been extracting a lot of code out of my specs into their own matchers, helpers, and macros. I notice that the plugins that have their own specs, such as rspec-rails, and even RSpec itself, have specs for the matchers and helpers. Is this generally a good thing to do, or is it unnecessary? Brandon From mark at mwilden.com Wed Apr 15 11:10:09 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 15 Apr 2009 08:10:09 -0700 Subject: [rspec-users] Specs for RSpec Matchers and Helpers In-Reply-To: <001801c9bdd9$c57a4f90$506eeeb0$@com> References: <001801c9bdd9$c57a4f90$506eeeb0$@com> Message-ID: <3c30da400904150810p45f47dcarbeb137d02daf1752@mail.gmail.com> On Wed, Apr 15, 2009 at 7:52 AM, Brandon Olivares wrote: > > I've been extracting a lot of code out of my specs into their own matchers, > helpers, and macros. > > I notice that the plugins that have their own specs, such as rspec-rails, > and even RSpec itself, have specs for the matchers and helpers. Is this > generally a good thing to do, or is it unnecessary? The main difference is that they ship their matchers and you don't. If their matchers have bugs, then their product has bugs. Not necessarily so with your matchers. In general, test code is simpler and more obvious than the code it tests. So we don't have to test our tests. But it certainly doesn't hurt, and if doing so increases the comfort level to a desired level, then by all means do it. Finally, much code can benefit from TDD, including matchers. ///ark From lists at ruby-forum.com Wed Apr 15 11:14:01 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Wed, 15 Apr 2009 17:14:01 +0200 Subject: [rspec-users] How to test/spec an ActiveRecord find that uses :include In-Reply-To: References: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> Message-ID: <5ca31d68f178dff9fb03874ea535946a@ruby-forum.com> > What's wrong with hitting the database? Actually it slows tests down like hell. I was able to ?10 my testing time by not hitting the DB as much as I used to. But I think that hitting DB for such case is acceptable. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Wed Apr 15 11:16:13 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 15 Apr 2009 16:16:13 +0100 Subject: [rspec-users] How to test/spec an ActiveRecord find that uses :include In-Reply-To: References: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> Message-ID: On 15 Apr 2009, at 15:30, Phlip wrote: > Fernando Perez wrote: > >> I was refactoring my model specs so that they don't hit the database, >> but how to handle a custom find that uses :joins or :include with >> some >> important :conditions? I can't see a way to not hit the database. > > What's wrong with hitting the database? > > When high-end consultants like Mike Feathers tell you not to hit the > database, what they are really saying is that programmers using big > iron languages like C++ or Java should start decoupling by any means > necessary. It's just a mind-game. > > At the other extreme, systems like Rails and its test fixtures have > illustrated how you can leverage the database for a pool of stub > objects. It doesn't lead to bad design, or slow tests down. It doesn't slow tests down!? Are you sure? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lenny at aps.org Wed Apr 15 11:23:46 2009 From: lenny at aps.org (Lenny Marks) Date: Wed, 15 Apr 2009 11:23:46 -0400 Subject: [rspec-users] [ANN] rspec 1.2.4 Released In-Reply-To: <57c63afe0904150718m42345029v61575df42617a31b@mail.gmail.com> References: <57c63afe0904150718m42345029v61575df42617a31b@mail.gmail.com> Message-ID: <0EDD31C2-88DD-4BFA-A605-9AF0BEC67401@aps.org> Just tried it out. Something missed? -lenny > cat t.rb describe 'test' do it "should not fail" do ['A'].should include('A') end end > spec -v rspec 1.2.4 > spec t.rb F 1) NoMethodError in 'test should not fail' undefined method `helper' for # t.rb:3: On Apr 15, 2009, at 10:18 AM, David Chelimsky wrote: > rspec version 1.2.4 has been released! > > Be sure to check History.rdoc and Updgrade.rdoc at > http://rspec.rubyforge.org/rspec/1.2.4/ before upgrading. > > * > * > * > * > > Behaviour Driven Development for Ruby. > > Changes: > > ### Version 1.2.4 > > * bug fix > * just one - update the manifest > > ### Version 1.2.3 > > * enhancements > * support for specifying single examples with colon syntax. Closes > #712. > (Ben Mabey) > * you can now say "spec some_spec.rb:12" in addition to "spec > some_spec.rb > --line 12" > * run specs locally with --drb if no drb server is running. Closes > #780. > * still prints "No server running" to stderr > > * bug fixes > * support expectations on DelegateClass (Clifford T. Matthews). > Closes #48. > * Fixed match_array blows up if elements can't be sorted (Jeff > Dean). Closes #779. > > * deprecations > * BaseFormatter#add_example_group (use #example_group_started > instead) > * ExampleGroupProxy#backtrace (use #location instead) > * ExampleProxy#backtrace (use #location instead) > * BaseFormatter#example_pending now expects two arguments. The third > argument is deprecated. > * ExampleGroupProxy#filtered_description. This was only used in one > place > internally, and was a confusing solution to the problem. If > you've got a > custom formatter that uses it, you can just use > ExampleGroupProxy#description and modify it directly. > * predicate_matchers (use the new Matcher DSL instead) > * Spec::Matchers.create (use Spec::Matchers.define instead) > > * > * > * > * > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Apr 15 11:45:59 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Wed, 15 Apr 2009 17:45:59 +0200 Subject: [rspec-users] RSpec makes me want to write better code In-Reply-To: <537533f3441d1651cb688abe73790685@ruby-forum.com> References: <25ae8c0f5f9b09f50538e8be2539f1f0@ruby-forum.com> <537533f3441d1651cb688abe73790685@ruby-forum.com> Message-ID: > 6 months since my initial post, what happened in between? Damn! BDD + writing specs that don't hit the database, also taught me to not break Demeter's law :-D It's simply a huge pain to spec a double dot method call, i.e: user.membership.paid? ActiveRecord associations are super, but they can back fire pretty bad if you abuse them. -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Wed Apr 15 11:53:07 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 15 Apr 2009 08:53:07 -0700 Subject: [rspec-users] How to test/spec an ActiveRecord find that uses :include In-Reply-To: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> References: <359c46bca38b733c5ae6e77a444f09f8@ruby-forum.com> Message-ID: <2c7e61990904150853s51d178fn9956c7596ca7054f@mail.gmail.com> You have to hit the db here to make sure that it works. Can't isolate all the time, especially when building database-centric apps ;) As for testing it, the easiest way I know of to test the association was included is to check #loaded? on the proxy. h = Harbor.first h.marinas.should be_loaded That works right out of the box and is usually enough to make you confident that the find was done with an include. You can also hook into AR.find/execute and count the number of queries and verify that there's only one. Pat On Wed, Apr 15, 2009 at 7:19 AM, Fernando Perez wrote: > Hi, > > I was refactoring my model specs so that they don't hit the database, > but how to handle a custom find that uses :joins or :include with some > important :conditions? I can't see a way to not hit the database. > > Should that spec actually belong to an integration spec? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pat.maddox at gmail.com Wed Apr 15 11:56:21 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 15 Apr 2009 08:56:21 -0700 Subject: [rspec-users] How to write a feature that calls for a prompt? In-Reply-To: <5A95EAE4A3FE1645992FAF868AD6DCDC09B48C9C@DEN-EXM-06.corp.ebay.com> References: <5A95EAE4A3FE1645992FAF868AD6DCDC09B48C9C@DEN-EXM-06.corp.ebay.com> Message-ID: <2c7e61990904150856j780b52f0sceab2f2c96209d91@mail.gmail.com> You can use IO.popen to run and interact with a command line program. Pat On Tue, Apr 14, 2009 at 1:58 PM, Colfer, Brian wrote: > I am writing a feature that will test an LDAP protected site.? I need to > login as my self with my real password. > > I'm thinking of writing a feature that looks something like this > > Feature: Login > > As a LDAP user > I want to login > And see the welcome banner > So that I can know that I can login to the system > > Scenario: LDAP login > > Given a LDAP user > When I go to the site "https://toolsite.domain.com" > And I enter the login name "enter_login_name" > And I enter the password "enter_password" > Then I should see the welcome banner "Tool Site at Domain.com" > > I imagine that I can have a step that would look something like this? > > require 'highline/import' > require 'my-user-def' > require 'my-site-runner' > > Given /^a LDAP user$/ do > ? @user.new > end > > When /^I go to the site "([^\"]*)"$/ do |arg1| > ? @site.goto(arg1) > end > > When /^I enter the login name "([^\"]*)"$/ do |arg1| > ? if arg1 == "enter_login_name" > ????? @user.login_name = ask("Enter login name") {|q| q.echo = true} > ? end > end > > When /^I enter the password "([^\"]*)"$/ do |arg1| > ? if arg1 == "enter_password" > ????? @user.password = ask("Enter password") {|q| q.echo = false} > ? end > end > > Then /^I should see the welcome banner "([^\"]*)"$/ do |arg1| > ? @site.text.include? arg1 == true > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Apr 15 12:17:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 15 Apr 2009 18:17:35 +0200 Subject: [rspec-users] Cucumber features for RSS feeds In-Reply-To: References: Message-ID: <67a9357900f663a6ba4f34c66f929b80@ruby-forum.com> Q. Is there anything special about the Rails test environment that would inhibit an ActivieResource object from connecting to an outside URL? I am presently working inside the console with this expression: >> forex = ForexCASource.find and receiving a 404 error. The resource is defined as: class ForexCASource < ActiveResource::Base self.site = 'http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml' end I can reach the site url from a Firefox instance running on the same host using cut and paste so the url in the site assignment is valid. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Apr 15 12:36:12 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Wed, 15 Apr 2009 18:36:12 +0200 Subject: [rspec-users] Rate my code: refactoring from spec Message-ID: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> Hi, I used to have the following method: def Paypal.process_ipn(params) ... paypal = create!(params) paypal.order.update_from_ipn(completed?) end That method obviously is not easily specable because of the double dot method call, and when specing it, it would hit the DB for nothing. I used to actually spec the associated order status to know if everything went on well which breaks the isolation of unit tests. Bad bad bad. ----------- So I refactored it as following: def Paypal.new_from_ipn(params) ... new(params) end So that it doesn't hit the DB when I spec the method, and specing the method can now be done in isolation, as I only set some values returned by IPN to something more compliant with my DB storage and then in the controller that calls this method: paypal = Paypal.new_from_ipn(params) paypal.update_order if paypal.save! So the paypal instance still gets saved, but instead of getting saved in the model it occurs in the controller, no big deal. Also I added a new instance method to Paypal class to abid to Demeter's law: def update_order order.update_from_paypal_ipn!(completed?) end But now I am wondering how to spec this instance method, I thought of the following: it "should update the associated order" do @paypal = Paypal.new(:payment_status => 'Completed') @order = @paypal.order @order.expects(:update_from_paypal_ipn!).with(true) @paypal.update_order end Is that spec acceptable? I mean I am not sure about the following two lines: @order = @paypal.order @order.expects(:update_from_paypal_ipn!).with(true) I thought about this other solution which is slightly more complicated: @order = Order.new @paypal = Paypal.new(:payment_status => 'Completed') @paypal.stubs(:order).returns(@order) @order.expects(:update_from_paypal_ipn!).with(true) @paypal.update_order So which is best? And what do you think of my refactoring and my new specs? Did I improve the code or is it just crap? -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Wed Apr 15 13:25:52 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 15 Apr 2009 10:25:52 -0700 Subject: [rspec-users] Rate my code: refactoring from spec In-Reply-To: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> References: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> Message-ID: <2c7e61990904151025x6a74927em431384885e7e725d@mail.gmail.com> On Wed, Apr 15, 2009 at 9:36 AM, Fernando Perez wrote: > Hi, > > I used to have the following method: > > def Paypal.process_ipn(params) > ?... > ?paypal = create!(params) > ?paypal.order.update_from_ipn(completed?) > end > > That method obviously is not easily specable because of the double dot > method call, and when specing it, it would hit the DB for nothing. I > used to actually spec the associated order status to know if everything > went on well which breaks the isolation of unit tests. Bad bad bad. > > ----------- > > So I refactored it as following: > > def Paypal.new_from_ipn(params) > ?... > ?new(params) > end > > So that it doesn't hit the DB when I spec the method, and specing the > method can now be done in isolation, as I only set some values returned > by IPN to something more compliant with my DB storage and then in the > controller that calls this method: > > paypal = Paypal.new_from_ipn(params) > paypal.update_order if paypal.save! > > > So the paypal instance still gets saved, but instead of getting saved in > the model it occurs in the controller, no big deal. Also I added a new > instance method to Paypal class to abid to Demeter's law: > > def update_order > ?order.update_from_paypal_ipn!(completed?) > end > > But now I am wondering how to spec this instance method, I thought of > the following: > > it "should update the associated order" do > ?@paypal = Paypal.new(:payment_status => 'Completed') > ?@order = @paypal.order > ?@order.expects(:update_from_paypal_ipn!).with(true) > > ?@paypal.update_order > end > > > Is that spec acceptable? I mean I am not sure about the following two > lines: > > @order = @paypal.order > @order.expects(:update_from_paypal_ipn!).with(true) > > I thought about this other solution which is slightly more complicated: > ?@order = Order.new > ?@paypal = Paypal.new(:payment_status => 'Completed') > ?@paypal.stubs(:order).returns(@order) > ?@order.expects(:update_from_paypal_ipn!).with(true) > ?@paypal.update_order > > So which is best? > > And what do you think of my refactoring and my new specs? Did I improve > the code or is it just crap? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > I would probably move the call to update_order into a before/after_create on Paypal. Then I would write a spec on Paypal that checks that the right thing happened. I would not likely use a mock unless Order#update_from_paypal_ipn! is very complex. describe Paypal, "from IPN" do it "should update its order when created" do paypal = Paypal.new_from_ipn :ipn => {:completed => true} paypal.save! paypal.order.should be_completed end end class Paypal after_create :update_order def update_order order.update_from_paypal_ipn! completed? end end By doing it in a callback you get * transaction semantics for free * ability to use resource_controller * simpler model API If you only want to update the order when Paypal.new_from_ipn is called (and not Paypal.new, for example) then just put an ivar in Paypal and check for it in the callback. So to recap, I would test this behavior via the Paypal examples, because that's where the behavior originates. I may or may not mock the call to order.update_from_paypal depending on how complex it is. Does that make sense? Pat From lists at ruby-forum.com Wed Apr 15 14:24:05 2009 From: lists at ruby-forum.com (Wolfram Arnold) Date: Wed, 15 Apr 2009 20:24:05 +0200 Subject: [rspec-users] [Cucumber] How can I pass an XML block as a parameter? In-Reply-To: <8d961d900904142348q1a009c0ete5046a450adb0477@mail.gmail.com> References: <35dd5921f6efd97767e6657278c23b3a@ruby-forum.com> <84FFEAB3-75CA-4C52-883A-365C7C94A273@benmabey.com> <1fb4df0904141937u667142ebs53cfbddb26a4f474@mail.gmail.com> <1fb4df0904142003s6aef285dlf6f65921434918a2@mail.gmail.com> <49E563CE.40409@benmabey.com> <8d961d900904142348q1a009c0ete5046a450adb0477@mail.gmail.com> Message-ID: <4f1933d2b0a29be835137e5fa53c7351@ruby-forum.com> Thanks to all for the prompt answer and new docs!!! -- Posted via http://www.ruby-forum.com/. From vanweerd at gmail.com Wed Apr 15 10:10:49 2009 From: vanweerd at gmail.com (vanweerd) Date: Wed, 15 Apr 2009 07:10:49 -0700 (PDT) Subject: [rspec-users] `add_example_group': undefined method `deprecate' for Spec:Module (NoMethodError) Message-ID: <8ea72409-2ed1-409a-a56a-4192c489b37e@r33g2000yqn.googlegroups.com> I'm the getting the following error when running rspec on a rails project. /Users/vanweerd/work2/innerplate/vendor/plugins/rspec/lib/spec/runner/ formatter/base_formatter.rb:52:in `add_example_group': undefined method `deprecate' for Spec:Module (NoMethodError) from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/runner/ reporter.rb:14:in `add_example_group' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/runner/ reporter.rb:13:in `each' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/runner/ reporter.rb:13:in `add_example_group' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/example/ example_group_methods.rb:116:in `notify' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/example/ example_group_methods.rb:97:in `run' The method is: # Deprecated - use example_group_started instead def add_example_group(example_group_proxy) Spec.deprecate("BaseFormatter#add_example_group", "BaseFormatter#example_group_started") example_group_started(example_group_proxy) end I'm wondering if the issue is the base_formatter.rb is referencing the gem instead of the reporter.rb installed under the rails project vendor/plugins/rspec directory? This is on a rails 2.3.2 project with the restful authentication plugin. Thanks, Nick From dchelimsky at gmail.com Wed Apr 15 22:26:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 15 Apr 2009 23:26:42 -0300 Subject: [rspec-users] `add_example_group': undefined method `deprecate' for Spec:Module (NoMethodError) In-Reply-To: <8ea72409-2ed1-409a-a56a-4192c489b37e@r33g2000yqn.googlegroups.com> References: <8ea72409-2ed1-409a-a56a-4192c489b37e@r33g2000yqn.googlegroups.com> Message-ID: <57c63afe0904151926j21e187a0y36763431e1e6530@mail.gmail.com> On Wed, Apr 15, 2009 at 11:10 AM, vanweerd wrote: > I'm the getting the following error when running rspec on a rails > project. > > /Users/vanweerd/work2/innerplate/vendor/plugins/rspec/lib/spec/runner/ > formatter/base_formatter.rb:52:in `add_example_group': undefined > method `deprecate' for Spec:Module (NoMethodError) > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/runner/ > reporter.rb:14:in `add_example_group' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/runner/ > reporter.rb:13:in `each' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/runner/ > reporter.rb:13:in `add_example_group' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/example/ > example_group_methods.rb:116:in `notify' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/lib/spec/example/ > example_group_methods.rb:97:in `run' > > The method is: > ? ? ? ?# Deprecated - use example_group_started instead > ? ? ? ?def add_example_group(example_group_proxy) > ? ? ? ? ?Spec.deprecate("BaseFormatter#add_example_group", > "BaseFormatter#example_group_started") > ? ? ? ? ?example_group_started(example_group_proxy) > ? ? ? ?end > > I'm wondering if the issue is the base_formatter.rb is referencing the > gem instead of the reporter.rb installed under the rails project > vendor/plugins/rspec directory? That's definitely the issue. May I recommend that you get rid of the plugin and install as a gem? > > This is on a rails 2.3.2 project with the restful authentication > plugin. > > Thanks, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Apr 16 03:36:36 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 09:36:36 +0200 Subject: [rspec-users] Rate my code: refactoring from spec In-Reply-To: <2c7e61990904151025x6a74927em431384885e7e725d@mail.gmail.com> References: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> <2c7e61990904151025x6a74927em431384885e7e725d@mail.gmail.com> Message-ID: > So to recap, I would test this behavior via the Paypal examples, > because that's where the behavior originates. I may or may not mock > the call to order.update_from_paypal depending on how complex it is. > > Does that make sense? Argh! I had sent you an answer but for some reason my session expired and the message didn't go through. Anyway, thank you Pat for your message, I like to check out your blog to fetch some tips on how to spec correctly. The callback is a good idea, I don't use them often enough. order.update_from_paypal is a simple method that just sets the order state to 'paid' or 'unpaid' depending on the payment status. I use other payment gateways so it is paypal agnostic. Now that I test my code I tend to write smaller methods. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 16 04:35:43 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 10:35:43 +0200 Subject: [rspec-users] Rate my code: refactoring from spec In-Reply-To: References: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> <2c7e61990904151025x6a74927em431384885e7e725d@mail.gmail.com> Message-ID: <02eedd20a91408a6777e3de350e8e231@ruby-forum.com> By the way in Rails I am now finding myself replacing: update_attributes, create! and their friends with something that looks like: new(...) save! Then in the spec I stub the save! method so that it doesn't hit the DB, and then I can easily compare the object attributes if they are as expected. Pros: - specs are lightning fast Cons: - data isn't actually inserted in DB, so there is a 0.000001% chance that the object has bad attributes that would raise an error if it was actually saved in DB. But that would mean that my spec is false as I myself set the comparison value. Is it clever or not to do something like that? Maybe I can use that idea sometimes, and the other times it is safer to really save the object in DB? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 16 05:58:57 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 11:58:57 +0200 Subject: [rspec-users] Rate my code: refactoring from spec In-Reply-To: <8277b7f40904160159y2d633108mb05f1ec0020dc168@mail.gmail.com> References: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> <2c7e61990904151025x6a74927em431384885e7e725d@mail.gmail.com> <02eedd20a91408a6777e3de350e8e231@ruby-forum.com> <8277b7f40904160159y2d633108mb05f1ec0020dc168@mail.gmail.com> Message-ID: <5d53375781403f227c83f8a7debe4441@ruby-forum.com> Joaquin Rivera Padron wrote: > hey there, > maybe you should take a look at solutions that fake your database in > memory > for such cases, saving your time doing all that stubbing and mocking Yeah you are right. I am refactoring (messing up?) code because I have a DB constraint, so instead of rewriting the code I should find a better DB to use during tests. What's up will nullDB? I once saw the developper post a few message on the mailing-list. Anyone using it with success? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 16 06:24:18 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 12:24:18 +0200 Subject: [rspec-users] Rate my code: refactoring from spec In-Reply-To: <5d53375781403f227c83f8a7debe4441@ruby-forum.com> References: <80fb8b5437dc698231757b8afe35a2ec@ruby-forum.com> <2c7e61990904151025x6a74927em431384885e7e725d@mail.gmail.com> <02eedd20a91408a6777e3de350e8e231@ruby-forum.com> <8277b7f40904160159y2d633108mb05f1ec0020dc168@mail.gmail.com> <5d53375781403f227c83f8a7debe4441@ruby-forum.com> Message-ID: <154c7d67bd5f4abdd7d3f49dfc551f86@ruby-forum.com> > What's up will nullDB? I once saw the developper post a few message on > the mailing-list. Anyone using it with success? I saw a post by Pat Maddox and he talked about Sqlite in-memory, so I decided to give it a try using this tutorial: http://www.mathewabonyi.com/articles/2006/11/26/superfast-testing-how-to-in-memory-sqlite3/ When I run 'rake test', I have 1 failure in one of my test file. if I test that file alone, there is no failure. The test that fails doesn't hit the DB at any time though, so it's really strange. So for now I will forget about hitting the database and in-memory databases, and just focus on writing my specs, but it's definitely an interesting idea. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 16 07:51:57 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 13:51:57 +0200 Subject: [rspec-users] Testing discovered a problem in my code Message-ID: When trying to test using sqlite in-memory in ran into a problem: - rake test raises an error on a test - running the failing test alone works perfectly. So what's the problem? here is the method giving the trouble: def self.expiry_date_for(user) @expiry_date_cache ||= find_if_expiry_date_for(user) end That cached method is also called by another file, and therefore sets the @expiry_date_cache to some value therefore not acting correctly. So is my code flawed or is it the testing framework that doesn't clear correctly the cached variable? In production, would my code work correctly? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Thu Apr 16 07:59:00 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 16 Apr 2009 12:59:00 +0100 Subject: [rspec-users] Cucumber - step negating another expecting step In-Reply-To: <8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com> References: <8277b7f40904160307q5f18c563vab70b80a2e64cb8@mail.gmail.com> <8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com> Message-ID: On 16 Apr 2009, at 11:22, Joaquin Rivera Padron wrote: > at the moment I do it this way, hiding the complexity out of the > steps: > > Then /^I should see the people search form$/ do > people_search_form_exists > end > > Then /^I should not see the people search form$/ do > people_search_form_exists "not" > end > > and then the method: > > def people_search_form_exists negation = "" > neg = "_not" unless negation.blank? > response.send "should#{neg}".to_sym, have_tag('form#frmSearch') > end > > this is a simple case, but what do you think about this? any blog > post or so Yeah this is an annoying one isn't it. I sometimes get around it by going old-skool and pulling out the Test::Unit assertion methods instead: Then /^I (should|should not) see the people search form$/ do | maybe| has_matching_tags = current_dom.css('form#frmSearch').length > 0 assert has_matching_tags == (maybe == "should") end I think that would work. It's shorter, but is it much easier to understand? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matthew.krom at gmail.com Thu Apr 16 08:03:47 2009 From: matthew.krom at gmail.com (Matthew Krom) Date: Thu, 16 Apr 2009 08:03:47 -0400 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: References: Message-ID: Your single test may be relying on database data that is set up (and left there) by a different test. (In your non-sqlite database, the data may be sitting there as the result of previous testing activity, so the single test may pass there and not on sqlite) On Thu, Apr 16, 2009 at 7:51 AM, Fernando Perez wrote: > When trying to test using sqlite in-memory in ran into a problem: > > - rake test raises an error on a test > - running the failing test alone works perfectly. > > So what's the problem? here is the method giving the trouble: > > def self.expiry_date_for(user) > @expiry_date_cache ||= find_if_expiry_date_for(user) > end > > That cached method is also called by another file, and therefore sets > the @expiry_date_cache to some value therefore not acting correctly. > > So is my code flawed or is it the testing framework that doesn't clear > correctly the cached variable? In production, would my code work > correctly? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Apr 16 08:20:37 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 14:20:37 +0200 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: References: Message-ID: <7d9173e6c601f271d0c3c1173de2e81b@ruby-forum.com> Matthew Krom wrote: > Your single test may be relying on database data that is set up (and The tests don't hit the database. Only one previous test hits the same method and forces the class to set this instance variable. But I thing that I really have a flaw in my code, as this class instance variable will be set once by the process and will keep the same value as long as the process is running. I should probably rewrite it to an instance variable. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 16 08:46:35 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 14:46:35 +0200 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: <7d9173e6c601f271d0c3c1173de2e81b@ruby-forum.com> References: <7d9173e6c601f271d0c3c1173de2e81b@ruby-forum.com> Message-ID: > But I thing that I really have a flaw in my code I confirm, my code had a big flaw. -- Posted via http://www.ruby-forum.com/. From matthew.krom at gmail.com Thu Apr 16 08:43:38 2009 From: matthew.krom at gmail.com (Matthew Krom) Date: Thu, 16 Apr 2009 08:43:38 -0400 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: <7d9173e6c601f271d0c3c1173de2e81b@ruby-forum.com> References: <7d9173e6c601f271d0c3c1173de2e81b@ruby-forum.com> Message-ID: I missed that; sorry. When code uses class-cached data for performance, I've developed a testing pattern that explicitly clears class-cached data as part of the test data setup. It does require careful attention. I'd be interested in what others do! On Thu, Apr 16, 2009 at 8:20 AM, Fernando Perez wrote: > Matthew Krom wrote: > > Your single test may be relying on database data that is set up (and > The tests don't hit the database. Only one previous test hits the same > method and forces the class to set this instance variable. > > But I thing that I really have a flaw in my code, as this class instance > variable will be set once by the process and will keep the same value as > long as the process is running. I should probably rewrite it to an > instance variable. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew.krom at gmail.com Thu Apr 16 08:46:11 2009 From: matthew.krom at gmail.com (Matthew Krom) Date: Thu, 16 Apr 2009 08:46:11 -0400 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: References: Message-ID: Also, just noticed your class-caching isn't keyed off user. (I'm also honestly not sure what @ instead of @@ means inside a self. class method; I'd have to look that up and write specs to test it!) Something like this may work better. @expiry_date_cache ||= {} @expiry_date_cache[user.id] ||= find_if_expiry_date_for(user) (Also Rails 2.something has a memoize feature which does key off arguments--see the Railscast. Not sure if it works for class methods). Matt On Thu, Apr 16, 2009 at 7:51 AM, Fernando Perez wrote: > When trying to test using sqlite in-memory in ran into a problem: > > - rake test raises an error on a test > - running the failing test alone works perfectly. > > So what's the problem? here is the method giving the trouble: > > def self.expiry_date_for(user) > @expiry_date_cache ||= find_if_expiry_date_for(user) > end > > That cached method is also called by another file, and therefore sets > the @expiry_date_cache to some value therefore not acting correctly. > > So is my code flawed or is it the testing framework that doesn't clear > correctly the cached variable? In production, would my code work > correctly? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- matthew.krom at gmail.com 617 852 5130 -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Apr 16 09:00:13 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 15:00:13 +0200 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: References: Message-ID: > @expiry_date_cache ||= {} > @expiry_date_cache[user.id] ||= find_if_expiry_date_for(user) >From the beginning my code was silly. The cache has to be tied to an object that only exists for the current request being processed. So I have refactored it. tdd/bdd/rspec/test::unit/whatever helped me to discover this. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 16 09:36:44 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 15:36:44 +0200 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <4F1BF726-377C-4085-870B-63387DE41AAA@gmail.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> <8b63a41dc81127c4757c911228d167f8@ruby-forum.com> <4F1BF726-377C-4085-870B-63387DE41AAA@gmail.com> Message-ID: Chad Humphries wrote: > Githubs recent gem builder changes have caused some issues with > this. We are looking into it today in more detail. Pulling it down > and manually building should definitely work in the meantime. How can I uninstall a manually installed spicycode-rcov gem? I'd like to install it using the rubygems management tool. -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Thu Apr 16 09:59:27 2009 From: phlip2005 at gmail.com (Phlip) Date: Thu, 16 Apr 2009 06:59:27 -0700 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: <8d961d900904160649l24ae9512m459a8d86a4ab29ff@mail.gmail.com> References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> <8b63a41dc81127c4757c911228d167f8@ruby-forum.com> <4F1BF726-377C-4085-870B-63387DE41AAA@gmail.com> <8d961d900904160649l24ae9512m459a8d86a4ab29ff@mail.gmail.com> Message-ID: aslak hellesoy wrote: > How can I uninstall a manually installed spicycode-rcov gem? I'd like to > install it using the rubygems management tool. > > gem --help > gem help commands > gem uninstall spicycode-rcov I thought he meant ruby setup.rb installed it. I would either find it and yank it out of the file system, or just install a new version thru gems and then see if the gems appear at the head of the source paths and get pulled first... From lists at ruby-forum.com Thu Apr 16 10:30:57 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 16:30:57 +0200 Subject: [rspec-users] [RSpec] rcov and/or rexml bug? In-Reply-To: References: <1d5d31eff1533f2d92d2ac0bc40c97d9@ruby-forum.com> <226f56f3f134b7e2635100218229096a@ruby-forum.com> <57c63afe0902030732l6b7db945pf97035e2a7e592f4@mail.gmail.com> <7a98104e01b51224e4cb66cea68977b6@ruby-forum.com> <8b63a41dc81127c4757c911228d167f8@ruby-forum.com> <4F1BF726-377C-4085-870B-63387DE41AAA@gmail.com> <8d961d900904160649l24ae9512m459a8d86a4ab29ff@mail.gmail.com> Message-ID: <1f56e37ad72a5d1e118b243018e07241@ruby-forum.com> > I thought he meant ruby setup.rb installed it. Thanks for reading my message :-) The problem is that it seems spicycode-rcov installs itself as an ersatz of rcov with same names, so I cannot grep or locate spicycode-rcov specific files, and I don't want to mess up my gem system. I tried to look at setup.rb but it's quite big. So if anybody knows which files to remove, please help me out. -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Thu Apr 16 10:33:32 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 16 Apr 2009 07:33:32 -0700 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: References: Message-ID: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> You're setting an instance variable on a class, which is a global variable and is not garbage collected. The state you set is maintained across runs, screwing things up. If you set config.cache_classes to false in environments/test.rb I think it ought to reload the classes each time. There's no way for rspec to know that you would want to clear that variable, you have to do that yourself. This is one example of how global variables suck. Also your code doesn't make sense to me. I'd you called it twice, each with different users, you would get the same result which is prob not what you want. Pat On Thursday, April 16, 2009, Fernando Perez wrote: > When trying to test using sqlite in-memory in ran into a problem: > > - rake test raises an error on a test > - running the failing test alone works perfectly. > > So what's the problem? here is the method giving the trouble: > > def self.expiry_date_for(user) > ?@expiry_date_cache ||= find_if_expiry_date_for(user) > end > > That cached method is also called by another file, and therefore sets > the @expiry_date_cache to some value therefore not acting correctly. > > So is my code flawed or is it the testing framework that doesn't clear > correctly the cached variable? In production, would my code work > correctly? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Thu Apr 16 10:52:33 2009 From: mark at mwilden.com (Mark Wilden) Date: Thu, 16 Apr 2009 07:52:33 -0700 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: References: Message-ID: <3c30da400904160752h4b295938o14a96b0b09b5e4e9@mail.gmail.com> On Thu, Apr 16, 2009 at 5:46 AM, Matthew Krom wrote: > Also, just noticed your class-caching isn't keyed off user.? (I'm also > honestly not sure what @ instead of @@ means inside a self. class method; > I'd have to look that up and write specs to test it!) @var inside a class method is just an instance variable like any other. There's one for each object instantiated from its class and no other object can access it. The difference is that in this case, the object is a class - i.e., it is instantiated from the Class class. It's call a class instance variable. @@var is a class variable and can be accessed from both the class itself and objects instantiated from it. ///ark From lists at ruby-forum.com Thu Apr 16 10:52:55 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 16 Apr 2009 16:52:55 +0200 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> References: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> Message-ID: <777e4176b0e1945b4830742ebc79f8f5@ruby-forum.com> > This is one example of how global variables suck. > > Also your code doesn't make sense to me. I'd you called it twice, each > with different users, you would get the same result which is prob not > what you want. Yup, that's why I corrected it. Now the method is an instance method of User, so I call it as following: current_user.membership_expiry_date -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Thu Apr 16 11:35:01 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 16 Apr 2009 16:35:01 +0100 Subject: [rspec-users] Cucumber - step negating another expecting step In-Reply-To: <8277b7f40904160606w18fc469ek7a582fcefad144ce@mail.gmail.com> References: <8277b7f40904160307q5f18c563vab70b80a2e64cb8@mail.gmail.com> <8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com> <8277b7f40904160606w18fc469ek7a582fcefad144ce@mail.gmail.com> Message-ID: On 16 Apr 2009, at 14:06, Joaquin Rivera Padron wrote: > thanks matt, > yes, the regexp in the step matcher is a good one to dry it up > > So I end up with this one: > > Then /^I (should|should not) see the people search form$/ do |maybe| > people_search_form_should_exist maybe == "should" > end > > and the method: > > def people_search_form_should_exist it_should_exist > _not = "_not" unless it_should_exist > > response.send "should#{_not}".to_sym, have_tag('form#frmSearch') > end > > only because I find it easier to read (when I don't need to jump to > the method), but yours maybe faster (shorter it is), I could come > back to it later and benchmark both If you don't mind using the #send (I was trying to help you get rid of it) then just do this: Then /^I (should|should not) see the people search form$/ do |maybe| response.send maybe.underscore.to_sym, have_tag('form#frmSearch') end > thanks again, > joaquin > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From mark at mwilden.com Thu Apr 16 12:15:55 2009 From: mark at mwilden.com (Mark Wilden) Date: Thu, 16 Apr 2009 09:15:55 -0700 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> References: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> Message-ID: <3c30da400904160915i486ca2e6lf6600db98a809fc3@mail.gmail.com> On Thu, Apr 16, 2009 at 7:33 AM, Pat Maddox wrote: > You're setting an instance variable on a class, which is a global > variable I wouldn't call a class instance variable global. It's accessible to only one object, after all. > and is not garbage collected. The state you set is maintained > across runs, screwing things up. But that's a good point. ///ark From pat.maddox at gmail.com Thu Apr 16 13:23:41 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 16 Apr 2009 10:23:41 -0700 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: <3c30da400904160915i486ca2e6lf6600db98a809fc3@mail.gmail.com> References: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> <3c30da400904160915i486ca2e6lf6600db98a809fc3@mail.gmail.com> Message-ID: <2c7e61990904161023u141ef269jedf590678f151e87@mail.gmail.com> On Thursday, April 16, 2009, Mark Wilden wrote: > On Thu, Apr 16, 2009 at 7:33 AM, Pat Maddox wrote: > >> You're setting an instance variable on a class, which is a global >> variable > > I wouldn't call a class instance variable global. It's accessible to > only one object, after all. Neither would I :) A class, being referenced by a constant, is a global variable. Pat From svoop at delirium.ch Thu Apr 16 13:43:50 2009 From: svoop at delirium.ch (svoop) Date: Thu, 16 Apr 2009 17:43:50 +0000 (UTC) Subject: [rspec-users] specs for attributes with default values on the SQL layer Message-ID: Hi I'm not sure what would be best practise to treat this case. Migration: t.boolean :fetched, :null => false, :default => false Model: validates_inclusion_of :fetched, :in => [true, false] Spec: it do article = Article.new(valid_attributes.except(:fetched)) article.should have(1).error_on(:fetched) end Like this the spec will always fail because although fetched is excepted from the hash returned by valid_attributes, it still gets set to false due to the default value. Therefore no error and therefore the spec booms. A solution would be to use this instead: article = Article.new(valid_attributes.with(:fetched => nil)) But that would block refactoring if many attributes are tested for errors. Ideas? From mark at mwilden.com Thu Apr 16 14:04:21 2009 From: mark at mwilden.com (Mark Wilden) Date: Thu, 16 Apr 2009 11:04:21 -0700 Subject: [rspec-users] Testing discovered a problem in my code In-Reply-To: <2c7e61990904161023u141ef269jedf590678f151e87@mail.gmail.com> References: <2c7e61990904160733l127dcd43jfc1d650b2aae36f3@mail.gmail.com> <3c30da400904160915i486ca2e6lf6600db98a809fc3@mail.gmail.com> <2c7e61990904161023u141ef269jedf590678f151e87@mail.gmail.com> Message-ID: <3c30da400904161104u5ef263b8k3e3d29ad6a888307@mail.gmail.com> On Thu, Apr 16, 2009 at 10:23 AM, Pat Maddox wrote: > On Thursday, April 16, 2009, Mark Wilden wrote: >> On Thu, Apr 16, 2009 at 7:33 AM, Pat Maddox wrote: >> >>> You're setting an instance variable on a class, which is a global >>> variable >> >> I wouldn't call a class instance variable global. It's accessible to >> only one object, after all. > > Neither would I :) ?A class, being referenced by a constant, is a > global variable. Sorry I misunderstood you - the perils of relative pronouns. :) ///ark From pat.maddox at gmail.com Thu Apr 16 14:12:18 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 16 Apr 2009 11:12:18 -0700 Subject: [rspec-users] best practice for model callbacks? In-Reply-To: <83e853830904161025j256646c3r1840b239a90310df@mail.gmail.com> References: <83e853830904161025j256646c3r1840b239a90310df@mail.gmail.com> Message-ID: <2c7e61990904161112w1155872euf575ed3b02c597e6@mail.gmail.com> What is the thing that's being done in a callback and also sometimes called by clients? Usually the semantics are different and you don't want to treat them exactly the same... At any rate, you can be creative with shared example groups to get rid of the duplication. Something like describe "do_something", :shared => true do it "should update the posts_count" do lambda { do_action }. should change(subject, :posts_count).by(1) end it "should send an email" do do_action # however you get emails..I forget end end describe Foo, "when saved" do it_should_behave_like "do_something" subject { new_foo } def do_action subject.save! end end describe Foo, "when do_something is called" do it_should_behave_like "do_something" subject { new_foo } def do_action subject.do_something end end Does that help? Pat On Thu, Apr 16, 2009 at 10:25 AM, Barun Singh wrote: > In many of my models, I have callback methods like this: > > class MyModel < ActiveRecord::Base > > ? before_save?? :do_something > > ? def do_something > ??? some code here... > ? end > > end > > The do_something method is a public method that is sometimes called on its > own, and also called whenever the model is saved.? Let's say there are six > specs that are required to fully test the do_something method.? What is > considered best practice for how the before_save filter should be tested? > If I say that I'm only ever going to test the behavior, it means that I need > to basically rewrite those six specs to make sure they hold whenever the > model is saved, as well as when the do_something method is called > explicitly.? I don't like having to repeat myself this way, particularly > considering that a model may have multiple callbacks like this so I end up > having to repeat myself a lot.? The alternative is to just do something > like: > > x = MyModel.new > x.should_receive(:do_something) > x.save > > But of course this tests implementation rather than behavior which is > usually not desirable.? But in this situation I'm tending to prefer it over > having to do a ton of rewriting of specs.? What are others' thoughts on > this? > > Thanks.. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pat.maddox at gmail.com Thu Apr 16 14:15:26 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 16 Apr 2009 11:15:26 -0700 Subject: [rspec-users] specs for attributes with default values on the SQL layer In-Reply-To: References: Message-ID: <2c7e61990904161115r4a607a6cm1b7496eaffd2df39@mail.gmail.com> On Thu, Apr 16, 2009 at 10:43 AM, svoop wrote: > Hi > > I'm not sure what would be best practise to treat this case. > > Migration: > t.boolean :fetched, :null => false, :default => false > > Model: > validates_inclusion_of :fetched, :in => [true, false] > > Spec: > it do > ?article = Article.new(valid_attributes.except(:fetched)) > ?article.should have(1).error_on(:fetched) > end > > Like this the spec will always fail because although fetched is excepted from > the hash returned by valid_attributes, it still gets set to false due to the > default value. Therefore no error and therefore the spec booms. The two examples you gave are very different semantically. The first follows "no value was provided, so use the default." The second is "an invalid value was provided." > A solution would be to use this instead: > article = Article.new(valid_attributes.with(:fetched => nil)) > > But that would block refactoring if many attributes are tested for errors. > Ideas? What do you mean by it blocks refactorings? This isn't any different from the first example, with the exception that you provide a value instead of letting the default kick in... Pat From svoop at delirium.ch Thu Apr 16 16:15:25 2009 From: svoop at delirium.ch (svoop) Date: Thu, 16 Apr 2009 20:15:25 +0000 (UTC) Subject: [rspec-users] =?utf-8?q?specs_for_attributes_with_default_values_?= =?utf-8?q?on_the=09SQL_layer?= References: <2c7e61990904161115r4a607a6cm1b7496eaffd2df39@mail.gmail.com> Message-ID: > What do you mean by it blocks refactorings? This isn't any different > from the first example, with the exception that you provide a value > instead of letting the default kick in... article = Article.new article.fetched # => false (due to default) article = Article.new(valid_attributes.except(:fetched)) article.fetched # => false (again due to default) article.should have(1).error_on(:fetched) # => RED LIGHT This would work: article = Article.new(:fetched => nil) article.fetched # => nil (default overridden) article.should have(1).error_on(:fetched) # => GREEN LIGHT The problem is that Article.new doesn't return an object where all attributes are nil and therefore the attributes passed must set defaultet attributes explicitly to nil for it to override the defaults. I wonder how other people treat this case. From pat.maddox at gmail.com Thu Apr 16 17:07:12 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Thu, 16 Apr 2009 14:07:12 -0700 Subject: [rspec-users] specs for attributes with default values on the SQL layer In-Reply-To: References: <2c7e61990904161115r4a607a6cm1b7496eaffd2df39@mail.gmail.com> Message-ID: <2c7e61990904161407o38cd2539q1a287b35c2444bad@mail.gmail.com> On Thu, Apr 16, 2009 at 1:15 PM, svoop wrote: >> What do you mean by it blocks refactorings? ?This isn't any different >> from the first example, with the exception that you provide a value >> instead of letting the default kick in... > > article = Article.new > article.fetched ? # => false (due to default) > > article = Article.new(valid_attributes.except(:fetched)) > article.fetched ? # => false (again due to default) > article.should have(1).error_on(:fetched) ? # => RED LIGHT > > This would work: > > article = Article.new(:fetched => nil) > article.fetched ? # => nil (default overridden) > article.should have(1).error_on(:fetched) ? # => GREEN LIGHT > > The problem is that Article.new doesn't return an object where all attributes > are nil and therefore the attributes passed must set defaultet attributes > explicitly to nil for it to override the defaults. > > I wonder how other people treat this case. Okay I must be dense because I'm not sure what you mean by it gets in the way of refactoring. And you're right about how it behaves...that's exactly how default attrs work. If you want to test that your model doesn't allow invalid data, you have to explicitly give it invalid data. Could you rephrase the problem perhaps? Or wait for someone smarter to come along. Pat From lenny at aps.org Thu Apr 16 22:23:06 2009 From: lenny at aps.org (Lenny Marks) Date: Thu, 16 Apr 2009 22:23:06 -0400 Subject: [rspec-users] [ANN] rspec 1.2.4 Released In-Reply-To: <0EDD31C2-88DD-4BFA-A605-9AF0BEC67401@aps.org> References: <57c63afe0904150718m42345029v61575df42617a31b@mail.gmail.com> <0EDD31C2-88DD-4BFA-A605-9AF0BEC67401@aps.org> Message-ID: On Apr 15, 2009, at 11:23 AM, Lenny Marks wrote: > Just tried it out. Something missed? > > -lenny > > > cat t.rb > > describe 'test' do > it "should not fail" do > ['A'].should include('A') > end > end > > > spec -v > > rspec 1.2.4 > > > spec t.rb > F > > 1) > NoMethodError in 'test should not fail' > undefined method `helper' for # > t.rb:3: > I thought I must be crazy since no-one else seems to be complaining about this but I do still have this problem. I previously left out an important detail that I am using jruby 1.2.0. This was probably present in 1.2.3 but I had previously been at 1.2.2. No problems with MRI. I tried removing all rspec gems and re-installing only rspec 1.2.4 but that still didn't work. Anyone else running into this? Maybe a JRuby issue? Full backtrace: NoMethodError in 'test should not fail' undefined method `helper' for # /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ matchers/include.rb:22:in `__instance_exec0' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ matchers/extensions/instance_exec.rb:19:in `instance_exec' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ matchers/matcher.rb:23:in `matches?' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ expectations/handler.rb:11:in `handle_matcher' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ expectations/extensions/kernel.rb:27:in `should' t.rb:3: /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_methods.rb:41:in `instance_eval' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_methods.rb:41:in `execute' /projects/eds_test/share/jruby/lib/ruby/1.8/timeout.rb:53:in `timeout' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_methods.rb:38:in `execute' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_group_methods.rb:203:in `run_examples' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_group_methods.rb:201:in `each' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_group_methods.rb:201:in `run_examples' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ example/example_group_methods.rb:99:in `run' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ runner/example_group_runner.rb:23:in `run' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ runner/example_group_runner.rb:22:in `each' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ runner/example_group_runner.rb:22:in `run' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ runner/options.rb:119:in `run_examples' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/ runner/command_line.rb:9:in `run' /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/bin/spec:4: /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/bin/spec: 19:in `load' /Users/Shared/eds_test/share/RubyGems/1.8/bin/spec:19: > > On Apr 15, 2009, at 10:18 AM, David Chelimsky wrote: > >> rspec version 1.2.4 has been released! >> >> Be sure to check History.rdoc and Updgrade.rdoc at >> http://rspec.rubyforge.org/rspec/1.2.4/ before upgrading. >> >> * >> * >> * >> * >> >> Behaviour Driven Development for Ruby. >> >> Changes: >> >> ### Version 1.2.4 >> >> * bug fix >> * just one - update the manifest >> >> ### Version 1.2.3 >> >> * enhancements >> * support for specifying single examples with colon syntax. Closes >> #712. >> (Ben Mabey) >> * you can now say "spec some_spec.rb:12" in addition to "spec >> some_spec.rb >> --line 12" >> * run specs locally with --drb if no drb server is running. Closes >> #780. >> * still prints "No server running" to stderr >> >> * bug fixes >> * support expectations on DelegateClass (Clifford T. Matthews). >> Closes #48. >> * Fixed match_array blows up if elements can't be sorted (Jeff >> Dean). Closes #779. >> >> * deprecations >> * BaseFormatter#add_example_group (use #example_group_started >> instead) >> * ExampleGroupProxy#backtrace (use #location instead) >> * ExampleProxy#backtrace (use #location instead) >> * BaseFormatter#example_pending now expects two arguments. The third >> argument is deprecated. >> * ExampleGroupProxy#filtered_description. This was only used in one >> place >> internally, and was a confusing solution to the problem. If >> you've got a >> custom formatter that uses it, you can just use >> ExampleGroupProxy#description and modify it directly. >> * predicate_matchers (use the new Matcher DSL instead) >> * Spec::Matchers.create (use Spec::Matchers.define instead) >> >> * >> * >> * >> * >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 16 23:47:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 17 Apr 2009 00:47:08 -0300 Subject: [rspec-users] [ANN] rspec 1.2.4 Released In-Reply-To: References: <57c63afe0904150718m42345029v61575df42617a31b@mail.gmail.com> <0EDD31C2-88DD-4BFA-A605-9AF0BEC67401@aps.org> Message-ID: <57c63afe0904162047i7966eb18ja61980a7d0784545@mail.gmail.com> On Thu, Apr 16, 2009 at 11:23 PM, Lenny Marks wrote: > > On Apr 15, 2009, at 11:23 AM, Lenny Marks wrote: > >> Just tried it out. Something missed? >> >> -lenny >> >> > cat t.rb >> >> describe 'test' do >> it "should not fail" do >> ['A'].should include('A') >> end >> end >> >> > spec -v >> >> rspec 1.2.4 >> >> > spec t.rb >> F >> >> 1) >> NoMethodError in 'test should not fail' >> undefined method `helper' for # >> t.rb:3: >> > > I thought I must be crazy since no-one else seems to be complaining about > this but I do still have this problem. I previously left out an important > detail that I am using jruby 1.2.0. This was probably present in 1.2.3 but I > had previously been at 1.2.2. No problems with MRI. I tried removing all > rspec gems and re-installing only rspec 1.2.4 but that still didn't work. > Anyone else running into this? Maybe a JRuby issue? There is an issue with JRuby and RSpec >= 1.2.0 that only reveals itself under special circumstances, but reveals itself all the time with 1.2.3/4. Please stick with 1.2.2 for now. There will be a 1.2.5 release some time soon that will fix this issue so you can upgrade then (or you can build now from git). Thanks, David > > Full backtrace: > > NoMethodError in 'test should not fail' > undefined method `helper' for # > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/matchers/include.rb:22:in > `__instance_exec0' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/matchers/extensions/instance_exec.rb:19:in > `instance_exec' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/matchers/matcher.rb:23:in > `matches?' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/expectations/handler.rb:11:in > `handle_matcher' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/expectations/extensions/kernel.rb:27:in > `should' > t.rb:3: > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_methods.rb:41:in > `instance_eval' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_methods.rb:41:in > `execute' > /projects/eds_test/share/jruby/lib/ruby/1.8/timeout.rb:53:in `timeout' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_methods.rb:38:in > `execute' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_group_methods.rb:203:in > `run_examples' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_group_methods.rb:201:in > `each' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_group_methods.rb:201:in > `run_examples' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/example/example_group_methods.rb:99:in > `run' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/runner/example_group_runner.rb:23:in > `run' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/runner/example_group_runner.rb:22:in > `each' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/runner/example_group_runner.rb:22:in > `run' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/runner/options.rb:119:in > `run_examples' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/lib/spec/runner/command_line.rb:9:in > `run' > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/bin/spec:4: > /Users/Shared/eds_test/share/RubyGems/1.8/gems/rspec-1.2.4/bin/spec:19:in > `load' > /Users/Shared/eds_test/share/RubyGems/1.8/bin/spec:19: > >> >> On Apr 15, 2009, at 10:18 AM, David Chelimsky wrote: >> >>> rspec version 1.2.4 has been released! >>> >>> Be sure to check History.rdoc and Updgrade.rdoc at >>> http://rspec.rubyforge.org/rspec/1.2.4/ before upgrading. >>> >>> * >>> * >>> * >>> * >>> >>> Behaviour Driven Development for Ruby. >>> >>> Changes: >>> >>> ### Version 1.2.4 >>> >>> * bug fix >>> * just one - update the manifest >>> >>> ### Version 1.2.3 >>> >>> * enhancements >>> * support for specifying single examples with colon syntax. Closes #712. >>> (Ben Mabey) >>> * you can now say "spec some_spec.rb:12" in addition to "spec >>> some_spec.rb >>> --line 12" >>> * run specs locally with --drb if no drb server is running. Closes #780. >>> * still prints "No server running" to stderr >>> >>> * bug fixes >>> * support expectations on DelegateClass (Clifford T. Matthews). Closes >>> #48. >>> * Fixed match_array blows up if elements can't be sorted (Jeff >>> Dean). Closes #779. >>> >>> * deprecations >>> * BaseFormatter#add_example_group (use #example_group_started instead) >>> * ExampleGroupProxy#backtrace (use #location instead) >>> * ExampleProxy#backtrace (use #location instead) >>> * BaseFormatter#example_pending now expects two arguments. The third >>> argument is deprecated. >>> * ExampleGroupProxy#filtered_description. This was only used in one place >>> internally, and was a confusing solution to the problem. If you've got a >>> custom formatter that uses it, you can just use >>> ExampleGroupProxy#description and modify it directly. >>> * predicate_matchers (use the new Matcher DSL instead) >>> * Spec::Matchers.create (use Spec::Matchers.define instead) >>> >>> * >>> * >>> * >>> * >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at experthuman.com Fri Apr 17 04:45:37 2009 From: tom at experthuman.com (Tom Stuart) Date: Fri, 17 Apr 2009 09:45:37 +0100 Subject: [rspec-users] But rspec can not be found Message-ID: Hi, I've been seeing the below problem since RSpec 1.2.1 on any machine that doesn't have the RSpec gems installed. 1.2.0 was fine. I'd hoping it would magically go away with later versions but it hasn't; does anyone have any clues? -- $ git clone git://github.com/rails/rails testapp/vendor/rails $ cd testapp/vendor/rails; git checkout v2.3.2; cd ../../.. $ ruby testapp/vendor/rails/railties/bin/rails testapp $ cd testapp $ ruby script/generate model comment body:text $ rake db:migrate $ cd vendor/plugins $ git clone git://github.com/dchelimsky/rspec.git $ cd rspec; git checkout 1.2.4; cd .. $ git clone git://github.com/dchelimsky/rspec-rails.git $ cd rspec-rails; git checkout 1.2.4; cd .. $ cd ../..; ruby script/generate rspec $ rake spec (in /Users/tom/testapp) rake aborted! ******************************************************************************** * You are trying to run an rspec rake task defined in * /Users/tom/testapp/lib/tasks/rspec.rake, * but rspec can not be found in vendor/gems, vendor/plugins or system gems. ******************************************************************************** -- Cheers, -Tom From dchelimsky at gmail.com Fri Apr 17 06:35:12 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 17 Apr 2009 07:35:12 -0300 Subject: [rspec-users] But rspec can not be found In-Reply-To: References: Message-ID: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> On Fri, Apr 17, 2009 at 5:45 AM, Tom Stuart wrote: > Hi, > > I've been seeing the below problem since RSpec 1.2.1 on any machine that > doesn't have the RSpec gems installed. 1.2.0 was fine. I'd hoping it would > magically go away with later versions but it hasn't; does anyone have any > clues? > > -- > > $ git clone git://github.com/rails/rails testapp/vendor/rails > $ cd testapp/vendor/rails; git checkout v2.3.2; cd ../../.. > > $ ruby testapp/vendor/rails/railties/bin/rails testapp > $ cd testapp > $ ruby script/generate model comment body:text > $ rake db:migrate > > $ cd vendor/plugins > $ git clone git://github.com/dchelimsky/rspec.git > $ cd rspec; git checkout 1.2.4; cd .. > $ git clone git://github.com/dchelimsky/rspec-rails.git > $ cd rspec-rails; git checkout 1.2.4; cd .. > $ cd ../..; ruby script/generate rspec > > $ rake spec > (in /Users/tom/testapp) > rake aborted! > > ******************************************************************************** > * ?You are trying to run an rspec rake task defined in > * ?/Users/tom/testapp/lib/tasks/rspec.rake, > * ?but rspec can not be found in vendor/gems, vendor/plugins or system gems. > ******************************************************************************** I just cut and pasted this entire set of steps and got this at the end: $ rake spec (in /Users/david/projects/ruby/tmp/testapp) $ There were no specs generated yet, so no output. I then added a couple of steps: $ script/generate rspec_model thing name:string $ rake db:migrate $ rake spec (in /Users/david/projects/ruby/tmp/testapp) . Finished in 0.13164 seconds 1 example, 0 failures So there is something different about your environment than mine. What OS? Ruby version? Versions of rspec/rspec-rails installed on the system? > > -- > > Cheers, > -Tom > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tom at experthuman.com Fri Apr 17 09:56:47 2009 From: tom at experthuman.com (Tom Stuart) Date: Fri, 17 Apr 2009 14:56:47 +0100 Subject: [rspec-users] But rspec can not be found In-Reply-To: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> References: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> Message-ID: On 17 Apr 2009, at 11:35, David Chelimsky wrote: > So there is something different about your environment than mine. Hm, that's weird. Thanks for trying. > What OS? Ruby version? Versions of rspec/rspec-rails installed on > the system? I'm trying to run everything vendored, so no RSpec (or Rails) gems installed: $ gem list rspec *** LOCAL GEMS *** $ gem list rails *** LOCAL GEMS *** $ gem list acti *** LOCAL GEMS *** It's ruby 1.8.6 (stock, AFAIK) on OS X 10.5.6, and rubygems 1.3.2. Can I git-bisect rspec and rspec-rails independently to try to track down the problem, or are there going to be interdependent changes between RSpec versions 1.2.0 and 1.2.1? Cheers, -Tom From tom at experthuman.com Fri Apr 17 10:03:38 2009 From: tom at experthuman.com (Tom Stuart) Date: Fri, 17 Apr 2009 15:03:38 +0100 Subject: [rspec-users] But rspec can not be found In-Reply-To: References: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> Message-ID: On 17 Apr 2009, at 14:56, Tom Stuart wrote: > Can I git-bisect rspec and rspec-rails independently to try to track > down the problem, or are there going to be interdependent changes > between RSpec versions 1.2.0 and 1.2.1? I tried this anyway; the bad commit is http://github.com/dchelimsky/rspec-rails/commit/c9abdccedee97217f28e07ec824bb12cda1c9173 . Cheers, -Tom From matt at mattwynne.net Fri Apr 17 12:06:50 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 17 Apr 2009 17:06:50 +0100 Subject: [rspec-users] AfterCurrentScenario block Message-ID: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> Is there currently a way to register a block to run after the current scenario completes? If not, we've implemented one. Would anyone be interested in us submitting it as a patch to Cucumber? Something like Given "something that will not be rolled back after the scenario is finished" do original = SomeClass.a_value SomeClass.a_value = 7 AfterCurrentScenario do # undo stuff SomeClass.a_value = original end end If you're interested, our use case is for pagination, where we explicitly set the length of a page to something much shorter than the default in a step, so that we only have to create a small number of objects to spill over onto another page. The page length value is set on a class variable, and would pollute other tests, so we want to reset it when the scenario is finished. e.g. Given the maximum number of Users to display is 2 And there are 3 Users When I view the Users page Then I should see the text "see all 3 users" Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Fri Apr 17 12:31:03 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 17 Apr 2009 18:31:03 +0200 Subject: [rspec-users] AfterCurrentScenario block In-Reply-To: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> References: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> Message-ID: Den 17. april. 2009 kl. 18.06 skrev Matt Wynne : > Is there currently a way to register a block to run after the > current scenario completes? > After. > If not, we've implemented one. Would anyone be interested in us > submitting it as a patch to Cucumber? > How is this different from After? Aslak > Something like > > Given "something that will not be rolled back after the scenario is > finished" do > original = SomeClass.a_value > SomeClass.a_value = 7 > > AfterCurrentScenario do > # undo stuff > SomeClass.a_value = original > end > end > > If you're interested, our use case is for pagination, where we > explicitly set the length of a page to something much shorter than > the default in a step, so that we only have to create a small number > of objects to spill over onto another page. The page length value is > set on a class variable, and would pollute other tests, so we want > to reset it when the scenario is finished. > > e.g. Given the maximum number of Users to display is 2 > And there are 3 Users > When I view the Users page > Then I should see the text "see all 3 users" > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From joe at josephwilk.net Fri Apr 17 12:45:57 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Fri, 17 Apr 2009 17:45:57 +0100 Subject: [rspec-users] AfterCurrentScenario block In-Reply-To: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> References: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> Message-ID: <49E8B245.6060202@josephwilk.net> Matt Wynne wrote: > Is there currently a way to register a block to run after the current > scenario completes? > You could achieve the same thing with After and tags: http://wiki.github.com/aslakhellesoy/cucumber/hooks @please-clean-me Scenario: dirty ... After "@please-clean-me" do #clean end -- Joseph Wilk http://blog.josephwilk.net > If not, we've implemented one. Would anyone be interested in us > submitting it as a patch to Cucumber? > > Something like > > Given "something that will not be rolled back after the scenario is > finished" do > original = SomeClass.a_value > SomeClass.a_value = 7 > > AfterCurrentScenario do > # undo stuff > SomeClass.a_value = original > end > end > > If you're interested, our use case is for pagination, where we > explicitly set the length of a page to something much shorter than the > default in a step, so that we only have to create a small number of > objects to spill over onto another page. The page length value is set > on a class variable, and would pollute other tests, so we want to > reset it when the scenario is finished. > > e.g. Given the maximum number of Users to display is 2 > And there are 3 Users > When I view the Users page > Then I should see the text "see all 3 users" > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Fri Apr 17 12:54:58 2009 From: mark at mwilden.com (Mark Wilden) Date: Fri, 17 Apr 2009 09:54:58 -0700 Subject: [rspec-users] AfterCurrentScenario block In-Reply-To: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> References: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> Message-ID: <3c30da400904170954s5db1f642u347ee44cb7e8dc8a@mail.gmail.com> On Fri, Apr 17, 2009 at 9:06 AM, Matt Wynne wrote: > > If you're interested, our use case is for pagination, where we explicitly > set the length of a page to something much shorter than the default in a > step, so that we only have to create a small number of objects to spill over > onto another page. Is this necessary? I mean, is the page length so long that creating that many objects takes appreciably longer than otherwise? I like to leave such values as page length alone in a scenario, because that's part of the user requirement (if not a vitally important one). ///ark From zach.dennis at gmail.com Fri Apr 17 12:58:57 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 17 Apr 2009 12:58:57 -0400 Subject: [rspec-users] AfterCurrentScenario block In-Reply-To: References: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> Message-ID: <85d99afe0904170958h10af1ac5n4df0693dd3007491@mail.gmail.com> On Fri, Apr 17, 2009 at 12:31 PM, Aslak Helles?y wrote: > > > Den 17. april. 2009 kl. 18.06 skrev Matt Wynne : > >> Is there currently a way to register a block to run after the current >> scenario completes? >> > After. After is used after *any* scenario completes thought, right? If you add an After block inside of a step definition, it's going to be executed from that point on, rather than clear out at the end of the scenario that ran it, correct? >> If not, we've implemented one. Would anyone be interested in us submitting >> it as a patch to Cucumber? >> > How is this different from After? * It clears out after the current scenario. * It doesn't require to be run for scenarios that don't need it. * It allows you to cleanly place the handler next to the code that it is so closely related * It doesn't require you know the name of the scenario(s) that would need it (it's simply determined by if a step definition is run) > > Aslak >> >> Something like >> >> Given "something that will not be rolled back after the scenario is >> finished" do >> ?original = SomeClass.a_value >> ?SomeClass.a_value = 7 >> >> ?AfterCurrentScenario do >> ? # undo stuff >> ? SomeClass.a_value = original >> ?end >> end >> >> If you're interested, our use case is for pagination, where we explicitly >> set the length of a page to something much shorter than the default in a >> step, so that we only have to create a small number of objects to spill over >> onto another page. The page length value is set on a class variable, and >> would pollute other tests, so we want to reset it when the scenario is >> finished. >> >> ?e.g. ?Given the maximum number of Users to display is 2 >> ? And there are 3 Users >> ? When I view the Users page >> ? Then I should see the text "see all 3 users" >> >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Fri Apr 17 13:20:24 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 17 Apr 2009 19:20:24 +0200 Subject: [rspec-users] AfterCurrentScenario block In-Reply-To: <85d99afe0904170958h10af1ac5n4df0693dd3007491@mail.gmail.com> References: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> <85d99afe0904170958h10af1ac5n4df0693dd3007491@mail.gmail.com> Message-ID: Den 17. april. 2009 kl. 18.58 skrev Zach Dennis : > On Fri, Apr 17, 2009 at 12:31 PM, Aslak Helles?y > wrote: >> >> >> Den 17. april. 2009 kl. 18.06 skrev Matt Wynne : >> >>> Is there currently a way to register a block to run after the >>> current >>> scenario completes? >>> >> After. > > After is used after *any* scenario completes thought, right? If you > add an After block inside of a step definition, it's going to be Aha now I understand. Matt, would Joseph's suggestion work for you? Aslak > > executed from that point on, rather than clear out at the end of the > scenario that ran it, correct? > >>> If not, we've implemented one. Would anyone be interested in us >>> submitting >>> it as a patch to Cucumber? >>> >> How is this different from After? > > * It clears out after the current scenario. > * It doesn't require to be run for scenarios that don't need it. > * It allows you to cleanly place the handler next to the code that it > is so closely related > * It doesn't require you know the name of the scenario(s) that would > need it (it's simply determined by if a step definition is run) > >> >> Aslak >>> >>> Something like >>> >>> Given "something that will not be rolled back after the scenario is >>> finished" do >>> original = SomeClass.a_value >>> SomeClass.a_value = 7 >>> >>> AfterCurrentScenario do >>> # undo stuff >>> SomeClass.a_value = original >>> end >>> end >>> >>> If you're interested, our use case is for pagination, where we >>> explicitly >>> set the length of a page to something much shorter than the >>> default in a >>> step, so that we only have to create a small number of objects to >>> spill over >>> onto another page. The page length value is set on a class >>> variable, and >>> would pollute other tests, so we want to reset it when the >>> scenario is >>> finished. >>> >>> e.g. Given the maximum number of Users to display is 2 >>> And there are 3 Users >>> When I view the Users page >>> Then I should see the text "see all 3 users" >>> >>> Matt Wynne >>> http://blog.mattwynne.net >>> http://www.songkick.com >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Fri Apr 17 18:00:02 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 17 Apr 2009 23:00:02 +0100 Subject: [rspec-users] AfterCurrentScenario block In-Reply-To: References: <1EDA591D-01E7-4017-8BC5-662FFC9777A0@mattwynne.net> <85d99afe0904170958h10af1ac5n4df0693dd3007491@mail.gmail.com> Message-ID: <1640332A-11DD-4007-8F9C-928C0DEAD6ED@mattwynne.net> On 17 Apr 2009, at 18:20, Aslak Helles?y wrote: > Den 17. april. 2009 kl. 18.58 skrev Zach Dennis > : > >> On Fri, Apr 17, 2009 at 12:31 PM, Aslak Helles?y >> wrote: >>> >>> >>> Den 17. april. 2009 kl. 18.06 skrev Matt Wynne : >>> >>>> Is there currently a way to register a block to run after the >>>> current >>>> scenario completes? >>>> >>> After. >> >> After is used after *any* scenario completes thought, right? If you >> add an After block inside of a step definition, it's going to be > > Aha now I understand. Matt, would Joseph's suggestion work for you? > > Aslak It would work, yes, but I have to say I like ours a bit better - you can put the undo code right next to the code it's undoing, as Zach pointed out. With the tags thing I'd have to put a tag in the feature file which is introducing a tiny bit more coupling and noise which I'd rather avoid. I had pondered on the idea of changing the After method to use a syntax a bit like RSpec's #before(:each) where we could say: After(:each) do # general post-scenario clean-up After(:current) do # one-time clean-up Anyway, just a thought. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Sat Apr 18 00:08:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 18 Apr 2009 01:08:17 -0300 Subject: [rspec-users] But rspec can not be found In-Reply-To: <80F73DB4-5D7E-4305-AA35-111B8E12B153@experthuman.com> References: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> <80F73DB4-5D7E-4305-AA35-111B8E12B153@experthuman.com> Message-ID: <57c63afe0904172108q75fbec13ne096a245484f54c8@mail.gmail.com> On Fri, Apr 17, 2009 at 5:37 PM, Tom Stuart wrote: > On 17 Apr 2009, at 15:03, Tom Stuart wrote: >> >> the bad commit is >> http://github.com/dchelimsky/rspec-rails/commit/c9abdccedee97217f28e07ec824bb12cda1c9173 > > I don't understand what's happening to rspec.rake in this commit. In > particular, how is the "require 'spec/rake/spectask'" line meant to succeed > once the $LOAD_PATH.unshift has been removed? On my system it's this code > that adds vendor/plugins/rspec/lib to the load path, so removing it causes > the require to fail. Turns out it was working for me because I have the rspec gem installed. I'm not sure that requiring environment.rb is the right solution because it will be loaded no matter what rake task is invoked, and that is clearly not the intent for all rake tasks. I hate to go back to the ugly mess that was there to add either the plugin or installed gem path to the load path, but that may be the only reasonable alternative. Any other ideas? David > > If this was just a mistake then perhaps the attached patch is the > appropriate fix. However, I'm confused why nobody else has seen this problem > -- am I the last man on earth to be using RSpec as plugins instead of gems? > > Cheers, > -Tom > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sat Apr 18 02:23:18 2009 From: lists at ruby-forum.com (Neema Cheriyath) Date: Sat, 18 Apr 2009 08:23:18 +0200 Subject: [rspec-users] =?utf-8?q?=5Bcucumber=2C_jruby=5D_Same_steps_are_be?= =?utf-8?q?ing_added_=09multiple_t?= In-Reply-To: <8d961d900904131556k5d8c1dfbr81b4f0f0731bf050@mail.gmail.com> References: <8d961d900904110056m3aa1a85m808ec42305adff7@mail.gmail.com> <8d961d900904131556k5d8c1dfbr81b4f0f0731bf050@mail.gmail.com> Message-ID: <2061997c1f8f000f5bbb9e41f823f68c@ruby-forum.com> Aslak Helles?y wrote: > On Tue, Apr 14, 2009 at 12:08 AM, John Goodsen > wrote: > >> OK, I'll reproduce in a simple example and create a ticket... >> >> > Excellent - I'll get to it ASAP I am also having the same issue with cucumber-java. please refer - http://www.ruby-forum.com/topic/184342#new With cucumber-java , it seems that we would be able to run only one feature file and one scenario in that file. Is there any way by which we can execute multiple feature files that will invoke seperate scenarios? Thanks, Neema -- Posted via http://www.ruby-forum.com/. From tom at experthuman.com Sat Apr 18 03:16:46 2009 From: tom at experthuman.com (Tom Stuart) Date: Sat, 18 Apr 2009 08:16:46 +0100 Subject: [rspec-users] But rspec can not be found In-Reply-To: <57c63afe0904172108q75fbec13ne096a245484f54c8@mail.gmail.com> References: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> <80F73DB4-5D7E-4305-AA35-111B8E12B153@experthuman.com> <57c63afe0904172108q75fbec13ne096a245484f54c8@mail.gmail.com> Message-ID: On 18 Apr 2009, at 05:08, David Chelimsky wrote: > I'm not sure that requiring environment.rb is the right solution > because it will be loaded no matter what rake task is invoked, and > that is clearly not the intent for all rake tasks. > > I hate to go back to the ugly mess that was there to add either the > plugin or installed gem path to the load path, but that may be the > only reasonable alternative. > > Any other ideas? Not from me, no, sorry. That's what I did to fix it in the end -- you're right about it being overkill to require environment.rb. Cheers, -Tom From aslak.hellesoy at gmail.com Sat Apr 18 03:50:46 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Sat, 18 Apr 2009 09:50:46 +0200 Subject: [rspec-users] [cucumber, jruby] Same steps are being added multiple t In-Reply-To: <2061997c1f8f000f5bbb9e41f823f68c@ruby-forum.com> References: <8d961d900904110056m3aa1a85m808ec42305adff7@mail.gmail.com> <8d961d900904131556k5d8c1dfbr81b4f0f0731bf050@mail.gmail.com> <2061997c1f8f000f5bbb9e41f823f68c@ruby-forum.com> Message-ID: <941BB9F6-0D71-494B-BF59-DDF566A8E2B3@gmail.com> > Aslak Helles?y wrote: >> On Tue, Apr 14, 2009 at 12:08 AM, John Goodsen >> wrote: >> >>> OK, I'll reproduce in a simple example and create a ticket... >>> >>> >> Excellent - I'll get to it ASAP > > I am also having the same issue with cucumber-java. > > please refer - http://www.ruby-forum.com/topic/184342#new > > With cucumber-java , it seems that we would be able to run only one > feature file and one scenario in that file. > Sounds like a bug then. > Is there any way by which we can execute multiple feature files that > will invoke seperate scenarios? > Someone fixes the bug ;-) Aslak > Thanks, > Neema > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From kero at chello.nl Sat Apr 18 05:26:48 2009 From: kero at chello.nl (Kero van Gelder) Date: Sat, 18 Apr 2009 11:26:48 +0200 Subject: [rspec-users] Cucumber - step negating another expecting step In-Reply-To: References: <8277b7f40904160307q5f18c563vab70b80a2e64cb8@mail.gmail.com> <8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com> <8277b7f40904160606w18fc469ek7a582fcefad144ce@mail.gmail.com> <8277b7f40904160903v7bd4e757n6cf9fe2db1f34e6b@mail.gmail.com> Message-ID: <20090418092648.GC27365@bumblebee.m38c.nl> > I've been doing something similar. I think the benefit of having half > the steps(each can be negated) wins over the small impact it has on step > readability. Personally I started adding stuff like this(perhaps not as > DRY but simple enough): > > Then /^the correspondence should (not )?have inclusions$/ do |negate| > if negate > @outcorr.inclusions.should be_empty > else > @outcorr.inclusions.should_not be_empty > end > end What's the advantage of having half the steps? They should be grouped in a nice way in files anyway. This one's quite readable, though. >> yes, the regexp in the step matcher is a good one to dry it up >> >> So I end up with this one: >> >> Then /^I (should|should not) see the people search form$/ do |maybe| >> people_search_form_should_exist maybe == "should" >> end should ... exist ... maybe... should Unreadable? >> and the method: >> >> def people_search_form_should_exist it_should_exist >> _not = "_not" unless it_should_exist >> >> response.send "should#{_not}".to_sym, have_tag('form#frmSearch') >> end Convoluted. >> only because I find it easier to read (when I don't need to jump to >> the method), but yours maybe faster (shorter it is), I could come back >> to it later and benchmark both >> >> If you don't mind using the #send (I was trying to help you get rid of >> it) then just do this: >> >> >> Then /^I (should|should not) see the people search form$/ do |maybe| >> response.send maybe.underscore.to_sym, have_tag('form#frmSearch') >> end If you go with this kind of abstraction, this solution and the topmost in this mail at least do not introduce extra methods to deal with the should/should not. more methods to have fewer steps can not be an advantage, I think. But the readbility of Then /^I should see the people search form$/ do response.should have_tag('form#peopleSearch') end Then /^I should not see the people search form$/ do response.should_not have_tag('form#peopleSearch') end is higher for me, as I only need to think what the have_tag means, but do not have to parse the should/not, send, underscore and to_sym. The difference in readability is from about 2 seconds to at least 10 seconds. That's a disadvantage that I'm not willing to pay for any advantage of having "fewer steps". Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From svoop at delirium.ch Sat Apr 18 06:09:45 2009 From: svoop at delirium.ch (svoop) Date: Sat, 18 Apr 2009 10:09:45 +0000 (UTC) Subject: [rspec-users] =?utf-8?q?specs_for_attributes_with_default_values_?= =?utf-8?q?on_the=09SQL_layer?= References: <2c7e61990904161115r4a607a6cm1b7496eaffd2df39@mail.gmail.com> <2c7e61990904161407o38cd2539q1a287b35c2444bad@mail.gmail.com> Message-ID: Pat Maddox writes: > Okay I must be dense because I'm not sure what you mean by it gets in > the way of refactoring. Actually, scratch that, because... > And you're right about how it behaves...that's exactly how default > attrs work. If you want to test that your model doesn't allow invalid > data, you have to explicitly give it invalid data. Using .with instead of .except does the trick just fine and does just that, set the model explicitly to invalid data. Cheers, -sven From pat.maddox at gmail.com Sat Apr 18 10:46:15 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Sat, 18 Apr 2009 07:46:15 -0700 Subject: [rspec-users] specs for attributes with default values on the SQL layer In-Reply-To: References: <2c7e61990904161115r4a607a6cm1b7496eaffd2df39@mail.gmail.com> <2c7e61990904161407o38cd2539q1a287b35c2444bad@mail.gmail.com> Message-ID: <2c7e61990904180746h26b51030x7ab6891bc71ab37f@mail.gmail.com> On Sat, Apr 18, 2009 at 3:09 AM, svoop wrote: > Pat Maddox writes: >> Okay I must be dense because I'm not sure what you mean by it gets in >> the way of refactoring. > > Actually, scratch that, because... > >> And you're right about how it behaves...that's exactly how default >> attrs work. ?If you want to test that your model doesn't allow invalid >> data, you have to explicitly give it invalid data. > > Using .with instead of .except does the trick just fine and does just that, set > the model explicitly to invalid data. gah, I totally get it now! Wasn't noticing that in one case you were passing in a full attributes hash (valid_attributes) and in the second you were only setting one value. Makes sense to me now. Glad you figured it out :) Pat From lists at ruby-forum.com Sat Apr 18 13:17:44 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sat, 18 Apr 2009 19:17:44 +0200 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing Message-ID: Hi, Let's take the example of the depot app. In my controller I set @order. Then in the view comes the bad stuff: @order.items.each do |item| item.product.title end Now I'm having problems specing item.product.title. A quick and dirty fix is to trade a for for an underscore, so I create Item#product_title: def product_title product.title end The problem is that I have a few models that act the same way, so I would find myself writing lot's of these little instance methods, and the solution looks a bit stupid to me. So how do you handle such issue? I thought about composed_of, but AWDWR's examples still break Demeter's law and that annoys me. Thanks in advance -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sat Apr 18 14:50:33 2009 From: mark at mwilden.com (Mark Wilden) Date: Sat, 18 Apr 2009 11:50:33 -0700 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: References: Message-ID: <3c30da400904181150v2e4f63efy948137402218b9fe@mail.gmail.com> On Sat, Apr 18, 2009 at 10:17 AM, Fernando Perez wrote: > > @order.items.each do |item| > ?item.product.title > end > > Now I'm having problems specing item.product.title. A quick and dirty > fix is to trade a for for an underscore, so I create Item#product_title: > > def product_title > ?product.title > end And this still doesn't satifsy the "Law" of Demeter because you're still calling order.items[x].product_title. Simply adding a method call in between doesn't obviate the fact that you need the order's item's product's title. I would split the difference and have an orders helper that knew how to format each component of a displayed item. ///ark From sfeley at gmail.com Sat Apr 18 16:44:31 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sat, 18 Apr 2009 16:44:31 -0400 Subject: [rspec-users] specs for attributes with default values on the SQL layer In-Reply-To: <2c7e61990904180746h26b51030x7ab6891bc71ab37f@mail.gmail.com> References: <2c7e61990904161115r4a607a6cm1b7496eaffd2df39@mail.gmail.com> <2c7e61990904161407o38cd2539q1a287b35c2444bad@mail.gmail.com> <2c7e61990904180746h26b51030x7ab6891bc71ab37f@mail.gmail.com> Message-ID: <1fb4df0904181344u7939354fj4cd8aebbe7a6ae2c@mail.gmail.com> My question is, why bother? Unless I'm missing something, testing for the existence of an error that your code will never provide sounds backwards. Instead test that you DON'T get an error when the required value isn't explicitly supplied, to confirm that the default works. (Although, really, the "pure" time to do that would've been before writing the migration, to get the red-to-green verification. That may be excessively pedantic though.) On 4/18/09, Pat Maddox wrote: > On Sat, Apr 18, 2009 at 3:09 AM, svoop wrote: >> Pat Maddox writes: >>> Okay I must be dense because I'm not sure what you mean by it gets in >>> the way of refactoring. >> >> Actually, scratch that, because... >> >>> And you're right about how it behaves...that's exactly how default >>> attrs work. ?If you want to test that your model doesn't allow invalid >>> data, you have to explicitly give it invalid data. >> >> Using .with instead of .except does the trick just fine and does just >> that, set >> the model explicitly to invalid data. > > gah, I totally get it now! Wasn't noticing that in one case you were > passing in a full attributes hash (valid_attributes) and in the second > you were only setting one value. Makes sense to me now. Glad you > figured it out :) > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lenny at aps.org Sat Apr 18 18:08:06 2009 From: lenny at aps.org (Lenny Marks) Date: Sat, 18 Apr 2009 18:08:06 -0400 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: References: Message-ID: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> On Apr 18, 2009, at 1:17 PM, Fernando Perez wrote: > Hi, > > Let's take the example of the depot app. In my controller I set > @order. > Then in the view comes the bad stuff: > > @order.items.each do |item| > item.product.title > end > > Now I'm having problems specing item.product.title. A quick and dirty > fix is to trade a for for an underscore, so I create > Item#product_title: > > def product_title > product.title > end > > The problem is that I have a few models that act the same way, so I > would find myself writing lot's of these little instance methods, and > the solution looks a bit stupid to me. So how do you handle such > issue? > Personally, I don't think its so bad to violate the 'Law of Demeter'(which of course is really just a guideline) in cases such as these dealing with domain models. All but the simplest apps will have entities that relate to other entities and each entity will of course have its own attributes. Sometimes I'll bring up a property from a child entity if its extremely common(as may be the case with product_title) but that's not the case most of the time. In this case, IF I was trying to spec a view for an 'Order', I'd probably use a factory method of some sort that would handle creating the desired object graph. If these models already exist, I usually use real objects in place of mocks. There are quite a few Factory/Builder type libs out there for ActiveRecord. In my case, we're typically dealing with Java/Hibernate domain layers through JRuby so I haven't used any of them, but its been simple enough to roll my own so far. it "should show product title" do order = new_order(:title => 'the product title') .... end -lenny > I thought about composed_of, but AWDWR's examples still break > Demeter's > law and that annoys me. > > From lists at ruby-forum.com Sat Apr 18 19:02:57 2009 From: lists at ruby-forum.com (James Byrne) Date: Sun, 19 Apr 2009 01:02:57 +0200 Subject: [rspec-users] How to approach testing automated processing Message-ID: I have a requirement to fetch a data feed from our central bank and set a variety of currency exchange rates from that feed. My question is how does one approach behavioural driven design with autonomous automated processing? What I started with is this: Feature: Automatically Retrieve and Store Foreign Currency Exchange Rates In order to accurately set foreign currency exchange rates daily The automated system Should automatically retrieve and store central bank exchange rates To Reduce Costs and Protect Revenue Scenario: Retrieve Exchange Rates from the Bank of Canada RSS feed Given an RSS feed "http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml" When I access the RSS feed Then I should see "Bank of Canada: Noon Foreign Exchange Rates" And I should see today's date in "yyyy-mm-dd" format Now, while I have a pretty good idea how I am going to accomplish this, via cron and a standalone Ruby script, I am sort of perplexed about how I should construct the feature step definitions and how I would test this. I figure I just have to take as given that cron works because that is not my code. But how best to test that the rest works? The automatic script will contain not much more than a list of the external libraries a call to a methods in class that I have named ForexCASource, loop through and map the returned array of hashes to the corresponding CurrencyExchangeRate attributes of a new row, call #save! and repeat until finished. How have others handled this sort of thing? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Sat Apr 18 19:09:13 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 18 Apr 2009 19:09:13 -0400 Subject: [rspec-users] DDL Rails 2.3 nested transactions causing problems in specs In-Reply-To: <5b1b5e890904171536o7e6c61cesf2057ff64ddf86d8@mail.gmail.com> References: <5b1b5e890904171536o7e6c61cesf2057ff64ddf86d8@mail.gmail.com> Message-ID: <85d99afe0904181609p6d984c17pa11025cc50e509e0@mail.gmail.com> On Fri, Apr 17, 2009 at 6:36 PM, john wrote: > Mysql::Error: You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use near > 'RELEASE SAVEPOINT active_record_1' at line 1: RELEASE SAVEPOINT > active_record_1 > a rails ticket concerning this error which was marked > invalid:?https://rails.lighthouseapp.com/projects/8994/tickets/1925-mysqlerror-savepoint-active_record_1-does-not-exist-rollback-to-savepoint-active_record_1 > > another rails doc concerning > issue:?http://github.com/lifo/docrails/commit/0e6b9695aff6500ad48c4dd9ab61343d7090b030 > > Good grief! The issue seems to not be ActiveRecord, but limitations of MySQL. Elia Schito gave a good explanation IMO on the rails ticket. > > Apparently any nested transaction (ex. a create statement inside a test) > will fail if you're using MySQL. > still fighting it. If you create an ActiveRecord object in one 'it' block, > it's still there in the next block ?!? Do you have transactional fixtures turned off? The following works fine with Rails 2.3.2: http://gist.github.com/97819 Can you provide more information about your problem? You didn't really show us what you were doing, and what you thought was failing, and what you actually expected. > The only workaround I've found for the MySQL's unsupported nested > transactions is the following: > > User.transaction do > ??user1 = User.create(:name => "Alice") > ??User.transaction(:requires_new => true) do > ?? ?user2 = User.create(:name => "Bob") > ?? end > end > This is actually emulated using save points because most databases do not > support nested transactions. Some databases (SQLite) don?t support either > save points or nested transactions, so in that case this works just like > Rails 2.2 where the inner transaction(s) have no effect and if there are any > exceptions the entire transaction is rolled back. > > > PLUGIN SOLUTIONS that DON'T fix spec issues: > http://svn.viney.net.nz/things/rails/plugins/savepoints/ > http://github.com/spint/savepoints/tree/master?(github version with added > support for oracle) > > > ?HELP, RSPEC COMMUNITY!!! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Sat Apr 18 19:26:27 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sat, 18 Apr 2009 19:26:27 -0400 Subject: [rspec-users] How to approach testing automated processing In-Reply-To: References: Message-ID: <85d99afe0904181626w6a3dabc9s4e4f0e20c01da7be@mail.gmail.com> On Sat, Apr 18, 2009 at 7:02 PM, James Byrne wrote: > I have a requirement to fetch a data feed from our central bank and set > a variety of currency exchange rates from that feed. My question is how > does one approach behavioural driven design with autonomous automated > processing? What I started with is this: > > Feature: Automatically Retrieve and Store Foreign Currency Exchange > Rates > ?In order to accurately set foreign currency exchange rates daily > ?The automated system > ?Should automatically retrieve and store central bank exchange rates > ?To Reduce Costs and Protect Revenue > > ?Scenario: ?Retrieve Exchange Rates from the Bank of Canada RSS feed > ? ?Given an RSS feed > "http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml" > ? ?When I access the RSS feed > ? ?Then I should see "Bank of Canada: Noon Foreign Exchange Rates" > ? ? ?And I should see today's date in "yyyy-mm-dd" format > > Now, while I have a pretty good idea how I am going to accomplish this, > via cron and a standalone Ruby script, I am sort of perplexed about how > I should construct the feature step definitions and how I would test > this. ?I figure I just have to take as given that cron works because > that is not my code. ?But how best to test that the rest works? I would probably approach it this way. - Make a local copy of the RSS feed you're expecting to import - Write a feature which specifies the command you want to run. This command would be the same command you used with cron. I would make it take a path or URI as an argument. - Have the feature ensure the the right number of records were created based on your local copy of the feed - Drop down to RSpec and re-use the local copy of the feed to ensure that all of the little details (if you have little details) are properly imported When that is done I would probably write a feature that actually hits the Bank of Canada's site, and I would set this up to run on continuous integration only. Maybe using Cucumber tags or a directory structure, and a new rake task to help isolate CI only features from the rest. Now when I run features locally I can be very very confident everything works, and if CI fails one day because the Bank of Canada changed their format, now you know you need to pull over a new copy of the feed locally, and update your local features and specs. That general approach has worked well in the past (and I say past because before Cucumber existed I still wrote features/scenarios with StoryRunner, and before that my team had tooled its own ad hoc story runner). HTH > > The automatic script will contain not much more than a list of the > external libraries a call to a methods in class that I have named > ForexCASource, loop through and map the returned array of hashes to the > corresponding CurrencyExchangeRate attributes of a new row, call #save! > and repeat until finished. > > How have others handled this sort of thing? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From ben at benmabey.com Sat Apr 18 19:49:58 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 18 Apr 2009 17:49:58 -0600 Subject: [rspec-users] How to approach testing automated processing In-Reply-To: <85d99afe0904181626w6a3dabc9s4e4f0e20c01da7be@mail.gmail.com> References: <85d99afe0904181626w6a3dabc9s4e4f0e20c01da7be@mail.gmail.com> Message-ID: <49EA6726.2060601@benmabey.com> Zach Dennis wrote: > On Sat, Apr 18, 2009 at 7:02 PM, James Byrne wrote: > >> I have a requirement to fetch a data feed from our central bank and set >> a variety of currency exchange rates from that feed. My question is how >> does one approach behavioural driven design with autonomous automated >> processing? What I started with is this: >> >> Feature: Automatically Retrieve and Store Foreign Currency Exchange >> Rates >> In order to accurately set foreign currency exchange rates daily >> The automated system >> Should automatically retrieve and store central bank exchange rates >> To Reduce Costs and Protect Revenue >> >> Scenario: Retrieve Exchange Rates from the Bank of Canada RSS feed >> Given an RSS feed >> "http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml" >> When I access the RSS feed >> Then I should see "Bank of Canada: Noon Foreign Exchange Rates" >> And I should see today's date in "yyyy-mm-dd" format >> >> Now, while I have a pretty good idea how I am going to accomplish this, >> via cron and a standalone Ruby script, I am sort of perplexed about how >> I should construct the feature step definitions and how I would test >> this. I figure I just have to take as given that cron works because >> that is not my code. But how best to test that the rest works? >> > > I would probably approach it this way. > > - Make a local copy of the RSS feed you're expecting to import > - Write a feature which specifies the command you want to run. This > command would be the same command you used with cron. I would make it > take a path or URI as an argument. > - Have the feature ensure the the right number of records were created > based on your local copy of the feed > - Drop down to RSpec and re-use the local copy of the feed to ensure > that all of the little details (if you have little details) are > properly imported > +1 I have done this in the past and it worked well. If you haven't already checkout the fakeweb library for stubbing out the calls to Net::HTTP: http://github.com/chrisk/fakeweb -Ben > When that is done I would probably write a feature that actually hits > the Bank of Canada's site, and I would set this up to run on > continuous integration only. Maybe using Cucumber tags or a directory > structure, and a new rake task to help isolate CI only features from > the rest. > > Now when I run features locally I can be very very confident > everything works, and if CI fails one day because the Bank of Canada > changed their format, now you know you need to pull over a new copy of > the feed locally, and update your local features and specs. > > That general approach has worked well in the past (and I say past > because before Cucumber existed I still wrote features/scenarios with > StoryRunner, and before that my team had tooled its own ad hoc story > runner). > > HTH > > >> The automatic script will contain not much more than a list of the >> external libraries a call to a methods in class that I have named >> ForexCASource, loop through and map the returned array of hashes to the >> corresponding CurrencyExchangeRate attributes of a new row, call #save! >> and repeat until finished. >> >> How have others handled this sort of thing? >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > From lists at ruby-forum.com Sat Apr 18 20:07:20 2009 From: lists at ruby-forum.com (James Byrne) Date: Sun, 19 Apr 2009 02:07:20 +0200 Subject: [rspec-users] How to approach testing automated processing In-Reply-To: <85d99afe0904181626w6a3dabc9s4e4f0e20c01da7be@mail.gmail.com> References: <85d99afe0904181626w6a3dabc9s4e4f0e20c01da7be@mail.gmail.com> Message-ID: Zach Dennis wrote: > On Sat, Apr 18, 2009 at 7:02 PM, James Byrne > wrote: >> ?To Reduce Costs and Protect Revenue >> I should construct the feature step definitions and how I would test >> this. ?I figure I just have to take as given that cron works because >> that is not my code. ?But how best to test that the rest works? > > I would probably approach it this way. > > - Make a local copy of the RSS feed you're expecting to import Yup, done that. Mainly because I now have fixed data to test against but in the exact format that the feed supplies. > - Write a feature which specifies the command you want to run. This > command would be the same command you used with cron. I would make it > take a path or URI as an argument. Ahh. I had not thought of that. > - Have the feature ensure the the right number of records were created > based on your local copy of the feed K. > - Drop down to RSpec and re-use the local copy of the feed to ensure > that all of the little details (if you have little details) are > properly imported > > When that is done ... Will do. > That general approach has worked well in the past (and I say past > because before Cucumber existed I still wrote features/scenarios with > StoryRunner, and before that my team had tooled its own ad hoc story > runner). > > HTH > It certainly does. Thanks. -- Posted via http://www.ruby-forum.com/. From programmer2188 at gmail.com Sun Apr 19 02:31:43 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 19 Apr 2009 02:31:43 -0400 Subject: [rspec-users] Custom Example Groups Message-ID: <000001c9c0b8$827941b0$876bc510$@com> Hi, I want to build a custom example group, but there really aren't any examples anywhere for how to do so. The new chapter in The RSpec Book talks about it, but doesn't actually show an example, only how to register it. Looking at rspec-rails, I can see a pattern, but I don't know if that's specific to rspec-rails, or if it is what should be done. In rspec-rails, it has: Class << self Within the class, and all the methods are within that. So, are there any examples anywhere for how to write an example group? Also, if I set an instance variable within the example group, will the matchers specific to that group be able to access it? That'll simplify my design a bit. Thanks, Brandon From pat.maddox at gmail.com Sun Apr 19 04:10:08 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Sun, 19 Apr 2009 01:10:08 -0700 Subject: [rspec-users] Custom Example Groups In-Reply-To: <000001c9c0b8$827941b0$876bc510$@com> References: <000001c9c0b8$827941b0$876bc510$@com> Message-ID: <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> Check out http://gist.github.com/97967 - top one is a custom example group, and bottom one is accessing an example's instance var from within a matcher. Pat On Sat, Apr 18, 2009 at 11:31 PM, Brandon Olivares wrote: > Hi, > > I want to build a custom example group, but there really aren't any examples > anywhere for how to do so. The new chapter in The RSpec Book talks about it, > but doesn't actually show an example, only how to register it. > > Looking at rspec-rails, I can see a pattern, but I don't know if that's > specific to rspec-rails, or if it is what should be done. In rspec-rails, it > has: > > Class << self > > Within the class, and all the methods are within that. > > So, are there any examples anywhere for how to write an example group? > > Also, if I set an instance variable within the example group, will the > matchers specific to that group be able to access it? That'll simplify my > design a bit. > > Thanks, > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Sun Apr 19 04:35:05 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 19 Apr 2009 09:35:05 +0100 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> Message-ID: <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> On 18 Apr 2009, at 23:08, Lenny Marks wrote: > > On Apr 18, 2009, at 1:17 PM, Fernando Perez wrote: > >> Hi, >> >> Let's take the example of the depot app. In my controller I set >> @order. >> Then in the view comes the bad stuff: >> >> @order.items.each do |item| >> item.product.title >> end >> >> Now I'm having problems specing item.product.title. A quick and dirty >> fix is to trade a for for an underscore, so I create >> Item#product_title: >> >> def product_title >> product.title >> end >> >> The problem is that I have a few models that act the same way, so I >> would find myself writing lot's of these little instance methods, and >> the solution looks a bit stupid to me. So how do you handle such >> issue? The risk you've identified here is that your views are coupled to the relationship between an order and the title of the products that make up that order. If you were coding down in your model layer and decided to make a change to the structure of your models then code far, far, away in the views would break. In a small application like a blog, this might not be a problem, but as your codebase starts to get bigger, it's a worry you want to avoid. Putting on your 'outside-in' hat and thinking about *what the view wants*, you could code the view, which doesn't need or want to care about the structure of these models, more like this: @order.product_titles do |product_title| <%= product_title %> end Now you're going to need to add this Order#product_titles method to your model layer. Having this extra method buys you more maintainability in the future: the structure of the model objects is hidden from the views, and if you need to change that structure, the code you'll need to change to keep the views working (Order#product_titles) is right down there next to you in the model layer where you're working. This sort of cohesion - keeping the things that change together in the same part of the codebase, makes maintenance much easier and less accident-prone. By designing a custom protocol (think 'API') on your model layer for the use by the views, rather than constraining yourself to the ones that come out of the box with ActiveRecord, you're putting some lubrication in between the layers, making it easier for them to move independently. The trade-off, obviously, is that you're adding extra methods to your models. If you imagine doing this for every view on a large project, you might end up with quite a bit of clutter on those models. This is where you could consider adding another 'facade' layer that wraps the models and presents them to the views in the appropriate manner. At Songkick, we use a presenter layer for this purpose, and it works very nicely. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Sun Apr 19 06:08:02 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 19 Apr 2009 12:08:02 +0200 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> Message-ID: <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> > @order.product_titles do |product_title| > <%= product_title %> > end > Another problem, is that not only do I need the title, but also a clickable permalink which uses a url helper (not available to models), the product price, and maybe other stuff in the future. So I might end up with a nice messy code. For the time being I use delegate, so I traded a dot for an underscore. It's easy to spec, and after all, an item only exists in the context of an Order, so I think it's fine to break Demeter's 'guideline' and say that it's cool that Order knows a little bit stuff about Item's internal. However a Product can exist without an Order, so Order doesn't need to know anything about Product and vice versa. But I'll have to think more about it, because as you said making a little change in a model can result in having to fix places that are far far away and totoally unexpected. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Sun Apr 19 06:51:55 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 19 Apr 2009 11:51:55 +0100 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> Message-ID: On 19 Apr 2009, at 11:08, Fernando Perez wrote: >> @order.product_titles do |product_title| >> <%= product_title %> >> end >> > > Another problem, is that not only do I need the title, but also a > clickable permalink which uses a url helper (not available to models), > the product price, and maybe other stuff in the future. So I might end > up with a nice messy code. This is where I start to introduce a presenter layer in between the view and the models. If you have a Ruby class anywhere in rails, you can access the auto- generated url helpers just by including ActionController::UrlWriter. class OrderPresenter include ActionController::UrlWriter def initialize(order) @order = order end def product_titles @order.items.map{ |i| i.product.title, product_url(i.product) } end end Construct the presenter in the Controller. Then in the view: @order_presenter.product_titles do |product_title, url| <%= link_to product_title, url %> end > For the time being I use delegate, so I traded a dot for an > underscore. > It's easy to spec, and after all, an item only exists in the context > of > an Order, so I think it's fine to break Demeter's 'guideline' and say > that it's cool that Order knows a little bit stuff about Item's > internal. However a Product can exist without an Order, so Order > doesn't > need to know anything about Product and vice versa. > > But I'll have to think more about it, because as you said making a > little change in a model can result in having to fix places that are > far > far away and totoally unexpected. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From programmer2188 at gmail.com Sun Apr 19 08:04:04 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 19 Apr 2009 08:04:04 -0400 Subject: [rspec-users] Custom Example Groups In-Reply-To: <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> Message-ID: <000001c9c0e6$f0311790$d09346b0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Pat Maddox > Sent: Sunday, April 19, 2009 4:10 AM > To: rspec-users > Subject: Re: [rspec-users] Custom Example Groups > > Check out http://gist.github.com/97967 - top one is a custom example > group, and bottom one is accessing an example's instance var from > within a matcher. > Thank you very much! That helps a lot. One more question: is it possible to specify that an example group must be nested within another example group? Say I want to act on controller, so I'd like it to be within a controller example group. Only thing I can think of is to check described_class, but are there any other methods? I'd like to check the class of the group it's nested in. Thanks, Brandon > Pat > > On Sat, Apr 18, 2009 at 11:31 PM, Brandon Olivares > wrote: > > Hi, > > > > I want to build a custom example group, but there really aren't any > examples > > anywhere for how to do so. The new chapter in The RSpec Book talks > about it, > > but doesn't actually show an example, only how to register it. > > > > Looking at rspec-rails, I can see a pattern, but I don't know if > that's > > specific to rspec-rails, or if it is what should be done. In rspec- > rails, it > > has: > > > > Class << self > > > > Within the class, and all the methods are within that. > > > > So, are there any examples anywhere for how to write an example > group? > > > > Also, if I set an instance variable within the example group, will > the > > matchers specific to that group be able to access it? That'll > simplify my > > design a bit. > > > > Thanks, > > Brandon > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Apr 19 08:04:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 09:04:47 -0300 Subject: [rspec-users] Custom Example Groups In-Reply-To: <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> Message-ID: <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> On Sun, Apr 19, 2009 at 5:10 AM, Pat Maddox wrote: > Check out http://gist.github.com/97967 - top one is a custom example > group, and bottom one is accessing an example's instance var from > within a matcher. I forked this and modified it a bit: http://gist.github.com/98041 This shows how to set up class methods that you can access outside examples (inside groups) and instance methods you can access inside the examples. Also - just a word of caution - even though you *can* access instance variables in matchers, it seems very brittle to me to attach matchers to specifically named instance variables like that. Can you show us what you're trying to do? Perhaps there are less brittle alternatives. Cheers, David > > Pat > > On Sat, Apr 18, 2009 at 11:31 PM, Brandon Olivares > wrote: >> Hi, >> >> I want to build a custom example group, but there really aren't any examples >> anywhere for how to do so. The new chapter in The RSpec Book talks about it, >> but doesn't actually show an example, only how to register it. >> >> Looking at rspec-rails, I can see a pattern, but I don't know if that's >> specific to rspec-rails, or if it is what should be done. In rspec-rails, it >> has: >> >> Class << self >> >> Within the class, and all the methods are within that. >> >> So, are there any examples anywhere for how to write an example group? >> >> Also, if I set an instance variable within the example group, will the >> matchers specific to that group be able to access it? That'll simplify my >> design a bit. >> >> Thanks, >> Brandon >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Apr 19 08:28:56 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 09:28:56 -0300 Subject: [rspec-users] Custom Example Groups In-Reply-To: <000001c9c0e6$f0311790$d09346b0$@com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <000001c9c0e6$f0311790$d09346b0$@com> Message-ID: <57c63afe0904190528k4a6f53dg1c08643120907510@mail.gmail.com> On Sun, Apr 19, 2009 at 9:04 AM, Brandon Olivares wrote: > > >> -----Original Message----- >> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- >> bounces at rubyforge.org] On Behalf Of Pat Maddox >> Sent: Sunday, April 19, 2009 4:10 AM >> To: rspec-users >> Subject: Re: [rspec-users] Custom Example Groups >> >> Check out http://gist.github.com/97967 - top one is a custom example >> group, and bottom one is accessing an example's instance var from >> within a matcher. >> > > Thank you very much! That helps a lot. > > One more question: is it possible to specify that an example group must be > nested within another example group? Say I want to act on controller, so I'd > like it to be within a controller example group. Only thing I can think of > is to check described_class, but are there any other methods? I'd like to > check the class of the group it's nested in. Why would you want this ensurance/protection? Are you planning on writing controller examples in your coffee-maker example group? Seems like overkill to me. FWIW, David > > Thanks, > Brandon > >> Pat >> >> On Sat, Apr 18, 2009 at 11:31 PM, Brandon Olivares >> wrote: >> > Hi, >> > >> > I want to build a custom example group, but there really aren't any >> examples >> > anywhere for how to do so. The new chapter in The RSpec Book talks >> about it, >> > but doesn't actually show an example, only how to register it. >> > >> > Looking at rspec-rails, I can see a pattern, but I don't know if >> that's >> > specific to rspec-rails, or if it is what should be done. In rspec- >> rails, it >> > has: >> > >> > Class << self >> > >> > Within the class, and all the methods are within that. >> > >> > So, are there any examples anywhere for how to write an example >> group? >> > >> > Also, if I set an instance variable within the example group, will >> the >> > matchers specific to that group be able to access it? That'll >> simplify my >> > design a bit. >> > >> > Thanks, >> > Brandon >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Sun Apr 19 08:32:35 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 19 Apr 2009 08:32:35 -0400 Subject: [rspec-users] Custom Example Groups In-Reply-To: <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> Message-ID: <000701c9c0ea$ec074730$c415d590$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of David Chelimsky > Sent: Sunday, April 19, 2009 8:05 AM > To: rspec-users > Subject: Re: [rspec-users] Custom Example Groups > > On Sun, Apr 19, 2009 at 5:10 AM, Pat Maddox > wrote: > > Check out http://gist.github.com/97967 - top one is a custom example > > group, and bottom one is accessing an example's instance var from > > within a matcher. > > I forked this and modified it a bit: http://gist.github.com/98041 > > This shows how to set up class methods that you can access outside > examples (inside groups) and instance methods you can access inside > the examples. > Thank you. That also helps a lot. > Also - just a word of caution - even though you *can* access instance > variables in matchers, it seems very brittle to me to attach matchers > to specifically named instance variables like that. > > Can you show us what you're trying to do? Perhaps there are less > brittle alternatives. > Well, as an example, let's say I would want to be able to do something like this, where the matcher is aware of its context: describe '/posts', :type => :route do with_method :get do it { should be_accepted } it { should map_to_action 'index' } end end Well that with_method would either be a class method like that or use context somehow. But either way, in that example, I'd like be_accepted to know it's testing the /posts route, for method GET. Thanks, Brandon > Che