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 > 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 > > > _______________________________________________ > 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:58:37 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 09:58:37 -0300 Subject: [rspec-users] Custom Example Groups In-Reply-To: <000701c9c0ea$ec074730$c415d590$@com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> <000701c9c0ea$ec074730$c415d590$@com> Message-ID: <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> On Sun, Apr 19, 2009 at 9:32 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: 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. You should be able to get what you're after like this: A class method: class MyGroup < Spec::ExampleGroup class << self def with_method(verb) subject { send(verb, description_args.first) } yield end end end This is a bit tricky, but basically description_args is an array of all the arguments sent to describe() (including in nested groups). The first one, in your example above, is '/posts'. So the result of this code is that when you call with_method(:get), the subject becomes the result of calling get '/posts'. Give that a shot and let us know if it works. Also - you really don't need custom groups for this sort of thing, because you can define with_method in a module and extend the configuration w/ that module: module WithMethod def with_method(verb) subject { send(verb, description_args.first) } yield end end Spec::Runner.configure {|c| c.extend(WithMethod)} Cheers, David > > Thanks, > Brandon > >> 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 >> > >> _______________________________________________ >> 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 09:50:14 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 19 Apr 2009 09:50:14 -0400 Subject: [rspec-users] Custom Example Groups In-Reply-To: <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> <000701c9c0ea$ec074730$c415d590$@com> <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> Message-ID: <000e01c9c0f5$c52b7590$4f8260b0$@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:59 AM > To: rspec-users > Subject: Re: [rspec-users] Custom Example Groups > > You should be able to get what you're after like this: > > A class method: > > class MyGroup < Spec::ExampleGroup > class << self > def with_method(verb) > subject { send(verb, description_args.first) } > yield > end > end > end > > This is a bit tricky, but basically description_args is an array of > all the arguments sent to describe() (including in nested groups). The > first one, in your example above, is '/posts'. So the result of this > code is that when you call with_method(:get), the subject becomes the > result of calling get '/posts'. > > Give that a shot and let us know if it works. > > Also - you really don't need custom groups for this sort of thing, > because you can define with_method in a module and extend the > configuration w/ that module: > > module WithMethod > def with_method(verb) > subject { send(verb, description_args.first) } > yield > end > end > > Spec::Runner.configure {|c| c.extend(WithMethod)} > Thanks. I'm not sure I want to actually do a request though, because it's really only testing the routes in that example. I know there are already ways of spec'ing the routes of course, but I'm trying to learn more about customizing RSpec. And I really like this syntax. So as a more expanded version, let's say this: describe '/posts' do with_method :get do it { should be_accepted } it { should map_to_action 'index' } end with_method :post do it { should be_accepted } it { should map_to_action 'create' } end with_method :put do it { should_not be_accepted } end with_method :delete do it { should_not be_accepted } end end Thanks, Brandon > Cheers, > David > > > > > Thanks, > > Brandon > > > >> 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 > >> > > >> _______________________________________________ > >> 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 19 10:03:28 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 09:03:28 -0500 Subject: [rspec-users] Custom Example Groups In-Reply-To: <000e01c9c0f5$c52b7590$4f8260b0$@com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> <000701c9c0ea$ec074730$c415d590$@com> <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> <000e01c9c0f5$c52b7590$4f8260b0$@com> Message-ID: <57c63afe0904190703x5f85dee6vd2c7e2f848478bdf@mail.gmail.com> On Sun, Apr 19, 2009 at 8:50 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: Sunday, April 19, 2009 8:59 AM >> To: rspec-users >> Subject: Re: [rspec-users] Custom Example Groups >> >> You should be able to get what you're after like this: >> >> A class method: >> >> class MyGroup < Spec::ExampleGroup >> ? class << self >> ? ? def with_method(verb) >> ? ? ? subject { send(verb, description_args.first) } >> ? ? ? yield >> ? ? end >> ? end >> end >> >> This is a bit tricky, but basically description_args is an array of >> all the arguments sent to describe() (including in nested groups). The >> first one, in your example above, is '/posts'. So the result of this >> code is that when you call with_method(:get), the subject becomes the >> result of calling get '/posts'. >> >> Give that a shot and let us know if it works. >> >> Also - you really don't need custom groups for this sort of thing, >> because you can define with_method in a module and extend the >> configuration w/ that module: >> >> ? module WithMethod >> ? ? def with_method(verb) >> ? ? ? subject { send(verb, description_args.first) } >> ? ? ? yield >> ? ? end >> ? end >> >> ? Spec::Runner.configure {|c| c.extend(WithMethod)} >> > > Thanks. I'm not sure I want to actually do a request though, because it's > really only testing the routes in that example. > > I know there are already ways of spec'ing the routes of course, but I'm > trying to learn more about customizing RSpec. And I really like this syntax. > > So as a more expanded version, let's say this: > > describe '/posts' do > ?with_method :get do > ? ?it { should be_accepted } > ? ?it { should map_to_action 'index' } > ?end > > ?with_method :post do > ? ?it { should be_accepted } > ? ?it { should map_to_action 'create' } > ?end > > ?with_method :put do > ?it { should_not be_accepted } > ?end > > ?with_method :delete do > ?it { should_not be_accepted } > ?end > end So you probably want to wrap asset_recognizes and assert_generates in custom matchers at that point: def with_method(verb) do |verb| subject { {:path => description_args.first, :method => verb } } yield end Spec::Matchers.define :be_accepted do match do |path_and_method| wrap_expectation do assert_recognizes path_and_method end end end That's all off the top of my head, so it might not work exactly as/is - but that's the basic idea. Cheers, David > > Thanks, > Brandon > >> Cheers, >> David >> >> > >> > Thanks, >> > Brandon >> > >> >> 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 >> >> > >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From Richard.T.Lloyd at gmail.com Sat Apr 18 14:15:45 2009 From: Richard.T.Lloyd at gmail.com (Rick) Date: Sat, 18 Apr 2009 11:15:45 -0700 (PDT) Subject: [rspec-users] autospec startup problem Message-ID: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> Following the instructions in the beta Rspec book, /Rspec/mastermind 536 > autospec /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) from /opt/RoR/bin/autotest:19:in `
' Here's where I'm at for local gems: actionmailer (2.3.2) actionpack (2.3.2) activerecord (2.3.2) activeresource (2.3.2) activesupport (2.3.2) archive-gem (0.0.1) archive-tar (0.9.0) archive-tar-external (1.2.1) archive-tar-minitar (0.5.2) archive-tarsimple (1.1.1) archive-zip (0.3.0) archives (0.0.1) builder (2.1.2) columnize (0.3.0) commonwatir (1.6.2) cucumber (0.3.0) daemons (1.0.10) diff-lcs (1.1.2) eventmachine (0.12.6) firewatir (1.6.2) flexmock (0.8.5) giraffesoft-resource_controller (0.6.1) hoe (1.10.0) io-like (0.2.0) memcache-client (1.7.0) mislav-will_paginate (2.3.8) mocha (0.9.5) mysql (2.8.1) newgem (1.2.3) nokogiri (1.2.1) pg (0.7.9.2009.02.26) polyglot (0.2.5) rack (0.9.1) railroad (0.5.0) rails (2.3.2) rake (0.8.4) rb-appscript (0.5.1) rcov (0.8.2.1) RedCloth (4.1.9) rmagick (2.9.1) rspec (1.2.4) rspec-rails (1.2.4) rubigen (1.5.2) ruby-openid (2.1.4) rubyforge (1.0.3) rubyist-aasm (2.0.5) s4t-utils (1.0.4) safariwatir (0.3.3) sqlite3-ruby (1.2.4) syntax (1.0.0) term-ansicolor (1.0.3) test-unit (1.2.3) thin (1.0.0) treetop (1.2.5) user-choices (1.1.6) webrat (0.4.4) xml-simple (1.0.12) ZenTest (4.0.0) thanks in advance, rick From matt at mattwynne.net Sun Apr 19 10:11:25 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 19 Apr 2009 15:11:25 +0100 Subject: [rspec-users] Custom Example Groups In-Reply-To: <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> <000701c9c0ea$ec074730$c415d590$@com> <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> Message-ID: <0954EAF7-1E7D-4F07-A9DD-F7A0570BFF0B@mattwynne.net> On 19 Apr 2009, at 13:58, David Chelimsky wrote: > Also - you really don't need custom groups for this sort of thing, > because you can define with_method in a module and extend the > configuration w/ that module: > > module WithMethod > def with_method(verb) > subject { send(verb, description_args.first) } > yield > end > end > > Spec::Runner.configure {|c| c.extend(WithMethod)} > > Cheers, > David Or even (if I'm following this correctly) just define it right there inside your describe block: describe "custom example group" do # available in groups def self.custom_example_group_method puts "hello from a custom example group class" end # available in examples def custom_example_method puts "hello from a custom example group instance" end custom_example_group_method it "provides access to instance methods" do custom_example_method end end Obviously this doesn't give you any re-use yet, but it's usually the very first step I take before factoring out a module like David's suggested. I've yet to need to take it as far as the custom example group class, but I like the concept. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Sun Apr 19 10:16:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 09:16:04 -0500 Subject: [rspec-users] autospec startup problem In-Reply-To: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> Message-ID: <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> On Sat, Apr 18, 2009 at 1:15 PM, Rick wrote: > Following the instructions in the beta Rspec book, Where are you in the book when you see this? And which version of the beta? > > /Rspec/mastermind 536 > > autospec > /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ > gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) > ? ? ? ?from /opt/RoR/bin/autotest:19:in `
' > > Here's where I'm at for local gems: > > actionmailer (2.3.2) > actionpack (2.3.2) > activerecord (2.3.2) > activeresource (2.3.2) > activesupport (2.3.2) > archive-gem (0.0.1) > archive-tar (0.9.0) > archive-tar-external (1.2.1) > archive-tar-minitar (0.5.2) > archive-tarsimple (1.1.1) > archive-zip (0.3.0) > archives (0.0.1) > builder (2.1.2) > columnize (0.3.0) > commonwatir (1.6.2) > cucumber (0.3.0) > daemons (1.0.10) > diff-lcs (1.1.2) > eventmachine (0.12.6) > firewatir (1.6.2) > flexmock (0.8.5) > giraffesoft-resource_controller (0.6.1) > hoe (1.10.0) > io-like (0.2.0) > memcache-client (1.7.0) > mislav-will_paginate (2.3.8) > mocha (0.9.5) > mysql (2.8.1) > newgem (1.2.3) > nokogiri (1.2.1) > pg (0.7.9.2009.02.26) > polyglot (0.2.5) > rack (0.9.1) > railroad (0.5.0) > rails (2.3.2) > rake (0.8.4) > rb-appscript (0.5.1) > rcov (0.8.2.1) > RedCloth (4.1.9) > rmagick (2.9.1) > rspec (1.2.4) > rspec-rails (1.2.4) > rubigen (1.5.2) > ruby-openid (2.1.4) > rubyforge (1.0.3) > rubyist-aasm (2.0.5) > s4t-utils (1.0.4) > safariwatir (0.3.3) > sqlite3-ruby (1.2.4) > syntax (1.0.0) > term-ansicolor (1.0.3) > test-unit (1.2.3) > thin (1.0.0) > treetop (1.2.5) > user-choices (1.1.6) > webrat (0.4.4) > xml-simple (1.0.12) > ZenTest (4.0.0) > > thanks in advance, > rick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From Richard.T.Lloyd at gmail.com Sun Apr 19 10:33:54 2009 From: Richard.T.Lloyd at gmail.com (Rick) Date: Sun, 19 Apr 2009 07:33:54 -0700 (PDT) Subject: [rspec-users] autospec startup problem In-Reply-To: <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> Message-ID: <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> sorry about the miss-direction, the command is autotest not autospec but the result is the same: from archbd-b4_0.pdf, Section 14.3 Autotest, page 171 /Rspec/mastermind 523 > autotest /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) from /opt/RoR/bin/autotest:19:in `
' rick On Apr 19, 4:16?am, David Chelimsky wrote: > On Sat, Apr 18, 2009 at 1:15 PM, Rick wrote: > > Following the instructions in the beta Rspec book, > > Where are you in the book when you see this? And which version of the beta? > > > > > > > /Rspec/mastermind 536 > > > autospec > > /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ > > gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) > > ? ? ? ?from /opt/RoR/bin/autotest:19:in `
' > > > Here's where I'm at for local gems: > > > actionmailer (2.3.2) > > actionpack (2.3.2) > > activerecord (2.3.2) > > activeresource (2.3.2) > > activesupport (2.3.2) > > archive-gem (0.0.1) > > archive-tar (0.9.0) > > archive-tar-external (1.2.1) > > archive-tar-minitar (0.5.2) > > archive-tarsimple (1.1.1) > > archive-zip (0.3.0) > > archives (0.0.1) > > builder (2.1.2) > > columnize (0.3.0) > > commonwatir (1.6.2) > > cucumber (0.3.0) > > daemons (1.0.10) > > diff-lcs (1.1.2) > > eventmachine (0.12.6) > > firewatir (1.6.2) > > flexmock (0.8.5) > > giraffesoft-resource_controller (0.6.1) > > hoe (1.10.0) > > io-like (0.2.0) > > memcache-client (1.7.0) > > mislav-will_paginate (2.3.8) > > mocha (0.9.5) > > mysql (2.8.1) > > newgem (1.2.3) > > nokogiri (1.2.1) > > pg (0.7.9.2009.02.26) > > polyglot (0.2.5) > > rack (0.9.1) > > railroad (0.5.0) > > rails (2.3.2) > > rake (0.8.4) > > rb-appscript (0.5.1) > > rcov (0.8.2.1) > > RedCloth (4.1.9) > > rmagick (2.9.1) > > rspec (1.2.4) > > rspec-rails (1.2.4) > > rubigen (1.5.2) > > ruby-openid (2.1.4) > > rubyforge (1.0.3) > > rubyist-aasm (2.0.5) > > s4t-utils (1.0.4) > > safariwatir (0.3.3) > > sqlite3-ruby (1.2.4) > > syntax (1.0.0) > > term-ansicolor (1.0.3) > > test-unit (1.2.3) > > thin (1.0.0) > > treetop (1.2.5) > > user-choices (1.1.6) > > webrat (0.4.4) > > xml-simple (1.0.12) > > ZenTest (4.0.0) > > > thanks in advance, > > rick > > _______________________________________________ > > 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 programmer2188 at gmail.com Sun Apr 19 10:39:02 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 19 Apr 2009 10:39:02 -0400 Subject: [rspec-users] Custom Example Groups In-Reply-To: <57c63afe0904190703x5f85dee6vd2c7e2f848478bdf@mail.gmail.com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> <000701c9c0ea$ec074730$c415d590$@com> <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> <000e01c9c0f5$c52b7590$4f8260b0$@com> <57c63afe0904190703x5f85dee6vd2c7e2f848478bdf@mail.gmail.com> Message-ID: <001201c9c0fc$96399ee0$c2acdca0$@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 10:03 AM > To: rspec-users > Subject: Re: [rspec-users] Custom Example Groups > > So you probably want to wrap asset_recognizes and assert_generates in > custom matchers at that point: > > def with_method(verb) do |verb| > subject { {:path => description_args.first, :method => verb } } > yield > end > > Spec::Matchers.define :be_accepted do > match do |path_and_method| > wrap_expectation do > assert_recognizes path_and_method > end > end > end > > That's all off the top of my head, so it might not work exactly as/is > - but that's the basic idea. > Oh, perfect. I didn't think of making the subject a hash. Is it best just to use it within any matcher using that DSL syntax? Thanks, Brandon Just one more question. When should you use wrap_expectation? > Cheers, > David > > > > > Thanks, > > Brandon > > > >> Cheers, > >> David > >> > >> > > >> > Thanks, > >> > Brandon > >> > > >> >> 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 > >> >> > > >> >> _______________________________________________ > >> >> rspec-users mailing list > >> >> rspec-users at rubyforge.org > >> >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> > _______________________________________________ > >> > rspec-users mailing list > >> > rspec-users at rubyforge.org > >> > http://rubyforge.org/mailman/listinfo/rspec-users > >> > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From Richard.T.Lloyd at gmail.com Sun Apr 19 10:49:35 2009 From: Richard.T.Lloyd at gmail.com (Rick) Date: Sun, 19 Apr 2009 07:49:35 -0700 (PDT) Subject: [rspec-users] autospec startup problem In-Reply-To: <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> Message-ID: <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> David - here's some more info... This is a ruby1.9.1p0/rails2.3.2 issue. If I run under ruby1.8.7/rails2.3.2 autotest starts fine: /Rspec/mastermind 528 > autotest (Not running features. To run features in autotest, set AUTOFEATURE=true.) *** LOCAL GEMS *** actionmailer (2.3.2, 2.3.1, 2.2.2) actionpack (2.3.2, 2.3.1, 2.2.2) activerecord (2.3.2, 2.3.1, 2.2.2) activeresource (2.3.2, 2.3.1, 2.2.2) activesupport (2.3.2, 2.3.1, 2.2.2) builder (2.1.2) columnize (0.3.0) commonwatir (1.6.2) cucumber (0.3.0, 0.1.16) daemons (1.0.10) diff-lcs (1.1.2) eventmachine (0.12.6, 0.12.4) firewatir (1.6.2) flexmock (0.8.6, 0.8.4) hoe (1.12.2, 1.9.0) linecache (0.43) mocha (0.9.5) mysql (2.8) nokogiri (1.2.3, 1.2.1) pg (0.8.0, 0.7.9.2008.10.13) polyglot (0.2.5) rack (0.9.1) rails (2.3.2, 2.3.1, 2.2.2) rake (0.8.4) rb-appscript (0.5.1) rcov (0.8.1.2.0) rspec (1.2.4, 1.2.2, 1.1.99.12, 1.1.12) rspec-rails (1.2.4, 1.1.99.12, 1.1.12) ruby-debug (0.10.3) ruby-debug-base (0.10.3) rubyforge (1.0.3) rubyist-aasm (2.0.5) s4t-utils (1.0.4) safariwatir (0.3.3) sqlite3-ruby (1.2.4) term-ansicolor (1.0.3) thin (1.0.0) treetop (1.2.5, 1.2.4) user-choices (1.1.6) webrat (0.4.2) xml-simple (1.0.12) ZenTest (4.0.0) On Apr 19, 4:33?am, Rick wrote: > sorry about the miss-direction, the command is autotest not autospec > but the result is the same: > > from archbd-b4_0.pdf, Section 14.3 Autotest, page 171 > > /Rspec/mastermind 523 > autotest > /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ > gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) > ? ? ? ? from /opt/RoR/bin/autotest:19:in `
' > > rick > > On Apr 19, 4:16?am, David Chelimsky wrote: > > > On Sat, Apr 18, 2009 at 1:15 PM, Rick wrote: > > > Following the instructions in the beta Rspec book, > > > Where are you in the book when you see this? And which version of the beta? > > > > /Rspec/mastermind 536 > > > > autospec > > > /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ > > > gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) > > > ? ? ? ?from /opt/RoR/bin/autotest:19:in `
' > > > > Here's where I'm at for local gems: > > > > actionmailer (2.3.2) > > > actionpack (2.3.2) > > > activerecord (2.3.2) > > > activeresource (2.3.2) > > > activesupport (2.3.2) > > > archive-gem (0.0.1) > > > archive-tar (0.9.0) > > > archive-tar-external (1.2.1) > > > archive-tar-minitar (0.5.2) > > > archive-tarsimple (1.1.1) > > > archive-zip (0.3.0) > > > archives (0.0.1) > > > builder (2.1.2) > > > columnize (0.3.0) > > > commonwatir (1.6.2) > > > cucumber (0.3.0) > > > daemons (1.0.10) > > > diff-lcs (1.1.2) > > > eventmachine (0.12.6) > > > firewatir (1.6.2) > > > flexmock (0.8.5) > > > giraffesoft-resource_controller (0.6.1) > > > hoe (1.10.0) > > > io-like (0.2.0) > > > memcache-client (1.7.0) > > > mislav-will_paginate (2.3.8) > > > mocha (0.9.5) > > > mysql (2.8.1) > > > newgem (1.2.3) > > > nokogiri (1.2.1) > > > pg (0.7.9.2009.02.26) > > > polyglot (0.2.5) > > > rack (0.9.1) > > > railroad (0.5.0) > > > rails (2.3.2) > > > rake (0.8.4) > > > rb-appscript (0.5.1) > > > rcov (0.8.2.1) > > > RedCloth (4.1.9) > > > rmagick (2.9.1) > > > rspec (1.2.4) > > > rspec-rails (1.2.4) > > > rubigen (1.5.2) > > > ruby-openid (2.1.4) > > > rubyforge (1.0.3) > > > rubyist-aasm (2.0.5) > > > s4t-utils (1.0.4) > > > safariwatir (0.3.3) > > > sqlite3-ruby (1.2.4) > > > syntax (1.0.0) > > > term-ansicolor (1.0.3) > > > test-unit (1.2.3) > > > thin (1.0.0) > > > treetop (1.2.5) > > > user-choices (1.1.6) > > > webrat (0.4.4) > > > xml-simple (1.0.12) > > > ZenTest (4.0.0) > > > > thanks in advance, > > > rick > > > _______________________________________________ > > > 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-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From Richard.T.Lloyd at gmail.com Sun Apr 19 11:13:45 2009 From: Richard.T.Lloyd at gmail.com (Rick) Date: Sun, 19 Apr 2009 08:13:45 -0700 (PDT) Subject: [rspec-users] autospec startup problem In-Reply-To: <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> Message-ID: It hurts when I do this... The command (of course) is autospec. It works as advertised when run under ruby1.8.7 but fails as initially reported under ruby1.9.1p0 rick On Apr 19, 4:49?am, Rick wrote: > David - here's some more info... > > This is a ruby1.9.1p0/rails2.3.2 issue. > > If I run under ruby1.8.7/rails2.3.2 autotest starts fine: > > /Rspec/mastermind 528 > autotest > (Not running features. ?To run features in autotest, set > AUTOFEATURE=true.) > > *** LOCAL GEMS *** > > actionmailer (2.3.2, 2.3.1, 2.2.2) > actionpack (2.3.2, 2.3.1, 2.2.2) > activerecord (2.3.2, 2.3.1, 2.2.2) > activeresource (2.3.2, 2.3.1, 2.2.2) > activesupport (2.3.2, 2.3.1, 2.2.2) > builder (2.1.2) > columnize (0.3.0) > commonwatir (1.6.2) > cucumber (0.3.0, 0.1.16) > daemons (1.0.10) > diff-lcs (1.1.2) > eventmachine (0.12.6, 0.12.4) > firewatir (1.6.2) > flexmock (0.8.6, 0.8.4) > hoe (1.12.2, 1.9.0) > linecache (0.43) > mocha (0.9.5) > mysql (2.8) > nokogiri (1.2.3, 1.2.1) > pg (0.8.0, 0.7.9.2008.10.13) > polyglot (0.2.5) > rack (0.9.1) > rails (2.3.2, 2.3.1, 2.2.2) > rake (0.8.4) > rb-appscript (0.5.1) > rcov (0.8.1.2.0) > rspec (1.2.4, 1.2.2, 1.1.99.12, 1.1.12) > rspec-rails (1.2.4, 1.1.99.12, 1.1.12) > ruby-debug (0.10.3) > ruby-debug-base (0.10.3) > rubyforge (1.0.3) > rubyist-aasm (2.0.5) > s4t-utils (1.0.4) > safariwatir (0.3.3) > sqlite3-ruby (1.2.4) > term-ansicolor (1.0.3) > thin (1.0.0) > treetop (1.2.5, 1.2.4) > user-choices (1.1.6) > webrat (0.4.2) > xml-simple (1.0.12) > ZenTest (4.0.0) > > On Apr 19, 4:33?am, Rick wrote: > > > sorry about the miss-direction, the command is autotest not autospec > > but the result is the same: > > > from archbd-b4_0.pdf, Section 14.3 Autotest, page 171 > > > /Rspec/mastermind 523 > autotest > > /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ > > gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) > > ? ? ? ? from /opt/RoR/bin/autotest:19:in `
' > > > rick > > > On Apr 19, 4:16?am, David Chelimsky wrote: > > > > On Sat, Apr 18, 2009 at 1:15 PM, Rick wrote: > > > > Following the instructions in the beta Rspec book, > > > > Where are you in the book when you see this? And which version of the beta? > > > > > /Rspec/mastermind 536 > > > > > autospec > > > > /opt/RoR/bin/autotest:19:in `load': Is a directory - /opt/RoR/lib/ruby/ > > > > gems/1.9.1/gems/cucumber-0.3.0/lib/autotest (Errno::EISDIR) > > > > ? ? ? ?from /opt/RoR/bin/autotest:19:in `
' > > > > > Here's where I'm at for local gems: > > > > > actionmailer (2.3.2) > > > > actionpack (2.3.2) > > > > activerecord (2.3.2) > > > > activeresource (2.3.2) > > > > activesupport (2.3.2) > > > > archive-gem (0.0.1) > > > > archive-tar (0.9.0) > > > > archive-tar-external (1.2.1) > > > > archive-tar-minitar (0.5.2) > > > > archive-tarsimple (1.1.1) > > > > archive-zip (0.3.0) > > > > archives (0.0.1) > > > > builder (2.1.2) > > > > columnize (0.3.0) > > > > commonwatir (1.6.2) > > > > cucumber (0.3.0) > > > > daemons (1.0.10) > > > > diff-lcs (1.1.2) > > > > eventmachine (0.12.6) > > > > firewatir (1.6.2) > > > > flexmock (0.8.5) > > > > giraffesoft-resource_controller (0.6.1) > > > > hoe (1.10.0) > > > > io-like (0.2.0) > > > > memcache-client (1.7.0) > > > > mislav-will_paginate (2.3.8) > > > > mocha (0.9.5) > > > > mysql (2.8.1) > > > > newgem (1.2.3) > > > > nokogiri (1.2.1) > > > > pg (0.7.9.2009.02.26) > > > > polyglot (0.2.5) > > > > rack (0.9.1) > > > > railroad (0.5.0) > > > > rails (2.3.2) > > > > rake (0.8.4) > > > > rb-appscript (0.5.1) > > > > rcov (0.8.2.1) > > > > RedCloth (4.1.9) > > > > rmagick (2.9.1) > > > > rspec (1.2.4) > > > > rspec-rails (1.2.4) > > > > rubigen (1.5.2) > > > > ruby-openid (2.1.4) > > > > rubyforge (1.0.3) > > > > rubyist-aasm (2.0.5) > > > > s4t-utils (1.0.4) > > > > safariwatir (0.3.3) > > > > sqlite3-ruby (1.2.4) > > > > syntax (1.0.0) > > > > term-ansicolor (1.0.3) > > > > test-unit (1.2.3) > > > > thin (1.0.0) > > > > treetop (1.2.5) > > > > user-choices (1.1.6) > > > > webrat (0.4.4) > > > > xml-simple (1.0.12) > > > > ZenTest (4.0.0) > > > > > thanks in advance, > > > > rick > > > > _______________________________________________ > > > > 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-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Sun Apr 19 11:07:41 2009 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 19 Apr 2009 12:07:41 -0300 Subject: [rspec-users] autospec startup problem In-Reply-To: <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> Message-ID: <71166b3b0904190807v2ba12150xd86e00896d2c815e@mail.gmail.com> On Sun, Apr 19, 2009 at 11:49 AM, Rick wrote: > David - here's some more info... > > This is a ruby1.9.1p0/rails2.3.2 issue. > > If I run under ruby1.8.7/rails2.3.2 autotest starts fine: > > /Rspec/mastermind 528 > autotest > (Not running features. ?To run features in autotest, set > AUTOFEATURE=true.) > I believe the root of this issue with 1.9.1 is that load and require are a bit messed up in 1.9. I've seen this for other projects and a few but reports to ruby-core. You can try 1.9.2-dev (which is trunk right now I believe) and see if that solves your problem. Hopefully that get backported to 1_9_1 branch and you can build 1.9.1 from it. -- 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 luislavena at gmail.com Sun Apr 19 11:23:06 2009 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 19 Apr 2009 12:23:06 -0300 Subject: [rspec-users] autospec startup problem In-Reply-To: References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> Message-ID: <71166b3b0904190823u45a5cb3dv76e44294ff190f7a@mail.gmail.com> On Sun, Apr 19, 2009 at 12:13 PM, Rick wrote: > It hurts when I do this... > > The command (of course) is autospec. ?It works as advertised when run > under ruby1.8.7 but fails as initially reported under ruby1.9.1p0 > Just replied to you about this. Please see my previous answer here: http://rubyforge.org/pipermail/rspec-users/2009-April/013896.html -- 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 mark at mwilden.com Sun Apr 19 12:24:09 2009 From: mark at mwilden.com (Mark Wilden) Date: Sun, 19 Apr 2009 09:24:09 -0700 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> Message-ID: <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: > @order_presenter.product_titles do |product_title, url| > ?<%= link_to product_title, url %> > end The presentation of an order in most apps will be constructed from additional columns (e.g., color, size, price, extended price). These columns may well be formatted differently depending on the circumstance (e.g, printed or on-screen). Now, it might be a good idea to put this construction and formatting in a helper or presenter outside the view (though it won't be TSTTCPW). But anywhere you put it, there will be non-Demeterian code that needs to drill down into each order's items', products' information (as well as non-product information, such as line-item discount). If the underlying model changes, this code will have to change - you can't avoid it. ///ark From michael at schuerig.de Sun Apr 19 12:27:03 2009 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 19 Apr 2009 18:27:03 +0200 Subject: [rspec-users] Controller spec: testing that scope is set Message-ID: <200904191827.04395.michael@schuerig.de> In a Rails controller I set the scope on a model class in an around filter. I have defined expectations on the model classes, and ideally, I would add a further expectation for the scope. Is this already possible in some way? How would I go about adding support a scope expectation? Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From zach.dennis at gmail.com Sun Apr 19 12:32:49 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 19 Apr 2009 12:32:49 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904191827.04395.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> Message-ID: <85d99afe0904190932m61eb760r18bad7266a329b70@mail.gmail.com> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig wrote: > > In a Rails controller I set the scope on a model class in an around > filter. I have defined expectations on the model classes, and ideally, I > would add a further expectation for the scope. Is this already possible > in some way? How would I go about adding support a scope expectation? How are you setting the said scope? > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Sun Apr 19 12:44:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 11:44:58 -0500 Subject: [rspec-users] Custom Example Groups In-Reply-To: <001201c9c0fc$96399ee0$c2acdca0$@com> References: <000001c9c0b8$827941b0$876bc510$@com> <2c7e61990904190110p269085c3rdb3bd1750c4c1f0@mail.gmail.com> <57c63afe0904190504s4358b0b8q6da83a5b8cb49cd4@mail.gmail.com> <000701c9c0ea$ec074730$c415d590$@com> <57c63afe0904190558y70b45d94of7a2336b9071f70e@mail.gmail.com> <000e01c9c0f5$c52b7590$4f8260b0$@com> <57c63afe0904190703x5f85dee6vd2c7e2f848478bdf@mail.gmail.com> <001201c9c0fc$96399ee0$c2acdca0$@com> Message-ID: <57c63afe0904190944w221ab2a9q38bff7fc0b302acb@mail.gmail.com> On Sun, Apr 19, 2009 at 9:39 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: Sunday, April 19, 2009 10:03 AM >> To: rspec-users >> Subject: Re: [rspec-users] Custom Example Groups >> >> So you probably want to wrap asset_recognizes and assert_generates in >> custom matchers at that point: >> >> def with_method(verb) do |verb| >> ? subject { {:path => description_args.first, :method => verb } } >> ? yield >> end >> >> Spec::Matchers.define :be_accepted do >> ? match do |path_and_method| >> ? ? wrap_expectation do >> ? ? ? assert_recognizes path_and_method >> ? ? end >> ? end >> end >> >> That's all off the top of my head, so it might not work exactly as/is >> - but that's the basic idea. >> > > Oh, perfect. I didn't think of making the subject a hash. Is it best just to > use it within any matcher using that DSL syntax? > > Thanks, > Brandon > > Just one more question. When should you use wrap_expectation? http://rspec.rubyforge.org/rspec/1.2.4/classes/Spec/Matchers.html#M000441 > >> Cheers, >> David >> >> > >> > Thanks, >> > Brandon >> > >> >> Cheers, >> >> David >> >> >> >> > >> >> > Thanks, >> >> > Brandon >> >> > >> >> >> 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 >> >> >> > >> >> >> _______________________________________________ >> >> >> rspec-users mailing list >> >> >> rspec-users at rubyforge.org >> >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > >> >> > _______________________________________________ >> >> > rspec-users mailing list >> >> > rspec-users at rubyforge.org >> >> > http://rubyforge.org/mailman/listinfo/rspec-users >> >> > >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sun Apr 19 13:10:13 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 19 Apr 2009 19:10:13 +0200 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> Message-ID: <71b4883022fc6595e431581dbc927f3b@ruby-forum.com> > This is where I start to introduce a presenter layer in between the > view and the models. Very interesting. Thank you very much. -- Posted via http://www.ruby-forum.com/. From michael at schuerig.de Sun Apr 19 14:09:12 2009 From: michael at schuerig.de (Michael Schuerig) Date: Sun, 19 Apr 2009 20:09:12 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <85d99afe0904190932m61eb760r18bad7266a329b70@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <85d99afe0904190932m61eb760r18bad7266a329b70@mail.gmail.com> Message-ID: <200904192009.12749.michael@schuerig.de> On Sunday 19 April 2009, Zach Dennis wrote: > On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig wrote: > > In a Rails controller I set the scope on a model class in an around > > filter. I have defined expectations on the model classes, and > > ideally, I would add a further expectation for the scope. Is this > > already possible in some way? How would I go about adding support a > > scope expectation? > > How are you setting the said scope? In an around filter. However, I don't want to test the around filter mechanism, it might as well be rack middleware instead. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From zach.dennis at gmail.com Sun Apr 19 14:23:59 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 19 Apr 2009 14:23:59 -0400 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> Message-ID: <85d99afe0904191123k21374630w24fd6d6138a1b650@mail.gmail.com> On Sun, Apr 19, 2009 at 12:24 PM, Mark Wilden wrote: > On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: > >> @order_presenter.product_titles do |product_title, url| >> ?<%= link_to product_title, url %> >> end > > The presentation of an order in most apps will be constructed from > additional columns (e.g., color, size, price, extended price). These > columns may well be formatted differently depending on the > circumstance (e.g, printed or on-screen). > > Now, it might be a good idea to put this construction and formatting > in a helper or presenter outside the view (though it won't be > TSTTCPW). But anywhere you put it, there will be non-Demeterian code > that needs to drill down into each order's items', products' > information (as well as non-product information, such as line-item > discount). If the underlying model changes, this code will have to > change - you can't avoid it. Agreed. I think Dan Manges post is a good one on this topic as well: http://www.dcmanges.com/blog/37 His second to last paragraph: "The crux of this is that webpage views aren't domain objects and can't adhere to the Law of Demeter. Clearly from the examples of behavior delegation the Law of Demeter leads to cleaner code. However, when rendering a view, it's natural and expected that the view needs to branch out into the domain model. Also, anytime something in a view dictates code in models, take caution. Models should define business logic and be able to stand alone from views. If this "train-wreck" method calling in your views is bothersome, there is a better solution that I will blog about later." I tend to agree his thoughts on this, but be careful how you read the sentence "anytime something in a view dictates code in models, take caution". He isn't referring outside-in development practices. He's referring to adding methods in a model for strictly presentation purposes, which is bad because it dilutes the richness of the model, and makes it change for reasons it shouldn't. Here's another article which discusses why methods shouldn't be added to models for presentation purposes: http://spin.atomicobject.com/2008/01/27/the-exceptional-presenter Although if you read that article and want to try out presenters, you should know that CachingPresenter supersedes the PresentationObject library in the article. And you don't need a library to use presenters, your presenters can be POROs just like Matt Wynne posted. I tend to like the CachingPresenter library (heck I wrote it) approach so I can utilize caching, memoization, and a slightly more declarative API and list of helper methods. One technique I've employed in the past along side presenters (although it can be done w/o presenters) is to make use of partials, and actually treat them like little view objects. So you could take what you had: @order.items.each do |item| item.product.title end And transform it into two views, one that is concerned with the order, and a partial which is concerned with the product of an item. : <%= render :partial "items/product", :collection => @order.items.map(&:product) %> And then add a "items/product" partial and spec it in isolation. Spec'ing views (and partials) in isolation gives you the ability to have simpler view specs, and you're able to avoid feeling the awkward need to build up a network of objects. And you don't have to worry about adding a bunch of little delegate methods all over the place. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Sun Apr 19 14:26:06 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 19 Apr 2009 14:26:06 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904192009.12749.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <85d99afe0904190932m61eb760r18bad7266a329b70@mail.gmail.com> <200904192009.12749.michael@schuerig.de> Message-ID: <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig wrote: > On Sunday 19 April 2009, Zach Dennis wrote: >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig > wrote: >> > In a Rails controller I set the scope on a model class in an around >> > filter. I have defined expectations on the model classes, and >> > ideally, I would add a further expectation for the scope. Is this >> > already possible in some way? How would I go about adding support a >> > scope expectation? >> >> How are you setting the said scope? > > In an around filter. However, I don't want to test the around filter > mechanism, it might as well be rack middleware instead. Sorry, I don't know what scope means to you in your app. Can you share your around_filter? > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From dchelimsky at gmail.com Sun Apr 19 14:54:39 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 13:54:39 -0500 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> Message-ID: <57c63afe0904191154s2145e678k782d24e5fbdad1a5@mail.gmail.com> On Sun, Apr 19, 2009 at 11:24 AM, Mark Wilden wrote: > On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne wrote: > >> @order_presenter.product_titles do |product_title, url| >> ?<%= link_to product_title, url %> >> end > > The presentation of an order in most apps will be constructed from > additional columns (e.g., color, size, price, extended price). These > columns may well be formatted differently depending on the > circumstance (e.g, printed or on-screen). > > Now, it might be a good idea to put this construction and formatting > in a helper or presenter outside the view (though it won't be > TSTTCPW). But anywhere you put it, there will be non-Demeterian code > that needs to drill down into each order's items', products' > information (as well as non-product information, such as line-item > discount). If the underlying model changes, this code will have to > change - you can't avoid it. The motivation behind demeter is to localize change. The cost is method bloat and potential lack of cohesion on a model. Having a single presenter object act as the one and only place that will change besides the model itself is a good compromise between complete localization of change in the model and method bloat on the model. A very interesting approach to all this was presented by Allen Holub in his talk boldly entitled "Everything You Know is Wrong," in which he tears apart common misunderstandings about OO. http://www.holub.com/publications/notes_and_slides/Everything.You.Know.is.Wrong.pdf The idea, as I understand it (but, according to his basic premise, I'm probably wrong) is to have data importers and exporters on domain objects in order to minimize getters and setters. These collaborators are going to take the hit of changes to the model objects, but *only* they will if you follow this approach. In the example we're talking about here, we'd end up with code like this in the controller: def some_view @order = find_order.export_to(OrderPresenter.new) end OrderPresenter would have a bunch of setters on it, which *the order, which knows its own data structure* would call. Now you don't need a bunch of getter methods on order. Similarly, data importers would have a bunch of getters on them, and you would use them to import data into an order like this: order_form = OrderForm.new(params[:order]) order = Order.create_from(order_form) Obviously, ActiveRecord provides the getters and setters anyway, but the real violator of encapsulation is the consumer, not the vendor. Just because a flasher opens his coat doesn't mean that reaching inside is a good idea ;) Cheers, David > > ///ark > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From html-kurs at gmx.de Sun Apr 19 14:56:54 2009 From: html-kurs at gmx.de (Martin) Date: Sun, 19 Apr 2009 20:56:54 +0200 Subject: [rspec-users] Cucmber: Mysql::Error: query: not connected: ROLLBACK Message-ID: <49EB73F6.7080801@gmx.de> Hi, I ran in trouble with unexpected rollbacks using cucumber 0.3.0. My feature-file looks like Scenario: Create Valid Item Given I start and the step is Given /^I start$/ do get "/items" end In my log/test.log I get SQL (0.2ms) SET NAMES 'utf8' SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 SQL (0.1ms) BEGIN Processing ItemsController#index (for 127.0.0.1 at 2009-04-19 20:54:08) [GET] Item Load (0.2ms) SELECT * FROM `items` Rendering template within layouts/application Rendering items/index Completed in 41ms (View: 30, DB: 1) | 200 OK [http://www.example.com/items] SQL (0.0ms) Mysql::Error: query: not connected: ROLLBACK If using my browser directing it at /items in the test-environment I get SQL (0.3ms) SET NAMES 'utf8' SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 Processing ItemsController#index (for 192.168.192.1 at 2009-04-19 20:55:07) [GET] Item Load (0.3ms) SELECT * FROM `items` Rendering template within layouts/application Rendering items/index Completed in 35ms (View: 23, DB: 1) | 200 OK [http://192.168.192.25/items] (see also http://www.pastie.org/451600 for the logs) Any idea what causes the error? TIA, Martin From lists at ruby-forum.com Sun Apr 19 15:37:27 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Sun, 19 Apr 2009 21:37:27 +0200 Subject: [rspec-users] =?utf-8?q?Depot_app=2C_Demeter=27s_law_and_troubles?= =?utf-8?q?_cleanly_=09specing?= In-Reply-To: <85d99afe0904191123k21374630w24fd6d6138a1b650@mail.gmail.com> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> <85d99afe0904191123k21374630w24fd6d6138a1b650@mail.gmail.com> Message-ID: <5a1b94c60142279732af09f3bb09fef0@ruby-forum.com> > http://spin.atomicobject.com/2008/01/27/the-exceptional-presenter Interesting idea too. So basically I need to totally rethink and refactor the way my views display the information to the customer: Let's see how I currently display or not an add to cart button depending whether or not the product is free. My very first quick and very ugly procedural hard to spec solution was to do in the view: <%- if @product.price >= 0 -%> <%= display_button %> <%- else -%> This product is free! <%- end -%> Then my second solution was to create an instance method so that the view doesn't know about the Product internal mechanism about it's freeness: <%- if @product.free? -%> This product is free! <%- else ... -%> Yeah I thought I was an OOP master and Demeter could rest in peace! But thinking about the GOF Builder and Exceptional Presenter design patterns you talk about, that would mean that the html output for a Product should therefore happen in the Model itself. And then in the show.html.erb, I simply call: <%= @product.display -%> and all the magic about whether or not the product is free and to display the button has already been handled inside the model (or another related place) when it gets instantiated. Same applies to item.product.title, that would be handled elsewhere than in the view. However it might clutter the Model, so actually there is more to MVC: each Model should have a sub class or something that handles how the model instance will be presented to the view. How do you handle such issue? Are there some open source rails apps that I could learn from? -- Posted via http://www.ruby-forum.com/. From Richard.T.Lloyd at gmail.com Sun Apr 19 16:09:42 2009 From: Richard.T.Lloyd at gmail.com (Rick) Date: Sun, 19 Apr 2009 13:09:42 -0700 (PDT) Subject: [rspec-users] autospec startup problem In-Reply-To: <71166b3b0904190823u45a5cb3dv76e44294ff190f7a@mail.gmail.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> <71166b3b0904190823u45a5cb3dv76e44294ff190f7a@mail.gmail.com> Message-ID: <08fcb9d9-e89e-4bd9-9ec9-889cdaa02d3f@v23g2000pro.googlegroups.com> Luis Done and done. I was unclear how to obtain 1.9.2-dev so I went to ftp://ftp.ruby-lang.org and grabbed the today snapshot for 1.9. Perhaps you could clue me in to the way to obtain 1.9.2-dev if this is not what I've got. At any rate, I built and installed ruby. Autospec now loads as advertised in the beta book - now for some serious testing. Thank you for that, rick --- I've been cutting and cutting and it's still too short! Fred Linquist On Apr 19, 5:23?am, Luis Lavena wrote: > On Sun, Apr 19, 2009 at 12:13 PM, Rick wrote: > > It hurts when I do this... > > > The command (of course) is autospec. ?It works as advertised when run > > under ruby1.8.7 but fails as initially reported under ruby1.9.1p0 > > Just replied to you about this. Please see my previous answer here: > > http://rubyforge.org/pipermail/rspec-users/2009-April/013896.html > > -- > 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 > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Sun Apr 19 16:37:57 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 19 Apr 2009 21:37:57 +0100 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <57c63afe0904191154s2145e678k782d24e5fbdad1a5@mail.gmail.com> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> <57c63afe0904191154s2145e678k782d24e5fbdad1a5@mail.gmail.com> Message-ID: <1E9A613C-62DD-4E52-BAF5-6B713B879695@mattwynne.net> On 19 Apr 2009, at 19:54, David Chelimsky wrote: > On Sun, Apr 19, 2009 at 11:24 AM, Mark Wilden > wrote: >> On Sun, Apr 19, 2009 at 3:51 AM, Matt Wynne >> wrote: >> >>> @order_presenter.product_titles do |product_title, url| >>> <%= link_to product_title, url %> >>> end >> >> The presentation of an order in most apps will be constructed from >> additional columns (e.g., color, size, price, extended price). These >> columns may well be formatted differently depending on the >> circumstance (e.g, printed or on-screen). >> >> Now, it might be a good idea to put this construction and formatting >> in a helper or presenter outside the view (though it won't be >> TSTTCPW). But anywhere you put it, there will be non-Demeterian code >> that needs to drill down into each order's items', products' >> information (as well as non-product information, such as line-item >> discount). If the underlying model changes, this code will have to >> change - you can't avoid it. > > The motivation behind demeter is to localize change. The cost is > method bloat and potential lack of cohesion on a model. Having a > single presenter object act as the one and only place that will change > besides the model itself is a good compromise between complete > localization of change in the model and method bloat on the model. > > A very interesting approach to all this was presented by Allen Holub > in his talk boldly entitled "Everything You Know is Wrong," in which > he tears apart common misunderstandings about OO. > > http://www.holub.com/publications/notes_and_slides/Everything.You.Know.is.Wrong.pdf > > The idea, as I understand it (but, according to his basic premise, I'm > probably wrong) is to have data importers and exporters on domain > objects in order to minimize getters and setters. These collaborators > are going to take the hit of changes to the model objects, but *only* > they will if you follow this approach. In the example we're talking > about here, we'd end up with code like this in the controller: > > def some_view > @order = find_order.export_to(OrderPresenter.new) > end > > OrderPresenter would have a bunch of setters on it, which *the order, > which knows its own data structure* would call. Now you don't need a > bunch of getter methods on order. > > Similarly, data importers would have a bunch of getters on them, and > you would use them to import data into an order like this: > > order_form = OrderForm.new(params[:order]) > order = Order.create_from(order_form) I think (but I'm probably wrong too!) that this is what people like Nat Pryce and Steve Freeman are describing when they talk about keeping state and behaviour separate. It's something that functional programming languages like Haskell force you to do, but it's decent practice to use day-to-day even in languages that let you mix the two together, IMO. > Obviously, ActiveRecord provides the getters and setters anyway, but > the real violator of encapsulation is the consumer, not the vendor. > Just because a flasher opens his coat doesn't mean that reaching > inside is a good idea ;) LOL. I had half-written my own reply to Mark, but that says it all :) Matt Wynne http://blog.mattwynne.net http://www.songkick.com From bj at aboutus.org Sun Apr 19 17:04:18 2009 From: bj at aboutus.org (BJ Clark) Date: Sun, 19 Apr 2009 14:04:18 -0700 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <5a1b94c60142279732af09f3bb09fef0@ruby-forum.com> References: <222DD9C6-5181-48DC-AB6F-5C011D516D5F@aps.org> <18FCD42B-00BB-4185-9E30-F69A72FABC03@mattwynne.net> <2869df69f5f7843244adaa01849d8ec8@ruby-forum.com> <3c30da400904190924v53b50b41r1333f0afcc57018a@mail.gmail.com> <85d99afe0904191123k21374630w24fd6d6138a1b650@mail.gmail.com> <5a1b94c60142279732af09f3bb09fef0@ruby-forum.com> Message-ID: <50933FB5-2F7E-4BA3-8655-9E21FC896D32@aboutus.org> The way I go about this is, IMO, pretty straight forward. I cringe when people start talking about generating html in models, since I think separation of concerns is much more important than law of demeter, and I think that the model most definitely shouldn't be concerned with how it needs to be displayed. In your original example you have: @order.items.each do |item| item.product.title end The way I would do this is: @order.items.each do |item| render :partial => "product/line_item", :locals => {:product => item.product} end In other words, I might have the following partials: product/_line_item product/_product (full representation of product probably for detail page) product/_search_item (for display in a search result) etc. All the partials simply take a product object. There is probably already some smart, intention revealing name, but I call them "nanoformats". I'm not exactly an Academic, so I have no idea the validity of my approach, but this seems to get around the law of demeter enough for me (thought, obviously not totally since order still *technically* knows about order.items.products). Order doesn't actually know anything about products or it's internals, except that it has some. The partial could be reused in other places, and with semantic markup, can be displayed in very different ways with a little CSS. A change to Product only necessitates changes to the app/views/products/* files. Your Orders don't need to know anything, item probably doesn't even need to be updated. the partials can be spec'd independently of wherever they are being used. Your view and your models are always going to be tightly coupled, and a change in your domain object should probably necessitate a change in your views. That's the way it *should* work. However, your views shouldn't be tightly coupled with each other but they will have to be coupled in some way or another. ----- BJ Clark On Apr 19, 2009, at 12:37 PM, Fernando Perez wrote: > >> http://spin.atomicobject.com/2008/01/27/the-exceptional-presenter > Interesting idea too. So basically I need to totally rethink and > refactor the way my views display the information to the customer: > > Let's see how I currently display or not an add to cart button > depending > whether or not the product is free. > > My very first quick and very ugly procedural hard to spec solution was > to do in the view: > > <%- if @product.price >= 0 -%> > <%= display_button %> > <%- else -%> > This product is free! > <%- end -%> > > Then my second solution was to create an instance method so that the > view doesn't know about the Product internal mechanism about it's > freeness: > > <%- if @product.free? -%> > This product is free! > <%- else ... -%> > > Yeah I thought I was an OOP master and Demeter could rest in peace! > > But thinking about the GOF Builder and Exceptional Presenter design > patterns you talk about, that would mean that the html output for a > Product should therefore happen in the Model itself. And then in the > show.html.erb, I simply call: > <%= @product.display -%> > > and all the magic about whether or not the product is free and to > display the button has already been handled inside the model (or > another > related place) when it gets instantiated. Same applies to > item.product.title, that would be handled elsewhere than in the view. > > However it might clutter the Model, so actually there is more to MVC: > each Model should have a sub class or something that handles how the > model instance will be presented to the view. > > How do you handle such issue? Are there some open source rails apps > that > I could learn from? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Sun Apr 19 17:08:31 2009 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 19 Apr 2009 18:08:31 -0300 Subject: [rspec-users] autospec startup problem In-Reply-To: <08fcb9d9-e89e-4bd9-9ec9-889cdaa02d3f@v23g2000pro.googlegroups.com> References: <8d335819-dd56-4e1b-83a4-d7e2acf1aa1c@v1g2000prd.googlegroups.com> <57c63afe0904190716p3542cdb7r2ce7bc1fa09a5f0d@mail.gmail.com> <7c55ed60-2251-41a2-bb81-6f1fe8b5e959@d7g2000prl.googlegroups.com> <3f144701-4328-495d-bf11-7da2b0be1d58@y34g2000prb.googlegroups.com> <71166b3b0904190823u45a5cb3dv76e44294ff190f7a@mail.gmail.com> <08fcb9d9-e89e-4bd9-9ec9-889cdaa02d3f@v23g2000pro.googlegroups.com> Message-ID: <71166b3b0904191408m5149675dp3deb7758fb5a9a8f@mail.gmail.com> On Sun, Apr 19, 2009 at 5:09 PM, Rick wrote: > Luis > > Done and done. ?I was unclear how to obtain 1.9.2-dev so I went to > ftp://ftp.ruby-lang.org and grabbed the today snapshot for 1.9. > Perhaps you could clue me in to the way to obtain 1.9.2-dev if this is > not what I've got. > ruby -v should tell you what you just built :-) If you're on a Mac/Linux I recommend you using multiruby (that cames with ZenTest gem). to setup multiple versions of Ruby. > At any rate, I built and installed ruby. ?Autospec now loads as > advertised in the beta book - now for some serious testing. > Awesome! Don't hesitate in let us know how everything works. > Thank you for that, > rick Sure! Cheers! -- 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 michael at schuerig.de Sun Apr 19 18:41:58 2009 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 20 Apr 2009 00:41:58 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <200904192009.12749.michael@schuerig.de> <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> Message-ID: <200904200041.58797.michael@schuerig.de> On Sunday 19 April 2009, Zach Dennis wrote: > On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig wrote: > > On Sunday 19 April 2009, Zach Dennis wrote: > >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig > > > > wrote: > >> > In a Rails controller I set the scope on a model class in an > >> > around filter. I have defined expectations on the model classes, > >> > and ideally, I would add a further expectation for the scope. Is > >> > this already possible in some way? How would I go about adding > >> > support a scope expectation? > >> > >> How are you setting the said scope? > > > > In an around filter. However, I don't want to test the around > > filter mechanism, it might as well be rack middleware instead. > > Sorry, I don't know what scope means to you in your app. Can you > share your around_filter? Oops, sorry, I assumed the concept from ActiveRecord would be familiar. If you know ActiveRecord::Base#with_scope that's really all there is. A scope, within a block or through a proxy, defines options that are merged with the arguments to #find et al. This merging happens behind the scenes, therefore the scoped options are effective, but don't show up as arguments anywhere. I'm using this in conjunction with a generic query representation (inspired by JSON Query) that is map through a combination of Rack middleware and generated around_filters, see below for a glimpse. Michael class PeopleController < ApplicationController include QueryScope query_scope :only => :index do # Only allow to filter and order by the # virtual name attribute. # This attribute is mapped onto the real # firstname and lastname attributes. allow :name condition :name => "LOWER(firstname || ' ' || lastname) :op LOWER(?)" order :name => "lastname :dir, firstname :dir" end ... Somewhere in QueryScope def query_scope(options = {}, &config_block) model_class = extract_resource!(options) builder = QueryScopeBuilder.new(config_block) around_filter(options) do |controller, action| req = builder.build_request_conditioner(controller.request) controller.instance_variable_set(:@offset_limit, req.offset_limit) model_class.send(:with_scope, :find => req.find_options, &action) end end -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sun Apr 19 19:09:58 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 18:09:58 -0500 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904200041.58797.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904192009.12749.michael@schuerig.de> <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> <200904200041.58797.michael@schuerig.de> Message-ID: <57c63afe0904191609j49d85911p292318e664b46b04@mail.gmail.com> On Sun, Apr 19, 2009 at 5:41 PM, Michael Schuerig wrote: > On Sunday 19 April 2009, Zach Dennis wrote: >> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig > wrote: >> > On Sunday 19 April 2009, Zach Dennis wrote: >> >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig >> > >> > wrote: >> >> > In a Rails controller I set the scope on a model class in an >> >> > around filter. I have defined expectations on the model classes, >> >> > and ideally, I would add a further expectation for the scope. Is >> >> > this already possible in some way? How would I go about adding >> >> > support a scope expectation? >> >> >> >> How are you setting the said scope? >> > >> > In an around filter. However, I don't want to test the around >> > filter mechanism, it might as well be rack middleware instead. >> >> Sorry, I don't know what scope means to you in your app. Can you >> share your around_filter? > > Oops, sorry, I assumed the concept from ActiveRecord would be familiar. It *is* familiar, but setting a model scope from the controller violates the widely-accepted guideline of skinny controllers and fat models. I'm guessing that's why Zach wasn't sure what you were talking about. > If you know ActiveRecord::Base#with_scope that's really all there is. A > scope, within a block or through a proxy, defines options that are > merged with the arguments to #find et al. This merging happens behind > the scenes, therefore the scoped options are effective, but don't show > up as arguments anywhere. > > I'm using this in conjunction with a generic query representation > (inspired by JSON Query) that is map through a combination of Rack > middleware and generated around_filters, see below for a glimpse. > > Michael > > > class PeopleController < ApplicationController > ?include QueryScope > > ?query_scope :only => :index do > ? ?# Only allow to filter and order by the > ? ?# virtual name attribute. > ? ?# This attribute is mapped onto the real > ? ?# firstname and lastname attributes. > ? ?allow ? ? :name > ? ?condition :name => > ? ? ?"LOWER(firstname || ' ' || lastname) :op LOWER(?)" > ? ?order ? ? :name => "lastname :dir, firstname :dir" > ?end > ?... > > Somewhere in QueryScope > > def query_scope(options = {}, &config_block) > ?model_class = extract_resource!(options) > ?builder = QueryScopeBuilder.new(config_block) > ?around_filter(options) do |controller, action| > ? ?req = builder.build_request_conditioner(controller.request) > ? ?controller.instance_variable_set(:@offset_limit, req.offset_limit) > ? ?model_class.send(:with_scope, :find => req.find_options, &action) > ?end > end Unless I'm mistaken, it is code like this outside models that was the underlying motivation for adding named scopes to active record. The reason it is problematic is that it tends to result in a lot of duplication outside the models, and makes the controllers really hard to understand. Consider this alternative: describe PeopleController do describe "GET index" do it "assigns a list of all people filtered by virtual name attributes" do people = [mock_model(Person)] Person.stub!(:all).and_return(people) people.should_receive(:with_virtual_names).and_return(people) get :index end end end class PeopleController def index @people = PeopleController.all.with_virtual_names end end Now you can specify what with_virtual_names means in a model spec. This is easier and far less invasive than trying to specify that specific filters are applied from the controller spec. HTH, David > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From michael at schuerig.de Sun Apr 19 20:19:05 2009 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 20 Apr 2009 02:19:05 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <57c63afe0904191609j49d85911p292318e664b46b04@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <200904200041.58797.michael@schuerig.de> <57c63afe0904191609j49d85911p292318e664b46b04@mail.gmail.com> Message-ID: <200904200219.05850.michael@schuerig.de> On Monday 20 April 2009, David Chelimsky wrote: > On Sun, Apr 19, 2009 at 5:41 PM, Michael Schuerig wrote: > > On Sunday 19 April 2009, Zach Dennis wrote: > >> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig > > > > wrote: > >> > On Sunday 19 April 2009, Zach Dennis wrote: > >> >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig > >> > > >> > wrote: > >> >> > In a Rails controller I set the scope on a model class in an > >> >> > around filter. I have defined expectations on the model > >> >> > classes, and ideally, I would add a further expectation for > >> >> > the scope. Is this already possible in some way? How would I > >> >> > go about adding support a scope expectation? > >> >> > >> >> How are you setting the said scope? > >> > > >> > In an around filter. However, I don't want to test the around > >> > filter mechanism, it might as well be rack middleware instead. > >> > >> Sorry, I don't know what scope means to you in your app. Can you > >> share your around_filter? > > > > Oops, sorry, I assumed the concept from ActiveRecord would be > > familiar. > > It *is* familiar, but setting a model scope from the controller > violates the widely-accepted guideline of skinny controllers and fat > models. I'm guessing that's why Zach wasn't sure what you were > talking about. My controllers are anorexic. The functionality I'm trying to spec is completely generic, I just mix it into the controller. [snip] > > Somewhere in QueryScope > > > > def query_scope(options = {}, &config_block) > > model_class = extract_resource!(options) > > builder = QueryScopeBuilder.new(config_block) > > around_filter(options) do |controller, action| > > req = builder.build_request_conditioner(controller.request) > > controller.instance_variable_set(:@offset_limit, > > req.offset_limit) model_class.send(:with_scope, :find => > > req.find_options, &action) end > > end > > Unless I'm mistaken, it is code like this outside models that was the > underlying motivation for adding named scopes to active record. The > reason it is problematic is that it tends to result in a lot of > duplication outside the models, and makes the controllers really hard > to understand. You are mistaken as there is no duplication at all. Among other things, I have Rack middleware that maps request like (appropriately escaped) /resource/?[?name='Dav*'][/name] to a params hash like { :query => [{:attribute => 'name', :op => '=', :target => 'Dav*'}], :order => [{:attribute => 'name'}] } This, in turn, is interpreted by a RequestConditioner (bad name) which in this case would, with the help of some mappings passed to it, return rc.conditions == ["(firstname || ' ' || lastname) LIKE ?", 'Dav%'] rc.order == 'lastname, firstname' As the last step, these pieces are used to define a scope around certain controller actions. I could pass them explicitly to, say, #find, but then I'd have to manually merge them with other conditions. As to whether this functionality belongs in the model -- I am against it. What I've described is an adapter layer that translates from one representation of a query to another. It is not at all related to the core logic enclosed in the models. > Consider this alternative: > > describe PeopleController do > describe "GET index" do > it "assigns a list of all people filtered by virtual name > attributes" do people = [mock_model(Person)] > Person.stub!(:all).and_return(people) > people.should_receive(:with_virtual_names).and_return(people) > get :index > end > end > end > > class PeopleController > def index > @people = PeopleController.all.with_virtual_names > end > end That code is sclerotic. I'm building a RIA-client that only requests JSON-formatted data from the server. Say, I add a date of birth column to the people grid. Then the most I want to (and have to) do is ensure that the requisite attribute is whitelisted for querying and contained in the response data. (Yes, I have JSON "views" with accompanying specs.) Taking your non-generic approach, I'd have to repeatedly write and explicitly test, very similar code. Consider adding date of birth for sorting and filtering to your example. Then consider writing another controller that does roughly the same for movies with titles and release dates. You'll end up with repetitive code. Of course, you're going to factor out the repetition -- and that's where I already am. So, long story short, I still think I could make good use of a way to define an expectation for a specific scope in effect during a #find. Apart from my current case, this would make it possible to check on dynamic scopes introduced in Rails 2.3. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From dchelimsky at gmail.com Sun Apr 19 21:00:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 19 Apr 2009 20:00:16 -0500 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904200219.05850.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904200041.58797.michael@schuerig.de> <57c63afe0904191609j49d85911p292318e664b46b04@mail.gmail.com> <200904200219.05850.michael@schuerig.de> Message-ID: <57c63afe0904191800i65099c7du1178d717bd607603@mail.gmail.com> On Sun, Apr 19, 2009 at 7:19 PM, Michael Schuerig wrote: > On Monday 20 April 2009, David Chelimsky wrote: >> On Sun, Apr 19, 2009 at 5:41 PM, Michael Schuerig > wrote: >> > On Sunday 19 April 2009, Zach Dennis wrote: >> >> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig >> > >> > wrote: >> >> > On Sunday 19 April 2009, Zach Dennis wrote: >> >> >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig >> >> > >> >> > wrote: >> >> >> > In a Rails controller I set the scope on a model class in an >> >> >> > around filter. I have defined expectations on the model >> >> >> > classes, and ideally, I would add a further expectation for >> >> >> > the scope. Is this already possible in some way? How would I >> >> >> > go about adding support a scope expectation? >> >> >> >> >> >> How are you setting the said scope? >> >> > >> >> > In an around filter. However, I don't want to test the around >> >> > filter mechanism, it might as well be rack middleware instead. >> >> >> >> Sorry, I don't know what scope means to you in your app. Can you >> >> share your around_filter? >> > >> > Oops, sorry, I assumed the concept from ActiveRecord would be >> > familiar. >> >> It *is* familiar, but setting a model scope from the controller >> violates the widely-accepted guideline of skinny controllers and fat >> models. I'm guessing that's why Zach wasn't sure what you were >> talking about. > > My controllers are anorexic. The functionality I'm trying to spec is > completely generic, I just mix it into the controller. > > [snip] >> > Somewhere in QueryScope >> > >> > def query_scope(options = {}, &config_block) >> > ?model_class = extract_resource!(options) >> > ?builder = QueryScopeBuilder.new(config_block) >> > ?around_filter(options) do |controller, action| >> > ? ?req = builder.build_request_conditioner(controller.request) >> > ? ?controller.instance_variable_set(:@offset_limit, >> > req.offset_limit) model_class.send(:with_scope, :find => >> > req.find_options, &action) end >> > end >> >> Unless I'm mistaken, it is code like this outside models that was the >> underlying motivation for adding named scopes to active record. The >> reason it is problematic is that it tends to result in a lot of >> duplication outside the models, and makes the controllers really hard >> to understand. > > You are mistaken as there is no duplication at all. Among other things, > I have Rack middleware that maps request like (appropriately escaped) > > ?/resource/?[?name='Dav*'][/name] > > to a params hash like > > ?{ :query => [{:attribute => 'name', :op => '=', :target => 'Dav*'}], > ? ?:order => [{:attribute => 'name'}] } > > This, in turn, is interpreted by a RequestConditioner (bad name) which > in this case would, with the help of some mappings passed to it, return > > ?rc.conditions == ["(firstname || ' ' || lastname) LIKE ?", 'Dav%'] > ?rc.order ? ? ?== 'lastname, firstname' > > As the last step, these pieces are used to define a scope around certain > controller actions. I could pass them explicitly to, say, #find, but > then I'd have to manually merge them with other conditions. > > As to whether this functionality belongs in the model -- I am against > it. What I've described is an adapter layer that translates from one > representation of a query to another. It is not at all related to the > core logic enclosed in the models. > > >> Consider this alternative: >> >> describe PeopleController do >> ? describe "GET index" do >> ? ? it "assigns a list of all people filtered by virtual name >> attributes" do people = [mock_model(Person)] >> ? ? ? Person.stub!(:all).and_return(people) >> ? ? ? people.should_receive(:with_virtual_names).and_return(people) >> ? ? ? get :index >> ? ? end >> ? end >> end >> >> class PeopleController >> ? def index >> ? ? @people = PeopleController.all.with_virtual_names >> ? end >> end > > That code is sclerotic. I'm building a RIA-client that only requests > JSON-formatted data from the server. Say, I add a date of birth column > to the people grid. Then the most I want to (and have to) do is ensure > that the requisite attribute is whitelisted for querying and contained > in the response data. (Yes, I have JSON "views" with accompanying > specs.) > > Taking your non-generic approach, I'd have to repeatedly write and > explicitly test, very similar code. Consider adding date of birth for > sorting and filtering to your example. Then consider writing another > controller that does roughly the same for movies with titles and release > dates. You'll end up with repetitive code. Of course, you're going to > factor out the repetition -- and that's where I already am. > > So, long story short, I still think I could make good use of a way to > define an expectation for a specific scope in effect during a #find. > Apart from my current case, this would make it possible to check on > dynamic scopes introduced in Rails 2.3. So what does the controller's index method actually look like? > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Sun Apr 19 21:36:46 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 19 Apr 2009 21:36:46 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904200041.58797.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904192009.12749.michael@schuerig.de> <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> <200904200041.58797.michael@schuerig.de> Message-ID: <85d99afe0904191836i5cb403fbj9e26f4541ebff825@mail.gmail.com> On Sun, Apr 19, 2009 at 6:41 PM, Michael Schuerig wrote: > On Sunday 19 April 2009, Zach Dennis wrote: >> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig > wrote: >> > On Sunday 19 April 2009, Zach Dennis wrote: >> >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig >> > >> > wrote: >> >> > In a Rails controller I set the scope on a model class in an >> >> > around filter. I have defined expectations on the model classes, >> >> > and ideally, I would add a further expectation for the scope. Is >> >> > this already possible in some way? How would I go about adding >> >> > support a scope expectation? >> >> >> >> How are you setting the said scope? >> > >> > In an around filter. However, I don't want to test the around >> > filter mechanism, it might as well be rack middleware instead. >> >> Sorry, I don't know what scope means to you in your app. Can you >> share your around_filter? > > Oops, sorry, I assumed the concept from ActiveRecord would be familiar. > If you know ActiveRecord::Base#with_scope that's really all there is. A > scope, within a block or through a proxy, defines options that are > merged with the arguments to #find et al. This merging happens behind > the scenes, therefore the scoped options are effective, but don't show > up as arguments anywhere. > > I'm using this in conjunction with a generic query representation > (inspired by JSON Query) that is map through a combination of Rack > middleware and generated around_filters, see below for a glimpse. > > Michael > > > class PeopleController < ApplicationController > ?include QueryScope > > ?query_scope :only => :index do > ? ?# Only allow to filter and order by the > ? ?# virtual name attribute. > ? ?# This attribute is mapped onto the real > ? ?# firstname and lastname attributes. > ? ?allow ? ? :name > ? ?condition :name => > ? ? ?"LOWER(firstname || ' ' || lastname) :op LOWER(?)" > ? ?order ? ? :name => "lastname :dir, firstname :dir" > ?end > ?... > > Somewhere in QueryScope > > def query_scope(options = {}, &config_block) > ?model_class = extract_resource!(options) > ?builder = QueryScopeBuilder.new(config_block) > ?around_filter(options) do |controller, action| > ? ?req = builder.build_request_conditioner(controller.request) > ? ?controller.instance_variable_set(:@offset_limit, req.offset_limit) > ? ?model_class.send(:with_scope, :find => req.find_options, &action) > ?end > end In your original post you asked: "How would I go about adding support a scope expectation?" Given the code you've shown it is not clear exactly what you are expecting. Do you just want to be able to expect that you call model_class.send(:with_scope) with the appropriate arguments? I'm sorry if I seem dense, but you have a very clear idea of what you want to accomplish, but it's coming out very piece meal across multiple emails and it's quite difficult to pick up on, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From michael at schuerig.de Sun Apr 19 21:47:22 2009 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 20 Apr 2009 03:47:22 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <57c63afe0904191800i65099c7du1178d717bd607603@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <200904200219.05850.michael@schuerig.de> <57c63afe0904191800i65099c7du1178d717bd607603@mail.gmail.com> Message-ID: <200904200347.22413.michael@schuerig.de> On Monday 20 April 2009, David Chelimsky wrote: > >> Consider this alternative: > >> > >> describe PeopleController do > >> describe "GET index" do > >> it "assigns a list of all people filtered by virtual name > >> attributes" do people = [mock_model(Person)] > >> Person.stub!(:all).and_return(people) > >> > >> people.should_receive(:with_virtual_names).and_return(people) get > >> :index > >> end > >> end > >> end > >> > >> class PeopleController > >> def index > >> @people = PeopleController.all.with_virtual_names > >> end > >> end > > > > That code is sclerotic. I'm building a RIA-client that only > > requests JSON-formatted data from the server. Say, I add a date of > > birth column to the people grid. Then the most I want to (and have > > to) do is ensure that the requisite attribute is whitelisted for > > querying and contained in the response data. (Yes, I have JSON > > "views" with accompanying specs.) > > > > Taking your non-generic approach, I'd have to repeatedly write and > > explicitly test, very similar code. Consider adding date of birth > > for sorting and filtering to your example. Then consider writing > > another controller that does roughly the same for movies with > > titles and release dates. You'll end up with repetitive code. Of > > course, you're going to factor out the repetition -- and that's > > where I already am. > > > > So, long story short, I still think I could make good use of a way > > to define an expectation for a specific scope in effect during a > > #find. Apart from my current case, this would make it possible to > > check on dynamic scopes introduced in Rails 2.3. > > So what does the controller's index method actually look like? class PeopleController < ApplicationController ... def index respond_to do |format| format.html { render :layout => false } format.json do @people = Person.all( :offset => @offset_limit[0], :limit => @offset_limit[1]) @count = Person.count render end end end ... # app/views/people/index.json.rb { :identifier => Person.primary_key, :totalCount => @count, :items => @people.map { |p| render :partial => 'people/item', :locals => { :person => p } } } # app/views/people/_item.json.rb { :id => person.id, :name => person.name, :dob => person.date_of_birth } :offset and :limit are the only warts, but I can't set them in a scope as that would affect the total #count to, not just #find. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From michael at schuerig.de Sun Apr 19 21:57:19 2009 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 20 Apr 2009 03:57:19 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <85d99afe0904191836i5cb403fbj9e26f4541ebff825@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <200904200041.58797.michael@schuerig.de> <85d99afe0904191836i5cb403fbj9e26f4541ebff825@mail.gmail.com> Message-ID: <200904200357.19493.michael@schuerig.de> On Monday 20 April 2009, Zach Dennis wrote: > In your original post you asked: > > "How would I go about adding support a scope expectation?" > > Given the code you've shown it is not clear exactly what you are > expecting. Do you just want to be able to expect that you call > model_class.send(:with_scope) with the appropriate arguments? I'd rather check that a particular scope is in effect for a call to #find. Just as I said. ;-) The reason is that I don't want to encumber my controller specs with how or where the currently effective scope was set. It might have been multiple nested calls to with_scope or named scopes. In my current code this is not the case, but that's an implementation detail. In the specs for the code that does set the scope, an expectation on the call to with_scope is the right thing. But that's an entirely different spec at a lower level ob abstraction. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From tom at experthuman.com Mon Apr 20 03:59:43 2009 From: tom at experthuman.com (Tom Stuart) Date: Mon, 20 Apr 2009 08:59:43 +0100 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904200357.19493.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904200041.58797.michael@schuerig.de> <85d99afe0904191836i5cb403fbj9e26f4541ebff825@mail.gmail.com> <200904200357.19493.michael@schuerig.de> Message-ID: On 20 Apr 2009, at 02:57, Michael Schuerig wrote: > I'd rather check that a particular scope is in effect for a call to > #find. Just as I said. ;-) As is always the case with spec'ing Rails, I don't know which level of abstraction is the right one to check, but it seems like what you're asking for is literally: Person.should_receive(:all) do find_scope = Person.send(:scope, :find) find_scope[:conditions].should == { name => ["LOWER(firstname || ' ' || lastname) = LOWER(?)", 'Dav%'] } find_scope[:order].should == { :name => "lastname ASC, firstname ASC" } end However this is obviously getting your hands a bit dirty with Rails guts -- I suspect others would suggest that you just set an expectation on with_scope and be done with it (or just load some fixtures, let the find hit the database, and make sure you get the right records back? presumably that's wrong in another way, as is traditional). Cheers, -Tom From julian at leviston.net Mon Apr 20 04:24:56 2009 From: julian at leviston.net (Julian Leviston) Date: Mon, 20 Apr 2009 18:24:56 +1000 Subject: [rspec-users] Appropriate adapter (Rails, Cucumber) Message-ID: Hi All, I've got a bunch of tests written in cucumber, and they're all lovely... this is rails testing i'm doing by the way.... and now I'm coming to testing the javascript and AJAX parts of the app... and I've decided to plug in selenium... my issue is, I'd like to select which adapter to use on a per-scenario basis... is there any easy way to do this, and yet still maintain the no-implementation-details in the cucumber side type of thing that cucumber encourages... I mean, basically, I just want it to use the fastest method possible.... so for non-ajax/non-js stuff, I'd like it to use the default adapter and others I'd like it to use selenium.... Julian. From joe at josephwilk.net Mon Apr 20 05:50:44 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Mon, 20 Apr 2009 10:50:44 +0100 Subject: [rspec-users] Appropriate adapter (Rails, Cucumber) In-Reply-To: References: Message-ID: <49EC4574.7060006@josephwilk.net> Julian Leviston wrote: > Hi All, > I've got a bunch of tests written in cucumber, and they're all > lovely... this is rails testing i'm doing by the way.... and now I'm > coming to testing the javascript and AJAX parts of the app... and I've > decided to plug in selenium... my issue is, I'd like to select which > adapter to use on a per-scenario basis... is there any easy way to do > this, and yet still maintain the no-implementation-details in the > cucumber side type of thing that cucumber encourages... > > I mean, basically, I just want it to use the fastest method > possible.... so for non-ajax/non-js stuff, I'd like it to use the > default adapter and others I'd like it to use selenium.... > > Julian. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Have you looked at using Cucumber's Tagging feature? (http://wiki.github.com/aslakhellesoy/cucumber/tags) --- @js Scenario: I'm javascript Scenario: I'm not using javascript --- --- #Run scenarios excluding any that are tagged as js > cucumber --tags ~@js features/ #Run just the js scenarios. > cucumber --tags @js features/ --- So you have two separate runs of Cucumber. Hence you could have a env.rb for each. One that loads Selenium (or Webrat driving Selenium) and the other Webrat. HTH, -- Joseph Wilk http://blog.josephwilk.net From zach.dennis at gmail.com Mon Apr 20 13:35:42 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 20 Apr 2009 13:35:42 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904200041.58797.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904192009.12749.michael@schuerig.de> <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> <200904200041.58797.michael@schuerig.de> Message-ID: <85d99afe0904201035k1d1053a2ifcceeba507f1277f@mail.gmail.com> On Sun, Apr 19, 2009 at 6:41 PM, Michael Schuerig wrote: > On Sunday 19 April 2009, Zach Dennis wrote: >> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig > wrote: >> > On Sunday 19 April 2009, Zach Dennis wrote: >> >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig >> > >> > wrote: >> >> > In a Rails controller I set the scope on a model class in an >> >> > around filter. I have defined expectations on the model classes, >> >> > and ideally, I would add a further expectation for the scope. Is >> >> > this already possible in some way? How would I go about adding >> >> > support a scope expectation? >> >> >> >> How are you setting the said scope? >> > >> > In an around filter. However, I don't want to test the around >> > filter mechanism, it might as well be rack middleware instead. >> >> Sorry, I don't know what scope means to you in your app. Can you >> share your around_filter? > > Oops, sorry, I assumed the concept from ActiveRecord would be familiar. > If you know ActiveRecord::Base#with_scope that's really all there is. A > scope, within a block or through a proxy, defines options that are > merged with the arguments to #find et al. This merging happens behind > the scenes, therefore the scoped options are effective, but don't show > up as arguments anywhere. > > I'm using this in conjunction with a generic query representation > (inspired by JSON Query) that is map through a combination of Rack > middleware and generated around_filters, see below for a glimpse. > > Michael > > > class PeopleController < ApplicationController > include QueryScope > > query_scope :only => :index do > # Only allow to filter and order by the > # virtual name attribute. > # This attribute is mapped onto the real > # firstname and lastname attributes. > allow :name > condition :name => > "LOWER(firstname || ' ' || lastname) :op LOWER(?)" > order :name => "lastname :dir, firstname :dir" > end > ... > > Somewhere in QueryScope > > def query_scope(options = {}, &config_block) > model_class = extract_resource!(options) > builder = QueryScopeBuilder.new(config_block) > around_filter(options) do |controller, action| > req = builder.build_request_conditioner(controller.request) > controller.instance_variable_set(:@offset_limit, req.offset_limit) > model_class.send(:with_scope, :find => req.find_options, &action) > end > end I think I am starting to understand what you're after. You want to ensure the scope defined in your query_scope configuration block in the controller is used to set the scope on the controller's model. Right? With the assumption that that is correct, I would probably refactor how your #query_scope method works. Right now you're implicitly going through a QueryScopeBuilder to get a RequestConditioner, in order to access the #find_options and #offset_limit behaviour on that RequestConditioner. I would make your controller deal with one object, perhaps a RequestToQueryTranslator. Your #query_scope method would come out looking like: def query_scope(options = {}, &config_block) model_class = extract_resource!(options) query = RequestToQueryTranslator.translate(controller.request, &config_block) around_filter(options) do |controller, action| controller.instance_variable_set(:@offset_limit, query.offset_limit) model_class.send(:with_scope, :find => query.find_options, &action) end end This simplifies the #query_scope method and gives you more implementation freedom how your query is constructed. This still leaves something difficult to spec though, you are passing your query_scope config_block through, and I'm guessing it is instance_eval'd. You can't be sure of what's going on in that config_block unless you actually instance_eval inside of the appropriate object. This limits your ability to write a clean object-level example expecting the right query is constructed because it requires your controller to work with real dependent objects. Two approaches that come to mind for dealing with this are to change how your config_block works. Rather than: query_scope :only => :index do allow :name condition :name => "LOWER(firstname || ' ' || lastname) :op LOWER(?)" order :name => "lastname :dir, firstname :dir" end You could do: query_scope :only => :index do |query| query.allow :name query.condition :name => "LOWER(firstname || ' ' || lastname) :op LOWER(?)" query.order :name => "lastname :dir, firstname :dir" end Now in your spec, you can write a spec against the query_scope, by ensuring the passed in object receives #allow, #condition and #order with appropriate arguments. Now you don't have instance eval the block in some dependent object somewhere, you can simply pass the query your RequestToQueryTranslator.translate method returns to the config_block. This gives you the advantage of ensuring that the controller sets up the proper query, and it allows you to spec your RequestToQueryTranslator in isolation to ensure that given a certain set of method calls that it builds the right find options. The code is not as pretty I agree because you have to call methods on the query object passed to your config block. However, the advantage is that its much easier to spec out, and you're able to right examples that are clearer than the alternative (ones that ensure magic happens with a set dependent objects). WDYT? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Mon Apr 20 13:38:04 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 20 Apr 2009 13:38:04 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <85d99afe0904201035k1d1053a2ifcceeba507f1277f@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <200904192009.12749.michael@schuerig.de> <85d99afe0904191126v6cc01a9ewfe790acfcd7dd1e0@mail.gmail.com> <200904200041.58797.michael@schuerig.de> <85d99afe0904201035k1d1053a2ifcceeba507f1277f@mail.gmail.com> Message-ID: <85d99afe0904201038nfc846dfl8b0e92263f8b07fd@mail.gmail.com> On Mon, Apr 20, 2009 at 1:35 PM, Zach Dennis wrote: > On Sun, Apr 19, 2009 at 6:41 PM, Michael Schuerig wrote: >> On Sunday 19 April 2009, Zach Dennis wrote: >>> On Sun, Apr 19, 2009 at 2:09 PM, Michael Schuerig >> wrote: >>> > On Sunday 19 April 2009, Zach Dennis wrote: >>> >> On Sun, Apr 19, 2009 at 12:27 PM, Michael Schuerig >>> > >>> > wrote: >>> >> > In a Rails controller I set the scope on a model class in an >>> >> > around filter. I have defined expectations on the model classes, >>> >> > and ideally, I would add a further expectation for the scope. Is >>> >> > this already possible in some way? How would I go about adding >>> >> > support a scope expectation? >>> >> >>> >> How are you setting the said scope? >>> > >>> > In an around filter. However, I don't want to test the around >>> > filter mechanism, it might as well be rack middleware instead. >>> >>> Sorry, I don't know what scope means to you in your app. Can you >>> share your around_filter? >> >> Oops, sorry, I assumed the concept from ActiveRecord would be familiar. >> If you know ActiveRecord::Base#with_scope that's really all there is. A >> scope, within a block or through a proxy, defines options that are >> merged with the arguments to #find et al. This merging happens behind >> the scenes, therefore the scoped options are effective, but don't show >> up as arguments anywhere. >> >> I'm using this in conjunction with a generic query representation >> (inspired by JSON Query) that is map through a combination of Rack >> middleware and generated around_filters, see below for a glimpse. >> >> Michael >> >> >> class PeopleController < ApplicationController >> ?include QueryScope >> >> ?query_scope :only => :index do >> ? ?# Only allow to filter and order by the >> ? ?# virtual name attribute. >> ? ?# This attribute is mapped onto the real >> ? ?# firstname and lastname attributes. >> ? ?allow ? ? :name >> ? ?condition :name => >> ? ? ?"LOWER(firstname || ' ' || lastname) :op LOWER(?)" >> ? ?order ? ? :name => "lastname :dir, firstname :dir" >> ?end >> ?... >> >> Somewhere in QueryScope >> >> def query_scope(options = {}, &config_block) >> ?model_class = extract_resource!(options) >> ?builder = QueryScopeBuilder.new(config_block) >> ?around_filter(options) do |controller, action| >> ? ?req = builder.build_request_conditioner(controller.request) >> ? ?controller.instance_variable_set(:@offset_limit, req.offset_limit) >> ? ?model_class.send(:with_scope, :find => req.find_options, &action) >> ?end >> end > > I think I am starting to understand what you're after. You want to > ensure the scope defined in your query_scope configuration block in > the controller is used to set the scope on the controller's model. > Right? > > With the assumption that that is correct, I would probably refactor > how your #query_scope method works. Right now you're implicitly going > through a QueryScopeBuilder to get a RequestConditioner, in order to > access the #find_options and #offset_limit behaviour on that > RequestConditioner. I would make your controller deal with one object, > perhaps a RequestToQueryTranslator. Your #query_scope method would > come out looking like: > > ? def query_scope(options = {}, &config_block) > ? ?model_class = extract_resource!(options) > ? ?query = RequestToQueryTranslator.translate(controller.request, > &config_block) > ? ?around_filter(options) do |controller, action| > ? ? ?controller.instance_variable_set(:@offset_limit, query.offset_limit) > ? ? ?model_class.send(:with_scope, :find => query.find_options, &action) > ? ?end > ? end > > This simplifies the #query_scope method and gives you more > implementation freedom how your query is constructed. This still > leaves something difficult to spec though, you are passing your > query_scope config_block through, and I'm guessing it is > instance_eval'd. You can't be sure of what's going on in that > config_block unless you actually instance_eval inside of the > appropriate object. This limits your ability to write a clean > object-level example expecting the right query is constructed because > it requires your controller to work with real dependent objects. > > Two approaches that come to mind for dealing with this are to change > how your config_block works. Rather than: > > ?query_scope :only => :index do > ? ?allow ? ? :name > ? ?condition :name => > ? ? ?"LOWER(firstname || ' ' || lastname) :op LOWER(?)" > ? ?order ? ? :name => "lastname :dir, firstname :dir" > ?end > > You could do: > > ?query_scope :only => :index do |query| > ? ?query.allow ? ? :name > ? ?query.condition :name => > ? ? ?"LOWER(firstname || ' ' || lastname) :op LOWER(?)" > ? ?query.order ? ? :name => "lastname :dir, firstname :dir" > ?end > > Now in your spec, you can write a spec against the query_scope, by > ensuring the passed in object receives #allow, #condition and #order > with appropriate arguments. Now you don't have instance eval the block > in some dependent object somewhere, you can simply pass the query your > RequestToQueryTranslator.translate method returns to the config_block. > This gives you the advantage of ensuring that the controller sets up > the proper query, and it allows you to spec your > RequestToQueryTranslator in isolation to ensure that given a certain > set of method calls that it builds the right find options. > In addition to this I would still have an example that expected with_scope to be set on the appropriate model based on the results of query.find_options, and that @offset_limit was assigned based on the results of query.offest_limit. > The code is not as pretty I agree because you have to call methods on > the query object passed to your config block. However, the advantage > is that its much easier to spec out, and you're able to right examples > that are clearer than the alternative (ones that ensure magic happens > with a set dependent objects). > > WDYT? > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From john.goodsen.time at gmail.com Mon Apr 20 13:25:51 2009 From: john.goodsen.time at gmail.com (John Goodsen) Date: Mon, 20 Apr 2009 13:25:51 -0400 Subject: [rspec-users] [cucumber, jruby] Same steps are being added multiple times Message-ID: <52d418100904201025tf521e12i45136140619373d5@mail.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 never got a ticket from any of you, but I have committed a fix: http://github.com/aslakhellesoy/cucumber_java/commit/5f8f31b3d2b34050a93e27990ed25ce9274f49ac So it will be in the next release. Aslak --------- Aslak, I pulled this version and I"m using it now. It has a Java 6 dependency: in the maven build - see file CucumberMojo.java, you are referencing a String method isEmpty() that doesn't exist in prior Java releases. The project I'm consulting with right now is on Java 5, so I had to change 3 lines in that file to use the String size()==0 method instead. You might want to make this change permanent so it works on other Java 5 installations also? Thanks!, John From html-kurs at gmx.de Mon Apr 20 15:07:53 2009 From: html-kurs at gmx.de (Martin) Date: Mon, 20 Apr 2009 21:07:53 +0200 Subject: [rspec-users] Cucmber: Mysql::Error: query: not connected: ROLLBACK In-Reply-To: <8d961d900904191348p3abecfd1x73e69e169a58a4@mail.gmail.com> References: <49EB73F6.7080801@gmx.de> <8d961d900904191316g750470f0o322c5bc1f1fe0a41@mail.gmail.com> <8d961d900904191348p3abecfd1x73e69e169a58a4@mail.gmail.com> Message-ID: <49ECC809.90801@gmx.de> Hi Aslkak, > Did you change your test.rb to use > config.cache_classes = false > ? you're right, I changed it because of rspec-server. Now I found the hint on http://wiki.github.com/dchelimsky/rspec/spec_server-autospec-nearly-pure-bdd-joy that it breaks cucumber... Thanks, Martin From pat.maddox at gmail.com Mon Apr 20 15:40:08 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Mon, 20 Apr 2009 12:40:08 -0700 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: References: Message-ID: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> I wrote a blog post that may be helpful. http://www.patmaddox.com/blog/demeter-is-for-encapsulation Basically, when you have structural objects as in this case, demeter isn't useful. Luke Redpath wrote something called Demeter's Revenge which you might want to look at. I've not used it though so I can't tell you if it will solve your problems. Pat From pat.maddox at gmail.com Mon Apr 20 15:41:51 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Mon, 20 Apr 2009 12:41:51 -0700 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904191827.04395.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> Message-ID: <2c7e61990904201241h9a52702g1aba5a834874345@mail.gmail.com> In a functional test, create some records that will be in the scope and some that will be out of the scope, hit the page and make sure you only see the ones that you want. I would either do this with cucumber, or write a controller spec and verify that only certain records show in the the assigns var. Either way you're going to have to hit the db because obviously the scope affects the db queries. This is why you'd typically like to keep that stuff in the model. Pat On Sun, Apr 19, 2009 at 9:27 AM, Michael Schuerig wrote: > > In a Rails controller I set the scope on a model class in an around > filter. I have defined expectations on the model classes, and ideally, I > would add a further expectation for the scope. Is this already possible > in some way? How would I go about adding support a scope expectation? > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Mon Apr 20 16:25:38 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 20 Apr 2009 16:25:38 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904202127.54838.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904200041.58797.michael@schuerig.de> <85d99afe0904201035k1d1053a2ifcceeba507f1277f@mail.gmail.com> <200904202127.54838.michael@schuerig.de> Message-ID: <85d99afe0904201325o3693e281m470ff305bfd21ea6@mail.gmail.com> On Mon, Apr 20, 2009 at 3:27 PM, Michael Schuerig wrote: > On Monday 20 April 2009, Zach Dennis wrote: >> On Sun, Apr 19, 2009 at 6:41 PM, Michael Schuerig > wrote: > [big snip] > >> I think I am starting to understand what you're after. You want to >> ensure the scope defined in your query_scope configuration block in >> the controller is used to set the scope on the controller's model. >> Right? > > Exactly. > >> With the assumption that that is correct, I would probably refactor >> how your #query_scope method works. Right now you're implicitly going >> through a QueryScopeBuilder to get a RequestConditioner, in order to >> access the #find_options and #offset_limit behaviour on that >> RequestConditioner. I would make your controller deal with one >> object, perhaps a RequestToQueryTranslator. Your #query_scope method >> would come out looking like: >> >> ? ?def query_scope(options = {}, &config_block) >> ? ? model_class = extract_resource!(options) >> ? ? query = RequestToQueryTranslator.translate(controller.request, >> &config_block) >> ? ? around_filter(options) do |controller, action| >> ? ? ? controller.instance_variable_set(:@offset_limit, >> query.offset_limit) model_class.send(:with_scope, :find => >> query.find_options, &action) end >> ? ?end > > I don't agress. Both classes have distinct, although related purposes. > RequestCondition implements the translation from request parameters to > #find-options. QueryScope(Builder) fits it in with ActionController and > adds syntactic sugar. The former is easy to spec, for the latter, I've > been to lazy to figure out a good way. I'm just suggesting that RequestCondition and QueryScopeBuilder are encapsulated behind RequestToQueryTranslator, so your controller doesn't have to know about both of them. Your controller doesn't actually care about request conditioners and query scope builders. It only cares that it can translate a request to a query so it can be used to set the scope on the model. > >> WDYT? > > I've attached the involved files. I try to avoid doing that on mailing > lists, but we're going in circles otherwise. > > In the meantime I've looked into rspec's message expectation in order to > add an expectation for a particular scope being set on an ActiveRecord > class. What I'd need to implement this is a way to get hold of the > partially mocked class. There may not be one. > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From michael at schuerig.de Mon Apr 20 16:26:14 2009 From: michael at schuerig.de (Michael Schuerig) Date: Mon, 20 Apr 2009 22:26:14 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <2c7e61990904201241h9a52702g1aba5a834874345@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <2c7e61990904201241h9a52702g1aba5a834874345@mail.gmail.com> Message-ID: <200904202226.15607.michael@schuerig.de> On Monday 20 April 2009, Pat Maddox wrote: > In a functional test, create some records that will be in the scope > and some that will be out of the scope, hit the page and make sure > you only see the ones that you want. I would either do this with > cucumber, or write a controller spec and verify that only certain > records show in the the assigns var. Either way you're going to have > to hit the db because obviously the scope affects the db queries. Yes, and that feels a bit like cheating. > This is why you'd typically like to keep that stuff in the model. I agree on the typically, but disagree specifically. I've tried my way into rspec, see below, but got stuck at the point where I'd have to get hold of the model class. Michael require 'spec/mocks/message_expectation' module Spec #:nodoc: module Mocks #:nodoc: class ScopeExpectation def initialize(args) @args = args end def scope_matches? # here a miracle occurs ... end end module MessageExpectationScopeExtension def self.included(base) base.send(:alias_method, :matches_without_scope, :matches) base.send(:alias_method, :matches, :matches_with_scope) end def within_scope(*args) @scope_expectation = ScopeExpectation.new(args) self end def matches_with_scope(*args, &block) matches_without_scope(*args, &block) && (!@scope_expectation || @scope_expectation.scope_matches?) end end end end Spec::Mocks::MessageExpectation.class_eval do include Spec::Mocks::MessageExpectationScopeExtension end -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From pat.maddox at gmail.com Mon Apr 20 18:46:03 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Mon, 20 Apr 2009 15:46:03 -0700 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904202226.15607.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <2c7e61990904201241h9a52702g1aba5a834874345@mail.gmail.com> <200904202226.15607.michael@schuerig.de> Message-ID: <2c7e61990904201546x13028a8eu5880e284c676d2b9@mail.gmail.com> On Mon, Apr 20, 2009 at 1:26 PM, Michael Schuerig wrote: > On Monday 20 April 2009, Pat Maddox wrote: >> In a functional test, create some records that will be in the scope >> and some that will be out of the scope, hit the page and make sure >> you only see the ones that you want. ?I would either do this with >> cucumber, or write a controller spec and verify that only certain >> records show in the the assigns var. ?Either way you're going to have >> to hit the db because obviously the scope affects the db queries. > > Yes, and that feels a bit like cheating. What feels like cheating, and why? Look at the BDD process again. 1. Write failing acceptance test 2. Drill down, write failing unit tests 3. Make unit tests pass. Go to 2 until 4. Acceptance test passes, go to the pub In this case, you would 1. Write failing acceptance test 2. Realize that the code you're writing is not unit testable 3. Unit test other parts of code 4. Acceptance test passes, go to the pub >> This is why you'd typically like to keep that stuff in the model. > > I agree on the typically, but disagree specifically. Agreed, which is why I gave a solution instead of just saying to put it in the model. Pat From matt at mattwynne.net Tue Apr 21 03:21:06 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 21 Apr 2009 08:21:06 +0100 Subject: [rspec-users] How would I spec this? --Rails subscriptions In-Reply-To: <5A95EAE4A3FE1645992FAF868AD6DCDC09C00005@DEN-EXM-06.corp.ebay.com> References: <5A95EAE4A3FE1645992FAF868AD6DCDC09C00005@DEN-EXM-06.corp.ebay.com> Message-ID: On 21 Apr 2009, at 00:34, Colfer, Brian wrote: > > I have a set of users > And a set of things ? podcasts > Users should get a page that shows all of the podcassts with a check > box > If they are subscribed then the check box is checked > > Users table has first_name, last_name, user_name > Podcats table has podcast_name, description, url > Subscriptions table has user_id, podcast_id, subscription_type > > > Would the view go in the subscription views? > > Is this a index view? > > > How do I mock out the view? > > I think I want to spec something so that I set up three mock models > for podcasts: > > > before(:each) do > assigns[:user] = @user = stub_model(User, > :new_record? => false, > :user_id => 1, > :first_name => "Fred", > :last_name => "Flintstone", > :user_name => "fflintstone" > ) > assings[:repository] = @repository = [stub_model(Podcast, > :new_record? => false, > :name => "podcast1", > :host => "podcast.podcast.com", > > ), > stub_model(Podcast, > :new_record? => false, > :name => "podcast2", > :host => "podcast.podcast.com", > ), > stub_model(Podcast, > :new_record? => false, > :name => "podcast3", > :host => "podcast.podcast.com", > ) > ] > assigns[:subscription] = @subscription = > [ stub_model(Subscription, > :new_record? => false, > :user_id => 1, > :podcast_id => 1 > ), > stub_model(Subscription, > :new_record? => false, > :user_id => 1, > :podcast_id => 2 > )] > end > > then look to make sure that it renders all of the podcasts and the > ones that are subscribed subscribed checkbox is selected: > > It "should render the subscriber select form" do > render > > # now what? > > end > > > Thanks > > > Brian Colfer > I am going to go out on a limb... I would suggest, if you have, time, that you do some research on using Cucumber to express these specifications instead. These are precisely the kind of brittle view tests (smelled by the large amounts of mocking set up required) that I built loads of myself 9 months ago when I first started with RSpec (and before I discovered Cucumber) and have spent the last 6 months, once I'd learned better, dismantling again and replacing with much more flexible, readable, Cucumber features. Sorry, I know that's not a direct answer to your question, but you might thank me for it eventually. If you want some help learning Cucumber, try these resources: http://cukes.info/ http://wiki.github.com/aslakhellesoy/cucumber Hope that helps. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Tue Apr 21 03:28:54 2009 From: lists at ruby-forum.com (Newb Newb) Date: Tue, 21 Apr 2009 09:28:54 +0200 Subject: [rspec-users] How to get stacktrace for extending Ruby in C Message-ID: <629d18fddea0e1d0754fb88b3fefd6f2@ruby-forum.com> Hi I extend ruby with C . i get error like segmentation fault when i call my client.rb how can i get the stacktrace ? Pls help me out Thanks -- Posted via http://www.ruby-forum.com/. From michael at schuerig.de Tue Apr 21 04:02:29 2009 From: michael at schuerig.de (Michael Schuerig) Date: Tue, 21 Apr 2009 10:02:29 +0200 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <85d99afe0904201325o3693e281m470ff305bfd21ea6@mail.gmail.com> References: <200904191827.04395.michael@schuerig.de> <200904202127.54838.michael@schuerig.de> <85d99afe0904201325o3693e281m470ff305bfd21ea6@mail.gmail.com> Message-ID: <200904211002.29648.michael@schuerig.de> On Monday 20 April 2009, Zach Dennis wrote: > > I don't agress. Both classes have distinct, although related > > purposes. RequestCondition implements the translation from request > > parameters to #find-options. QueryScope(Builder) fits it in with > > ActionController and adds syntactic sugar. The former is easy to > > spec, for the latter, I've been to lazy to figure out a good way. > > I'm just suggesting that RequestCondition and QueryScopeBuilder are > encapsulated behind RequestToQueryTranslator, so your controller > doesn't have to know about both of them. Your controller doesn't > actually care about request conditioners and query scope builders. It > only cares that it can translate a request to a query so it can be > used to set the scope on the model. That's already the case. Both of these classes are only internally used by module QueryScope, which is the only thing a controller sees: class PeopleController < ApplicationController include QueryScope query_scope :only => :index do # Only allow to filter and order by the # virtual name attribute. # This attribute is mapped onto the real # firstname and lastname attributes. allow :name condition :name => "LOWER(firstname || ' ' || lastname) :op LOWER(?)" order :name => "lastname :dir, firstname :dir" end Michael. -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/ From bcolfer at shopping.com Tue Apr 21 04:50:31 2009 From: bcolfer at shopping.com (Colfer, Brian) Date: Tue, 21 Apr 2009 01:50:31 -0700 Subject: [rspec-users] How would I spec this? --Rails subscriptions In-Reply-To: References: <5A95EAE4A3FE1645992FAF868AD6DCDC09C00005@DEN-EXM-06.corp.ebay.com> Message-ID: <4320391C-ACAA-4F64-B0E1-FB198A7967F1@shopping.com> Thanks Matt I'm fairly comfortable with cucumber and I have the acceptance tests. I'm looking to see if I can follow through on the BDD process. Sent from Brian's iPhone On Apr 21, 2009, at 12:27 AM, "Matt Wynne" wrote: > > On 21 Apr 2009, at 00:34, Colfer, Brian wrote: > >> >> I have a set of users >> And a set of things ? podcasts >> Users should get a page that shows all of the podcassts with a >> check box >> If they are subscribed then the check box is checked >> >> Users table has first_name, last_name, user_name >> Podcats table has podcast_name, description, url >> Subscriptions table has user_id, podcast_id, subscription_type >> >> >> Would the view go in the subscription views? >> >> Is this a index view? >> >> >> How do I mock out the view? >> >> I think I want to spec something so that I set up three mock models >> for podcasts: >> >> >> before(:each) do >> assigns[:user] = @user = stub_model(User, >> :new_record? => false, >> :user_id => 1, >> :first_name => "Fred", >> :last_name => "Flintstone", >> :user_name => "fflintstone" >> ) >> assings[:repository] = @repository = [stub_model(Podcast, >> :new_record? => false, >> :name => "podcast1", >> :host => "podcast.podcast.com", >> >> ), >> stub_model(Podcast, >> :new_record? => false, >> :name => "podcast2", >> :host => "podcast.podcast.com", >> ), >> stub_model(Podcast, >> :new_record? => false, >> :name => "podcast3", >> :host => "podcast.podcast.com", >> ) >> ] >> assigns[:subscription] = @subscription = >> [ stub_model(Subscription, >> :new_record? => false, >> :user_id => 1, >> :podcast_id => 1 >> ), >> stub_model(Subscription, >> :new_record? => false, >> :user_id => 1, >> :podcast_id => 2 >> )] >> end >> >> then look to make sure that it renders all of the podcasts and the >> ones that are subscribed subscribed checkbox is selected: >> >> It "should render the subscriber select form" do >> render >> >> # now what? >> >> end >> >> >> Thanks >> >> >> Brian Colfer >> > > I am going to go out on a limb... > > I would suggest, if you have, time, that you do some research on > using Cucumber to express these specifications instead. These are > precisely the kind of brittle view tests (smelled by the large > amounts of mocking set up required) that I built loads of myself 9 > months ago when I first started with RSpec (and before I discovered > Cucumber) and have spent the last 6 months, once I'd learned better, > dismantling again and replacing with much more flexible, readable, > Cucumber features. > > Sorry, I know that's not a direct answer to your question, but you > might thank me for it eventually. > > If you want some help learning Cucumber, try these resources: > http://cukes.info/ > http://wiki.github.com/aslakhellesoy/cucumber > > Hope that helps. > > 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 zach.dennis at gmail.com Tue Apr 21 08:52:59 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 21 Apr 2009 08:52:59 -0400 Subject: [rspec-users] Controller spec: testing that scope is set In-Reply-To: <200904211002.29648.michael@schuerig.de> References: <200904191827.04395.michael@schuerig.de> <200904202127.54838.michael@schuerig.de> <85d99afe0904201325o3693e281m470ff305bfd21ea6@mail.gmail.com> <200904211002.29648.michael@schuerig.de> Message-ID: <85d99afe0904210552w2b44bb7aoe88624bf5b92eb10@mail.gmail.com> On Tue, Apr 21, 2009 at 4:02 AM, Michael Schuerig wrote: > On Monday 20 April 2009, Zach Dennis wrote: >> > I don't agress. Both classes have distinct, although related >> > purposes. RequestCondition implements the translation from request >> > parameters to #find-options. QueryScope(Builder) fits it in with >> > ActionController and adds syntactic sugar. The former is easy to >> > spec, for the latter, I've been to lazy to figure out a good way. >> >> I'm just suggesting that RequestCondition and QueryScopeBuilder are >> encapsulated behind RequestToQueryTranslator, so your controller >> doesn't have to know about both of them. Your controller doesn't >> actually care about request conditioners and query scope builders. It >> only cares that it can translate a request to a query so it can be >> used to set the scope on the model. > > That's already the case. Both of these classes are only internally used > by module QueryScope, which is the only thing a controller sees: But you're mixing in QueryScope to the controller, it's just like if you put #query_scope inside of the controller itself. Mixins are a way to organize and re-use code, but putting code in modules does not automatically mean you are decoupling parts of your app. Your controller spec will have to take into account whatever dependencies your #query_scope method has unless you completely mock/stub it out, but that seems to work against your goal, > > class PeopleController < ApplicationController > ?include QueryScope > > ?query_scope :only => :index do > ? ?# Only allow to filter and order by the > ? ?# virtual name attribute. > ? ?# This attribute is mapped onto the real > ? ?# firstname and lastname attributes. > ? ?allow ? ? :name > ? ?condition :name => > ? ? ?"LOWER(firstname || ' ' || lastname) :op LOWER(?)" > ? ?order ? ? :name => "lastname :dir, firstname :dir" > ?end > > Michael. > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From scott at railsnewbie.com Tue Apr 21 09:39:53 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 21 Apr 2009 09:39:53 -0400 Subject: [rspec-users] How to get stacktrace for extending Ruby in C In-Reply-To: <629d18fddea0e1d0754fb88b3fefd6f2@ruby-forum.com> References: <629d18fddea0e1d0754fb88b3fefd6f2@ruby-forum.com> Message-ID: <49EDCCA9.3060808@railsnewbie.com> Newb Newb wrote: > Hi > > I extend ruby with C . > > i get error like segmentation fault when i call my client.rb > > how can i get the stacktrace ? > You can use gdb to get a stack trace, as was documented by Mauricio, Jamis, and Why a while back. Not sure what this has to do with rspec, though. Scott > > Pls help me out > > Thanks > From steve at fenestra.com Tue Apr 21 09:45:12 2009 From: steve at fenestra.com (Steve Schafer) Date: Tue, 21 Apr 2009 09:45:12 -0400 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly spe cing In-Reply-To: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> References: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> Message-ID: On Mon, 20 Apr 2009 12:40:08 -0700, you wrote: >I wrote a blog post that may be helpful. >http://www.patmaddox.com/blog/demeter-is-for-encapsulation Basically, >when you have structural objects as in this case, demeter isn't >useful. That's a good example as far as it goes, but I think it makes a distinction that isn't quite the true distinction. For example, I remember dragsters from the '60s that had as many as four engines. What does car.engine.name do in that case? And the car I drive these days has a pair of electric motors in addition to an internal combustion engine... Likewise with the stereo--some minivans and SUVs come with two independent stereo/entertainment systems, one for the front seat passengers and one for the rear. When I invoke car.stereo.has_cd_player, am I asking about the "default" front-seat stereo, or do I only care whether or not the car has a cd player somewhere? The point, of course, is that digging down into the structure of an object, even if structural information is what you're after, requires that you make assumptions about that structure. And _that_ should be the criterion. You have to ask yourself: (a) What implicit assumptions am I making by doing this? (b) Is is safe to make those assumptions? If you can reasonably answer yes to the second question, then you're in good shape. But you still have to accept that future changes to the design can lead to structural changes that retroactively invalidate your answer. -Steve From dchelimsky at gmail.com Tue Apr 21 12:56:36 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 21 Apr 2009 11:56:36 -0500 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> Message-ID: <57c63afe0904210956o203ee0b1n4247645a895e94f1@mail.gmail.com> On Tue, Apr 21, 2009 at 11:39 AM, aslak hellesoy wrote: > Being the author of Cucumber, some of you might be surprised that I ask this > question: > > How should I go about to implement a Cucumber feature and step definition > with the following data? > http://gist.github.com/99220 (just look at the first file for now) You left out: | Vegetarian | N | N | N | > > Imagine I'm opening a restaurant where customers are asked for their > religion. Based on what they answer, they will be presented with a tailored > menu. (Apologies in advance if I'm ignorant about what different people it). > > In Cucumber, there are several ways to put this table in a feature. It can > be part of a table in a Scenario Outline's Examples section > (http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines), or it can > be sent to a Step as a multiline argument > (http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments). > > In either case, I'm not happy about the feature and step definitions I end > up with. The Scenario Outline version has annoying duplication. I have to > duplicate each meat 3 times! This makes it hard to read and edit. The > multiline step argument version isn't much better. If a menu for a religion > is wrong I'll only get one error, the error won't tell me what's wrong > (unless I explicitly craft my error messages in the step definition) and max > one failure will show (there is only one scenario). > > There should be a better way to express this kind of tests. But I'm not sure > how. Is there a smarter way with the current Cucumber? If not, how would you > *like* to express this sort of problem? How about something like this: http://gist.github.com/99235 That doesn't require a new construct and I *think* it solves the problem (obviously I haven't run it). An alternative would be to add a new rule or construct in which the step definition can drive things a bit more. Something like http://gist.github.com/99244 where the fact that the step def accepts 3 block args would let it consume the next three columns in the table. Not sure how crazy that would be - just an idea. WDYT? > > Cheers, > Aslak > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From joe at josephwilk.net Tue Apr 21 13:57:55 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Tue, 21 Apr 2009 18:57:55 +0100 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> Message-ID: <49EE0923.4000803@josephwilk.net> aslak hellesoy wrote: > Being the author of Cucumber, some of you might be surprised that I > ask this question: > > How should I go about to implement a Cucumber feature and step > definition with the following data? > http://gist.github.com/99220 (just look at the first file for now) > > Imagine I'm opening a restaurant where customers are asked for their > religion. Based on what they answer, they will be presented with a > tailored menu. (Apologies in advance if I'm ignorant about what > different people it). > > In Cucumber, there are several ways to put this table in a feature. It > can be part of a table in a Scenario Outline's Examples section > (http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines), or > it can be sent to a Step as a multiline argument > (http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments). > > In either case, I'm not happy about the feature and step definitions I > end up with. The Scenario Outline version has annoying duplication. I > have to duplicate each meat 3 times! This makes it hard to read and > edit. The multiline step argument version isn't much better. If a menu > for a religion is wrong I'll only get one error, the error won't tell > me what's wrong (unless I explicitly craft my error messages in the > step definition) and max one failure will show (there is only one > scenario). > > There should be a better way to express this kind of tests. But I'm > not sure how. Is there a smarter way with the current Cucumber? If > not, how would you *like* to express this sort of problem? I think the second way is a better way of expressing the problem, the output/run strategy is the problem. What you really want is an examples table that is embedded in a step (different from a step table, maybe by keyword?) that causes the step to be run multiple times for each of the values. So rather than using placeholders we embedded a Examples table in the step. Just my inital thoughts. I'll knock together an example and more ideas when I get home... -- Joseph Wilk http://blog.josephwilk.net > > Cheers, > Aslak > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue Apr 21 14:17:03 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 21 Apr 2009 19:17:03 +0100 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> Message-ID: <263CA907-583B-42E0-96B5-9DE8241AC805@mattwynne.net> On 21 Apr 2009, at 17:39, aslak hellesoy wrote: > Being the author of Cucumber, some of you might be surprised that I > ask this question: > > How should I go about to implement a Cucumber feature and step > definition with the following data? > http://gist.github.com/99220 (just look at the first file for now) > > Imagine I'm opening a restaurant where customers are asked for their > religion. Based on what they answer, they will be presented with a > tailored menu. (Apologies in advance if I'm ignorant about what > different people it). > > In Cucumber, there are several ways to put this table in a feature. > It can be part of a table in a Scenario Outline's Examples section (http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines > ), or it can be sent to a Step as a multiline argument (http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments > ). > > In either case, I'm not happy about the feature and step definitions > I end up with. The Scenario Outline version has annoying > duplication. I have to duplicate each meat 3 times! This makes it > hard to read and edit. The multiline step argument version isn't > much better. If a menu for a religion is wrong I'll only get one > error, the error won't tell me what's wrong (unless I explicitly > craft my error messages in the step definition) and max one failure > will show (there is only one scenario). > > There should be a better way to express this kind of tests. But I'm > not sure how. Is there a smarter way with the current Cucumber? If > not, how would you *like* to express this sort of problem? > > Cheers, > Aslak Looking at the forks of your example gist, I think I would have done it exactly the way mabes suggested. I'm not sure if I can think of a better way. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From jonathan at parkerhill.com Tue Apr 21 14:32:01 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 21 Apr 2009 14:32:01 -0400 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <49EE0923.4000803@josephwilk.net> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> <49EE0923.4000803@josephwilk.net> Message-ID: <8754E59E-4F76-4135-A85A-8B961FA7D55F@parkerhill.com> On Apr 21, 2009, at 1:57 PM, Joseph Wilk wrote: > What you really want is an examples table that is embedded in a > step (different from a step table, maybe by keyword?) that causes > the step to be run multiple times for each of the values. So rather > than using placeholders we embedded a Examples table in the step. like this? https://rspec.lighthouseapp.com/projects/16211/tickets/149-step-outline From joe at josephwilk.net Tue Apr 21 16:20:13 2009 From: joe at josephwilk.net (Joseph Wilk) Date: Tue, 21 Apr 2009 21:20:13 +0100 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8754E59E-4F76-4135-A85A-8B961FA7D55F@parkerhill.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> <49EE0923.4000803@josephwilk.net> <8754E59E-4F76-4135-A85A-8B961FA7D55F@parkerhill.com> Message-ID: On Tue, Apr 21, 2009 at 7:32 PM, Jonathan Linowes wrote: > > On Apr 21, 2009, at 1:57 PM, Joseph Wilk wrote: > >> What you really want is an examples table that is embedded in a step >> (different from a step table, maybe by keyword?) that causes the step to be >> run multiple times for each of the values. So rather than using placeholders >> we embedded a Examples table in the step. > > > like this? Not quite, I was thinking of running the whole scenario for the examples step table rather than just the step. However I really like Ben's suggestion of a sub-table (http://gist.github.com/99255). I think it would be conceptually easier for a non-technical user to grasp than my first suggestion which makes it a big win for me. -- Joseph Wilk http://blog.josephwilk.net > https://rspec.lighthouseapp.com/projects/16211/tickets/149-step-outline > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ashley.moran at patchspace.co.uk Tue Apr 21 16:43:39 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 21 Apr 2009 21:43:39 +0100 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: <8CF38A64-B406-4CFA-8045-59599B87A4BD@patchspace.co.uk> On 12 Apr 2009, at 05:19, Phlip wrote: > 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. > > ? > > 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. Hi Phlip Sorry for the late reply epicfail. I've been trying to visualise what you mean here. Can you give me a more concrete example of what you mean by "meatball-alone" vs "spaghetti-laden" design? BTW, as a pretty strict almost-carnivorous grain-avoider, I approve of your analogy =) Cheers Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From matt at mattwynne.net Tue Apr 21 17:17:03 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 21 Apr 2009 22:17:03 +0100 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8d961d900904211413qa4c85d6jf616c9c896b17535@mail.gmail.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> <49EE0923.4000803@josephwilk.net> <8754E59E-4F76-4135-A85A-8B961FA7D55F@parkerhill.com> <8d961d900904211413qa4c85d6jf616c9c896b17535@mail.gmail.com> Message-ID: <947C7434-7734-472A-A3A3-60DB729B0B12@mattwynne.net> On 21 Apr 2009, at 22:13, aslak hellesoy wrote: > > > On Tue, Apr 21, 2009 at 10:20 PM, Joseph Wilk > wrote: > On Tue, Apr 21, 2009 at 7:32 PM, Jonathan Linowes > wrote: > > > > On Apr 21, 2009, at 1:57 PM, Joseph Wilk wrote: > > > >> What you really want is an examples table that is embedded in a > step > >> (different from a step table, maybe by keyword?) that causes the > step to be > >> run multiple times for each of the values. So rather than using > placeholders > >> we embedded a Examples table in the step. > > > > > > like this? > > Not quite, I was thinking of running the whole scenario for the > examples step table rather than just the step. > > However I really like Ben's suggestion of a sub-table > (http://gist.github.com/99255). > > I think it would be conceptually easier for a non-technical user to > grasp than my first suggestion which makes it a big win for me. > > Thanks a lot for all the suggestions so far. I like Ben's subtable > too. > In the example: "I should be presented a menu with " I > assume the step definition would be: > > Then /I should be presented a menu with/ do |meat_hash| > # meat_hash has the following value the 2nd time (Jewish): > {'Pork'=>'N', 'Lamb'=>'Y', 'Veal'=>'Y'} > end > > However, having the as part of the step would be > inconsistent with how the regexp matching is currently working. > > Here is an alternative: http://gist.github.com/99376 > > The idea is that we add a new kind of multiline argument in addition > to pystrings and tables: Hash. This is > done using the familiar <> delimiters as a multiline argument. > What's inside it has no significance other than documentation. > The keys of the hash would be the same as the Examples table header > *minus* the columns that are referred in other steps. > > In essence it achieves the same as Ben's, but relying on a > convention (removing referenced columns) rather than introducing > a new, more complex table markup. > > WDYT? I like. I also like that it's called a 'meat hash'. Sounds tasty :) Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From ben at benmabey.com Tue Apr 21 18:20:23 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 21 Apr 2009 16:20:23 -0600 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8d961d900904211413qa4c85d6jf616c9c896b17535@mail.gmail.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> <49EE0923.4000803@josephwilk.net> <8754E59E-4F76-4135-A85A-8B961FA7D55F@parkerhill.com> <8d961d900904211413qa4c85d6jf616c9c896b17535@mail.gmail.com> Message-ID: <49EE46A7.4080901@benmabey.com> aslak hellesoy wrote: > > > On Tue, Apr 21, 2009 at 10:20 PM, Joseph Wilk > wrote: > > On Tue, Apr 21, 2009 at 7:32 PM, Jonathan Linowes > > wrote: > > > > On Apr 21, 2009, at 1:57 PM, Joseph Wilk wrote: > > > >> What you really want is an examples table that is embedded in a > step > >> (different from a step table, maybe by keyword?) that causes > the step to be > >> run multiple times for each of the values. So rather than using > placeholders > >> we embedded a Examples table in the step. > > > > > > like this? > > Not quite, I was thinking of running the whole scenario for the > examples step table rather than just the step. > > However I really like Ben's suggestion of a sub-table > (http://gist.github.com/99255). > > I think it would be conceptually easier for a non-technical user to > grasp than my first suggestion which makes it a big win for me. > > > Thanks a lot for all the suggestions so far. I like Ben's subtable too. > In the example: "I should be presented a menu with " I > assume the step definition would be: > > Then /I should be presented a menu with/ do |meat_hash| > # meat_hash has the following value the 2nd time (Jewish): > {'Pork'=>'N', 'Lamb'=>'Y', 'Veal'=>'Y'} > end > > However, having the as part of the step would be > inconsistent with how the regexp matching is currently working. > > Here is an alternative: http://gist.github.com/99376 > > The idea is that we add a new kind of multiline argument in addition > to pystrings and tables: Hash. This is > done using the familiar <> delimiters as a multiline argument. What's > inside it has no significance other than documentation. > The keys of the hash would be the same as the Examples table header > *minus* the columns that are referred in other steps. > > In essence it achieves the same as Ben's, but relying on a convention > (removing referenced columns) rather than introducing > a new, more complex table markup. > > WDYT? Interesting.. so your meat_hash was derived from the columns of the table that were not used previously in the scenario? Meaning, that is why Religion was not part of your meat_hash. That makes sense, and.. since the scenario outline is parsed before any of the examples are ran through that convention could be maintained no matter what order the delimiters appear in the scenario. (Just thinking out loud here...) Yeah, I like it. I also agree with Matt about meat_hash. All this meat_hash talk is making me hungry... However, what if people wanted multiple hashes? Subtables would allow for this but a single hash solution would not. FWIW, here is a very contrived exampled: http://gist.github.com/99424 I agree that the sub-table is probably adding too much complexity, especially since we have a simpler alternative and no real use cases for it yet. Basically, you can ignore that last gist, I was just experimenting with contrived use cases. :) -Ben > > Aslak > > > > -- > Joseph Wilk > http://blog.josephwilk.net > > > > https://rspec.lighthouseapp.com/projects/16211/tickets/149-step-outline > > > > _______________________________________________ > > 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 amos.l.king at gmail.com Tue Apr 21 22:58:40 2009 From: amos.l.king at gmail.com (Amos King) Date: Tue, 21 Apr 2009 21:58:40 -0500 Subject: [rspec-users] Why RSpec? Message-ID: I like Shoulda. Sometimes I like plain old Test::Unit. Cucumber gives me a different thought process. I'd just like to hear some thoughts on why RSpec? What does it buy me that I can't get with Shoulda? I just can't seem to think in RSpec. Where is there a good example of RSpec tests that will help me grasp the right path? Thanks! -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From lists at ruby-forum.com Tue Apr 21 23:28:27 2009 From: lists at ruby-forum.com (Newb Newb) Date: Wed, 22 Apr 2009 05:28:27 +0200 Subject: [rspec-users] How to get stacktrace for extending Ruby in C In-Reply-To: <49EDCCA9.3060808@railsnewbie.com> References: <629d18fddea0e1d0754fb88b3fefd6f2@ruby-forum.com> <49EDCCA9.3060808@railsnewbie.com> Message-ID: <736c3ff8402035678aa1ab3b1036e582@ruby-forum.com> Scott Taylor wrote: > Newb Newb wrote: >> Hi >> >> I extend ruby with C . >> >> i get error like segmentation fault when i call my client.rb >> >> how can i get the stacktrace ? >> > > You can use gdb to get a stack trace, as was documented by Mauricio, > Jamis, and Why a while back. > > Not sure what this has to do with rspec, though. > > Scott thanks for the reply.. I m running on windows.. so is it possible to use gdb on windows.. Thanks -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Wed Apr 22 00:41:24 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 21 Apr 2009 22:41:24 -0600 Subject: [rspec-users] How to get stacktrace for extending Ruby in C In-Reply-To: <736c3ff8402035678aa1ab3b1036e582@ruby-forum.com> References: <629d18fddea0e1d0754fb88b3fefd6f2@ruby-forum.com> <49EDCCA9.3060808@railsnewbie.com> <736c3ff8402035678aa1ab3b1036e582@ruby-forum.com> Message-ID: <49EE9FF4.2070704@benmabey.com> Newb Newb wrote: > Scott Taylor wrote: > >> Newb Newb wrote: >> >>> Hi >>> >>> I extend ruby with C . >>> >>> i get error like segmentation fault when i call my client.rb >>> >>> how can i get the stacktrace ? >>> >>> >> You can use gdb to get a stack trace, as was documented by Mauricio, >> Jamis, and Why a while back. >> >> Not sure what this has to do with rspec, though. >> >> Scott >> > > thanks for the reply.. > > I m running on windows.. > > so is it possible to use gdb on windows.. > http://hamsterrepublic.com/ohrrpgce/index.php/GDB_on_Windows.html I'm sorry, but I couldn't resist... http://tinyurl.com/dcz4b9 If I had more direct experience I would offer it. :) -Ben From saturn.sting at gmail.com Tue Apr 21 09:25:31 2009 From: saturn.sting at gmail.com (Saturn) Date: Tue, 21 Apr 2009 06:25:31 -0700 (PDT) Subject: [rspec-users] RSpec and Selenium automation of an application Message-ID: <48bc7b70-01e8-4566-af60-bf0081a3fec5@f1g2000prb.googlegroups.com> Hi All, I am new to rspec and I am using selenium with Rspec1.2.4, I have gone through describe, and it methods etc. I am automating an application which contains many testsuites and test methods. my question is 1. Should i write one describe method corresponding to one testsuite ??? And one it() method corresponding to one testcase???? 2. If Yes, then how would i execute more than one describe methods one by one as same as running testsuites one by one If i want to keep each describe() in separate file. From anthony at within3.com Tue Apr 21 20:43:59 2009 From: anthony at within3.com (Anthony Broad-Crawford) Date: Tue, 21 Apr 2009 20:43:59 -0400 Subject: [rspec-users] Tests for my gem cannot find classes in gems lib directory .. Message-ID: <5C851494-C671-49C6-B539-4BB144BAE6D9@within3.com> I am writing a gem and using RSpec to drive my development. However, whenever I describe a class within the gems lib I get an uninitialized constant error. I am placing my folder structure, spec.rake and first spec below. I feel I must be missing something obvious. Additionally, I did output the value of f in lib inclusion code and it is traversing the lib folder correctly and I can instantiate the class in my rake.spec. Thanks for your time. gem_name + lib +gem_name -foo.rb +spec - foo_spec.rb +tasks - spec.rake my spec rake require 'rubygems' require 'spec' require 'spec/rake/spectask' Dir[File.expand_path("lib/**/*.rb")].each do |f| require f end Spec::Rake::SpecTask.new do |t| t.spec_files = FileList['spec/*_spec.rb'] end and my spec describe Foo do end The error I get ./spec/Foo_spec.rb:1: uninitialized constant Foo (NameError) from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ example_group_runner.rb:15:in `load' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ example_group_runner.rb:15:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ example_group_runner.rb:14:in `each' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ example_group_runner.rb:14:in `load_files' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ options.rb:99:in `run_examples' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ command_line.rb:9:in `run' from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/bin/spec:4 rake aborted! Command /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ ruby -I"/Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib" "/Library/Ruby/ Gems/1.8/gems/rspec-1.2.4/bin/spec" "spec/foo_spec.rb" failed Thanks again! From manderson at drillinginfo.com Mon Apr 20 17:18:43 2009 From: manderson at drillinginfo.com (Mark Anderson) Date: Mon, 20 Apr 2009 16:18:43 -0500 Subject: [rspec-users] Cucumber - step negating another expecting step In-Reply-To: <20090418092648.GC27365@bumblebee.m38c.nl> References: <8277b7f40904160307q5f18c563vab70b80a2e64cb8@mail.gmail.com><8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com><8277b7f40904160606w18fc469ek7a582fcefad144ce@mail.gmail.com><8277b7f40904160903v7bd4e757n6cf9fe2db1f34e6b@mail.gmail.com> <20090418092648.GC27365@bumblebee.m38c.nl> Message-ID: <26893BF15D544D5F9CB86742BC3D4254@drillinginfo.com> > > 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. [snip] > 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". I use the first method for negating steps - when I need it. The advantage is DRY ("Don't Repeat Yourself"). While your method - having two separate step matchers - may be a little easier to comprehend, my worry would be maintainability. If another user (perhaps just future-me) comes along and adds another step matcher between those two without noticing that they negate each other, and then a third user (perhaps future-future-me) comes along and changes one step matcher but not the other, we no longer truly have negation. There is definitely a balancing act. Hopefully future-me is less likely to change one branch of my negating step matcher without mirroring the change in the other half, it is even less likely in some of the one-line solutions that are more difficult to quickly comprehend. If you value comprehension and are confident that you'll remember to update both cases together, then your solution is ideal. If you value idiot-proofing and don't mind slower comprehension, then a one-line solution may be ideal. I worry about everything and therefore take the middle of the road solution. /\/\ark __________ Information from ESET NOD32 Antivirus, version of virus signature database 4022 (20090420) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com From saturn.sting at gmail.com Wed Apr 22 01:58:23 2009 From: saturn.sting at gmail.com (Saturn) Date: Tue, 21 Apr 2009 22:58:23 -0700 (PDT) Subject: [rspec-users] Why RSpec? In-Reply-To: References: Message-ID: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> I am also having same question that i can't find the reason why i should go for RSpec instead of Test/Unit. There is no compelling reason / advantage offered by RSpec except semantics. Is RSpec all about different syntax??????? Thanks in advance for clarifying it??? From matt at mattwynne.net Wed Apr 22 03:44:43 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 22 Apr 2009 08:44:43 +0100 Subject: [rspec-users] Tests for my gem cannot find classes in gems lib directory .. In-Reply-To: <5C851494-C671-49C6-B539-4BB144BAE6D9@within3.com> References: <5C851494-C671-49C6-B539-4BB144BAE6D9@within3.com> Message-ID: <79C761D9-321D-41AA-A784-5DFAFB9DC3F3@mattwynne.net> On 22 Apr 2009, at 01:43, Anthony Broad-Crawford wrote: > I am writing a gem and using RSpec to drive my development. > However, whenever I describe a class within the gems lib I get an > uninitialized constant error. I am placing my folder structure, > spec.rake and first spec below. I feel I must be missing something > obvious. Additionally, I did output the value of f in lib inclusion > code and it is traversing the lib folder correctly and I can > instantiate the class in my rake.spec. Thanks for your time. > > gem_name > + lib > +gem_name > -foo.rb > +spec > - foo_spec.rb > +tasks > - spec.rake > > my spec rake > > require 'rubygems' > require 'spec' > require 'spec/rake/spectask' > > Dir[File.expand_path("lib/**/*.rb")].each do |f| > require f > end > > Spec::Rake::SpecTask.new do |t| > t.spec_files = FileList['spec/*_spec.rb'] > end > > > > and my spec > > describe Foo do > end > > > > The error I get > > ./spec/Foo_spec.rb:1: uninitialized constant Foo (NameError) > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ > example_group_runner.rb:15:in `load' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ > example_group_runner.rb:15:in `load_files' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ > example_group_runner.rb:14:in `each' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ > example_group_runner.rb:14:in `load_files' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ > options.rb:99:in `run_examples' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib/spec/runner/ > command_line.rb:9:in `run' > from /Library/Ruby/Gems/1.8/gems/rspec-1.2.4/bin/spec:4 > rake aborted! > Command /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/ > bin/ruby -I"/Library/Ruby/Gems/1.8/gems/rspec-1.2.4/lib" "/Library/ > Ruby/Gems/1.8/gems/rspec-1.2.4/bin/spec" "spec/foo_spec.rb" failed > > > > > Thanks again! You need to make sure that the foo_spec.rb requires the code in lib. The usual way to do this is to have a file 'spec_helper' in the root of the spec folder which requires the files in lib, then require spec_helper from foo_spec. That means that if you need to require anything else (e.g. mocking libraries) for all your spec files, you can just put it in spec_helper. Take a look at the specs for Cucumber, or practially any project on github that has a 'spec' folder in it's root, for an example. Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From amos.l.king at gmail.com Wed Apr 22 07:25:09 2009 From: amos.l.king at gmail.com (Amos King) Date: Wed, 22 Apr 2009 06:25:09 -0500 Subject: [rspec-users] Why RSpec? In-Reply-To: <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> Message-ID: I wasn't thinking about a gun. I was just wondering if there is some underlying reason that I'm missing. Is there a background structure that I'm not grasping? Is there a huge piece of functionality that I'm missing? Is it faster than Test:Unit or Shoulda? Amos(adkron) On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: > I think it's that RSpec encodes some of the latest BDD into its way of > thinking. > It has a vocabulary that encourages that, so in a way, yes, it's all about > semantics. > Semantics that encourage agile thinking & practice. > Also, it allows you to structure your specs (that become your regression > tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. > But if I understood all the pros & cons of two systems & preferred another, > I'd use that -- there's no gun against anyone's head. ;) > ?? Doug. > > 2009/4/22 Saturn >> >> I am also having same question that i can't find the reason why i >> should go for RSpec instead of Test/Unit. >> There is no compelling reason / advantage offered by RSpec except >> semantics. >> >> >> Is RSpec all about different syntax??????? >> >> Thanks in advance for clarifying it??? >> _______________________________________________ >> 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 > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From dchelimsky at gmail.com Wed Apr 22 09:49:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 08:49:57 -0500 Subject: [rspec-users] With RSpec 1.2.4, autospec runs twice In-Reply-To: References: Message-ID: <57c63afe0904220649h170dc5d9m6991f355e54ae1f4@mail.gmail.com> On Wed, Apr 22, 2009 at 8:29 AM, Charles Grindel wrote: > Hi, > > I created a ticket for this in Lighthouse > (https://rspec.lighthouseapp.com/projects/5645/tickets/797-with-rspec-124-autospec-runs-twice). > However, I wanted to throw this out to the mailing list.? Has anyone else > run into this after the 1.2.4 upgrade?? Previously on 1.2.2, autospec was > running properly.? I suspect that the issue is related to the DRB server > detection, but I have not dug into it too deep. Did you update the scripts with "script/generate rspec" when you upgraded? > > Thanks, > Chuck > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Apr 22 09:51:45 2009 From: lists at ruby-forum.com (Kerstin Geiling) Date: Wed, 22 Apr 2009 15:51:45 +0200 Subject: [rspec-users] But rspec can not be found In-Reply-To: References: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> <80F73DB4-5D7E-4305-AA35-111B8E12B153@experthuman.com> <57c63afe0904172108q75fbec13ne096a245484f54c8@mail.gmail.com> Message-ID: <5c0ff4978321c0cc9d405a9625eb5c03@ruby-forum.com> > 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? Hi, actually I had the same problems Tom had, 3 weeks ago, but thought that it might be somehow my fault that neither vendor/gems nor vendor/plugin worked with rspec-rails 1.2.2 (or now 1.2.4). I solved it now using the old task file from rspec-rails 1.2.0 and it works. I found it really puzzling to get an error message like: ******************************************************************************** * You are trying to run an rspec rake task defined in * .../lib/tasks/rspec.rake, * but rspec can not be found in vendor/gems, vendor/plugins or system gems. ******************************************************************************* because I tried to install rspec-rails and rspec in both ways. Thanks to Tom for making this issue public! @David: I followed the instructions in the beta "The Rspec Book" ebook, where vendor/gems and vendor/plugins are described for using rspec in rails Cheers, Kerstin -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Wed Apr 22 10:03:44 2009 From: phlip2005 at gmail.com (Phlip) Date: Wed, 22 Apr 2009 07:03:44 -0700 Subject: [rspec-users] Why RSpec? In-Reply-To: References: Message-ID: Amos King wrote: > I like Shoulda. Sometimes I like plain old Test::Unit. Cucumber > gives me a different thought process. > > I'd just like to hear some thoughts on why RSpec? What does it buy me > that I can't get with Shoulda? I just can't seem to think in RSpec. > Where is there a good example of RSpec tests that will help me grasp > the right path? RSpec is not DRY with respect to Test::Unit. A bit of "not invented here". RSpec's original incarnation should have been like test-spec. I suspect new syntax built within Test::Unit would have save us from tedious hours of reinventing all the test fixtures (such as the mock @request and @response for Rails). The only design point for the new syntax I can see is this: context 'general' do setup{ general } specify{ something general } specify{ another general thing } context 'specific' do setup{ specific } specify{ test general and specific together } specify{ test specific and general together! } end end The alternative in TestCase was only either a setup() that builds both 'general' and 'specific', when two cases don't need it, or duplicating 'specific' into two test cases, or merging the 'specific' setup into a global 'assemble_specific' method yadda yadda yadda. Nesting the contexts lets them share their setups, so the contexts are much easier to mix and match. -- Phlip http://flea.sourceforge.net/resume.html From dchelimsky at gmail.com Wed Apr 22 10:08:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 09:08:59 -0500 Subject: [rspec-users] Why RSpec? In-Reply-To: References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> Message-ID: <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: > I wasn't thinking about a gun. ?I was just wondering if there is some > underlying reason that I'm missing. ?Is there a background structure > that I'm not grasping? ?Is there a huge piece of functionality that > I'm missing? ?Is it faster than Test:Unit or Shoulda? RSpec is not just about RSpec. It's about BDD. It's about encouraging conversation about testing and looking at it in different ways. It's about illuminating the design, specification, collaboration and documentation aspects of tests, and thinking of them as executable examples of behaviour. You can do this all without RSpec, but RSpec aims to help with innovations like: * strings as example group names * strings as example names * pending examples * nested groups for flexible organization * should[_not] + matchers (inspired by hamcrest - a java library) * one matcher supports both positive and negative expectations * improved failure messages * flexible/readable/customizable output formats * built-in mocking framework * plain text scenarios (now in Cucumber) Specifically with Rails: * component isolation. ZenTest offered separate test cases for models/views/helpers/controllers before RSpec, and RSpec extended the idea by allowing you to run controller examples with no dependency on views and vice versa. Some folks get nervous with that sort of isolation, but, generally, folks coming to Ruby from a background in TDD with Java or .NET are all over it. That's not the full list, but a good overview. You can get some of these things from other frameworks, but they almost all originated in RSpec, which has been and will continue to be a center of innovation in testing in Ruby since its creation in 2005. To be clear, it is certainly not the only center of innovation. Shoulda brought us macros, which are great, and we've made it easier to write your own in RSpec, and now you can use shoulda matchers right in RSpec. Micronaut adds a tagging system that allows you to group examples together in different ways. This is definitely something we'll be adding to RSpec sooner or later. Ryan Davis and Eric Hodel continue to bring us game-changing testing tools like autotest, heckle, flog, and flay. RSpec has been around for nearly 4 years now. It has matured quite a bit, and continues to do so. A twitter poll back in January suggests that the majority of people doing testing in Ruby are using RSpec: http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against all other frameworks and it still gets the majority. Polls are polls, and in a community of over a million Ruby developers, it's hard (for me) to believe in the accuracy of a poll that 680ish ppl voted in. But hey, that's 360-ish ppl who are at least willing to say they use rspec, so at least we know that much :) The point being that with a lot of users comes a lot of mindshare. And as RSpec continues to mature and become easier to contribute to, that mindshare will grow. More and more extension libraries like rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get better and better at supporting them. It won't be long before "rspec OR test/unit" becomes a false choice, and you'll be able to seamlessly use both in a unified suite. This is already largely the case, but it will get better. And let's not forget http://rubyspec.org/ As for which tools to use, you should use the ones that make you happy and make your job and life easier. If there is something that you like about shoulda over rspec, then use shoulda. If prefer kickin' it old school, stick w/ test/unit or minitest. Regardless of the tools you use, I'd recommend that you pay attention to RSpec and its community. There is a lot of action here. I'd also recommend that you read The RSpec Book. While the material in the book is taught through RSpec, and much of the book is very RSpec-specific, there is quite a bit of exploration of the process of BDD that can be applied regardless of toolset. Not to mention introduction to other tools like Cucumber, Webrat and Selenium. Thanks for the thought provoking question. I've been involved with RSpec since shortly after its creation in 2005, and I sometimes lose sight of why I got into it and why I stay with it. This has been a helpful reminder to me, and I hope you find my ramblings helpful to you. Cheers, David > > Amos(adkron) > > On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >> I think it's that RSpec encodes some of the latest BDD into its way of >> thinking. >> It has a vocabulary that encourages that, so in a way, yes, it's all about >> semantics. >> Semantics that encourage agile thinking & practice. >> Also, it allows you to structure your specs (that become your regression >> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >> But if I understood all the pros & cons of two systems & preferred another, >> I'd use that -- there's no gun against anyone's head. ;) >> ?? Doug. >> >> 2009/4/22 Saturn >>> >>> I am also having same question that i can't find the reason why i >>> should go for RSpec instead of Test/Unit. >>> There is no compelling reason / advantage offered by RSpec except >>> semantics. >>> >>> >>> Is RSpec all about different syntax??????? >>> >>> Thanks in advance for clarifying it??? >>> _______________________________________________ >>> 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 >> > > > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From mikejeremiah at gmail.com Wed Apr 22 06:35:58 2009 From: mikejeremiah at gmail.com (mikej) Date: Wed, 22 Apr 2009 03:35:58 -0700 (PDT) Subject: [rspec-users] Select box with Webrat Message-ID: <6d0876c6-5dc1-499f-9fcd-010aacf2c295@k41g2000yqh.googlegroups.com> I have a select box: I would like to select the pollution option from the list using webrat. I've tried: select "Pollution", :from => "temp_aspect[topic_id]" select "Pollution" In both cases I receive the error: The 'Pollution' option was not found Any suggestions much appreciated, Mike From dchelimsky at gmail.com Wed Apr 22 10:25:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 09:25:57 -0500 Subject: [rspec-users] Why RSpec? In-Reply-To: References: Message-ID: <57c63afe0904220725m280c7cf5kfa11c129cec48a01@mail.gmail.com> On Wed, Apr 22, 2009 at 9:03 AM, Phlip wrote: > Amos King wrote: >> >> I like Shoulda. ?Sometimes I like plain old Test::Unit. ?Cucumber >> gives me a different thought process. >> >> I'd just like to hear some thoughts on why RSpec? ?What does it buy me >> that I can't get with Shoulda? ?I just can't seem to think in RSpec. >> Where is there a good example of RSpec tests that will help me grasp >> the right path? > > RSpec is not DRY with respect to Test::Unit. A bit of "not invented here". Agreed. That's partially resolved now and will be more fully resolved in the not-to-distant-future. > RSpec's original incarnation should have been like test-spec. In terms of the runner, yes. > I suspect new > syntax built within Test::Unit would have save us from tedious hours of > reinventing all the test fixtures (such as the mock @request and @response > for Rails). Not sure what you mean here. RSpec interops w/ t/u. You can do that explicitly outside rails, and it's implicit in rails. RSpec's manipulation of test request/response in rails is there to support component isolation, which rails does not. > The only design point for the new syntax I can see is this: > > ? context 'general' do > ? ? setup{ general } > ? ? specify{ something general } > ? ? specify{ another general thing } > ? ? context 'specific' do > ? ? ? setup{ specific } > ? ? ? specify{ test general and specific together } > ? ? ? specify{ test specific and general together! } > ? ? end > ? end > > The alternative in TestCase was only either a setup() that builds both > 'general' > and 'specific', when two cases don't need it, or duplicating 'specific' into > two > test cases, or merging the 'specific' setup into a global > 'assemble_specific' > method yadda yadda yadda. Nesting the contexts lets them share their setups, > so > the contexts are much easier to mix and match. It's not just about syntax and structure. It's also about process. Better failure messages, pending examples, and customizable output are all things that aim to make it easier to develop software. Cheers, David > > -- > ?Phlip > ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From amos.l.king at gmail.com Wed Apr 22 10:28:04 2009 From: amos.l.king at gmail.com (Amos King) Date: Wed, 22 Apr 2009 09:28:04 -0500 Subject: [rspec-users] Why RSpec? In-Reply-To: <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> Message-ID: Thanks, David. I do often read the rspec list because of the discussions that you site. The community maybe enough for me to make the jump. I can't wait to be able to use RSpec and Test::Unit together as a single cohesive framework. I'll keep working my side project with RSpec and see what ideas I can come up with. At work I will continue to use Shoulda, Test::Unit, and Webrat. We'll see what ideas can be ported around. I'll also take a look at the book. I've worked on Webrat::Selenium and grid support a bit so let's see where this can take me. Thanks for the ideas from everyone, and you've all encouraged me to take a deeper look. Amos(adkron) On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: > On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >> I wasn't thinking about a gun. ?I was just wondering if there is some >> underlying reason that I'm missing. ?Is there a background structure >> that I'm not grasping? ?Is there a huge piece of functionality that >> I'm missing? ?Is it faster than Test:Unit or Shoulda? > > RSpec is not just about RSpec. It's about BDD. It's about encouraging > conversation about testing and looking at it in different ways. It's > about illuminating the design, specification, collaboration and > documentation aspects of tests, and thinking of them as executable > examples of behaviour. You can do this all without RSpec, but RSpec > aims to help with innovations like: > > * strings as example group names > * strings as example names > * pending examples > * nested groups for flexible organization > * should[_not] + matchers (inspired by hamcrest - a java library) > ?* one matcher supports both positive and negative expectations > * improved failure messages > * flexible/readable/customizable output formats > * built-in mocking framework > * plain text scenarios (now in Cucumber) > > Specifically with Rails: > > * component isolation. ZenTest offered separate test cases for > models/views/helpers/controllers before RSpec, and RSpec extended the > idea by allowing you to run controller examples with no dependency on > views and vice versa. Some folks get nervous with that sort of > isolation, but, generally, folks coming to Ruby from a background in > TDD with Java or .NET are all over it. > > That's not the full list, but a good overview. You can get some of > these things from other frameworks, but they almost all originated in > RSpec, which has been and will continue to be a center of innovation > in testing in Ruby since its creation in 2005. > > To be clear, it is certainly not the only center of innovation. > Shoulda brought us macros, which are great, and we've made it easier > to write your own in RSpec, and now you can use shoulda matchers right > in RSpec. > > Micronaut adds a tagging system that allows you to group examples > together in different ways. This is definitely something we'll be > adding to RSpec sooner or later. > > Ryan Davis and Eric Hodel continue to bring us game-changing testing > tools like autotest, heckle, flog, and flay. > > RSpec has been around for nearly 4 years now. It has matured quite a > bit, and continues to do so. A twitter poll back in January suggests > that the majority of people doing testing in Ruby are using RSpec: > http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against > all other frameworks and it still gets the majority. Polls are polls, > and in a community of over a million Ruby developers, it's hard (for > me) to believe in the accuracy of a poll that 680ish ppl voted in. But > hey, that's 360-ish ppl who are at least willing to say they use > rspec, so at least we know that much :) > > The point being that with a lot of users comes a lot of mindshare. And > as RSpec continues to mature and become easier to contribute to, that > mindshare will grow. More and more extension libraries like > rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get > better and better at supporting them. It won't be long before "rspec > OR test/unit" becomes a false choice, and you'll be able to seamlessly > use both in a unified suite. This is already largely the case, but it > will get better. > > And let's not forget http://rubyspec.org/ > > As for which tools to use, you should use the ones that make you happy > and make your job and life easier. If there is something that you like > about shoulda over rspec, then use shoulda. If prefer kickin' it old > school, stick w/ test/unit or minitest. Regardless of the tools you > use, I'd recommend that you pay attention to RSpec and its community. > There is a lot of action here. > > I'd also recommend that you read The RSpec Book. While the material in > the book is taught through RSpec, and much of the book is very > RSpec-specific, there is quite a bit of exploration of the process of > BDD that can be applied regardless of toolset. Not to mention > introduction to other tools like Cucumber, Webrat and Selenium. > > Thanks for the thought provoking question. I've been involved with > RSpec since shortly after its creation in 2005, and I sometimes lose > sight of why I got into it and why I stay with it. This has been a > helpful reminder to me, and I hope you find my ramblings helpful to > you. > > Cheers, > David > >> >> Amos(adkron) >> >> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>> I think it's that RSpec encodes some of the latest BDD into its way of >>> thinking. >>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>> semantics. >>> Semantics that encourage agile thinking & practice. >>> Also, it allows you to structure your specs (that become your regression >>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>> But if I understood all the pros & cons of two systems & preferred another, >>> I'd use that -- there's no gun against anyone's head. ;) >>> ?? Doug. >>> >>> 2009/4/22 Saturn >>>> >>>> I am also having same question that i can't find the reason why i >>>> should go for RSpec instead of Test/Unit. >>>> There is no compelling reason / advantage offered by RSpec except >>>> semantics. >>>> >>>> >>>> Is RSpec all about different syntax??????? >>>> >>>> Thanks in advance for clarifying it??? >>>> _______________________________________________ >>>> 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 >>> >> >> >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.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 > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From lists at ruby-forum.com Wed Apr 22 10:52:37 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 16:52:37 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway Message-ID: This is the step definition: When /the xml document should have the Bank of Canada title/ do expected = 'Bank of Canada: Noon Foreign Exchange Rates' fx_doc = ForexCASource.new(@xchg_source) puts fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title') fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').should contain(expected) end When I exercise the feature I see this: When the currency exchange retrieval script runs # features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:9 Bank of Canada: Noon Foreign Exchange Rates <= from puts Then the xml document should have the Bank of Canada title # features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:13 expected the following element's content to include "Bank of Canada: Noon Foreign Exchange Rates": Bank of Canada: Noon Foreign Exchange Rates (Spec::Expectations::ExpectationNotMetError) ./features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:17:in `/the xml document should have the Bank of Canada title/' features/app/models/currency_exchange_rates/currency_exchange_rates.feature:10:in `Then the xml document should have the Bank of Canada title' 1 scenario 1 failed step 2 passed steps Now, other than the double quotes surrounding the comparison string in the failure message there is no difference between what I expected and what was returned. Nonetheless the specification failed? What am I doing wrong? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Apr 22 11:02:00 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 17:02:00 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: References: Message-ID: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> When I change the test to: expected = 'Bank of Canada: Noon Foreign Exchange Rates' fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').should =~ expected Then I see this instead: expected: "Bank of Canada: Noon Foreign Exchange Rates", got: Bank of Canada: Noon Foreign Exchange Rates (using =~) What is adding the double quotes? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Apr 22 11:12:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 10:12:05 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> Message-ID: <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> On Wed, Apr 22, 2009 at 10:02 AM, James Byrne wrote: > > When I change the test to: > > ?expected = 'Bank of Canada: Noon Foreign Exchange > Rates' > ?fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').should =~ expected > > Then I see this instead: > > ?expected: "Bank of Canada: Noon Foreign Exchange > Rates", > ? ? ? got: Bank of Canada: Noon Foreign Exchange Rates > (using =~) > > What is adding the double quotes? Ruby. Try this in irb: 'this' => "this" > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From walketim at gmail.com Wed Apr 22 11:27:41 2009 From: walketim at gmail.com (Tim Walker) Date: Wed, 22 Apr 2009 09:27:41 -0600 Subject: [rspec-users] [Cucumber] Textmate support for Background Message-ID: <1ebf5a4d0904220827w3d0c4f32vf54f85865abe2f27@mail.gmail.com> Howdy, Want to use the Background feature support and was curious if text mate support for it was coming or I could get a pointer on how to do text highlighting for "Background" was able to edit it as a Snippet but not sure how to make the syntax highlighting work. Many thanks, Tim From lists at ruby-forum.com Wed Apr 22 12:08:00 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 18:08:00 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> Message-ID: David Chelimsky wrote: > Ruby. Try this in irb: > > 'this' > => "this" This passes: assert_equal (expected, fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s, "#{expected} not found") This does not: fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ contain(expected) Or this: fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ equal(expected) gives this lovely, and illogical error: expected "Bank of Canada: Noon Foreign Exchange Rates" got "Bank of Canada: Noon Foreign Exchange Rates" (compared using equal?) (Spec::Expectations::ExpectationNotMetError) Do not even start on how equal? in Ruby is defined completely at odds with common usage. I am just pointing out that this type of thing definitely violates the principal of least surprise. So, test unit it is. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Apr 22 12:21:51 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 11:21:51 -0500 Subject: [rspec-users] With RSpec 1.2.4, autospec runs twice In-Reply-To: References: <57c63afe0904220649h170dc5d9m6991f355e54ae1f4@mail.gmail.com> Message-ID: <57c63afe0904220921v7dd2aa20l136729f0c04cc9a3@mail.gmail.com> On Wed, Apr 22, 2009 at 11:12 AM, Charles Grindel wrote: > I did.? BTW, I ended up digging into the issue and posted a patch for the > issue in the bug listed below.? In short, DrbCommandLine.run is returning > nil even if the running against Drb server succeeds.? This causes the logic > in Spec::Runner::OptionParser.parse_drb to return false which in turn causes > the specs to be run locally. Cool - thanks for the patch! > > Thanks, > Chuck > > On Wed, Apr 22, 2009 at 9:49 AM, David Chelimsky > wrote: >> >> On Wed, Apr 22, 2009 at 8:29 AM, Charles Grindel >> wrote: >> > Hi, >> > >> > I created a ticket for this in Lighthouse >> > >> > (https://rspec.lighthouseapp.com/projects/5645/tickets/797-with-rspec-124-autospec-runs-twice). >> > However, I wanted to throw this out to the mailing list.? Has anyone >> > else >> > run into this after the 1.2.4 upgrade?? Previously on 1.2.2, autospec >> > was >> > running properly.? I suspect that the issue is related to the DRB server >> > detection, but I have not dug into it too deep. >> >> Did you update the scripts with "script/generate rspec" when you upgraded? >> >> > >> > Thanks, >> > Chuck >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From brian.takita at gmail.com Wed Apr 22 12:34:09 2009 From: brian.takita at gmail.com (Brian Takita) Date: Wed, 22 Apr 2009 09:34:09 -0700 Subject: [rspec-users] Why RSpec? In-Reply-To: References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> Message-ID: <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> On Wed, Apr 22, 2009 at 7:28 AM, Amos King wrote: > Thanks, David. > > I do often read the rspec list because of the discussions that you > site. ?The community maybe enough for me to make the jump. ?I can't > wait to be able to use RSpec and Test::Unit together as a single > cohesive framework. ?I'll keep working my side project with RSpec and > see what ideas I can come up with. ?At work I will continue to use > Shoulda, Test::Unit, and Webrat. ?We'll see what ideas can be ported > around. ?I'll also take a look at the book. You can run test/unit & rspec together already. All you need to do is: require "spec/interop/test" before your spec definitions. Here is an example: http://gist.github.com/99895 The shoulda integration did not work, however > > I've worked on Webrat::Selenium and grid support a bit so let's see > where this can take me. ?Thanks for the ideas from everyone, and > you've all encouraged me to take a deeper look. > > Amos(adkron) > > On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: >> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >>> I wasn't thinking about a gun. ?I was just wondering if there is some >>> underlying reason that I'm missing. ?Is there a background structure >>> that I'm not grasping? ?Is there a huge piece of functionality that >>> I'm missing? ?Is it faster than Test:Unit or Shoulda? >> >> RSpec is not just about RSpec. It's about BDD. It's about encouraging >> conversation about testing and looking at it in different ways. It's >> about illuminating the design, specification, collaboration and >> documentation aspects of tests, and thinking of them as executable >> examples of behaviour. You can do this all without RSpec, but RSpec >> aims to help with innovations like: >> >> * strings as example group names >> * strings as example names >> * pending examples >> * nested groups for flexible organization >> * should[_not] + matchers (inspired by hamcrest - a java library) >> ?* one matcher supports both positive and negative expectations >> * improved failure messages >> * flexible/readable/customizable output formats >> * built-in mocking framework >> * plain text scenarios (now in Cucumber) >> >> Specifically with Rails: >> >> * component isolation. ZenTest offered separate test cases for >> models/views/helpers/controllers before RSpec, and RSpec extended the >> idea by allowing you to run controller examples with no dependency on >> views and vice versa. Some folks get nervous with that sort of >> isolation, but, generally, folks coming to Ruby from a background in >> TDD with Java or .NET are all over it. >> >> That's not the full list, but a good overview. You can get some of >> these things from other frameworks, but they almost all originated in >> RSpec, which has been and will continue to be a center of innovation >> in testing in Ruby since its creation in 2005. >> >> To be clear, it is certainly not the only center of innovation. >> Shoulda brought us macros, which are great, and we've made it easier >> to write your own in RSpec, and now you can use shoulda matchers right >> in RSpec. >> >> Micronaut adds a tagging system that allows you to group examples >> together in different ways. This is definitely something we'll be >> adding to RSpec sooner or later. >> >> Ryan Davis and Eric Hodel continue to bring us game-changing testing >> tools like autotest, heckle, flog, and flay. >> >> RSpec has been around for nearly 4 years now. It has matured quite a >> bit, and continues to do so. A twitter poll back in January suggests >> that the majority of people doing testing in Ruby are using RSpec: >> http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against >> all other frameworks and it still gets the majority. Polls are polls, >> and in a community of over a million Ruby developers, it's hard (for >> me) to believe in the accuracy of a poll that 680ish ppl voted in. But >> hey, that's 360-ish ppl who are at least willing to say they use >> rspec, so at least we know that much :) >> >> The point being that with a lot of users comes a lot of mindshare. And >> as RSpec continues to mature and become easier to contribute to, that >> mindshare will grow. More and more extension libraries like >> rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get >> better and better at supporting them. It won't be long before "rspec >> OR test/unit" becomes a false choice, and you'll be able to seamlessly >> use both in a unified suite. This is already largely the case, but it >> will get better. >> >> And let's not forget http://rubyspec.org/ >> >> As for which tools to use, you should use the ones that make you happy >> and make your job and life easier. If there is something that you like >> about shoulda over rspec, then use shoulda. If prefer kickin' it old >> school, stick w/ test/unit or minitest. Regardless of the tools you >> use, I'd recommend that you pay attention to RSpec and its community. >> There is a lot of action here. >> >> I'd also recommend that you read The RSpec Book. While the material in >> the book is taught through RSpec, and much of the book is very >> RSpec-specific, there is quite a bit of exploration of the process of >> BDD that can be applied regardless of toolset. Not to mention >> introduction to other tools like Cucumber, Webrat and Selenium. >> >> Thanks for the thought provoking question. I've been involved with >> RSpec since shortly after its creation in 2005, and I sometimes lose >> sight of why I got into it and why I stay with it. This has been a >> helpful reminder to me, and I hope you find my ramblings helpful to >> you. >> >> Cheers, >> David >> >>> >>> Amos(adkron) >>> >>> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>>> I think it's that RSpec encodes some of the latest BDD into its way of >>>> thinking. >>>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>>> semantics. >>>> Semantics that encourage agile thinking & practice. >>>> Also, it allows you to structure your specs (that become your regression >>>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>>> But if I understood all the pros & cons of two systems & preferred another, >>>> I'd use that -- there's no gun against anyone's head. ;) >>>> ?? Doug. >>>> >>>> 2009/4/22 Saturn >>>>> >>>>> I am also having same question that i can't find the reason why i >>>>> should go for RSpec instead of Test/Unit. >>>>> There is no compelling reason / advantage offered by RSpec except >>>>> semantics. >>>>> >>>>> >>>>> Is RSpec all about different syntax??????? >>>>> >>>>> Thanks in advance for clarifying it??? >>>>> _______________________________________________ >>>>> 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 >>>> >>> >>> >>> >>> -- >>> Amos King >>> http://dirtyInformation.com >>> http://github.com/Adkron >>> -- >>> Looking for something to do? Visit http://ImThere.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 >> > > > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From brian.takita at gmail.com Wed Apr 22 12:35:43 2009 From: brian.takita at gmail.com (Brian Takita) Date: Wed, 22 Apr 2009 09:35:43 -0700 Subject: [rspec-users] Why RSpec? In-Reply-To: <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> Message-ID: <1d7ddd110904220935s78c74484j783ac6fcfe474395@mail.gmail.com> On Wed, Apr 22, 2009 at 9:34 AM, Brian Takita wrote: > On Wed, Apr 22, 2009 at 7:28 AM, Amos King wrote: >> Thanks, David. >> >> I do often read the rspec list because of the discussions that you >> site. ?The community maybe enough for me to make the jump. ?I can't >> wait to be able to use RSpec and Test::Unit together as a single >> cohesive framework. ?I'll keep working my side project with RSpec and >> see what ideas I can come up with. ?At work I will continue to use >> Shoulda, Test::Unit, and Webrat. ?We'll see what ideas can be ported >> around. ?I'll also take a look at the book. > You can run test/unit & rspec together already. > > All you need to do is: > require "spec/interop/test" > before your spec definitions. > > Here is an example: > http://gist.github.com/99895 > > The shoulda integration did not work, however What do you think of having ExampleGroup.should create an Example? >> >> I've worked on Webrat::Selenium and grid support a bit so let's see >> where this can take me. ?Thanks for the ideas from everyone, and >> you've all encouraged me to take a deeper look. >> >> Amos(adkron) >> >> On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: >>> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >>>> I wasn't thinking about a gun. ?I was just wondering if there is some >>>> underlying reason that I'm missing. ?Is there a background structure >>>> that I'm not grasping? ?Is there a huge piece of functionality that >>>> I'm missing? ?Is it faster than Test:Unit or Shoulda? >>> >>> RSpec is not just about RSpec. It's about BDD. It's about encouraging >>> conversation about testing and looking at it in different ways. It's >>> about illuminating the design, specification, collaboration and >>> documentation aspects of tests, and thinking of them as executable >>> examples of behaviour. You can do this all without RSpec, but RSpec >>> aims to help with innovations like: >>> >>> * strings as example group names >>> * strings as example names >>> * pending examples >>> * nested groups for flexible organization >>> * should[_not] + matchers (inspired by hamcrest - a java library) >>> ?* one matcher supports both positive and negative expectations >>> * improved failure messages >>> * flexible/readable/customizable output formats >>> * built-in mocking framework >>> * plain text scenarios (now in Cucumber) >>> >>> Specifically with Rails: >>> >>> * component isolation. ZenTest offered separate test cases for >>> models/views/helpers/controllers before RSpec, and RSpec extended the >>> idea by allowing you to run controller examples with no dependency on >>> views and vice versa. Some folks get nervous with that sort of >>> isolation, but, generally, folks coming to Ruby from a background in >>> TDD with Java or .NET are all over it. >>> >>> That's not the full list, but a good overview. You can get some of >>> these things from other frameworks, but they almost all originated in >>> RSpec, which has been and will continue to be a center of innovation >>> in testing in Ruby since its creation in 2005. >>> >>> To be clear, it is certainly not the only center of innovation. >>> Shoulda brought us macros, which are great, and we've made it easier >>> to write your own in RSpec, and now you can use shoulda matchers right >>> in RSpec. >>> >>> Micronaut adds a tagging system that allows you to group examples >>> together in different ways. This is definitely something we'll be >>> adding to RSpec sooner or later. >>> >>> Ryan Davis and Eric Hodel continue to bring us game-changing testing >>> tools like autotest, heckle, flog, and flay. >>> >>> RSpec has been around for nearly 4 years now. It has matured quite a >>> bit, and continues to do so. A twitter poll back in January suggests >>> that the majority of people doing testing in Ruby are using RSpec: >>> http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against >>> all other frameworks and it still gets the majority. Polls are polls, >>> and in a community of over a million Ruby developers, it's hard (for >>> me) to believe in the accuracy of a poll that 680ish ppl voted in. But >>> hey, that's 360-ish ppl who are at least willing to say they use >>> rspec, so at least we know that much :) >>> >>> The point being that with a lot of users comes a lot of mindshare. And >>> as RSpec continues to mature and become easier to contribute to, that >>> mindshare will grow. More and more extension libraries like >>> rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get >>> better and better at supporting them. It won't be long before "rspec >>> OR test/unit" becomes a false choice, and you'll be able to seamlessly >>> use both in a unified suite. This is already largely the case, but it >>> will get better. >>> >>> And let's not forget http://rubyspec.org/ >>> >>> As for which tools to use, you should use the ones that make you happy >>> and make your job and life easier. If there is something that you like >>> about shoulda over rspec, then use shoulda. If prefer kickin' it old >>> school, stick w/ test/unit or minitest. Regardless of the tools you >>> use, I'd recommend that you pay attention to RSpec and its community. >>> There is a lot of action here. >>> >>> I'd also recommend that you read The RSpec Book. While the material in >>> the book is taught through RSpec, and much of the book is very >>> RSpec-specific, there is quite a bit of exploration of the process of >>> BDD that can be applied regardless of toolset. Not to mention >>> introduction to other tools like Cucumber, Webrat and Selenium. >>> >>> Thanks for the thought provoking question. I've been involved with >>> RSpec since shortly after its creation in 2005, and I sometimes lose >>> sight of why I got into it and why I stay with it. This has been a >>> helpful reminder to me, and I hope you find my ramblings helpful to >>> you. >>> >>> Cheers, >>> David >>> >>>> >>>> Amos(adkron) >>>> >>>> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>>>> I think it's that RSpec encodes some of the latest BDD into its way of >>>>> thinking. >>>>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>>>> semantics. >>>>> Semantics that encourage agile thinking & practice. >>>>> Also, it allows you to structure your specs (that become your regression >>>>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>>>> But if I understood all the pros & cons of two systems & preferred another, >>>>> I'd use that -- there's no gun against anyone's head. ;) >>>>> ?? Doug. >>>>> >>>>> 2009/4/22 Saturn >>>>>> >>>>>> I am also having same question that i can't find the reason why i >>>>>> should go for RSpec instead of Test/Unit. >>>>>> There is no compelling reason / advantage offered by RSpec except >>>>>> semantics. >>>>>> >>>>>> >>>>>> Is RSpec all about different syntax??????? >>>>>> >>>>>> Thanks in advance for clarifying it??? >>>>>> _______________________________________________ >>>>>> 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 >>>>> >>>> >>>> >>>> >>>> -- >>>> Amos King >>>> http://dirtyInformation.com >>>> http://github.com/Adkron >>>> -- >>>> Looking for something to do? Visit http://ImThere.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 >>> >> >> >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.com >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > From afolgueras at gmail.com Wed Apr 22 12:27:19 2009 From: afolgueras at gmail.com (Alex) Date: Wed, 22 Apr 2009 09:27:19 -0700 (PDT) Subject: [rspec-users] Problems withe the template... Message-ID: Hello everybody ! I have in a view something like this : <% unless (method_name?(id)) then %> <%= link_to h(t(:BTN)), new_url_path(id) %> <% else %> <%= link_to_function h(t(:BTN)), 'return false;' %> <% end %> all of this works well ... and in my spec I try to do this to go in the else part : @controller.template.stub!(:get_courtier_expire?).and_return (false) I tried a lot of combinations like ... @template.stub!( template.stub!( @controller.template.should_receive( template.should_receive( and it does'nt work ... it always goes in the if not in the else part ... any suggestions ? From dchelimsky at gmail.com Wed Apr 22 12:44:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 11:44:53 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> Message-ID: <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> On Wed, Apr 22, 2009 at 11:08 AM, James Byrne wrote: > David Chelimsky wrote: > >> Ruby. Try this in irb: >> >> 'this' >> => "this" > > This passes: > > ?assert_equal (expected, > ? ? ? ? ? ? ? ?fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s, > ? ? ? ? ? ? ? ?"#{expected} not found") > > This does not: > > ?fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ > ? ? ? ? ? ? ? ?contain(expected) > > Or this: > > ?fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ > ? ? ? ? ? ? ? ?equal(expected) > > gives this lovely, and illogical error: > > ? ? ?expected "Bank of Canada: Noon Foreign Exchange > Rates" > ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange > Rates" > > ? ? ?(compared using equal?) > ? ? ? (Spec::Expectations::ExpectationNotMetError) > > Do not even start on how equal? in Ruby is defined completely at odds > with common usage. I am just pointing out that this type of thing > definitely violates the principal of least surprise. Yeah - this is one of those decisions I made early on that I wish I could take back, but doing so would break a lot of people's specs. Maybe we should look into changing in it in rspec-2. The original rspec had should_equal (equivalence) and should_be (object identity). In the mean time, I'm not sure what better message we can give beyond "compared using .equal?" without getting into a long treatise on equality in Ruby, which seems out of place in a failure message. > So, test unit it is. The original issue you posted is with the contain matcher, which is in webrat, not rspec. Why it's not working, I'm not quite sure, but if you're going to throw out the baby with the bath water, you might consider figuring out who the parents are :) Looking at the webrat code for the contain matcher, it uses Nokogiri under the hood. Not sure what's happening there, but you might try have_tag instead: should have_tag("title", "Bank of Canada: Noon Foreign Exchange Rates") Let me know if it works. Cheers, David From dchelimsky at gmail.com Wed Apr 22 12:50:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 11:50:48 -0500 Subject: [rspec-users] Why RSpec? In-Reply-To: <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> Message-ID: <57c63afe0904220950r2a9d200ana6e75d8bd90598dd@mail.gmail.com> On Wed, Apr 22, 2009 at 11:34 AM, Brian Takita wrote: > On Wed, Apr 22, 2009 at 7:28 AM, Amos King wrote: >> Thanks, David. >> >> I do often read the rspec list because of the discussions that you >> site. ?The community maybe enough for me to make the jump. ?I can't >> wait to be able to use RSpec and Test::Unit together as a single >> cohesive framework. ?I'll keep working my side project with RSpec and >> see what ideas I can come up with. ?At work I will continue to use >> Shoulda, Test::Unit, and Webrat. ?We'll see what ideas can be ported >> around. ?I'll also take a look at the book. > You can run test/unit & rspec together already. > > All you need to do is: > require "spec/interop/test" With rspec 1.2.2 you can require "spec/test/unit'. > before your spec definitions. > > Here is an example: > http://gist.github.com/99895 > > The shoulda integration did not work, however I haven't looked, but I'll bet rspec and shoulda are doing some of the same monkey patching of test/unit. You can use shoulda matchers in rspec without the rest of shoulda's infrastructure if you want to. That gives you rspec structure + terse expressions like this: describe Person do it { should require_attributes(:email) } end If you prefer to use shoulda for structure, I *think* you can incorporate rspec's matchers in shoulda like this: require 'shoulda' require 'spec/expectations' class Test::Unit::TestCase include Spec::Matchers end Haven't tried it, but I don't see why it wouldn't work. >> >> I've worked on Webrat::Selenium and grid support a bit so let's see >> where this can take me. ?Thanks for the ideas from everyone, and >> you've all encouraged me to take a deeper look. >> >> Amos(adkron) >> >> On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: >>> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >>>> I wasn't thinking about a gun. ?I was just wondering if there is some >>>> underlying reason that I'm missing. ?Is there a background structure >>>> that I'm not grasping? ?Is there a huge piece of functionality that >>>> I'm missing? ?Is it faster than Test:Unit or Shoulda? >>> >>> RSpec is not just about RSpec. It's about BDD. It's about encouraging >>> conversation about testing and looking at it in different ways. It's >>> about illuminating the design, specification, collaboration and >>> documentation aspects of tests, and thinking of them as executable >>> examples of behaviour. You can do this all without RSpec, but RSpec >>> aims to help with innovations like: >>> >>> * strings as example group names >>> * strings as example names >>> * pending examples >>> * nested groups for flexible organization >>> * should[_not] + matchers (inspired by hamcrest - a java library) >>> ?* one matcher supports both positive and negative expectations >>> * improved failure messages >>> * flexible/readable/customizable output formats >>> * built-in mocking framework >>> * plain text scenarios (now in Cucumber) >>> >>> Specifically with Rails: >>> >>> * component isolation. ZenTest offered separate test cases for >>> models/views/helpers/controllers before RSpec, and RSpec extended the >>> idea by allowing you to run controller examples with no dependency on >>> views and vice versa. Some folks get nervous with that sort of >>> isolation, but, generally, folks coming to Ruby from a background in >>> TDD with Java or .NET are all over it. >>> >>> That's not the full list, but a good overview. You can get some of >>> these things from other frameworks, but they almost all originated in >>> RSpec, which has been and will continue to be a center of innovation >>> in testing in Ruby since its creation in 2005. >>> >>> To be clear, it is certainly not the only center of innovation. >>> Shoulda brought us macros, which are great, and we've made it easier >>> to write your own in RSpec, and now you can use shoulda matchers right >>> in RSpec. >>> >>> Micronaut adds a tagging system that allows you to group examples >>> together in different ways. This is definitely something we'll be >>> adding to RSpec sooner or later. >>> >>> Ryan Davis and Eric Hodel continue to bring us game-changing testing >>> tools like autotest, heckle, flog, and flay. >>> >>> RSpec has been around for nearly 4 years now. It has matured quite a >>> bit, and continues to do so. A twitter poll back in January suggests >>> that the majority of people doing testing in Ruby are using RSpec: >>> http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against >>> all other frameworks and it still gets the majority. Polls are polls, >>> and in a community of over a million Ruby developers, it's hard (for >>> me) to believe in the accuracy of a poll that 680ish ppl voted in. But >>> hey, that's 360-ish ppl who are at least willing to say they use >>> rspec, so at least we know that much :) >>> >>> The point being that with a lot of users comes a lot of mindshare. And >>> as RSpec continues to mature and become easier to contribute to, that >>> mindshare will grow. More and more extension libraries like >>> rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get >>> better and better at supporting them. It won't be long before "rspec >>> OR test/unit" becomes a false choice, and you'll be able to seamlessly >>> use both in a unified suite. This is already largely the case, but it >>> will get better. >>> >>> And let's not forget http://rubyspec.org/ >>> >>> As for which tools to use, you should use the ones that make you happy >>> and make your job and life easier. If there is something that you like >>> about shoulda over rspec, then use shoulda. If prefer kickin' it old >>> school, stick w/ test/unit or minitest. Regardless of the tools you >>> use, I'd recommend that you pay attention to RSpec and its community. >>> There is a lot of action here. >>> >>> I'd also recommend that you read The RSpec Book. While the material in >>> the book is taught through RSpec, and much of the book is very >>> RSpec-specific, there is quite a bit of exploration of the process of >>> BDD that can be applied regardless of toolset. Not to mention >>> introduction to other tools like Cucumber, Webrat and Selenium. >>> >>> Thanks for the thought provoking question. I've been involved with >>> RSpec since shortly after its creation in 2005, and I sometimes lose >>> sight of why I got into it and why I stay with it. This has been a >>> helpful reminder to me, and I hope you find my ramblings helpful to >>> you. >>> >>> Cheers, >>> David >>> >>>> >>>> Amos(adkron) >>>> >>>> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>>>> I think it's that RSpec encodes some of the latest BDD into its way of >>>>> thinking. >>>>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>>>> semantics. >>>>> Semantics that encourage agile thinking & practice. >>>>> Also, it allows you to structure your specs (that become your regression >>>>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>>>> But if I understood all the pros & cons of two systems & preferred another, >>>>> I'd use that -- there's no gun against anyone's head. ;) >>>>> ?? Doug. >>>>> >>>>> 2009/4/22 Saturn >>>>>> >>>>>> I am also having same question that i can't find the reason why i >>>>>> should go for RSpec instead of Test/Unit. >>>>>> There is no compelling reason / advantage offered by RSpec except >>>>>> semantics. >>>>>> >>>>>> >>>>>> Is RSpec all about different syntax??????? >>>>>> >>>>>> Thanks in advance for clarifying it??? >>>>>> _______________________________________________ >>>>>> 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 >>>>> >>>> >>>> >>>> >>>> -- >>>> Amos King >>>> http://dirtyInformation.com >>>> http://github.com/Adkron >>>> -- >>>> Looking for something to do? Visit http://ImThere.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 >>> >> >> >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.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 andrew at avit.ca Wed Apr 22 12:52:24 2009 From: andrew at avit.ca (Andrew Vit) Date: Wed, 22 Apr 2009 09:52:24 -0700 Subject: [rspec-users] Why RSpec? In-Reply-To: References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> Message-ID: <21C05969-F5FC-4F22-BC95-B8847BCE07FE@avit.ca> On Apr 22, 2009, at 4:25 AM, Amos King wrote: > I wasn't thinking about a gun. I was just wondering if there is some > underlying reason that I'm missing. Is there a background structure > that I'm not grasping? Is there a huge piece of functionality that > I'm missing? Is it faster than Test:Unit or Shoulda? > > Amos(adkron) Personally, I can't think of one single huge piece of functionality that makes RSpec win over TestUnit, but it's a whole bunch of little things. It can be faster if you make use of mocks/stubs, and separation between layers: you can test your controllers without having to render the views. Shoulda is good too. It adds some of the features that RSpec brought, like contexts, but having used Shoulda for over a year and recently using RSpec on a new project, I can say that I prefer RSpec overall... keep in mind Shoulda's macros and matchers are available in RSpec too. describe RSpec, "versus TestUnit" do it { should read_fluently } end Yes, a lot of the most visible differences seem to be around the syntax, but the point is that it helps you think more fluidly about what you're actually trying to do. TestUnit adds mental baggage for up- front testing and the tests have a backward-looking feel, in other words, they read more like they're verifying what should have happened after it's done. RSpec tests read more expressively as looking forward to what you would like to achieve, what "should" happen. While the tests are still pure ruby, they read almost like pure English, especially if you take a little extra effort to encapsulate some of the hairy logic into your own custom matchers. The specs can convey their intent much more clearly, instead of only serving as verification of your app's performance. Your spec suite becomes very readable (to a developer at least) as behaviour documentation, without needing to slow down to work it out too much. That's not to say you can't write readable tests in Shoulda or TestUnit, but RSpec helps you frame them better and convey what you mean more clearly. Cheers, Andrew Vit From dchelimsky at gmail.com Wed Apr 22 12:58:08 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 11:58:08 -0500 Subject: [rspec-users] Problems withe the template... In-Reply-To: References: Message-ID: <57c63afe0904220958v2046bfctd571142a3764b923@mail.gmail.com> On Wed, Apr 22, 2009 at 11:27 AM, Alex wrote: > Hello everybody ! > > I have in a view something like this : > > > <% unless (method_name?(id)) then %> > ? ? ? ? > ? ? ? ? ? ?<%= link_to h(t(:BTN)), new_url_path(id) %> > ? ? ? ? > <% else %> > ? ? ? ? > ? ? ? ? ? ? ? ?<%= link_to_function h(t(:BTN)), 'return false;' %> > ? ? ? ? > <% end %> > > > all of this works well ... > > and in my spec I try to do this to go in the else part : > > @controller.template.stub!(:get_courtier_expire?).and_return (false) So I'm clear - method_name? above is really get_courtier_expire? ?? The statement in the view is unless, not if - so if the method is returning false, then it's behaving as you would expect. Unless I'm missing something :) > > > > I tried a lot of combinations like ... > > @template.stub!( > template.stub!( > @controller.template.should_receive( > template.should_receive( > > and it does'nt work ... it always goes in the if not in the else > part ... any suggestions ? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Apr 22 12:59:55 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 11:59:55 -0500 Subject: [rspec-users] Why RSpec? In-Reply-To: <1d7ddd110904220935s78c74484j783ac6fcfe474395@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> <1d7ddd110904220935s78c74484j783ac6fcfe474395@mail.gmail.com> Message-ID: <57c63afe0904220959j13f7303do89b7c9f6de245dbd@mail.gmail.com> On Wed, Apr 22, 2009 at 11:35 AM, Brian Takita wrote: > On Wed, Apr 22, 2009 at 9:34 AM, Brian Takita wrote: >> On Wed, Apr 22, 2009 at 7:28 AM, Amos King wrote: >>> Thanks, David. >>> >>> I do often read the rspec list because of the discussions that you >>> site. ?The community maybe enough for me to make the jump. ?I can't >>> wait to be able to use RSpec and Test::Unit together as a single >>> cohesive framework. ?I'll keep working my side project with RSpec and >>> see what ideas I can come up with. ?At work I will continue to use >>> Shoulda, Test::Unit, and Webrat. ?We'll see what ideas can be ported >>> around. ?I'll also take a look at the book. >> You can run test/unit & rspec together already. >> >> All you need to do is: >> require "spec/interop/test" >> before your spec definitions. >> >> Here is an example: >> http://gist.github.com/99895 >> >> The shoulda integration did not work, however > What do you think of having ExampleGroup.should create an Example? Aside from the fact that all of the specs for ExampleGroup would start freaking out? :) I'm not sure how to best get around this conflict. "should" means something very specific in rspec, and shoulda gives it a different meaning. >>> >>> I've worked on Webrat::Selenium and grid support a bit so let's see >>> where this can take me. ?Thanks for the ideas from everyone, and >>> you've all encouraged me to take a deeper look. >>> >>> Amos(adkron) >>> >>> On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: >>>> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >>>>> I wasn't thinking about a gun. ?I was just wondering if there is some >>>>> underlying reason that I'm missing. ?Is there a background structure >>>>> that I'm not grasping? ?Is there a huge piece of functionality that >>>>> I'm missing? ?Is it faster than Test:Unit or Shoulda? >>>> >>>> RSpec is not just about RSpec. It's about BDD. It's about encouraging >>>> conversation about testing and looking at it in different ways. It's >>>> about illuminating the design, specification, collaboration and >>>> documentation aspects of tests, and thinking of them as executable >>>> examples of behaviour. You can do this all without RSpec, but RSpec >>>> aims to help with innovations like: >>>> >>>> * strings as example group names >>>> * strings as example names >>>> * pending examples >>>> * nested groups for flexible organization >>>> * should[_not] + matchers (inspired by hamcrest - a java library) >>>> ?* one matcher supports both positive and negative expectations >>>> * improved failure messages >>>> * flexible/readable/customizable output formats >>>> * built-in mocking framework >>>> * plain text scenarios (now in Cucumber) >>>> >>>> Specifically with Rails: >>>> >>>> * component isolation. ZenTest offered separate test cases for >>>> models/views/helpers/controllers before RSpec, and RSpec extended the >>>> idea by allowing you to run controller examples with no dependency on >>>> views and vice versa. Some folks get nervous with that sort of >>>> isolation, but, generally, folks coming to Ruby from a background in >>>> TDD with Java or .NET are all over it. >>>> >>>> That's not the full list, but a good overview. You can get some of >>>> these things from other frameworks, but they almost all originated in >>>> RSpec, which has been and will continue to be a center of innovation >>>> in testing in Ruby since its creation in 2005. >>>> >>>> To be clear, it is certainly not the only center of innovation. >>>> Shoulda brought us macros, which are great, and we've made it easier >>>> to write your own in RSpec, and now you can use shoulda matchers right >>>> in RSpec. >>>> >>>> Micronaut adds a tagging system that allows you to group examples >>>> together in different ways. This is definitely something we'll be >>>> adding to RSpec sooner or later. >>>> >>>> Ryan Davis and Eric Hodel continue to bring us game-changing testing >>>> tools like autotest, heckle, flog, and flay. >>>> >>>> RSpec has been around for nearly 4 years now. It has matured quite a >>>> bit, and continues to do so. A twitter poll back in January suggests >>>> that the majority of people doing testing in Ruby are using RSpec: >>>> http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against >>>> all other frameworks and it still gets the majority. Polls are polls, >>>> and in a community of over a million Ruby developers, it's hard (for >>>> me) to believe in the accuracy of a poll that 680ish ppl voted in. But >>>> hey, that's 360-ish ppl who are at least willing to say they use >>>> rspec, so at least we know that much :) >>>> >>>> The point being that with a lot of users comes a lot of mindshare. And >>>> as RSpec continues to mature and become easier to contribute to, that >>>> mindshare will grow. More and more extension libraries like >>>> rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get >>>> better and better at supporting them. It won't be long before "rspec >>>> OR test/unit" becomes a false choice, and you'll be able to seamlessly >>>> use both in a unified suite. This is already largely the case, but it >>>> will get better. >>>> >>>> And let's not forget http://rubyspec.org/ >>>> >>>> As for which tools to use, you should use the ones that make you happy >>>> and make your job and life easier. If there is something that you like >>>> about shoulda over rspec, then use shoulda. If prefer kickin' it old >>>> school, stick w/ test/unit or minitest. Regardless of the tools you >>>> use, I'd recommend that you pay attention to RSpec and its community. >>>> There is a lot of action here. >>>> >>>> I'd also recommend that you read The RSpec Book. While the material in >>>> the book is taught through RSpec, and much of the book is very >>>> RSpec-specific, there is quite a bit of exploration of the process of >>>> BDD that can be applied regardless of toolset. Not to mention >>>> introduction to other tools like Cucumber, Webrat and Selenium. >>>> >>>> Thanks for the thought provoking question. I've been involved with >>>> RSpec since shortly after its creation in 2005, and I sometimes lose >>>> sight of why I got into it and why I stay with it. This has been a >>>> helpful reminder to me, and I hope you find my ramblings helpful to >>>> you. >>>> >>>> Cheers, >>>> David >>>> >>>>> >>>>> Amos(adkron) >>>>> >>>>> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>>>>> I think it's that RSpec encodes some of the latest BDD into its way of >>>>>> thinking. >>>>>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>>>>> semantics. >>>>>> Semantics that encourage agile thinking & practice. >>>>>> Also, it allows you to structure your specs (that become your regression >>>>>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>>>>> But if I understood all the pros & cons of two systems & preferred another, >>>>>> I'd use that -- there's no gun against anyone's head. ;) >>>>>> ?? Doug. >>>>>> >>>>>> 2009/4/22 Saturn >>>>>>> >>>>>>> I am also having same question that i can't find the reason why i >>>>>>> should go for RSpec instead of Test/Unit. >>>>>>> There is no compelling reason / advantage offered by RSpec except >>>>>>> semantics. >>>>>>> >>>>>>> >>>>>>> Is RSpec all about different syntax??????? >>>>>>> >>>>>>> Thanks in advance for clarifying it??? >>>>>>> _______________________________________________ >>>>>>> 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 >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Amos King >>>>> http://dirtyInformation.com >>>>> http://github.com/Adkron >>>>> -- >>>>> Looking for something to do? Visit http://ImThere.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 >>>> >>> >>> >>> >>> -- >>> Amos King >>> http://dirtyInformation.com >>> http://github.com/Adkron >>> -- >>> Looking for something to do? Visit http://ImThere.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 kero at chello.nl Wed Apr 22 13:14:37 2009 From: kero at chello.nl (Kero van Gelder) Date: Wed, 22 Apr 2009 19:14:37 +0200 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: <8d961d900904211433x666a4534j7bcfc1da5fd6ff53@mail.gmail.com> References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> <780F9FD2-9859-42AD-B1B2-57F88F382468@parkerhill.com> <8d961d900904211433x666a4534j7bcfc1da5fd6ff53@mail.gmail.com> Message-ID: <20090422171437.GB7801@bumblebee.m38c.nl> > > Without adding a new feature to Cucumber, I'd probably do > > > > Scenario Outline: Religious menus > > Given the customer is a "" > > When they ask for the menu > > Then they should be presented with "" > > > > Examples: > > | Religion | Meats | > > | Christian | Pork, Lamb, Veal | > > | Jewish | Lamb, Veal | > > | Muslim | Lamb, Veal | > > | Hindu | Lamb | > > This certainly would work, but what if we're not dealing with booleans > (Lamb/No Lamb), but numbers? > |34,76,89| doesn't read so well... Actually, I did just that, together with a colleague. (I removed info about what the algorithm actually computes, but the +/- indicates a threshold for that algorithm is/is not crossed; there are four algorithms not two; sorry about all that editing) Scenario Outline: measuring a series of daily weights Given patient Lara When she measures her weight as kg Then ROT algorithm result should be And MACD algorithm result should be ... Examples: | weights | ROT | MACD | ... | 71 72.5 72 73.3 73.6 | + | - | | 71 72 73 74 75 | - | + | ... I find this readable enough (it is much more readable than the long series of scenarios we had before). The numbers are a sequence as input for the algorithm. The sequences are concrete examples to show the differences between the outcomes of the four algorithms. What strikes me in your meat examples, is that there is a mapping from religion to types of meat that can be served (or dishes, in the end). You can test that the mapping works, why are you trying to be exhaustive in your examples? Bye, Kero. From bcolfer at shopping.com Wed Apr 22 13:17:16 2009 From: bcolfer at shopping.com (Colfer, Brian) Date: Wed, 22 Apr 2009 11:17:16 -0600 Subject: [rspec-users] How to get stacktrace for extending Ruby in C In-Reply-To: <736c3ff8402035678aa1ab3b1036e582@ruby-forum.com> References: <629d18fddea0e1d0754fb88b3fefd6f2@ruby-forum.com><49EDCCA9.3060808@railsnewbie.com> <736c3ff8402035678aa1ab3b1036e582@ruby-forum.com> Message-ID: <5A95EAE4A3FE1645992FAF868AD6DCDC09C00A0A@DEN-EXM-06.corp.ebay.com> Newb, I assume you are working in VisualStudio ... Is it possible to recompile all of Ruby in this environment? Or is it possible ot recompile your extension in MingW? Sorry to the rest of the group ... This thread should be moved to the Ruby list. Brian -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Newb Newb Sent: Tuesday, April 21, 2009 8:28 PM To: rspec-users at rubyforge.org Subject: Re: [rspec-users] How to get stacktrace for extending Ruby in C Scott Taylor wrote: > Newb Newb wrote: >> Hi >> >> I extend ruby with C . >> >> i get error like segmentation fault when i call my client.rb >> >> how can i get the stacktrace ? >> > > You can use gdb to get a stack trace, as was documented by Mauricio, > Jamis, and Why a while back. > > Not sure what this has to do with rspec, though. > > Scott thanks for the reply.. I m running on windows.. so is it possible to use gdb on windows.. 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 afolgueras at gmail.com Wed Apr 22 13:57:14 2009 From: afolgueras at gmail.com (Alex) Date: Wed, 22 Apr 2009 10:57:14 -0700 (PDT) Subject: [rspec-users] Problems withe the template... In-Reply-To: References: Message-ID: Problem solved! Sorry about that, turns out it wasn't an error.... Thanks! On 22 avr, 12:27, Alex wrote: > Hello everybody ! > > I have in a view something like this : > > <% unless (method_name?(id)) then %> > ? ? ? ? > ? ? ? ? ? ? <%= link_to h(t(:BTN)), new_url_path(id) %> > ? ? ? ? ? > <% else %> > ? ? ? ? > ? ? ? ? ? ? ? ? <%= link_to_function h(t(:BTN)), 'return false;' %> > ? ? ? ? > <% end %> > > all of this works well ... > > and in my spec I try to do this to go in the else part : > > @controller.template.stub!(:get_courtier_expire?).and_return (false) > > I tried a lot of combinations like ... > > @template.stub!( > template.stub!( > @controller.template.should_receive( > template.should_receive( > > and it does'nt work ... it always goes in the if not in the else > part ... any suggestions ? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Apr 22 14:06:27 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 13:06:27 -0500 Subject: [rspec-users] [RSpec] Clarification on using shared_examples_for on a Rails Controller In-Reply-To: <433a591c0904221004l591e1dfbi3a86a08e6209a231@mail.gmail.com> References: <433a591c0904221004l591e1dfbi3a86a08e6209a231@mail.gmail.com> Message-ID: <57c63afe0904221106h66ea58b0j7db2fd6975c0ca6a@mail.gmail.com> On Wed, Apr 22, 2009 at 12:04 PM, Stephen H. Gerstacker wrote: > I have a Rails controller that I am using 'before_filter' on certain actions > to assign some extra variables.? I noticed the 'shared_examples_for' method > and thought this would be a good way to test that the given actions are > loading what they need.? I wrote the following: > > shared_examples_for 'pages showing the yearly archive' do > > ??? it 'should assign a list of yearly archives' do > ????? Factory.create(:post, :published_at => Time.local(2009,02,01)) > ????? Factory.create(:post, :published_at => Time.local(2009,01,01)) > ????? Factory.create(:post, :published_at => Time.local(2008,01,01)) > ????? Factory.create(:post, :published_at => Time.local(2007,01,01)) > ????? Factory.create(:post, :published_at => Time.local(2001,01,01)) > > ????? get :index > > ????? assigns[:years].should == [ 2009, 2008, 2007, 2001 ] > ??? end > > ? end > > The problem is, it is specific to the 'index' action.? I can't use the > 'it_should_behave_like "pages showing the yearly archive"' for other > actions. > > Am I just doing this wrong or is there a way to fix this? Shared examples don't support parameterization, but macros do. Try something like this: module Macros def shows_yearly_archive_for(requests={}) requests.keys.each do |action| it "should assign a list of yearly archives on #{requests[action]} #{action}" do Factory.create(:post, :published_at => Time.local(2009,02,01)) Factory.create(:post, :published_at => Time.local(2009,01,01)) Factory.create(:post, :published_at => Time.local(2008,01,01)) Factory.create(:post, :published_at => Time.local(2007,01,01)) Factory.create(:post, :published_at => Time.local(2001,01,01)) send requests[action], action assigns[:years].should == [ 2009, 2008, 2007, 2001 ] end end end end describe SomeController do extend Macros shows_yearly_archive_for :index => :get end You can also extend with Macros from the config in spec_helper: Spec::Runner.configure {|c| c.extend(Macros, :type => :controller)} HTH, David ps - completely un-tested - that was off the top of my head > > - Stephen H. Gerstacker > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mark at mwilden.com Wed Apr 22 14:07:52 2009 From: mark at mwilden.com (Mark Wilden) Date: Wed, 22 Apr 2009 11:07:52 -0700 Subject: [rspec-users] [RSpec] Clarification on using shared_examples_for on a Rails Controller In-Reply-To: <433a591c0904221004l591e1dfbi3a86a08e6209a231@mail.gmail.com> References: <433a591c0904221004l591e1dfbi3a86a08e6209a231@mail.gmail.com> Message-ID: <3c30da400904221107v6a8eb7aft275928a70e270ee5@mail.gmail.com> On Wed, Apr 22, 2009 at 10:04 AM, Stephen H. Gerstacker wrote: > I have a Rails controller that I am using 'before_filter' on certain actions > to assign some extra variables.? I noticed the 'shared_examples_for' method > and thought this would be a good way to test that the given actions are > loading what they need.? I wrote the following: > > shared_examples_for 'pages showing the yearly archive' do > > ??? it 'should assign a list of yearly archives' do > ????? Factory.create(:post, :published_at => Time.local(2009,02,01)) > ????? Factory.create(:post, :published_at => Time.local(2009,01,01)) > ????? Factory.create(:post, :published_at => Time.local(2008,01,01)) > ????? Factory.create(:post, :published_at => Time.local(2007,01,01)) > ????? Factory.create(:post, :published_at => Time.local(2001,01,01)) > > ????? get :index > > ????? assigns[:years].should == [ 2009, 2008, 2007, 2001 ] > ??? end > > ? end > > The problem is, it is specific to the 'index' action.? I can't use the > 'it_should_behave_like "pages showing the yearly archive"' for other > actions. Assign the action to an instance variable and set it to the desired value in a before(:all) in each of the sharers. In the shared example, do get @action. ///ark From kero at chello.nl Wed Apr 22 14:08:40 2009 From: kero at chello.nl (Kero van Gelder) Date: Wed, 22 Apr 2009 20:08:40 +0200 Subject: [rspec-users] [Cucumber] Options in tables In-Reply-To: <5d1f449a0904211828i4016b7f7mad58ed8dc63919d2@mail.gmail.com> References: <5d1f449a0904211828i4016b7f7mad58ed8dc63919d2@mail.gmail.com> Message-ID: <20090422180839.GC7801@bumblebee.m38c.nl> > In Cucumber I want to remove duplication from my examples tables. > see http://gist.github.com/99516 for an example of the type of situation I > am facing. > > I would like the second example to be equivalent to the first. > > To do this... I need cucumber to read a row in the examples and notice the > 'options', then run it as if it were several rows in the table, one for each > possible combination of options. > > Anyone else find this useful? .. or got any suggestions for better ways of > doing it? 1) See another current thread in this list: [Cucumber] Tables 2) [new|expired] does not matter, so you don't need the column at all you can put two checks in the step definition, I think. perhaps this allows you to write the remaining steps in another way, without duplication of steps. Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From lists at ruby-forum.com Wed Apr 22 14:45:30 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 20:45:30 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> Message-ID: David Chelimsky wrote: > > > The original issue you posted is with the contain matcher, which is in > webrat, not rspec. Why it's not working, I'm not quite sure, but if > you're going to throw out the baby with the bath water, you might > consider figuring out who the parents are :) > Yes, I figured out that #contain was the culprit when I discovered that this worked: fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ ==(expected) Ugly, to me, but it works so the problem is not RSpec. Strangely, however, this construct also failed: fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ =~(expected) I am not throwing out RSpec or using it any less. I just had to get around a specific problem and took the first route I found that worked. > In the mean time, I'm not sure what better message we can give beyond > "compared using .equal?" without getting into a long treatise on > equality in Ruby, which seems out of place in a failure message. How about: expected "Bank of Canada: Noon Foreign Exchange Rates" got "Bank of Canada: Noon Foreign Exchange Rates" (equal?: expected object is not the object returned, did you mean '==') (Spec::Expectations::ExpectationNotMetError) -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Apr 22 14:49:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 13:49:10 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> Message-ID: <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> On Wed, Apr 22, 2009 at 1:45 PM, James Byrne wrote: > David Chelimsky wrote: >> >> >> The original issue you posted is with the contain matcher, which is in >> webrat, not rspec. Why it's not working, I'm not quite sure, but if >> you're going to throw out the baby with the bath water, you might >> consider figuring out who the parents are :) >> > > Yes, I figured out that #contain was the culprit when I discovered that > this worked: > > fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ > ? ? ? ? ? ? ? ?==(expected) > > Ugly, to me, but it works so the problem is not RSpec. ?Strangely, > however, this construct also failed: > > fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \ > ? ? ? ? ? ? ? ?=~(expected) > > I am not throwing out RSpec or using it any less. ?I just had to get > around a specific problem and took the first route I found that worked. > >> In the mean time, I'm not sure what better message we can give beyond >> "compared using .equal?" without getting into a long treatise on >> equality in Ruby, which seems out of place in a failure message. > > How about: > > ? ? ? ?expected "Bank of Canada: Noon Foreign Exchange > Rates" > ? ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange > Rates" > > ? ? ?(equal?: expected object is not the object returned, did you mean > '==') > ? ? ? (Spec::Expectations::ExpectationNotMetError) I can live with that. Do you want to make a patch? If not I'll just add it. > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From r_j_h_box-sf at yahoo.com Wed Apr 22 15:00:14 2009 From: r_j_h_box-sf at yahoo.com (r_j_h_box-sf at yahoo.com) Date: Wed, 22 Apr 2009 12:00:14 -0700 (PDT) Subject: [rspec-users] [RSpec] Clarification on using shared_examples_for on a Rails Controller In-Reply-To: <57c63afe0904221106h66ea58b0j7db2fd6975c0ca6a@mail.gmail.com> References: <433a591c0904221004l591e1dfbi3a86a08e6209a231@mail.gmail.com> <57c63afe0904221106h66ea58b0j7db2fd6975c0ca6a@mail.gmail.com> Message-ID: <728953.87082.qm@web31813.mail.mud.yahoo.com> ----- Original Message ---- > From: David Chelimsky > Shared examples don't support parameterization, but macros do. Try > something like this: > > module Macros > def shows_yearly_archive_for(requests={}) [...] > end > end > > describe SomeController do > extend Macros > shows_yearly_archive_for :index => :get > end Nice. This must be newish (I see it in book beta4 - good!). I'd been using callbacks defined in the example group next to it_should_behave_like() to get any relevant parameters. A bit icky, I'll admit. So I can just pass the details from the callback directly to the macro, when I port it/them. Sweet. I've been using a pattern for my shared example groups, similar to one I correlate (erroneously?) to a Ben Mabey post. The original pattern: do_foo(), where foo is get, post, whatever and the shared example probes the calling example group to find which one is relevant. My variation is do_action(), where the example group directly defines do_action() in whatever way is suitable to the example group (using instance variables set by before blocks, etc). This method could be defined usefully by either a Controller example group or a Model example group. I feel like even when using macros, I'd want to continue using my do_action() pattern. But maybe I have a hammer and so I'm looking for a nail. Is there another approach that gives different/better value when using macros? Thanks, Randy From lists at ruby-forum.com Wed Apr 22 15:09:48 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 21:09:48 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> Message-ID: <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> David Chelimsky wrote: > On Wed, Apr 22, 2009 at 1:45 PM, James Byrne > wrote: >> this worked: >> I am not throwing out RSpec or using it any less. ?I just had to get >> ? ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange >> Rates" >> >> ? ? ?(equal?: expected object is not the object returned, did you mean >> '==') >> ? ? ? (Spec::Expectations::ExpectationNotMetError) > > I can live with that. Do you want to make a patch? If not I'll just add > it. I'll try and make a patch first. If that does not work out then I will beg a boon of you to do it. I think that the error message should change too. Instead of: expected "Bank of Canada: Noon Foreign Exchange Rates" got "Bank of Canada: Noon Foreign Exchange Rates" An equal? failure probably should return the metaclass like: expected "#>" got "#>" yada yada.... WDYT? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Apr 22 15:18:13 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 14:18:13 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> Message-ID: <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> On Wed, Apr 22, 2009 at 2:09 PM, James Byrne wrote: > David Chelimsky wrote: >> On Wed, Apr 22, 2009 at 1:45 PM, James Byrne >> wrote: >>> this worked: >>> I am not throwing out RSpec or using it any less. ?I just had to get >>> ? ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange >>> Rates" >>> >>> ? ? ?(equal?: expected object is not the object returned, did you mean >>> '==') >>> ? ? ? (Spec::Expectations::ExpectationNotMetError) >> >> I can live with that. Do you want to make a patch? If not I'll just add >> it. > > I'll try and make a patch first. ?If that does not work out then I will > beg a boon of you to do it. > > I think that the error message should change too. Instead of: > > ? ? ? ?expected "Bank of Canada: Noon Foreign Exchange > Rates" > ? ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange > Rates" > > An equal? failure probably should return the metaclass like: > > ? ? ? ?expected "#>" > ? ? ? ? ? ? got "#>" > > yada yada.... > > WDYT? I like the idea, though I think it's helpful to also have the strings in the case of String objects. But having the class and object id would really help tell the story we're looking for. wdYt? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Apr 22 16:22:41 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 22:22:41 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Wed, Apr 22, 2009 at 2:09 PM, James Byrne > wrote: >>>> ? ? ? (Spec::Expectations::ExpectationNotMetError) >> Rates" >> WDYT? > I like the idea, though I think it's helpful to also have the strings > in the case of String objects. But having the class and object id > would really help tell the story we're looking for. > > wdYt? After I posted I reconsidered the situation. When equal? is the comparison then the first step should be to check for identical objects (duhh). If that fails then do a supplementary == check. If that passes then append the ", did you mean '==' notice and display the values together with the object.metaclass. Otherwise, just display the objects are different warning and the object.metaclass for each. However, on reconsideration again, it seems best to skip the second check and just display this sort of thing for all equal? failures: expected: "#> => 'Bank of Canada: Noon Foreign Exchange Rates'" got: "#> => 'Bank of Canada: Noon Foreign Exchange Rates'" (equal?: expected object is not the object returned, did you mean '==') (Spec::Expectations::ExpectationNotMetError) Of course, to support this outside Rails, RSpec will have to provide and require the metaclass.rb (shamelessly stolen from Rails). unless Object.respond_to? :metaclass do class Object # Get object's meta (ghost, eigenclass, singleton) class def metaclass class << self self end end end end Thoughts? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Apr 22 16:35:27 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 22 Apr 2009 22:35:27 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> Message-ID: David Chelimsky wrote: > I like the idea, though I think it's helpful to also have the strings > in the case of String objects. But having the class and object id > would really help tell the story we're looking for. The relationship between "#>" and the object's id is rather bizarre. irb(main):022:0> x.metaclass => #> irb(main):023:0> x.object_id => 23714379460620 irb(main):024:0> 0x2b22de53e018.to_s(10) => "47428758921240" irb(main):025:0> 0x2b22de53e018.to_i => 47428758921240 irb(main):026:0> 23714379460620 * 2 => 47428758921240 Obviously an extra bit is getting set somewhere; or unset in #object_id. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Apr 22 16:50:27 2009 From: lists at ruby-forum.com (Eric Kramer) Date: Wed, 22 Apr 2009 22:50:27 +0200 Subject: [rspec-users] testing multiple sessions in cucumber/webrat In-Reply-To: References: Message-ID: Joe Van Dyk wrote: > Is it possible to have a scenario where you are testing the > interaction between two different session? Not sure if this is exactly what you need, but I found this technique to be very handy: http://erikonrails.snowedin.net/?p=159 It involves mixing in a method to ActionController::Integration::Session so that you can create a step definition that happens "outside" the current session: module ActionController module Integration class Session def in_a_separate_session old = @response.clone yield @response = old end end end end Here's a sample usage from his page: Then /^I should be logged in$/ do in_a_separate_session do Given "I visit /users/me" Then "I should see \"You are logged in\"" end end -- Posted via http://www.ruby-forum.com/. From brian.takita at gmail.com Wed Apr 22 17:05:57 2009 From: brian.takita at gmail.com (Brian Takita) Date: Wed, 22 Apr 2009 14:05:57 -0700 Subject: [rspec-users] Why RSpec? In-Reply-To: <57c63afe0904220959j13f7303do89b7c9f6de245dbd@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> <1d7ddd110904220935s78c74484j783ac6fcfe474395@mail.gmail.com> <57c63afe0904220959j13f7303do89b7c9f6de245dbd@mail.gmail.com> Message-ID: <1d7ddd110904221405r6306ec17k55ca5f795555523a@mail.gmail.com> On Wed, Apr 22, 2009 at 9:59 AM, David Chelimsky wrote: > On Wed, Apr 22, 2009 at 11:35 AM, Brian Takita wrote: >> On Wed, Apr 22, 2009 at 9:34 AM, Brian Takita wrote: >>> On Wed, Apr 22, 2009 at 7:28 AM, Amos King wrote: >>>> Thanks, David. >>>> >>>> I do often read the rspec list because of the discussions that you >>>> site. ?The community maybe enough for me to make the jump. ?I can't >>>> wait to be able to use RSpec and Test::Unit together as a single >>>> cohesive framework. ?I'll keep working my side project with RSpec and >>>> see what ideas I can come up with. ?At work I will continue to use >>>> Shoulda, Test::Unit, and Webrat. ?We'll see what ideas can be ported >>>> around. ?I'll also take a look at the book. >>> You can run test/unit & rspec together already. >>> >>> All you need to do is: >>> require "spec/interop/test" >>> before your spec definitions. >>> >>> Here is an example: >>> http://gist.github.com/99895 >>> >>> The shoulda integration did not work, however >> What do you think of having ExampleGroup.should create an Example? > > Aside from the fact that all of the specs for ExampleGroup would start > freaking out? :) The gist I posted works. All I needed to do it alias :should, :example. I suppose this would have major implications on the rspec suite though, so I can see this not being able to exist with Object#should in rspec core. Others can use this technique, if they like, as long as they do not need to make assertions on an ExampleGroup class instance. > > I'm not sure how to best get around this conflict. "should" means > something very specific in rspec, and shoulda gives it a different > meaning. True. Object#should limits us there. I think the intent and semantics are similar though (in a nested sort of way). describe Foo do describe "#do_something" do should "return true" do foo.do_something.should == true end end end Its like an assertion on the subject of the description. From an object structure point of view, Example != an assertion, but from a semantic point of view, we are making an assertion. Foo#do_something should return true, which means foo.do_something should == true. > >>>> >>>> I've worked on Webrat::Selenium and grid support a bit so let's see >>>> where this can take me. ?Thanks for the ideas from everyone, and >>>> you've all encouraged me to take a deeper look. >>>> >>>> Amos(adkron) >>>> >>>> On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: >>>>> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >>>>>> I wasn't thinking about a gun. ?I was just wondering if there is some >>>>>> underlying reason that I'm missing. ?Is there a background structure >>>>>> that I'm not grasping? ?Is there a huge piece of functionality that >>>>>> I'm missing? ?Is it faster than Test:Unit or Shoulda? >>>>> >>>>> RSpec is not just about RSpec. It's about BDD. It's about encouraging >>>>> conversation about testing and looking at it in different ways. It's >>>>> about illuminating the design, specification, collaboration and >>>>> documentation aspects of tests, and thinking of them as executable >>>>> examples of behaviour. You can do this all without RSpec, but RSpec >>>>> aims to help with innovations like: >>>>> >>>>> * strings as example group names >>>>> * strings as example names >>>>> * pending examples >>>>> * nested groups for flexible organization >>>>> * should[_not] + matchers (inspired by hamcrest - a java library) >>>>> ?* one matcher supports both positive and negative expectations >>>>> * improved failure messages >>>>> * flexible/readable/customizable output formats >>>>> * built-in mocking framework >>>>> * plain text scenarios (now in Cucumber) >>>>> >>>>> Specifically with Rails: >>>>> >>>>> * component isolation. ZenTest offered separate test cases for >>>>> models/views/helpers/controllers before RSpec, and RSpec extended the >>>>> idea by allowing you to run controller examples with no dependency on >>>>> views and vice versa. Some folks get nervous with that sort of >>>>> isolation, but, generally, folks coming to Ruby from a background in >>>>> TDD with Java or .NET are all over it. >>>>> >>>>> That's not the full list, but a good overview. You can get some of >>>>> these things from other frameworks, but they almost all originated in >>>>> RSpec, which has been and will continue to be a center of innovation >>>>> in testing in Ruby since its creation in 2005. >>>>> >>>>> To be clear, it is certainly not the only center of innovation. >>>>> Shoulda brought us macros, which are great, and we've made it easier >>>>> to write your own in RSpec, and now you can use shoulda matchers right >>>>> in RSpec. >>>>> >>>>> Micronaut adds a tagging system that allows you to group examples >>>>> together in different ways. This is definitely something we'll be >>>>> adding to RSpec sooner or later. >>>>> >>>>> Ryan Davis and Eric Hodel continue to bring us game-changing testing >>>>> tools like autotest, heckle, flog, and flay. >>>>> >>>>> RSpec has been around for nearly 4 years now. It has matured quite a >>>>> bit, and continues to do so. A twitter poll back in January suggests >>>>> that the majority of people doing testing in Ruby are using RSpec: >>>>> http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against >>>>> all other frameworks and it still gets the majority. Polls are polls, >>>>> and in a community of over a million Ruby developers, it's hard (for >>>>> me) to believe in the accuracy of a poll that 680ish ppl voted in. But >>>>> hey, that's 360-ish ppl who are at least willing to say they use >>>>> rspec, so at least we know that much :) >>>>> >>>>> The point being that with a lot of users comes a lot of mindshare. And >>>>> as RSpec continues to mature and become easier to contribute to, that >>>>> mindshare will grow. More and more extension libraries like >>>>> rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get >>>>> better and better at supporting them. It won't be long before "rspec >>>>> OR test/unit" becomes a false choice, and you'll be able to seamlessly >>>>> use both in a unified suite. This is already largely the case, but it >>>>> will get better. >>>>> >>>>> And let's not forget http://rubyspec.org/ >>>>> >>>>> As for which tools to use, you should use the ones that make you happy >>>>> and make your job and life easier. If there is something that you like >>>>> about shoulda over rspec, then use shoulda. If prefer kickin' it old >>>>> school, stick w/ test/unit or minitest. Regardless of the tools you >>>>> use, I'd recommend that you pay attention to RSpec and its community. >>>>> There is a lot of action here. >>>>> >>>>> I'd also recommend that you read The RSpec Book. While the material in >>>>> the book is taught through RSpec, and much of the book is very >>>>> RSpec-specific, there is quite a bit of exploration of the process of >>>>> BDD that can be applied regardless of toolset. Not to mention >>>>> introduction to other tools like Cucumber, Webrat and Selenium. >>>>> >>>>> Thanks for the thought provoking question. I've been involved with >>>>> RSpec since shortly after its creation in 2005, and I sometimes lose >>>>> sight of why I got into it and why I stay with it. This has been a >>>>> helpful reminder to me, and I hope you find my ramblings helpful to >>>>> you. >>>>> >>>>> Cheers, >>>>> David >>>>> >>>>>> >>>>>> Amos(adkron) >>>>>> >>>>>> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>>>>>> I think it's that RSpec encodes some of the latest BDD into its way of >>>>>>> thinking. >>>>>>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>>>>>> semantics. >>>>>>> Semantics that encourage agile thinking & practice. >>>>>>> Also, it allows you to structure your specs (that become your regression >>>>>>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>>>>>> But if I understood all the pros & cons of two systems & preferred another, >>>>>>> I'd use that -- there's no gun against anyone's head. ;) >>>>>>> ?? Doug. >>>>>>> >>>>>>> 2009/4/22 Saturn >>>>>>>> >>>>>>>> I am also having same question that i can't find the reason why i >>>>>>>> should go for RSpec instead of Test/Unit. >>>>>>>> There is no compelling reason / advantage offered by RSpec except >>>>>>>> semantics. >>>>>>>> >>>>>>>> >>>>>>>> Is RSpec all about different syntax??????? >>>>>>>> >>>>>>>> Thanks in advance for clarifying it??? >>>>>>>> _______________________________________________ >>>>>>>> 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 >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Amos King >>>>>> http://dirtyInformation.com >>>>>> http://github.com/Adkron >>>>>> -- >>>>>> Looking for something to do? Visit http://ImThere.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 >>>>> >>>> >>>> >>>> >>>> -- >>>> Amos King >>>> http://dirtyInformation.com >>>> http://github.com/Adkron >>>> -- >>>> Looking for something to do? Visit http://ImThere.com >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ginormous at gmail.com Wed Apr 22 17:06:40 2009 From: ginormous at gmail.com (stephanie) Date: Wed, 22 Apr 2009 14:06:40 -0700 (PDT) Subject: [rspec-users] Passing custom arguments to an rspec script. Is this possible? Message-ID: <14636ce4-46a7-4c20-ac68-8c91569e3589@x29g2000prf.googlegroups.com> Hi, I am writing a rspec script to use with selenium-client. I would like to pass the script some custom arguments in the command line to change a few test settings in the script. However, rspec gives errors when I pass arguments to the script because rspec does not expect them. Is there any way I can pass custom arguments to an rspec script? Thanks, Stephanie From brian.takita at gmail.com Wed Apr 22 17:09:09 2009 From: brian.takita at gmail.com (Brian Takita) Date: Wed, 22 Apr 2009 14:09:09 -0700 Subject: [rspec-users] Why RSpec? In-Reply-To: <1d7ddd110904221405r6306ec17k55ca5f795555523a@mail.gmail.com> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <57c63afe0904220708p19a1d79fte6e3b61cea3cc79b@mail.gmail.com> <1d7ddd110904220934v6aec8c5bk4a9fa6cb518adc43@mail.gmail.com> <1d7ddd110904220935s78c74484j783ac6fcfe474395@mail.gmail.com> <57c63afe0904220959j13f7303do89b7c9f6de245dbd@mail.gmail.com> <1d7ddd110904221405r6306ec17k55ca5f795555523a@mail.gmail.com> Message-ID: <1d7ddd110904221409je9b07a0q259b0341c71075e5@mail.gmail.com> On Wed, Apr 22, 2009 at 2:05 PM, Brian Takita wrote: > On Wed, Apr 22, 2009 at 9:59 AM, David Chelimsky wrote: >> On Wed, Apr 22, 2009 at 11:35 AM, Brian Takita wrote: >>> On Wed, Apr 22, 2009 at 9:34 AM, Brian Takita wrote: >>>> On Wed, Apr 22, 2009 at 7:28 AM, Amos King wrote: >>>>> Thanks, David. >>>>> >>>>> I do often read the rspec list because of the discussions that you >>>>> site. ?The community maybe enough for me to make the jump. ?I can't >>>>> wait to be able to use RSpec and Test::Unit together as a single >>>>> cohesive framework. ?I'll keep working my side project with RSpec and >>>>> see what ideas I can come up with. ?At work I will continue to use >>>>> Shoulda, Test::Unit, and Webrat. ?We'll see what ideas can be ported >>>>> around. ?I'll also take a look at the book. >>>> You can run test/unit & rspec together already. >>>> >>>> All you need to do is: >>>> require "spec/interop/test" >>>> before your spec definitions. >>>> >>>> Here is an example: >>>> http://gist.github.com/99895 >>>> >>>> The shoulda integration did not work, however >>> What do you think of having ExampleGroup.should create an Example? >> >> Aside from the fact that all of the specs for ExampleGroup would start >> freaking out? :) > The gist I posted works. All I needed to do it alias :should, :example. > I suppose this would have major implications on the rspec suite > though, so I can see this not being able to exist with Object#should > in rspec core. > > Others can use this technique, if they like, as long as they do not > need to make assertions on an ExampleGroup class instance. >> >> I'm not sure how to best get around this conflict. "should" means >> something very specific in rspec, and shoulda gives it a different >> meaning. > True. Object#should limits us there. I think the intent and semantics > are similar though (in a nested sort of way). > > describe Foo do > ?describe "#do_something" do > ? ?should "return true" do > ? ? ?foo.do_something.should == true > ? ?end > ?end > end > > Its like an assertion on the subject of the description. From an > object structure point of view, Example != an assertion, but from a > semantic point of view, we are making an assertion. > > Foo#do_something should return true, which means foo.do_something > should == true. Not that that's its a big deal to me, but this would be useful for somebody trying to use both shoulda + rspec. Maybe there is a better way? >> >>>>> >>>>> I've worked on Webrat::Selenium and grid support a bit so let's see >>>>> where this can take me. ?Thanks for the ideas from everyone, and >>>>> you've all encouraged me to take a deeper look. >>>>> >>>>> Amos(adkron) >>>>> >>>>> On Wed, Apr 22, 2009 at 9:08 AM, David Chelimsky wrote: >>>>>> On Wed, Apr 22, 2009 at 6:25 AM, Amos King wrote: >>>>>>> I wasn't thinking about a gun. ?I was just wondering if there is some >>>>>>> underlying reason that I'm missing. ?Is there a background structure >>>>>>> that I'm not grasping? ?Is there a huge piece of functionality that >>>>>>> I'm missing? ?Is it faster than Test:Unit or Shoulda? >>>>>> >>>>>> RSpec is not just about RSpec. It's about BDD. It's about encouraging >>>>>> conversation about testing and looking at it in different ways. It's >>>>>> about illuminating the design, specification, collaboration and >>>>>> documentation aspects of tests, and thinking of them as executable >>>>>> examples of behaviour. You can do this all without RSpec, but RSpec >>>>>> aims to help with innovations like: >>>>>> >>>>>> * strings as example group names >>>>>> * strings as example names >>>>>> * pending examples >>>>>> * nested groups for flexible organization >>>>>> * should[_not] + matchers (inspired by hamcrest - a java library) >>>>>> ?* one matcher supports both positive and negative expectations >>>>>> * improved failure messages >>>>>> * flexible/readable/customizable output formats >>>>>> * built-in mocking framework >>>>>> * plain text scenarios (now in Cucumber) >>>>>> >>>>>> Specifically with Rails: >>>>>> >>>>>> * component isolation. ZenTest offered separate test cases for >>>>>> models/views/helpers/controllers before RSpec, and RSpec extended the >>>>>> idea by allowing you to run controller examples with no dependency on >>>>>> views and vice versa. Some folks get nervous with that sort of >>>>>> isolation, but, generally, folks coming to Ruby from a background in >>>>>> TDD with Java or .NET are all over it. >>>>>> >>>>>> That's not the full list, but a good overview. You can get some of >>>>>> these things from other frameworks, but they almost all originated in >>>>>> RSpec, which has been and will continue to be a center of innovation >>>>>> in testing in Ruby since its creation in 2005. >>>>>> >>>>>> To be clear, it is certainly not the only center of innovation. >>>>>> Shoulda brought us macros, which are great, and we've made it easier >>>>>> to write your own in RSpec, and now you can use shoulda matchers right >>>>>> in RSpec. >>>>>> >>>>>> Micronaut adds a tagging system that allows you to group examples >>>>>> together in different ways. This is definitely something we'll be >>>>>> adding to RSpec sooner or later. >>>>>> >>>>>> Ryan Davis and Eric Hodel continue to bring us game-changing testing >>>>>> tools like autotest, heckle, flog, and flay. >>>>>> >>>>>> RSpec has been around for nearly 4 years now. It has matured quite a >>>>>> bit, and continues to do so. A twitter poll back in January suggests >>>>>> that the majority of people doing testing in Ruby are using RSpec: >>>>>> http://twtpoll.com/r/zhh2fm. Note that this poll pits RSpec against >>>>>> all other frameworks and it still gets the majority. Polls are polls, >>>>>> and in a community of over a million Ruby developers, it's hard (for >>>>>> me) to believe in the accuracy of a poll that 680ish ppl voted in. But >>>>>> hey, that's 360-ish ppl who are at least willing to say they use >>>>>> rspec, so at least we know that much :) >>>>>> >>>>>> The point being that with a lot of users comes a lot of mindshare. And >>>>>> as RSpec continues to mature and become easier to contribute to, that >>>>>> mindshare will grow. More and more extension libraries like >>>>>> rspec_on_rails_on_crack and remarkable will emerge, and RSpec will get >>>>>> better and better at supporting them. It won't be long before "rspec >>>>>> OR test/unit" becomes a false choice, and you'll be able to seamlessly >>>>>> use both in a unified suite. This is already largely the case, but it >>>>>> will get better. >>>>>> >>>>>> And let's not forget http://rubyspec.org/ >>>>>> >>>>>> As for which tools to use, you should use the ones that make you happy >>>>>> and make your job and life easier. If there is something that you like >>>>>> about shoulda over rspec, then use shoulda. If prefer kickin' it old >>>>>> school, stick w/ test/unit or minitest. Regardless of the tools you >>>>>> use, I'd recommend that you pay attention to RSpec and its community. >>>>>> There is a lot of action here. >>>>>> >>>>>> I'd also recommend that you read The RSpec Book. While the material in >>>>>> the book is taught through RSpec, and much of the book is very >>>>>> RSpec-specific, there is quite a bit of exploration of the process of >>>>>> BDD that can be applied regardless of toolset. Not to mention >>>>>> introduction to other tools like Cucumber, Webrat and Selenium. >>>>>> >>>>>> Thanks for the thought provoking question. I've been involved with >>>>>> RSpec since shortly after its creation in 2005, and I sometimes lose >>>>>> sight of why I got into it and why I stay with it. This has been a >>>>>> helpful reminder to me, and I hope you find my ramblings helpful to >>>>>> you. >>>>>> >>>>>> Cheers, >>>>>> David >>>>>> >>>>>>> >>>>>>> Amos(adkron) >>>>>>> >>>>>>> On Wed, Apr 22, 2009 at 2:01 AM, doug livesey wrote: >>>>>>>> I think it's that RSpec encodes some of the latest BDD into its way of >>>>>>>> thinking. >>>>>>>> It has a vocabulary that encourages that, so in a way, yes, it's all about >>>>>>>> semantics. >>>>>>>> Semantics that encourage agile thinking & practice. >>>>>>>> Also, it allows you to structure your specs (that become your regression >>>>>>>> tests) in a much more intuitive way than Test::Unit -- I don't know Shoulda. >>>>>>>> But if I understood all the pros & cons of two systems & preferred another, >>>>>>>> I'd use that -- there's no gun against anyone's head. ;) >>>>>>>> ?? Doug. >>>>>>>> >>>>>>>> 2009/4/22 Saturn >>>>>>>>> >>>>>>>>> I am also having same question that i can't find the reason why i >>>>>>>>> should go for RSpec instead of Test/Unit. >>>>>>>>> There is no compelling reason / advantage offered by RSpec except >>>>>>>>> semantics. >>>>>>>>> >>>>>>>>> >>>>>>>>> Is RSpec all about different syntax??????? >>>>>>>>> >>>>>>>>> Thanks in advance for clarifying it??? >>>>>>>>> _______________________________________________ >>>>>>>>> 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 >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Amos King >>>>>>> http://dirtyInformation.com >>>>>>> http://github.com/Adkron >>>>>>> -- >>>>>>> Looking for something to do? Visit http://ImThere.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 >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Amos King >>>>> http://dirtyInformation.com >>>>> http://github.com/Adkron >>>>> -- >>>>> Looking for something to do? Visit http://ImThere.com >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From kero at chello.nl Wed Apr 22 19:02:10 2009 From: kero at chello.nl (Kero van Gelder) Date: Thu, 23 Apr 2009 01:02:10 +0200 Subject: [rspec-users] [Cucumber] Options in tables In-Reply-To: <5d1f449a0904221450v1a2cde45mf2fa9ad5d0bf4bb2@mail.gmail.com> References: <5d1f449a0904211828i4016b7f7mad58ed8dc63919d2@mail.gmail.com> <20090422180839.GC7801@bumblebee.m38c.nl> <5d1f449a0904221444j7ad03dfel3cb2c375e3265995@mail.gmail.com> <5d1f449a0904221450v1a2cde45mf2fa9ad5d0bf4bb2@mail.gmail.com> Message-ID: <20090422230210.GD7801@bumblebee.m38c.nl> > sorry.. the first point.. you're right this feature is to do with tables > too, however this feature is orthogonal to the other one, so I decided to > start a new thread ... I hope that was right. Sure, just wanted to make sure you'd seen the other thread. (on a aside note: what would examples look like if both ideas get implemented? I'm afraid it'll be confusing.) > > I agree that in defining the rules that define the behaviour those > > situations are equivalent. > > > > However, as the examples _are the tests_ we need both as we need to test > > both those scenarios so the testers have confidence the feature is working > > in all situations. Given I am a And I am on the entity list screen When I a new or expired entity ... I realize the three Then steps become "double" steps, too. Doesn't really scale when you have more than two states... It scales fine when the state does not matter, no "double" steps at all. I'm out of ideas, time for someone else to chime in :) > > It's being a really good experience in my current project to work so > > closely with the test team. I'm getting some really good feedback. Cool! Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From dchelimsky at gmail.com Wed Apr 22 19:37:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 18:37:23 -0500 Subject: [rspec-users] Passing custom arguments to an rspec script. Is this possible? In-Reply-To: <14636ce4-46a7-4c20-ac68-8c91569e3589@x29g2000prf.googlegroups.com> References: <14636ce4-46a7-4c20-ac68-8c91569e3589@x29g2000prf.googlegroups.com> Message-ID: <57c63afe0904221637t6bd496a8m5630afc928b1c51d@mail.gmail.com> On Wed, Apr 22, 2009 at 4:06 PM, stephanie wrote: > Hi, > > I am writing a rspec script to use with selenium-client. I would like > to pass the script some custom arguments in the command line to change > a few test settings in the script. However, rspec gives errors when I > pass arguments to the script because rspec does not expect them. Is > there any way I can pass custom arguments to an rspec script? Arbitrary arguments, no. You can require arbitrary files though: spec --require path/to/config/file my_script.rb In which case you could configure things in different config files. Would that work for you? > > Thanks, > Stephanie > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Apr 22 19:39:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Apr 2009 18:39:25 -0500 Subject: [rspec-users] Passing custom arguments to an rspec script. Is this possible? In-Reply-To: <57c63afe0904221637t6bd496a8m5630afc928b1c51d@mail.gmail.com> References: <14636ce4-46a7-4c20-ac68-8c91569e3589@x29g2000prf.googlegroups.com> <57c63afe0904221637t6bd496a8m5630afc928b1c51d@mail.gmail.com> Message-ID: <57c63afe0904221639r3805bcg68bb39e3d3d42af6@mail.gmail.com> On Wed, Apr 22, 2009 at 6:37 PM, David Chelimsky wrote: > On Wed, Apr 22, 2009 at 4:06 PM, stephanie wrote: >> Hi, >> >> I am writing a rspec script to use with selenium-client. I would like >> to pass the script some custom arguments in the command line to change >> a few test settings in the script. However, rspec gives errors when I >> pass arguments to the script because rspec does not expect them. Is >> there any way I can pass custom arguments to an rspec script? > > Arbitrary arguments, no. You can require arbitrary files though: > > spec --require path/to/config/file my_script.rb > > In which case you could configure things in different config files. > > Would that work for you? The other alternative would be: ruby my_script.rb --custom-arg To get that to work, the args have to come after my_script.rb and my_script.rb would need to require 'spec/autorun'. > >> >> Thanks, >> Stephanie >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From ben at benmabey.com Wed Apr 22 19:40:14 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 22 Apr 2009 17:40:14 -0600 Subject: [rspec-users] [Cucumber] Textmate support for Background In-Reply-To: <1ebf5a4d0904220827w3d0c4f32vf54f85865abe2f27@mail.gmail.com> References: <1ebf5a4d0904220827w3d0c4f32vf54f85865abe2f27@mail.gmail.com> Message-ID: <49EFAADE.2060300@benmabey.com> Tim Walker wrote: > Howdy, > > Want to use the Background feature support and was curious if text > mate support for it was coming or I could get a pointer on how to do > text highlighting for "Background" was able to edit it as a Snippet > but not sure how to make the syntax highlighting work. > > Many thanks, > > Tim > Hey Tim, I thought that was added, but perhaps not... I need to do some cleaning around the syntax highlighting anyways. Do you mind adding an issue on the github project? http://github.com/bmabey/cucumber-tmbundle/issues Thanks! -Ben From ben at benmabey.com Wed Apr 22 19:48:58 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 22 Apr 2009 17:48:58 -0600 Subject: [rspec-users] [Cucumber] Tables In-Reply-To: References: <8d961d900904210939y5a5dbb52q481b1b2a799cdcd8@mail.gmail.com> <57c63afe0904210956o203ee0b1n4247645a895e94f1@mail.gmail.com> <8d961d900904212314nc1dc27et1b915d577b1cb7d1@mail.gmail.com> Message-ID: <49EFACEA.2060500@benmabey.com> John Goodsen wrote: > I definitely prefer the range solution over the others. I agree, it makes sense and is simple IMO. > > On Wed, Apr 22, 2009 at 2:14 AM, aslak hellesoy > > wrote: > > > > This is actually one of the best I've seen so far. However it > doesn't scale for multiple columns. (Imagine if you have 5 of them > - they easily get mixed up, or you make a spelling mistake). > > I have also taken the meat+hamburge example and tweaked a little > bit: http://gist.github.com/99620 > As you can see I'm a little sceptical of complex tables. Instead I > have invented the Range for feature writers. You specify a range > of columns you want for a column hash. (This could work along with > my example where you don't specify a range, just any token, and > get the "rest"). > > > > -- > 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 > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Wed Apr 22 20:02:47 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 23 Apr 2009 01:02:47 +0100 Subject: [rspec-users] Why RSpec? In-Reply-To: <21C05969-F5FC-4F22-BC95-B8847BCE07FE@avit.ca> References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> <21C05969-F5FC-4F22-BC95-B8847BCE07FE@avit.ca> Message-ID: <9A77FEDB-E77E-497E-9D42-8D69526B0EE8@mattwynne.net> On 22 Apr 2009, at 17:52, Andrew Vit wrote: > On Apr 22, 2009, at 4:25 AM, Amos King wrote: > >> I wasn't thinking about a gun. I was just wondering if there is some >> underlying reason that I'm missing. Is there a background structure >> that I'm not grasping? Is there a huge piece of functionality that >> I'm missing? Is it faster than Test:Unit or Shoulda? >> >> Amos(adkron) > > > Personally, I can't think of one single huge piece of functionality > that makes RSpec win over TestUnit, but it's a whole bunch of little > things. > > It can be faster if you make use of mocks/stubs, and separation > between layers: you can test your controllers without having to > render the views. > > Shoulda is good too. It adds some of the features that RSpec > brought, like contexts, but having used Shoulda for over a year and > recently using RSpec on a new project, I can say that I prefer RSpec > overall... keep in mind Shoulda's macros and matchers are available > in RSpec too. > > describe RSpec, "versus TestUnit" do > it { should read_fluently } > end > > Yes, a lot of the most visible differences seem to be around the > syntax, but the point is that it helps you think more fluidly about > what you're actually trying to do. TestUnit adds mental baggage for > up-front testing and the tests have a backward-looking feel, in > other words, they read more like they're verifying what should have > happened after it's done. RSpec tests read more expressively as > looking forward to what you would like to achieve, what "should" > happen. > > While the tests are still pure ruby, they read almost like pure > English, especially if you take a little extra effort to encapsulate > some of the hairy logic into your own custom matchers. The specs can > convey their intent much more clearly, instead of only serving as > verification of your app's performance. Your spec suite becomes very > readable (to a developer at least) as behaviour documentation, > without needing to slow down to work it out too much. That's not to > say you can't write readable tests in Shoulda or TestUnit, but RSpec > helps you frame them better and convey what you mean more clearly. > > Cheers, > Andrew Vit +1 Andrew. Thanks for summing up the subtle benefits so well. Also, I would add - RSpec has a solid community of extremely helpful, thoughtful and patient people who will guide you though as you learn BDD / TDD. I think that's a great reflection of the software itself. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From jgoodsen at radsoft.com Wed Apr 22 20:14:39 2009 From: jgoodsen at radsoft.com (John Goodsen) Date: Wed, 22 Apr 2009 20:14:39 -0400 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> Message-ID: +1. I like it. -- 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 On Wed, Apr 22, 2009 at 4:22 PM, James Byrne wrote: > David Chelimsky wrote: > > On Wed, Apr 22, 2009 at 2:09 PM, James Byrne > > wrote: > >>>> ? ? ? (Spec::Expectations::ExpectationNotMetError) > >> Rates" > >> WDYT? > > I like the idea, though I think it's helpful to also have the strings > > in the case of String objects. But having the class and object id > > would really help tell the story we're looking for. > > > > wdYt? > > After I posted I reconsidered the situation. When equal? is the > comparison then the first step should be to check for identical objects > (duhh). If that fails then do a supplementary == check. If that passes > then append the ", did you mean '==' notice and display the values > together with the object.metaclass. Otherwise, just display the objects > are different warning and the object.metaclass for each. > > However, on reconsideration again, it seems best to skip the second > check and just display this sort of thing for all equal? failures: > > expected: "#> => 'Bank of > Canada: Noon Foreign Exchange Rates'" > got: "#> => 'Bank of > Canada: Noon Foreign Exchange Rates'" > > (equal?: expected object is not the object returned, did you mean > '==') > (Spec::Expectations::ExpectationNotMetError) > > Of course, to support this outside Rails, RSpec will have to provide and > require the metaclass.rb (shamelessly stolen from Rails). > > unless Object.respond_to? :metaclass do > class Object > # Get object's meta (ghost, eigenclass, singleton) class > def metaclass > class << self > self > end > end > end > end > > > > Thoughts? > > > -- > 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 ginormous at gmail.com Wed Apr 22 20:31:01 2009 From: ginormous at gmail.com (stephanie) Date: Wed, 22 Apr 2009 17:31:01 -0700 (PDT) Subject: [rspec-users] Passing custom arguments to an rspec script. Is this possible? In-Reply-To: <57c63afe0904221637t6bd496a8m5630afc928b1c51d@mail.gmail.com> References: <14636ce4-46a7-4c20-ac68-8c91569e3589@x29g2000prf.googlegroups.com> <57c63afe0904221637t6bd496a8m5630afc928b1c51d@mail.gmail.com> Message-ID: <53f9f01d-9805-4499-a7dd-5bdf4c1055a5@b6g2000pre.googlegroups.com> Thanks, I'll check out both options. -Stephanie On Apr 22, 4:37?pm, David Chelimsky wrote: > On Wed, Apr 22, 2009 at 4:06 PM, stephanie wrote: > > Hi, > > > I am writing a rspec script to use with selenium-client. I would like > > to pass the script some custom arguments in the command line to change > > a few test settings in the script. However, rspec gives errors when I > > pass arguments to the script because rspec does not expect them. Is > > there any way I can pass custom arguments to an rspec script? > > Arbitrary arguments, no. You can require arbitrary files though: > > spec --require path/to/config/file my_script.rb > > In which case you could configure things in different config files. > > Would that work for you? > > > > > Thanks, > > Stephanie > > _______________________________________________ > > 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 jonathan at parkerhill.com Thu Apr 23 00:50:20 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Thu, 23 Apr 2009 00:50:20 -0400 Subject: [rspec-users] [Cucumber] Options in tables In-Reply-To: <5d1f449a0904222041u1f707cd6gd8af16f0963d3d59@mail.gmail.com> References: <5d1f449a0904211828i4016b7f7mad58ed8dc63919d2@mail.gmail.com> <20090422180839.GC7801@bumblebee.m38c.nl> <5d1f449a0904221444j7ad03dfel3cb2c375e3265995@mail.gmail.com> <5d1f449a0904221450v1a2cde45mf2fa9ad5d0bf4bb2@mail.gmail.com> <20090422230210.GD7801@bumblebee.m38c.nl> <5d1f449a0904222041u1f707cd6gd8af16f0963d3d59@mail.gmail.com> Message-ID: <87376C1A-A6D0-4F3F-A9DD-C95724B0688C@parkerhill.com> I'm no mathematician, but perhaps there's some notation from set theory that could be helpful? From sfeley at gmail.com Thu Apr 23 02:03:48 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 23 Apr 2009 02:03:48 -0400 Subject: [rspec-users] Why RSpec? In-Reply-To: References: <12e97324-2e25-4f1d-a156-dd7df3ec950b@c18g2000prh.googlegroups.com> <50873a360904220001o17bcf7ebh6f2c511ca7db7686@mail.gmail.com> Message-ID: <1fb4df0904222303h3d04e09r927291ebdf6c735d@mail.gmail.com> On Wed, Apr 22, 2009 at 7:25 AM, Amos King wrote: > I wasn't thinking about a gun. ?I was just wondering if there is some > underlying reason that I'm missing. ?Is there a background structure > that I'm not grasping? ?Is there a huge piece of functionality that > I'm missing? ?Is it faster than Test:Unit or Shoulda? RSpec appeals to my literary sensibilities. It helps me think about my code in English. As a writer and editor, I find this pleasant. And as a human who's spoken English longer than Ruby, I find it clarifies my thought and improves my productivity. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From mikejeremiah at gmail.com Thu Apr 23 04:35:02 2009 From: mikejeremiah at gmail.com (mikej) Date: Thu, 23 Apr 2009 01:35:02 -0700 (PDT) Subject: [rspec-users] Select box with Webrat In-Reply-To: References: <6d0876c6-5dc1-499f-9fcd-010aacf2c295@k41g2000yqh.googlegroups.com> Message-ID: <1e3f2c46-8ff2-4716-856a-0cae35c2e91d@f19g2000yqh.googlegroups.com> Thanks for the response. I think I tried that one, still get the response: The 'Pollution' option was not found in the "temp_aspect_topic_id" select box (Webrat::NotFoundError) Any more thought? Mike From mikejeremiah at gmail.com Thu Apr 23 04:34:45 2009 From: mikejeremiah at gmail.com (mikej) Date: Thu, 23 Apr 2009 01:34:45 -0700 (PDT) Subject: [rspec-users] Select box with Webrat In-Reply-To: References: <6d0876c6-5dc1-499f-9fcd-010aacf2c295@k41g2000yqh.googlegroups.com> Message-ID: Thanks for the response. I think I tried that one, still get the response: The 'Pollution' option was not found in the "temp_aspect_topic_id" select box (Webrat::NotFoundError) Any more thought? Mike From dchelimsky at gmail.com Thu Apr 23 08:51:43 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 07:51:43 -0500 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> Message-ID: <57c63afe0904230551i3d384c5ap8a793268e6777b5c@mail.gmail.com> On Thu, Apr 16, 2009 at 10:35 AM, Matt Wynne wrote: > > 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 I'm definitely on the "clarity trumps DRY" side of the fence here. But that doesn't deny that there is a problem to solve. This solution gets close but is still takes me some extra time to grok. What extracting that to a method like this: Then /^I (should|should not) see the people search form$/ do |should_or_should_not| expect_that(response, should_or_should_not, have_tag('form#frmSearch')) end def expect_that(target, should_or_should_not, matcher) target.send should_or_should_not.underscore.to_sym, matcher end I definitely don't see this in Cucumber, BTW as "should" and "should not" are not the only way to express positive and negative expectations even in English, let alone other languages that might not deal w/ negation in such clean and consistent ways. And it's not the least number of characters you can type. But it's grok-able IMO. And DRY. And cute, to boot. Of course, if anybody can come up with one word other than "maybe" (damn you Ben Mabey for f'ing up my ability to type that word) to express should_or_should_not more succinctly, that might help reduce the typing. "Maybe" doesn't work for me because it implies lack of precision rather than choice (to me). Don't know how helpful this is, but it's fun to explore. David > > >> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From zach.dennis at gmail.com Thu Apr 23 08:59:59 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 23 Apr 2009 08:59:59 -0400 Subject: [rspec-users] Select box with Webrat In-Reply-To: References: <6d0876c6-5dc1-499f-9fcd-010aacf2c295@k41g2000yqh.googlegroups.com> Message-ID: <85d99afe0904230559m62cd884fg7f88196ed2d58e64@mail.gmail.com> On Thu, Apr 23, 2009 at 4:34 AM, mikej wrote: > Thanks for the response. ?I think I tried that one, still get the > response: > > The 'Pollution' option was not found in the "temp_aspect_topic_id" > select box (Webrat::NotFoundError) > > Any more thought? Do you only have one select box on the page with that id (hidden or showing, maybe new and/or edit forms) ? > > Mike > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From walketim at gmail.com Thu Apr 23 09:16:09 2009 From: walketim at gmail.com (Tim Walker) Date: Thu, 23 Apr 2009 07:16:09 -0600 Subject: [rspec-users] [Cucumber] Textmate support for Background In-Reply-To: <49EFAADE.2060300@benmabey.com> References: <1ebf5a4d0904220827w3d0c4f32vf54f85865abe2f27@mail.gmail.com> <49EFAADE.2060300@benmabey.com> Message-ID: <1ebf5a4d0904230616l45f31893pec47c497c77db348@mail.gmail.com> Done. Many thanks! http://github.com/bmabey/cucumber-tmbundle/issues/#issue/1 Title: Support for Background (uh, Scenario?) Body: Would like support (Text Highlighting, Code Snippet) for the Cucumber "Background" key word. I'd imagine this would be a code snippet just like Scenario. Best regards and thanks for an awesome tool. Tim On Wed, Apr 22, 2009 at 5:40 PM, Ben Mabey wrote: > Tim Walker wrote: >> >> Howdy, >> >> Want to use the Background feature support and was curious if text >> mate support for it was coming or I could get a pointer on how to do >> text highlighting for "Background" was able to edit it as a Snippet >> but not sure how to make the syntax highlighting work. >> >> Many thanks, >> >> Tim >> > > Hey Tim, > I thought that was added, but perhaps not... I need to do some cleaning > around the syntax highlighting anyways. > > Do you mind adding an issue on the github project? > > http://github.com/bmabey/cucumber-tmbundle/issues > > Thanks! > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Apr 23 10:27:28 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 16:27:28 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> Message-ID: <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> David Chelimsky wrote: > On Wed, Apr 22, 2009 at 2:09 PM, James Byrne > wrote: >>>> ? ? ? (Spec::Expectations::ExpectationNotMetError) >> Rates" >> WDYT? > I like the idea, though I think it's helpful to also have the strings > in the case of String objects. But having the class and object id > would really help tell the story we're looking for. > > wdYt? I have come up with this spec. Before I poke at the code itself I would like you to comment. it "should display object and value, expected and actual, on #failure_message" do target = 1 matcher = equal("1") matcher.matches?(target) matcher.failure_message_for_should.should == \ "\n" + "expected \"#{matcher.metaclass} => 1\"\n" + " got \"#{target.metaclass} => 1\n" + " \n(compared using equal?, did you mean '==')\n" end -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Thu Apr 23 10:39:52 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 23 Apr 2009 08:39:52 -0600 Subject: [rspec-users] Cucumber - step negating another expecting step In-Reply-To: <57c63afe0904230551i3d384c5ap8a793268e6777b5c@mail.gmail.com> References: <8277b7f40904160307q5f18c563vab70b80a2e64cb8@mail.gmail.com> <8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com> <8277b7f40904160606w18fc469ek7a582fcefad144ce@mail.gmail.com> <57c63afe0904230551i3d384c5ap8a793268e6777b5c@mail.gmail.com> Message-ID: <49F07DB8.3010400@benmabey.com> David Chelimsky wrote: > On Thu, Apr 16, 2009 at 10:35 AM, Matt Wynne wrote: > >> 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 >> > > I'm definitely on the "clarity trumps DRY" side of the fence here. But > that doesn't deny that there is a problem to solve. This solution gets > close but is still takes me some extra time to grok. What extracting > that to a method like this: > > Then /^I (should|should not) see the people search form$/ do > |should_or_should_not| > expect_that(response, should_or_should_not, have_tag('form#frmSearch')) > end > > def expect_that(target, should_or_should_not, matcher) > target.send should_or_should_not.underscore.to_sym, matcher > end > > I definitely don't see this in Cucumber, BTW as "should" and "should > not" are not the only way to express positive and negative > expectations even in English, let alone other languages that might not > deal w/ negation in such clean and consistent ways. > > And it's not the least number of characters you can type. But it's > grok-able IMO. And DRY. And cute, to boot. > > Of course, if anybody can come up with one word other than "maybe" > (damn you Ben Mabey for f'ing up my ability to type that word) to > LOL... I seem to have that effect on people. :) But, think how I feel. Do you know how many "witty" people I have met who tell some "maybe" joke and think they are the first person to ever make it? Well, I can tell you that it does, in fact, get very old. :) > express should_or_should_not more succinctly, that might help reduce > the typing. "Maybe" doesn't work for me because it implies lack of > precision rather than choice (to me). > Back on topic... I like this proposal the best. Having the "should_or_should_not" makes it very clear what is happening. To reduce typing I suppose you could call it "expectation" in the step definition... and you could possibly even abbrevaite that more. But I wold probably stick with the more verbose "should_or_should_not". I also agree that this is something that shouldn't be part of Cucumber itself but I'll probably play around with it in my own projects. -Ben *Mabey* > Don't know how helpful this is, but it's fun to explore. > > David > > >> >>> 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 >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at bitwrangler.com Thu Apr 23 11:19:30 2009 From: lists at bitwrangler.com (Ken Mayer) Date: Thu, 23 Apr 2009 05:19:30 -1000 Subject: [rspec-users] [Cucumber, Rails] Load path hell with plugins /extensions Message-ID: <3A554D29-B9F1-4C94-904E-43B16D119DD1@bitwrangler.com> I discovered this while debugging a RadiantCMS extension: cucumber uses 'require' to load step definitions, _and_ since I loaded the rails environment (in features/support/env.rb) for testing, _and_ radiant necessarily adds extensions to the load path, the path to _every_ extension in your project is added to $LOAD_PATH ($:) -- and, it is a sorted list (items are not queued). Imagine the fun when you try to load 'features/support/paths.rb' only to discover (after single stepping through a lot of code) that it required an identically named file, but from a completely different project. DLL hell. e.g. Given this tree, trying to run 'rake spec:features' in .../ data_manager pulls in files from .../citations first because it is lexically before it. RAILS_ROOT |-- config | `-- environments `-- vendor |-- extensions | |-- citations | | |-- Rakefile | | |-- features | |-- data_manager | | |-- Rakefile | | |-- features `-- radiant |-- features | |-- admin | |-- step_definitions | `-- support I'm not sure what the solution is, but for now, if you modify your extension Rakefile to include the following (prepend the patterns with the current directory): ... Cucumber::Rake::Task.new(:features) do |t| # t.cucumber_opts = "..." t.step_pattern = File.dirname(__FILE__) + "/features/**/*.rb" t.feature_pattern = File.dirname(__FILE__) + "/features/**/ *.feature" end Please note: I'm getting deprecation warnings, in 3.0, about using these accessors, but the command line options are not yet available. Aloha a hui hou, Ken -- Ken Mayer / kmayer at bitwrangler.com / 808-722-6142 / http://www.bitwrangler.com/ From lists at ruby-forum.com Thu Apr 23 12:08:00 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 18:08:00 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> Message-ID: <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> Another question: Where should metaclass.rb go; lib? lib/spec? or should the method be put inside the spec_helper file? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Apr 23 12:40:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 11:40:17 -0500 Subject: [rspec-users] Cucumber - step negating another expecting step In-Reply-To: <49F07DB8.3010400@benmabey.com> References: <8277b7f40904160307q5f18c563vab70b80a2e64cb8@mail.gmail.com> <8277b7f40904160322nd8c6ff8mb4e26cb0086cf234@mail.gmail.com> <8277b7f40904160606w18fc469ek7a582fcefad144ce@mail.gmail.com> <57c63afe0904230551i3d384c5ap8a793268e6777b5c@mail.gmail.com> <49F07DB8.3010400@benmabey.com> Message-ID: <57c63afe0904230940s3c66eecau3bf3553d0c1c6e89@mail.gmail.com> On Thu, Apr 23, 2009 at 9:39 AM, Ben Mabey wrote: > David Chelimsky wrote: >> >> On Thu, Apr 16, 2009 at 10:35 AM, Matt Wynne wrote: >> >>> >>> 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 >>> >> >> I'm definitely on the "clarity trumps DRY" side of the fence here. But >> that doesn't deny that there is a problem to solve. This solution gets >> close but is still takes me some extra time to grok. What extracting >> that to a method like this: >> >> Then /^I (should|should not) see the people search form$/ do >> |should_or_should_not| >> ?expect_that(response, should_or_should_not, have_tag('form#frmSearch')) >> end >> >> def expect_that(target, should_or_should_not, matcher) >> ?target.send should_or_should_not.underscore.to_sym, matcher >> end >> >> I definitely don't see this in Cucumber, BTW as "should" and "should >> not" are not the only way to express positive and negative >> expectations even in English, let alone other languages that might not >> deal w/ negation in such clean and consistent ways. >> >> And it's not the least number of characters you can type. But it's >> grok-able IMO. And DRY. And cute, to boot. >> >> Of course, if anybody can come up with one word other than "maybe" >> (damn you Ben Mabey for f'ing up my ability to type that word) to >> > > LOL... I seem to have that effect on people. :) ?But, think how I feel. ?Do > you know how many "witty" people I have met who tell some "maybe" joke and > think they are the first person to ever make it? ?Well, I can tell you that > it does, in fact, get very old. :) >> >> express should_or_should_not more succinctly, that might help reduce >> the typing. "Maybe" doesn't work for me because it implies lack of >> precision rather than choice (to me). >> > > Back on topic... ?I like this proposal the best. ?Having the > ?"should_or_should_not" makes it very clear what is happening. ?To reduce > typing I suppose you could call it "expectation" in the step definition... > and you could possibly even abbrevaite that more. e9n ??? s18t ??? > But I wold probably stick > with the more verbose "should_or_should_not". ?I also agree that this is > something that shouldn't be part of Cucumber itself but I'll probably play > around with it in my own projects. > > -Ben *Mabey* > > > >> Don't know how helpful this is, but it's fun to explore. >> >> David >> >> >>> >>> >>>> >>>> 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 >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 23 12:43:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 11:43:10 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> References: <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> Message-ID: <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> On Thu, Apr 23, 2009 at 11:08 AM, James Byrne wrote: > Another question: Where should metaclass.rb go; lib? lib/spec? or should > the method be put inside the spec_helper file? This is a utility for matchers to give good messages, so I'd put it in lib/spec/matchers I don't think we should call it metaclass though, but I'm not sure what I *do* want to call it. Metaclass != eigenclass, which is what this really is, so maybe eigenclass.rb - don't let that hang you up though, I can always change the names after. Thanks! David > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Thu Apr 23 13:22:23 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 23 Apr 2009 18:22:23 +0100 Subject: [rspec-users] About the use of Scenario Outline for validation stuff In-Reply-To: <22919ced0904230903j638b927cw983454726b269507@mail.gmail.com> References: <22919ced0904230903j638b927cw983454726b269507@mail.gmail.com> Message-ID: On 23 Apr 2009, at 17:03, J?r?my FRERE wrote: > Hi there ! > I was wondering if the way I test the validation of my forms is > right or not. So here's a little example : > Imagine you have a form with some validations designed to create > some object. You want to test it using Scenario Outline and > Examples. So you fill in the fields using , and press the > create button. Then you "should see" (using webrat) the > telling you > - that the object has been well created > - that some field isn't well filled > > And after that, in the objects list, you "should see" the created > object in the list > > Assuming that the object has been created, you will see it in the > list BUT if it has NOT been created, you won't. And, in my case, it > will end in an error > > So my questions are : > - Is it possible, using some trick, to use some conditions inside > the .feature file ? Don't forget you don't have to just use the subsitutions for field values - you can change any of the text in a step. So it's pretty easy to negate things: And the VAT "" be present in the VAT list Examples: | caption | value | message | might | | Normal | 19.6 | VAT Normal well created | should | | | 19.6 | You are supposed to fill the caption field | should not | | Normal | | You are supposed to fill the VAT field | should not | | Normal | test | You are supposed to fill the VAT field with a numeric value | should not | Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Thu Apr 23 14:19:42 2009 From: lists at ruby-forum.com (Fernando Perez) Date: Thu, 23 Apr 2009 20:19:42 +0200 Subject: [rspec-users] =?utf-8?q?Depot_app=2C_Demeter=27s_law_and_troubles?= =?utf-8?q?_cleanly_=09spe_cing?= In-Reply-To: References: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> Message-ID: Rails definitely entices you to break Demeter's law just so often. Now how to cleanly spec: @comment = @article.comments.build(params[:comment]) ? Mocking and stubbing is starting to get ugly now. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Apr 23 14:23:11 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 23 Apr 2009 14:23:11 -0400 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly spe cing In-Reply-To: References: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> Message-ID: <85d99afe0904231123s5c8ac02fte06d4fd8482eebb8@mail.gmail.com> On Thu, Apr 23, 2009 at 2:19 PM, Fernando Perez wrote: > Rails definitely entices you to break Demeter's law just so often. > > Now how to cleanly spec: > > @comment = @article.comments.build(params[:comment]) ? You think that's bad, I've seen many a code that looks like: project.tasks.map(&:responsible_party).group_by{ ... }.map....sort > > Mocking and stubbing is starting to get ugly now. > > -- > 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 (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From lists at ruby-forum.com Thu Apr 23 14:56:49 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 20:56:49 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> Message-ID: <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> David Chelimsky wrote: > > > I don't think we should call it metaclass though, but I'm not sure > what I *do* want to call it. Metaclass != eigenclass, which is what > this really is, so maybe eigenclass.rb - don't let that hang you up > though, I can always change the names after. > The thing is, Rails already defines #metaclass. So, I thought to check for that method before extending Object with my own. If Object.respond_to? :metaclass == true then we are in Rails, or some other framework that provides the same thing, and so we need not provide our own. Otherwise we add it. Comments? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Apr 23 15:00:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 14:00:49 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> References: <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> Message-ID: <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> On Thu, Apr 23, 2009 at 1:56 PM, James Byrne wrote: > David Chelimsky wrote: >> >> >> I don't think we should call it metaclass though, but I'm not sure >> what I *do* want to call it. Metaclass != eigenclass, which is what >> this really is, so maybe eigenclass.rb - don't let that hang you up >> though, I can always change the names after. >> > > The thing is, Rails already defines #metaclass. ?So, I thought to check > for that method before extending Object with my own. If > Object.respond_to? :metaclass == true then we are in Rails, or some > other framework that provides the same thing, and so we need not provide > our own. ?Otherwise we add it. > > Comments? I'd rather always define our own so the results are consistent from RSpec regardless of other frameworks in the midst. Does that make sense to you? > -- > 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 Thu Apr 23 15:05:40 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 21:05:40 +0200 Subject: [rspec-users] Style issue Message-ID: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> In one of my features I have to check to see if a file is created by an external script and then determine if that file contains specific information. So, I ended up with these step definitions: When /currency exchange rate transfer file should contain rates/ do found = false fx_code = 'USD' File.open(FOREX_XFR_FN).each do |line| found = true if /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) break if found end fail(ArgumentError, "Exchange Rate not found for #{fx_code}") if not found end When /currency exchange rate transfer file should exist/ do File.open(FOREX_XFR_FN) end These work well enough. What I want to know if this is considered a normal style for testing this sort of specification and if not then what is? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 23 15:22:56 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 21:22:56 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> Message-ID: <9baab86336ed15123f97deb53fe7e83b@ruby-forum.com> David Chelimsky wrote: > On Thu, Apr 23, 2009 at 1:56 PM, James Byrne > wrote: >> for that method before extending Object with my own. If >> Object.respond_to? :metaclass == true then we are in Rails, or some >> other framework that provides the same thing, and so we need not provide >> our own. ?Otherwise we add it. >> >> Comments? > > I'd rather always define our own so the results are consistent from > RSpec regardless of other frameworks in the midst. Does that make > sense to you? Yes. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 23 15:26:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 21:26:35 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> Message-ID: David Chelimsky wrote: > I'd rather always define our own so the results are consistent from > RSpec regardless of other frameworks in the midst. Does that make > sense to you? Instead of metaclass how about object_handle ? wdt? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Apr 23 15:31:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 14:31:50 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: References: <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> Message-ID: <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> On Thu, Apr 23, 2009 at 2:26 PM, James Byrne wrote: > David Chelimsky wrote: > >> I'd rather always define our own so the results are consistent from >> RSpec regardless of other frameworks in the midst. Does that make >> sense to you? > > Instead of metaclass how about object_handle ? > > wdt? Go for it. I think that's good enough for now. It's for internal consumption only. Also, I'm better at making naming decisions when I see things in context, I may change it later if I come up w/ something that speaks to me more clearly. Good? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From sfeley at gmail.com Thu Apr 23 15:40:20 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 23 Apr 2009 15:40:20 -0400 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly spe cing In-Reply-To: References: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> Message-ID: <1fb4df0904231240i47e1d39cv8c6f61e67f41bf8f@mail.gmail.com> On Thu, Apr 23, 2009 at 2:19 PM, Fernando Perez wrote: > Rails definitely entices you to break Demeter's law just so often. So fix it. It's usually just a matter of putting in some delegators. If you don't like @article.comments.build, you can declare your own Article.build_comment() method and simply have it point to the comment's method. Or call it something else if you don't like the word "build." (I don't.) > Now how to cleanly spec: > @comment = @article.comments.build(params[:comment]) ? That's backwards. If you already have a line of code and you're asking how to write a spec for it, you're not honoring the behavior. You're honoring that line of code. I'm going to guess from knowledge of the idiom that this is for a 'create' method in the CommentsController, nested under ArticlesController. Whether it calls 'comments.build' or 'comments.create' or 'make_me_a_comment!' isn't important and doesn't need to be specified. What's important is the end result of the method, which is that the article gains a shiny new comment: # Assume an article with no comments and a params structure # have already been set up in before(:each) it "should make a new comment belonging to the article" do post :create, :comment => @my_valid_params @my_article.should have(1).comment end How clean is that? Now just a couple more specs for *invalid* params and for where the method directs to, and you're basically done. > Mocking and stubbing is starting to get ugly now. That much is true. You'll notice I didn't mock or stub anything up there. I honestly think the controller code by the RSpec scaffold generator is the wrong approach; it's specing implementation, not behavior. Even worse, it's specing the implementation details of *model* code, which shouldn't even be a consideration here. My way breaks isolation (it hits the database) but it's a lot simpler and focuses on behavior. Is it possible to get behavior focus *and* isolation? I started to think about that. And then I realized, in accordance with the "If it's hard to spec you're probably doing it wrong" principle, that...well, Rails is probably doing it wrong. Controllers in Rails are just doing the Wrong Thing. That's why specing them is so painful, and why so many of us skip trying. What's the right way? I'm still pondering. Yeah, I'm a smartass. -- 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 Thu Apr 23 16:16:15 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 22:16:15 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> Message-ID: David Chelimsky wrote: > On Thu, Apr 23, 2009 at 2:26 PM, James Byrne > wrote: >> David Chelimsky wrote: >> >>> I'd rather always define our own so the results are consistent from >>> RSpec regardless of other frameworks in the midst. Does that make >>> sense to you? >> >> Instead of metaclass how about object_handle ? >> >> wdt? > > Go for it. I think that's good enough for now. It's for internal > consumption only. Also, I'm better at making naming decisions when I > see things in context, I may change it later if I come up w/ something > that speaks to me more clearly. > > Good? OK. I have made the changes to the code in a local branch. I just need to stick the object_handle method in the right place and get the revised specs to pass. I should have a patch for you tomorrow. If not, then by Monday. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Apr 23 16:17:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 15:17:42 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: References: <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> Message-ID: <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> On Thu, Apr 23, 2009 at 3:16 PM, James Byrne wrote: > David Chelimsky wrote: >> On Thu, Apr 23, 2009 at 2:26 PM, James Byrne >> wrote: >>> David Chelimsky wrote: >>> >>>> I'd rather always define our own so the results are consistent from >>>> RSpec regardless of other frameworks in the midst. Does that make >>>> sense to you? >>> >>> Instead of metaclass how about object_handle ? >>> >>> wdt? >> >> Go for it. I think that's good enough for now. It's for internal >> consumption only. Also, I'm better at making naming decisions when I >> see things in context, I may change it later if I come up w/ something >> that speaks to me more clearly. >> >> Good? > > OK. ?I have made the changes to the code in a local branch. ?I just need > to stick the object_handle method in the right place and get the revised > specs to pass. ?I should have a patch for you tomorrow. If not, then by > Monday. Cool. I may need to get a release out before the weekend due to other pressures, so this might not make it until the next release, but that won't be too far off. Thanks James, David > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 23 16:18:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Apr 2009 15:18:46 -0500 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> References: <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> Message-ID: <57c63afe0904231318m38d9da86v83ad0a11672a859c@mail.gmail.com> On Thu, Apr 23, 2009 at 3:17 PM, David Chelimsky wrote: > On Thu, Apr 23, 2009 at 3:16 PM, James Byrne wrote: >> David Chelimsky wrote: >>> On Thu, Apr 23, 2009 at 2:26 PM, James Byrne >>> wrote: >>>> David Chelimsky wrote: >>>> >>>>> I'd rather always define our own so the results are consistent from >>>>> RSpec regardless of other frameworks in the midst. Does that make >>>>> sense to you? >>>> >>>> Instead of metaclass how about object_handle ? >>>> >>>> wdt? >>> >>> Go for it. I think that's good enough for now. It's for internal >>> consumption only. Also, I'm better at making naming decisions when I >>> see things in context, I may change it later if I come up w/ something >>> that speaks to me more clearly. >>> >>> Good? >> >> OK. ?I have made the changes to the code in a local branch. ?I just need >> to stick the object_handle method in the right place and get the revised >> specs to pass. ?I should have a patch for you tomorrow. If not, then by >> Monday. > > Cool. I may need to get a release out before the weekend due to other > pressures, so this might not make it until the next release, but that > won't be too far off. BTW - FWIW, this is a classic example of how OSS should work. User gets frustrated. User solves problem through contribution. Thanks for playing! > > Thanks James, > David > >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From lists at ruby-forum.com Thu Apr 23 16:18:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 22:18:59 +0200 Subject: [rspec-users] Style issue In-Reply-To: <3c30da400904231259t79028ec9p706e0ecf49e0f65@mail.gmail.com> References: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> <3c30da400904231259t79028ec9p706e0ecf49e0f65@mail.gmail.com> Message-ID: <955b923e58b19bf146812c4505f313c8@ruby-forum.com> Mark Wilden wrote: > I find this more straighforward and easy to understand: > > When /currency exchange rate transfer file should contain rates/ do > fx_code = 'USD' > File.open(FOREX_XFR_FN).each do |line| > return true if > /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) > end > fail(ArgumentError, "Exchange Rate not found for #{fx_code}") > end > > ///ark If I do a return from inside the iterator then I get a jump error. It has to be break, which is how I ended up with what I did. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 23 16:20:44 2009 From: lists at ruby-forum.com (James Byrne) Date: Thu, 23 Apr 2009 22:20:44 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> Message-ID: <96ff8f46ec5cd576130fa1e81d06cf6b@ruby-forum.com> David Chelimsky wrote: > On Thu, Apr 23, 2009 at 3:16 PM, James Byrne > wrote: >>>> >> to stick the object_handle method in the right place and get the revised >> specs to pass. ?I should have a patch for you tomorrow. If not, then by >> Monday. > > Cool. I may need to get a release out before the weekend due to other > pressures, so this might not make it until the next release, but that > won't be too far off. > > Thanks James, > David NP -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Apr 23 20:11:48 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 23 Apr 2009 20:11:48 -0400 Subject: [rspec-users] Style issue In-Reply-To: <3c30da400904231259t79028ec9p706e0ecf49e0f65@mail.gmail.com> References: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> <3c30da400904231259t79028ec9p706e0ecf49e0f65@mail.gmail.com> Message-ID: <85d99afe0904231711hc0fd3fpfeaf635e9b078fc6@mail.gmail.com> On Thu, Apr 23, 2009 at 3:59 PM, Mark Wilden wrote: > ?On Thu, Apr 23, 2009 at 12:05 PM, James Byrne wrote: > >> When /currency exchange rate transfer file should contain rates/ do >> found = false >> fx_code = 'USD' >> File.open(FOREX_XFR_FN).each do |line| >> ? found = true if >> /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) >> ? break if found >> end >> fail(ArgumentError, "Exchange Rate not found for #{fx_code}") if not >> found >> end > > I find this more straighforward and easy to understand: > > ?When /currency exchange rate transfer file should contain rates/ do > ? fx_code = 'USD' > ? File.open(FOREX_XFR_FN).each do |line| > ??? return true if > /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) > ? end > ? fail(ArgumentError, "Exchange Rate not found for #{fx_code}") > ?end I'd even vote for the more concise form: When /currency exchange rate transfer file should contain rates/ do fx_code = 'USD' IO.readlines(FOREX_XFR_FN).any?{ |line| line.match /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/ } || fail ArgumentError, "Exchange Rate not found for #{fx_code}" unless found end > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From zach.dennis at gmail.com Thu Apr 23 20:13:15 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 23 Apr 2009 20:13:15 -0400 Subject: [rspec-users] Style issue In-Reply-To: <85d99afe0904231711hc0fd3fpfeaf635e9b078fc6@mail.gmail.com> References: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> <3c30da400904231259t79028ec9p706e0ecf49e0f65@mail.gmail.com> <85d99afe0904231711hc0fd3fpfeaf635e9b078fc6@mail.gmail.com> Message-ID: <85d99afe0904231713h79bfe7a2jac55d19a63a7fb7@mail.gmail.com> On Thu, Apr 23, 2009 at 8:11 PM, Zach Dennis wrote: > On Thu, Apr 23, 2009 at 3:59 PM, Mark Wilden wrote: >> ?On Thu, Apr 23, 2009 at 12:05 PM, James Byrne wrote: >> >>> When /currency exchange rate transfer file should contain rates/ do >>> found = false >>> fx_code = 'USD' >>> File.open(FOREX_XFR_FN).each do |line| >>> ? found = true if >>> /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) >>> ? break if found >>> end >>> fail(ArgumentError, "Exchange Rate not found for #{fx_code}") if not >>> found >>> end >> >> I find this more straighforward and easy to understand: >> >> ?When /currency exchange rate transfer file should contain rates/ do >> ? fx_code = 'USD' >> ? File.open(FOREX_XFR_FN).each do |line| >> ??? return true if >> /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) >> ? end >> ? fail(ArgumentError, "Exchange Rate not found for #{fx_code}") >> ?end > > I'd even vote for the more concise form: > > When /currency exchange rate transfer file should contain rates/ do > ?fx_code = 'USD' > ?IO.readlines(FOREX_XFR_FN).any?{ |line| > ? ?line.match /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/ > ?} || fail ArgumentError, "Exchange Rate not found for #{fx_code}" unless found > end Whoops, make that... When /currency exchange rate transfer file should contain rates/ do fx_code = 'USD' IO.readlines(FOREX_XFR_FN).any?{ |line| line.match /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/ } || fail(ArgumentError, "Exchange Rate not found for #{fx_code}") end > > >> >> ///ark >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com (personal) > http://www.mutuallyhuman.com (hire me) > @zachdennis (twitter) > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From matt at mattwynne.net Fri Apr 24 03:34:27 2009 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 24 Apr 2009 08:34:27 +0100 Subject: [rspec-users] Style issue In-Reply-To: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> References: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> Message-ID: <64D64348-AF68-4A53-A98A-D5571A6063D4@mattwynne.net> On 23 Apr 2009, at 20:05, James Byrne wrote: > In one of my features I have to check to see if a file is created by > an > external script and then determine if that file contains specific > information. So, I ended up with these step definitions: > > > When /currency exchange rate transfer file should contain rates/ do > found = false > fx_code = 'USD' > File.open(FOREX_XFR_FN).each do |line| > found = true if > /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line) > break if found > end > fail(ArgumentError, "Exchange Rate not found for #{fx_code}") if not > found > end > > When /currency exchange rate transfer file should exist/ do > File.open(FOREX_XFR_FN) > end > > > These work well enough. What I want to know if this is considered a > normal style for testing this sort of specification and if not then > what > is? Slightly off-topic, but it seems a bit weird to have the word 'should' in a When step to me. Are these really Then steps? Matt Wynne http://beta.songkick.com http://blog.mattwynne.net From lists at ruby-forum.com Fri Apr 24 03:54:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 24 Apr 2009 09:54:59 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904231318m38d9da86v83ad0a11672a859c@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> <57c63afe0904231318m38d9da86v83ad0a11672a859c@mail.gmail.com> Message-ID: <167f91b7f48c8c391827f8366ca0d498@ruby-forum.com> David Chelimsky wrote: > BTW - FWIW, this is a classic example of how OSS should work. User > gets frustrated. User solves problem through contribution. Thanks for > playing! Patch is on Lighthouse. https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/804 I did this on my laptop so some of the file modes are whacked (775 vice 664). It seems that I am not the first to encounter this since I found other library files in the repository that have mode 775. Nonetheless, you may wish to tidy this situation up. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Apr 24 09:26:25 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 24 Apr 2009 15:26:25 +0200 Subject: [rspec-users] Style issue In-Reply-To: <64D64348-AF68-4A53-A98A-D5571A6063D4@mattwynne.net> References: <7318af632ffd5296626df9b90b986e38@ruby-forum.com> <64D64348-AF68-4A53-A98A-D5571A6063D4@mattwynne.net> Message-ID: Matt Wynne wrote: > Slightly off-topic, but it seems a bit weird to have the word 'should' > in a When step to me. Are these really Then steps? > Actually, all of my step definitions are always Thens. This one is a cut & paste artifact that I overlooked. -- Posted via http://www.ruby-forum.com/. From pat.maddox at gmail.com Fri Apr 24 12:12:40 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Fri, 24 Apr 2009 09:12:40 -0700 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> Message-ID: <2c7e61990904240912r33696431j27afbf813405deb8@mail.gmail.com> On Wed, Apr 22, 2009 at 12:18 PM, David Chelimsky wrote: > On Wed, Apr 22, 2009 at 2:09 PM, James Byrne wrote: >> David Chelimsky wrote: >>> On Wed, Apr 22, 2009 at 1:45 PM, James Byrne >>> wrote: >>>> this worked: >>>> I am not throwing out RSpec or using it any less. ?I just had to get >>>> ? ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange >>>> Rates" >>>> >>>> ? ? ?(equal?: expected object is not the object returned, did you mean >>>> '==') >>>> ? ? ? (Spec::Expectations::ExpectationNotMetError) >>> >>> I can live with that. Do you want to make a patch? If not I'll just add >>> it. >> >> I'll try and make a patch first. ?If that does not work out then I will >> beg a boon of you to do it. >> >> I think that the error message should change too. Instead of: >> >> ? ? ? ?expected "Bank of Canada: Noon Foreign Exchange >> Rates" >> ? ? ? ? ? ? got "Bank of Canada: Noon Foreign Exchange >> Rates" >> >> An equal? failure probably should return the metaclass like: >> >> ? ? ? ?expected "#>" >> ? ? ? ? ? ? got "#>" >> >> yada yada.... >> >> WDYT? > > I like the idea, though I think it's helpful to also have the strings > in the case of String objects. But having the class and object id > would really help tell the story we're looking for. > > wdYt? I like this idea. Maybe you show the object id and a truncated string. i.e. expected "# (Four score and seven years...)" got "# (Four score and seven years...)" using equal? So it's clear that they're different objects, and you get a bit of context to figure out which string it's referring to. Pat From lists at ruby-forum.com Fri Apr 24 13:10:23 2009 From: lists at ruby-forum.com (James Byrne) Date: Fri, 24 Apr 2009 19:10:23 +0200 Subject: [rspec-users] Cucumber ".should contain(expected) does but fails anyway In-Reply-To: <167f91b7f48c8c391827f8366ca0d498@ruby-forum.com> References: <59a965469f27c851d87e6e68f13e2956@ruby-forum.com> <57c63afe0904220812i1c46e953occ0a4bc8cd279a35@mail.gmail.com> <57c63afe0904220944x2abbf919y7a47b8cc80cd7b39@mail.gmail.com> <57c63afe0904221149q70c5fd9al6f18f57ee1c768ad@mail.gmail.com> <60c7c8eb8ecefbcd5c90c72421124866@ruby-forum.com> <57c63afe0904221218q320827dpeb2ef5695213bfb9@mail.gmail.com> <2b5bb95396c2d2e4855050d2fcd2bd84@ruby-forum.com> <38a6bffd082fec677a8517daba8a49ce@ruby-forum.com> <57c63afe0904230943g9e3e6ebyddf828ae31e61193@mail.gmail.com> <5e37f2e7d8d423ce9135a0516203c3b7@ruby-forum.com> <57c63afe0904231200j217415ccib872dee3f50530a5@mail.gmail.com> <57c63afe0904231231j30c3e1d0sf9a99147398da109@mail.gmail.com> <57c63afe0904231317t671838fo3ae01e70e3fdafd6@mail.gmail.com> <57c63afe0904231318m38d9da86v83ad0a11672a859c@mail.gmail.com> <167f91b7f48c8c391827f8366ca0d498@ruby-forum.com> Message-ID: James Byrne wrote: > > Patch is on Lighthouse. > > https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/804 > Besides Fixnum, are there any other Ruby Class Objects that do not have a virtual class? -- Posted via http://www.ruby-forum.com/. From Paul.Kelly at infineon.com Fri Apr 24 13:32:41 2009 From: Paul.Kelly at infineon.com (Paul.Kelly at infineon.com) Date: Fri, 24 Apr 2009 19:32:41 +0200 Subject: [rspec-users] rspec-rails fails to find a controller name Message-ID: <7EF868A200A2644A9A9DA85C5346C97704BC8D8E45@mucse405.eu.infineon.com> Hi, I have a problem that seems a bit strange. No matter how I specify the controller name in a rails controller rspec I am always presented with 'HostController Retrieving /host via GET should redirect if not logged in' FAILED Controller specs need to know what controller is being specified. You can indicate this by passing the controller to describe(): describe MyController do or by declaring the controller's name describe "a MyController" do controller_name :my #invokes the MyController end This is the result of running this command over this file Command : spec -c -fs spec/controllers/host_controller_spec.rb File: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HostController, "Retrieving /host via GET" do integrate_views controller_name :host it "should redirect if not logged in" do #session[:user] = nil #get :index #response.should redirect_to("/user/login") end end In have tried this with and without the text string after the controller name on the describe line. I have also tried it with and without the controller_name directive. It always gives this message. What am I doing wrong?!?!? Rails version 2.0.2 Rpec version 1.2.4 and 1.2.0 Rpsec-rails version 1.2.4 and 1.2.0 Thanks a lot if you can help in any way. Paul.kelly at infineon.com From wolfmanjm at gmail.com Fri Apr 24 18:22:30 2009 From: wolfmanjm at gmail.com (Jim Morris) Date: Fri, 24 Apr 2009 15:22:30 -0700 (PDT) Subject: [rspec-users] Background and scenario outline interaction Message-ID: <1b13c4d1-7e7a-4f24-93cc-594ad1e39f05@x29g2000prf.googlegroups.com> Hi, I was surprised by this so I suspect it may be a bug. I have a Scenario Outline, and a Background in my Feature and nothing else, The Background got executed 1 more time than expected. Details are the Scenario Outline had 4 entries in the table, so I expected 4 scenarios to get executed, and the Background to get executed before each Scenario. What happened was the Background got executed once initially, then once for each entry on the outline table, the After scenario hook got correctly executed after each of the 4 scenarios, but not after the first Background (understandably as there was no scenario executed). Is this a bug or feature ;) From phlip2005 at gmail.com Sat Apr 25 00:07:21 2009 From: phlip2005 at gmail.com (Phlip) Date: Fri, 24 Apr 2009 21:07:21 -0700 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? Message-ID: Cucumberists: The sample code: require 'treetop' require 'cucumber' require 'cucumber/parser' require 'cucumber/parser/treetop_ext' # too many requires because fishing around! include Cucumber include Parser include Feature @parser = FeatureParser.new exp = @parser.parse_or_fail(%{# My comment Feature: hi }) The error message: NameError: undefined local variable or method `_nt_scenario_outline_keyword' for # cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in `_nt_scenario_outline' cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in `_nt_feature' cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in `loop' ... Okay, how do I just whip out the parser and have it parse raw Cuke code? -- Phlip http://flea.sourceforge.net/resume.html From programmer2188 at gmail.com Sat Apr 25 00:22:03 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 25 Apr 2009 00:22:03 -0400 Subject: [rspec-users] BDD for C#? Message-ID: <000801c9c55d$63996f00$2acc4d00$@com> Hi, I know this is slightly off topic, but I'm having trouble finding something, and wondered if anyone here had experience with any BDD frameworks for C#. I found NBehave (http://www.codeplex.com/NBehave), but it seems a little out of date (last release says 2007 I think). I also found this post (http://www.lostechies.com/blogs/joe_ocampo/archive/2008/02/26/updates-to-nb ehave.aspx) which has a different syntax, but can't find what has happened to it since that post. Also, I really hate that the methods use underscores, though I don't know if that's their convention, or a requirement. Does anyone else here use C#? What do you use for testing / specs? Thanks, Brandon www.perpetualseeker.com Blog about college, programming, and other random things. Follow me on Twitter: http://twitter.com/devbanana From jonathan at parkerhill.com Sat Apr 25 00:46:08 2009 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Sat, 25 Apr 2009 00:46:08 -0400 Subject: [rspec-users] rspec-rails fails to find a controller name In-Reply-To: <7EF868A200A2644A9A9DA85C5346C97704BC8D8E45@mucse405.eu.infineon.com> References: <7EF868A200A2644A9A9DA85C5346C97704BC8D8E45@mucse405.eu.infineon.com> Message-ID: I assume you tried it with the 3 lines (including get :index) uncommented On Apr 24, 2009, at 1:32 PM, wrote: > Hi, > I have a problem that seems a bit strange. No matter how I specify > the controller name in a rails controller rspec I am always > presented with > > 'HostController Retrieving /host via GET should redirect if not > logged in' FAILED > Controller specs need to know what controller is being specified. > You can > indicate this by passing the controller to describe(): > > describe MyController do > > or by declaring the controller's name > > describe "a MyController" do > controller_name :my #invokes the MyController > end > > This is the result of running this command over this file > > Command : spec -c -fs spec/controllers/host_controller_spec.rb > File: > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe HostController, "Retrieving /host via GET" do > integrate_views > controller_name :host > it "should redirect if not logged in" do > #session[:user] = nil > #get :index > #response.should redirect_to("/user/login") > end > end > > In have tried this with and without the text string after the > controller name on the describe line. I have also tried it with and > without the controller_name directive. It always gives this > message. What am I doing wrong?!?!? > > Rails version 2.0.2 > > Rpec version 1.2.4 and 1.2.0 > Rpsec-rails version 1.2.4 and 1.2.0 > > Thanks a lot if you can help in any way. > > Paul.kelly at infineon.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Sat Apr 25 02:11:40 2009 From: ben at benmabey.com (Ben Mabey) Date: Sat, 25 Apr 2009 00:11:40 -0600 Subject: [rspec-users] BDD for C#? In-Reply-To: <000801c9c55d$63996f00$2acc4d00$@com> References: <000801c9c55d$63996f00$2acc4d00$@com> Message-ID: <49F2A99C.60701@benmabey.com> Brandon Olivares wrote: > Hi, > > I know this is slightly off topic, but I'm having trouble finding something, > and wondered if anyone here had experience with any BDD frameworks for C#. > > I found NBehave (http://www.codeplex.com/NBehave), but it seems a little out > of date (last release says 2007 I think). I also found this post > (http://www.lostechies.com/blogs/joe_ocampo/archive/2008/02/26/updates-to-nb > ehave.aspx) which has a different syntax, but can't find what has happened > to it since that post. Also, I really hate that the methods use underscores, > though I don't know if that's their convention, or a requirement. > > Does anyone else here use C#? What do you use for testing / specs? > > Thanks, > Brandon > > > I haven't used C# for years, so I don't have any experience with BDD frameworks in it but you might want to check out MSpec: http://github.com/machine/machine.specifications/tree/master http://codebetter.com/blogs/aaron.jensen/archive/2008/05/08/introducing-machine-specifications-or-mspec-for-short.aspx You may also want to post your question to the BDD google group: http://groups.google.com/group/behaviordrivendevelopment?hl=en HTH, Ben From aslak.hellesoy at gmail.com Sat Apr 25 04:05:57 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Sat, 25 Apr 2009 10:05:57 +0200 Subject: [rspec-users] Background and scenario outline interaction In-Reply-To: <1b13c4d1-7e7a-4f24-93cc-594ad1e39f05@x29g2000prf.googlegroups.com> References: <1b13c4d1-7e7a-4f24-93cc-594ad1e39f05@x29g2000prf.googlegroups.com> Message-ID: Den 25. april. 2009 kl. 00.22 skrev Jim Morris : > Hi, > > I was surprised by this so I suspect it may be a bug. > > I have a Scenario Outline, and a Background in my Feature and nothing > else, > > The Background got executed 1 more time than expected. > > Details are the Scenario Outline had 4 entries in the table, so I > expected 4 scenarios to get executed, and the Background to get > executed before each Scenario. > > What happened was the Background got executed once initially, then > once for each entry on the outline table, the After scenario hook got > correctly executed after each of the 4 scenarios, but not after the > first Background (understandably as there was no scenario executed). > Gist.github.com feature, output and expected output please Aslak > Is this a bug or feature ;) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From tom at experthuman.com Sat Apr 25 04:16:43 2009 From: tom at experthuman.com (Tom Stuart) Date: Sat, 25 Apr 2009 09:16:43 +0100 Subject: [rspec-users] But rspec can not be found In-Reply-To: <5c0ff4978321c0cc9d405a9625eb5c03@ruby-forum.com> References: <57c63afe0904170335l4f37186dwddc6111f889319c3@mail.gmail.com> <80F73DB4-5D7E-4305-AA35-111B8E12B153@experthuman.com> <57c63afe0904172108q75fbec13ne096a245484f54c8@mail.gmail.com> <5c0ff4978321c0cc9d405a9625eb5c03@ruby-forum.com> Message-ID: <85C945C8-E312-4F49-A600-8877E1D92467@experthuman.com> On 22 Apr 2009, at 14:51, Kerstin Geiling wrote: > actually I had the same problems > I solved it now using the old task file from rspec-rails 1.2.0 and > it works. > Thanks to Tom for making this issue public! I've opened a ticket in Lighthouse for this issue: http://rspec.lighthouseapp.com/projects/5645/tickets/807-rspecrake-no-longer-supports-rspec-plugin Cheers, -Tom From phlip2005 at gmail.com Sat Apr 25 06:50:29 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 25 Apr 2009 03:50:29 -0700 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> Message-ID: aslak hellesoy wrote: > Try this: > > require 'cucumber' > > Cucumber.load_language('en') > p = Cucumber::Parser::FeatureParser.new > f = p.parse_or_fail <<-EOF > Feature: Foo > Scenario: Bar > Given Zap > EOF > > Aslak Nope! Exact same error. Should I get the bench version? (It's 0.3.0 now.) -- Phlip http://flea.sourceforge.net/resume.html From phlip2005 at gmail.com Sat Apr 25 07:10:24 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 25 Apr 2009 04:10:24 -0700 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> Message-ID: Phlip wrote: > aslak hellesoy wrote: > >> Try this: >> >> require 'cucumber' >> >> Cucumber.load_language('en') >> p = Cucumber::Parser::FeatureParser.new >> f = p.parse_or_fail <<-EOF >> Feature: Foo >> Scenario: Bar >> Given Zap >> EOF >> >> Aslak > > Nope! Exact same error. Should I get the bench version? (It's 0.3.0 now.) That sample works in a standalone script, and does not work in a Rails unit test: require File.dirname(__FILE__) + '/../test_helper' class CukeFeatureParser < ActiveSupport::TestCase def test_parser require 'cucumber' Cucumber.load_language('en') p = Cucumber::Parser::FeatureParser.new f = p.parse_or_fail <<-EOF Feature: Foo Scenario: Bar Given Zap EOF end end -- Phlip http://flea.sourceforge.net/resume.html From aslak.hellesoy at gmail.com Sat Apr 25 08:51:38 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Sat, 25 Apr 2009 14:51:38 +0200 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> Message-ID: <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> Den 25. april. 2009 kl. 13.10 skrev Phlip : > Phlip wrote: >> aslak hellesoy wrote: >>> Try this: >>> >>> require 'cucumber' >>> >>> Cucumber.load_language('en') >>> p = Cucumber::Parser::FeatureParser.new >>> f = p.parse_or_fail <<-EOF >>> Feature: Foo >>> Scenario: Bar >>> Given Zap >>> EOF >>> >>> Aslak >> Nope! Exact same error. Should I get the bench version? (It's 0.3.0 >> now.) > > That sample works in a standalone script, and does not work in a > Rails unit test: > > require File.dirname(__FILE__) + '/../test_helper' > > class CukeFeatureParser < ActiveSupport::TestCase > > def test_parser > > require 'cucumber' > > Cucumber.load_language('en') > p = Cucumber::Parser::FeatureParser.new > f = p.parse_or_fail <<-EOF > Feature: Foo > Scenario: Bar > Given Zap > EOF > > end > end > Please explain how it doesn't work. Output, error etc. Aslak > -- > Phlip > http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From j.mcguinness at bigpond.com Sat Apr 25 06:43:09 2009 From: j.mcguinness at bigpond.com (jmac) Date: Sat, 25 Apr 2009 03:43:09 -0700 (PDT) Subject: [rspec-users] automating and end to end functional test. Message-ID: Hi, I am new to ruby and rspec. I would like to use ruby/rspec/cucumber to automate acceptance tests for a number of integrated systems at my work. I get the basics of cucumber features, but how do I chain these tests so that I can test a process from start to finish. Essentially, I want to use the features as components that I can plug together to create the different tests. Can cucumber/rspec be used this way. From dchelimsky at gmail.com Sat Apr 25 09:11:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 25 Apr 2009 08:11:54 -0500 Subject: [rspec-users] automating and end to end functional test. In-Reply-To: References: Message-ID: <57c63afe0904250611r20aec29dhf7a12ad5e693874f@mail.gmail.com> On Sat, Apr 25, 2009 at 5:43 AM, jmac wrote: > Hi, > I am new to ruby and rspec. I would like to use ruby/rspec/cucumber to > automate acceptance tests for a number of integrated systems at my > work. I get the basics of cucumber features, but how do I chain these > tests so that I can test a process from start to finish. Essentially, > I want to use the features as components that I can plug together to > create the different tests. Can cucumber/rspec be used this way. Can you give an example. Something simple, but just complex enough to get your goal across. I have an idea of what you're after, but don't want to waste my time writing or anybody else's time reading if I'm wrong :) From dchelimsky at gmail.com Sat Apr 25 09:25:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 25 Apr 2009 08:25:38 -0500 Subject: [rspec-users] rspec-rails fails to find a controller name In-Reply-To: <7EF868A200A2644A9A9DA85C5346C97704BC8D8E45@mucse405.eu.infineon.com> References: <7EF868A200A2644A9A9DA85C5346C97704BC8D8E45@mucse405.eu.infineon.com> Message-ID: <57c63afe0904250625w9b59dddw1ba04876777e53f4@mail.gmail.com> On Fri, Apr 24, 2009 at 12:32 PM, wrote: > Hi, > ? ? ? ?I have a problem that seems a bit strange. No matter how I specify the controller name in a rails controller rspec I am always presented with > > 'HostController Retrieving /host via GET should redirect if not logged in' FAILED > Controller specs need to know what controller is being specified. You can > indicate this by passing the controller to describe(): > > ?describe MyController do > > or by declaring the controller's name > > ?describe "a MyController" do > ? ?controller_name :my #invokes the MyController > end > > This is the result of running this command over this file > > Command : spec -c -fs spec/controllers/host_controller_spec.rb > File: > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe HostController, "Retrieving /host via GET" do > ?integrate_views > ?controller_name :host > ?it "should redirect if not logged in" do > ? ?#session[:user] = nil > ? ?#get :index > ? ?#response.should redirect_to("/user/login") > ?end > end > > ?In have tried this with and without the text string after the controller name on the describe line. I have also tried it with and without the controller_name directive. It always gives this message. What am I doing wrong?!?!? > > Rails version 2.0.2 The oldest rails supported by rspec-1.2.x is rails-2.0.5. Your options are to either upgrade your rails app to 2.0.5, which is what I'd recommend (path of least resistance since you're not crossing a minor version boundary) or to downgrade rspec to pre 1.2. Good luck. Cheers, David > > Rpec version 1.2.4 and 1.2.0 > Rpsec-rails version 1.2.4 and 1.2.0 > > Thanks a lot if you can help in any way. > > ? ? ? ?Paul.kelly at infineon.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sat Apr 25 09:28:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 25 Apr 2009 08:28:10 -0500 Subject: [rspec-users] rspec-rails fails to find a controller name In-Reply-To: <57c63afe0904250625w9b59dddw1ba04876777e53f4@mail.gmail.com> References: <7EF868A200A2644A9A9DA85C5346C97704BC8D8E45@mucse405.eu.infineon.com> <57c63afe0904250625w9b59dddw1ba04876777e53f4@mail.gmail.com> Message-ID: <57c63afe0904250628k754f166ay797a120fb73c6035@mail.gmail.com> On Sat, Apr 25, 2009 at 8:25 AM, David Chelimsky wrote: > On Fri, Apr 24, 2009 at 12:32 PM, ? wrote: >> Hi, >> ? ? ? ?I have a problem that seems a bit strange. No matter how I specify the controller name in a rails controller rspec I am always presented with >> >> 'HostController Retrieving /host via GET should redirect if not logged in' FAILED >> Controller specs need to know what controller is being specified. You can >> indicate this by passing the controller to describe(): >> >> ?describe MyController do >> >> or by declaring the controller's name >> >> ?describe "a MyController" do >> ? ?controller_name :my #invokes the MyController >> end >> >> This is the result of running this command over this file >> >> Command : spec -c -fs spec/controllers/host_controller_spec.rb >> File: >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> describe HostController, "Retrieving /host via GET" do >> ?integrate_views >> ?controller_name :host >> ?it "should redirect if not logged in" do >> ? ?#session[:user] = nil >> ? ?#get :index >> ? ?#response.should redirect_to("/user/login") >> ?end >> end >> >> ?In have tried this with and without the text string after the controller name on the describe line. I have also tried it with and without the controller_name directive. It always gives this message. What am I doing wrong?!?!? >> >> Rails version 2.0.2 > > The oldest rails supported by rspec-1.2.x is rails-2.0.5. Your options > are to either upgrade your rails app to 2.0.5, which is what I'd > recommend (path of least resistance since you're not crossing a minor > version boundary) or to downgrade rspec to pre 1.2. BTW, I was able to reproduce the behaviour you describe with rspec-1.2.4 and rails-2.0.2, so there is an incompatibility there (i.e. it's not something else that you're missing or is specific to your particular app or environment) > > Good luck. > > Cheers, > David > >> >> Rpec version 1.2.4 and 1.2.0 >> Rpsec-rails version 1.2.4 and 1.2.0 >> >> Thanks a lot if you can help in any way. >> >> ? ? ? ?Paul.kelly at infineon.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From phlip2005 at gmail.com Sat Apr 25 11:00:56 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 25 Apr 2009 08:00:56 -0700 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> Message-ID: Aslak Helles?y wrote: >> require File.dirname(__FILE__) + '/../test_helper' >> >> class CukeFeatureParser < ActiveSupport::TestCase >> >> def test_parser >> >> require 'cucumber' >> >> Cucumber.load_language('en') >> p = Cucumber::Parser::FeatureParser.new >> f = p.parse_or_fail <<-EOF >> Feature: Foo >> Scenario: Bar >> Given Zap >> EOF >> >> end >> end >> > > Please explain how it doesn't work. Output, error etc. Same as before: $ ruby test/unit/cuke_test.rb Loaded suite test/unit/cuke_test Started E Finished in 0.127149 seconds. 1) Error: test_parser(CukeFeatureParser): NameError: undefined local variable or method `_nt_scenario_outline_keyword' for # cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in `_nt_scenario_outline' cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in `_nt_feature' cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in `loop' cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in `_nt_feature' treetop (1.2.5) lib/treetop/runtime/compiled_parser.rb:18:in `send' treetop (1.2.5) lib/treetop/runtime/compiled_parser.rb:18:in `parse' cucumber (0.3.0) lib/cucumber/parser/treetop_ext.rb:79:in `parse_or_fail' test/unit/cuke_test.rb:12:in `test_parser' 1 tests, 0 assertions, 0 failures, 1 errors -- Phlip http://flea.sourceforge.net/resume.html From programmer2188 at gmail.com Sat Apr 25 20:28:17 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sat, 25 Apr 2009 20:28:17 -0400 Subject: [rspec-users] BDD for C#? In-Reply-To: <49F2A99C.60701@benmabey.com> References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> Message-ID: <000101c9c605$e5be7450$b13b5cf0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Ben Mabey > Sent: Saturday, April 25, 2009 2:12 AM > To: rspec-users > Subject: Re: [rspec-users] BDD for C#? > > Brandon Olivares wrote: > > Hi, > > > > I know this is slightly off topic, but I'm having trouble finding > something, > > and wondered if anyone here had experience with any BDD frameworks > for C#. > > > > I found NBehave (http://www.codeplex.com/NBehave), but it seems a > little out > > of date (last release says 2007 I think). I also found this post > > > (http://www.lostechies.com/blogs/joe_ocampo/archive/2008/02/26/updates- > to-nb > > ehave.aspx) which has a different syntax, but can't find what has > happened > > to it since that post. Also, I really hate that the methods use > underscores, > > though I don't know if that's their convention, or a requirement. > > > > Does anyone else here use C#? What do you use for testing / specs? > > > > Thanks, > > Brandon > > > > > > > I haven't used C# for years, so I don't have any experience with BDD > frameworks in it but you might want to check out MSpec: > > http://github.com/machine/machine.specifications/tree/master > > http://codebetter.com/blogs/aaron.jensen/archive/2008/05/08/introducing > -machine-specifications-or-mspec-for-short.aspx > > You may also want to post your question to the BDD google group: > > http://groups.google.com/group/behaviordrivendevelopment?hl=en > > HTH, > Ben Thanks a lot for the links. I didn't realize there was a BDD group, which is why I posted here, but I will check that out, too. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users www.perpetualseeker.com Blog about college, programming, and other random things. Follow me on Twitter: http://twitter.com/devbanana From phlip2005 at gmail.com Sun Apr 26 01:06:15 2009 From: phlip2005 at gmail.com (Phlip) Date: Sat, 25 Apr 2009 22:06:15 -0700 Subject: [rspec-users] BDD for C#? In-Reply-To: <000101c9c605$e5be7450$b13b5cf0$@com> References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> <000101c9c605$e5be7450$b13b5cf0$@com> Message-ID: Brandon Olivares wrote: > I know this is slightly off topic, but I'm having trouble finding > something, > and wondered if anyone here had experience with any BDD frameworks > for C#. Why not replicate Cucumber in C#? Not port or link, replicate. It's only like ~10 features, right? I don't know C#, but I could do it in C++ in a couple days. -- Phlip http://flea.sourceforge.net/resume.html From lee_longmore at yahoo.co.uk Sun Apr 26 02:47:23 2009 From: lee_longmore at yahoo.co.uk (Lee Longmore) Date: Sun, 26 Apr 2009 06:47:23 +0000 (GMT) Subject: [rspec-users] Cucumber/RSpec for an existing Rails project - generate rspec models and controllers? Message-ID: <323959.9302.qm@web23903.mail.ird.yahoo.com> Hi, I would like to use Cucumber and RSpec for my existing Rails project. I am now reasonably comfortable with the use of these, having studied the RSpec Book and various online resources. I am however unsure about one thing... Given that I have several existing models and controllers in my code base, how do I synch RSpec with these? That is, do I need to generate RSpec models and controllers for each of these existing models and controllers? If so, is there I anything I should be aware of when doing so? Many thanks, Lee. mobile: +44(0)775 392 8067 home: +44(0) 208 8358256 email: lee_longmore at yahoo.co.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Apr 26 05:02:43 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 26 Apr 2009 04:02:43 -0500 Subject: [rspec-users] Cucumber/RSpec for an existing Rails project - generate rspec models and controllers? In-Reply-To: <323959.9302.qm@web23903.mail.ird.yahoo.com> References: <323959.9302.qm@web23903.mail.ird.yahoo.com> Message-ID: <57c63afe0904260202v1d1c7104t28dd496f80383f06@mail.gmail.com> On Sun, Apr 26, 2009 at 1:47 AM, Lee Longmore wrote: > > Hi, > > I would like to use Cucumber and RSpec for my existing Rails project. > > I am now reasonably comfortable with the use of these, having studied the > RSpec Book and various online resources. I am however unsure about one > thing... > > Given that I have several existing models and controllers in my code base, > how do I synch RSpec with these? > > That is, do I need to generate RSpec models and controllers for each of > these existing models and controllers? If you already have code in place, I would recommend adding specs by hand instead of using the generators. > If so, is there I anything I should be aware of when doing so? Back-filling specs onto pre-existing code is a very different animal from driving out code with specs first. There is a book called Working Effectively with Legacy Code by Michael Feathers that deals with this topic very thoroughly. You might not think what you have is legacy code, but Michael (actually, Erik Meade, but in the WELC book), defines legacy code as any code without tests. Part of the premise of TDD (with a T) is that by writing tests and code in a tight cycle (small bit of test, small bit of code to make it pass, refactor), the resulting code is inherently testable. When you're backfilling tests, this is not necessarily the case. So the trick is to add the tests slowly, and *pay attention to the code* as you're doing so. If something is hard to test then use the opportunity to make it easier to test. Of course doing so is refactoring without tests, which is something to be avoided. So you've got a catch 22. And that's where the legacy code book can really help, as it offers a number of techniques and strategies to address this problem. So I'd recommend picking that up. Short of buying the book, the basic idea is that whenever you're modifying your existing code, find all the high level features that might be impacted and add cucumber scenarios for them first. Once those are in place, drive out the changes and/or new code spec first. With this strategy, you'll gradually improve the code base by getting it under test and refactoring as you go. This is more pain-staking than doing a one-time full coverage sort of thing, but in the end the result is going to be cleaner and better for you (and probably less work in the long run). Cheers, David > > Many thanks, > > Lee. > > mobile: +44(0)775 392 8067 > home: +44(0) 208 8358256 > email:?? lee_longmore at yahoo.co.uk > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From kero at chello.nl Sun Apr 26 08:16:49 2009 From: kero at chello.nl (Kero van Gelder) Date: Sun, 26 Apr 2009 14:16:49 +0200 Subject: [rspec-users] [Cucumber] gem missing dependencies Message-ID: <20090426121649.GA8422@bumblebee.m38c.nl> Hi! Looks like installing hoe (which brings in rubyforge and rake) solved the problem below. Who builds the gem / should I report this to / should I send a patch ? Bye, Kero. --- fresh install of debian lenny, upgraded to unstable. $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] $ gem -v 1.2.0 $ gem list *** LOCAL GEMS *** builder (2.1.2) cucumber (0.3.0) diff-lcs (1.1.2) polyglot (0.2.5) rspec (1.2.4) term-ansicolor (1.0.3) treetop (1.2.5) $ cucumber /usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find RubyGem hoe (>= 1.8.0) (Gem::LoadError) from /usr/lib/ruby/1.8/rubygems.rb:134:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:49:in `gem' from /var/lib/gems/1.8/bin/cucumber:18 From aslak.hellesoy at gmail.com Sun Apr 26 10:34:26 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 26 Apr 2009 16:34:26 +0200 Subject: [rspec-users] [Cucumber] gem missing dependencies In-Reply-To: <20090426121649.GA8422@bumblebee.m38c.nl> References: <20090426121649.GA8422@bumblebee.m38c.nl> Message-ID: <8d961d900904260734t24032535pbfc8d18812d3f3de@mail.gmail.com> On Sun, Apr 26, 2009 at 2:16 PM, Kero van Gelder wrote: > Hi! > > Looks like installing hoe (which brings in rubyforge and rake) solved the problem below. > Who builds the gem / should I report this to / should I send a patch ? > I just fixed that: http://github.com/aslakhellesoy/cucumber/commit/23cbc9b6c54ebe1ecf568610c2696762f22f0b06 Aslak > Bye, > Kero. > > --- > > fresh install of debian lenny, upgraded to unstable. > > $ ruby -v > ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] > $ gem -v > 1.2.0 > $ gem list > > *** LOCAL GEMS *** > > builder (2.1.2) > cucumber (0.3.0) > diff-lcs (1.1.2) > polyglot (0.2.5) > rspec (1.2.4) > term-ansicolor (1.0.3) > treetop (1.2.5) > $ cucumber > /usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find RubyGem hoe (>= 1.8.0) (Gem::LoadError) > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:134:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:49:in `gem' > ? ? ? ?from /var/lib/gems/1.8/bin/cucumber:18 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sun Apr 26 11:04:54 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 26 Apr 2009 17:04:54 +0200 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> Message-ID: <8d961d900904260804i810a0f8q18ddc7663475727e@mail.gmail.com> On Sat, Apr 25, 2009 at 5:00 PM, Phlip wrote: > Aslak Helles?y wrote: > >>> require File.dirname(__FILE__) + '/../test_helper' >>> >>> class CukeFeatureParser < ActiveSupport::TestCase >>> >>> ?def test_parser >>> >>> require 'cucumber' >>> >>> Cucumber.load_language('en') >>> p = Cucumber::Parser::FeatureParser.new >>> f = p.parse_or_fail <<-EOF >>> Feature: Foo >>> ?Scenario: Bar >>> ? Given Zap >>> EOF >>> >>> ?end >>> end >>> >> >> Please explain how it doesn't work. Output, error etc. > > Same as before: > > $ ruby test/unit/cuke_test.rb > Loaded suite test/unit/cuke_test > Started > E > Finished in 0.127149 seconds. > > ?1) Error: > test_parser(CukeFeatureParser): > NameError: undefined local variable or method `_nt_scenario_outline_keyword' The #_nt_scenario_outline_keyword method comes from Ruby code that is dynamically generated by Treetop while parsing the i18n.tt file. The i18n.tt file parsed when you call Cucumber.load_parser (which substitutes i18n keywords before passing it to Treetop). I'm not sure what's going on with your code. It works for me - also in a Rails environment: http://github.com/aslakhellesoy/cucumber_rails/commit/78b36a704279fab7e7ad47ccc3825916e5e9622c What happens when you run the test I added here? Aslak > for # > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in > `_nt_scenario_outline' > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in `_nt_feature' > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in `loop' > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in `_nt_feature' > ? ?treetop (1.2.5) lib/treetop/runtime/compiled_parser.rb:18:in `send' > ? ?treetop (1.2.5) lib/treetop/runtime/compiled_parser.rb:18:in `parse' > ? ?cucumber (0.3.0) lib/cucumber/parser/treetop_ext.rb:79:in `parse_or_fail' > ? ?test/unit/cuke_test.rb:12:in `test_parser' > > 1 tests, 0 assertions, 0 failures, 1 errors > > -- > ?Phlip > ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From programmer2188 at gmail.com Sun Apr 26 12:04:51 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 26 Apr 2009 12:04:51 -0400 Subject: [rspec-users] BDD for C#? In-Reply-To: References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> <000101c9c605$e5be7450$b13b5cf0$@com> Message-ID: <00a901c9c688$bc2b3550$34819ff0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Phlip > Sent: Sunday, April 26, 2009 1:06 AM > To: rspec-users at rubyforge.org > Subject: Re: [rspec-users] BDD for C#? > > Brandon Olivares wrote: > > > I know this is slightly off topic, but I'm having trouble finding > > something, > > and wondered if anyone here had experience with any BDD frameworks > > for C#. > > Why not replicate Cucumber in C#? > > Not port or link, replicate. It's only like ~10 features, right? I > don't know > C#, but I could do it in C++ in a couple days. > I'm not sure I'd be interested in that. I mean I'm creating a GUI application, so I'm not really sure how Cucumber could work with that. Well to be more specific, I'm creating a game for blind people, so it's purely sound output and keyboard control. But either way I don't see how Cucumber could work with it. More interested in RSpec for testing the logic. Though I am curious if you know of some way I could use Cucumber as well. Right now looking at either nBehave or SpecUnit.NET. I will miss the nested contexts of RSpec though. Brandon > -- > Phlip > http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users www.perpetualseeker.com Blog about college, programming, and other random things. Follow me on Twitter: http://twitter.com/devbanana From rick.denatale at gmail.com Sun Apr 26 14:53:44 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 26 Apr 2009 14:53:44 -0400 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle Message-ID: I finally plunked down for the beta RSpec bundle and I'm working through the initial example. Although I'm a fairly experienced RSpec user, I'm stlll learning new tricks. Anyway, I'm going though the mastermind example, and everything is going well, except that I decided to also try out the Textmate bundle for Cucumber. I decided to use Ben Mabey's fork on github since it seems to be the most evolved. When I try to run a feature with cmd-R, instead of actually running I see something like: Running: cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html false Cucumber runs fine from bash. Am I missing some setup? -- 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 From dchelimsky at gmail.com Sun Apr 26 17:17:42 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 26 Apr 2009 16:17:42 -0500 Subject: [rspec-users] RSPEC book example in Chapter 3. In-Reply-To: <20090426204527.GC11736@codemonkey> References: <20090426204527.GC11736@codemonkey> Message-ID: <57c63afe0904261417x75d0352au1054dc7d65155f90@mail.gmail.com> On Sun, Apr 26, 2009 at 3:45 PM, G. Brandon Hoyt wrote: > Hi! > I'm going through the rspec book in beta form right now and hit a snag > in chapter three. > I am developing an application in parallel to the book example instead > of writing the book example word for word. ?To the best of my knowledge, > I have duplicated a parallel example of the book example, changing what > needed to be changed to fit my example. ?Currently, I have a failing > spec when the book says my spec shouldn't be failing. > > http://pastie.org/458945 > that is the failing spec You've got the message expectation (should_receive) on the wrong object - it should be on the messenger, not the program. HTH, David > > here are my system specifications: > OS: Ubuntu 8.10_AMD64 > ruby -v ruby 1.8.8p1 (2009-04-09 revision 23162) [x86_64-linux] > rspec -v rspec 1.2.4 > > http://pastie.org/458949 > Here is the actual code that fails the spec. > any ideas? > I think I'm missing a require somewhere, that's what my gut is telling > me. > -- > ******************************************************* > ******************************************************* > ? ? ? ? ? ? ? ? From G. Brandon Hoyt > ? ? ? ? ? ? ? ? ? ? 863-397-7036 > ? ? ? ? ? ? ? ? "Do the RIGHT thang!" > ? ? ? ? ? ? ? ? --Uncle Kenny > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? de KG4GVL clear > ******************************************************* > ******************************************************* > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkn0x+cACgkQf3s7GyRXBzRe1QCeJgBAk6jJX4xinYTZYyQ05ngm > aGUAn1hU6grPNIXgoTYAW4t79a1qjOdq > =cn4o > -----END PGP SIGNATURE----- > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Sun Apr 26 17:20:59 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 26 Apr 2009 17:20:59 -0400 Subject: [rspec-users] RSPEC book example in Chapter 3. In-Reply-To: <20090426204527.GC11736@codemonkey> References: <20090426204527.GC11736@codemonkey> Message-ID: Methinks thou shoulds't have messenger.should_receive(:puts).with("Please make one of the following menu selections ") in lieu of program.should_receive(:puts).with("Please make one of the following menu selections ") Sorry, I'm just in a medieval mood this afternoon for some reason. On Sun, Apr 26, 2009 at 4:45 PM, G. Brandon Hoyt wrote: > Hi! > I'm going through the rspec book in beta form right now and hit a snag > in chapter three. > I am developing an application in parallel to the book example instead > of writing the book example word for word. ?To the best of my knowledge, > I have duplicated a parallel example of the book example, changing what > needed to be changed to fit my example. ?Currently, I have a failing > spec when the book says my spec shouldn't be failing. > > http://pastie.org/458945 > that is the failing spec > > here are my system specifications: > OS: Ubuntu 8.10_AMD64 > ruby -v ruby 1.8.8p1 (2009-04-09 revision 23162) [x86_64-linux] > rspec -v rspec 1.2.4 > > http://pastie.org/458949 > Here is the actual code that fails the spec. > any ideas? > I think I'm missing a require somewhere, that's what my gut is telling > me. > -- > ******************************************************* > ******************************************************* > ? ? ? ? ? ? ? ? From G. Brandon Hoyt > ? ? ? ? ? ? ? ? ? ? 863-397-7036 > ? ? ? ? ? ? ? ? "Do the RIGHT thang!" > ? ? ? ? ? ? ? ? --Uncle Kenny > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? de KG4GVL clear > ******************************************************* > ******************************************************* > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkn0x+cACgkQf3s7GyRXBzRe1QCeJgBAk6jJX4xinYTZYyQ05ngm > aGUAn1hU6grPNIXgoTYAW4t79a1qjOdq > =cn4o > -----END PGP SIGNATURE----- > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- 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 From ben at benmabey.com Sun Apr 26 23:38:42 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 26 Apr 2009 21:38:42 -0600 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: References: Message-ID: <49F528C2.2070703@benmabey.com> Rick DeNatale wrote: > I finally plunked down for the beta RSpec bundle and I'm working > through the initial example. Although I'm a fairly experienced RSpec > user, I'm stlll learning new tricks. > > Anyway, I'm going though the mastermind example, and everything is > going well, except that I decided to also try out the Textmate bundle > for Cucumber. I decided to use Ben Mabey's fork on github since it > seems to be the most evolved. > > When I try to run a feature with cmd-R, instead of actually running I > see something like: > > Running: cucumber > /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html > false > > Cucumber runs fine from bash. > > Am I missing some setup? > > Hmm.. that is odd. What version of Cucumber are you using? When you run that exact command from the shell does it output the HTML report? -Ben From programmer2188 at gmail.com Sun Apr 26 23:45:49 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Sun, 26 Apr 2009 23:45:49 -0400 Subject: [rspec-users] BDD for C#? In-Reply-To: <8d961d900904260332s742e3e81x7d964dfb3d7beb6b@mail.gmail.com> References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> <000101c9c605$e5be7450$b13b5cf0$@com> <8d961d900904260332s742e3e81x7d964dfb3d7beb6b@mail.gmail.com> Message-ID: <000601c9c6ea$a8a45a40$f9ed0ec0$@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 26, 2009 6:32 AM > To: rspec-users > Subject: Re: [rspec-users] BDD for C#? > > > > Cucumber has been working with .NET for a while: > http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net > > IronRuby was really slow last time I tried (4-5 months ago), so unless > it has improved its speed it will be too slow for practical use. On the > other hand, if IronRuby matures, Cucumber should work well with .NET. > It already does for Java (using JRuby). > > I recently added pure java support to Cucumber, meaning steps can be > written in Java instead of Ruby. > http://github.com/aslakhellesoy/cucumber_java/tree/master > > This obviously makes it easier to use for Java programmers. It should > be fairly easy to implement similar pure C# support. But a quicker > IronRuby is still needed. > Thanks, that does look interesting. Does RSpec work along with it though, or are the step definitions written in C#? I might try it, if I can find a way to do acceptance tests for this application. It might not be as hard as I thought. Brandon > Aslak > > > > Not port or link, replicate. It's only like ~10 features, right? > I don't know C#, but I could do it in C++ in a couple days. > > -- > Phlip > http://flea.sourceforge.net/resume.html > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > www.perpetualseeker.com Blog about college, programming, and other random things. Follow me on Twitter: http://twitter.com/devbanana From lists at ruby-forum.com Mon Apr 27 00:44:10 2009 From: lists at ruby-forum.com (Neema Cheriyath) Date: Mon, 27 Apr 2009 06:44:10 +0200 Subject: [rspec-users] Cucumber: Setting Dependency among scenarios Message-ID: <16f256aba30adeaf75c586456a9901dd@ruby-forum.com> Hi, I am planning to use cucumber-java for my java project for automated testing. I would like to know if there is any option in cucumber, by which we can explicitly provide dependency among running scenarios. For example: I have a ValidateProfile.java and a ProfileSignIn.java. public class ValidateProfile { ... public ValidatedProfile validate(String userName, String password) { ... ... } } public class ProfileSignIn { public void doSignIn(ValidatedProfile profile) { ... ... } } Suppose I have a step definition for ValidateProfile as: public class ValidateProfileTest { @Given("I have user credential as (.*) and (.*)$") public void setCredentials(String userName, String password) { // set credentials to members ... } @When("I call Validate Profile") public void validateProfile() { ... ValidatedProfile profile = validateProfile.validate(_userName, _password); // set profile in class member ... } @Then("Profile should validate successfully() { // assert contents of Validated Profile } } Now I would like to create a Test case, say ProfileSignInTest, for ProfileSignIn. As ProfileSignIn requires a ValidatedProfile, I would like to run ValidateProfileTest prior to that and make use of the ValidatedProfile as input to ProfileSignInTest. Before running a scenario in ProfileSignInTest's feature(say profilesignin.feature) , Is there any option to run the features of ValidateProfileTest(say validateprofile.feature), get its output and pass the same as input to profilesignin.feature 's scenario as below: validateprofile.feature ----------------------- @getValidatedProfiles Given I have a username and password When I call Validate Profile Then Profile should validate successfully profilesignin.feature --------------------- @profilesignin use output as validatedProfile from @getValidatedProfiles Given I have the validated profile as validatedProfile When I call SignIn Then I should get Signed In successfully My idea is to make use of hooks as below, and if possible pass the output of @getValidatedProfiles to the 'Given' of @profilesSignin. If that's not possible, I can make use of a java framework to store and retrieve the output, but the priority is to make a scenario dependent on one or more other scenarios. Before('@profilesignin') do //run the scenario with tag @getValidatedProfiles end Other than hooks, If there are any other better ways of handling this, please let me know. Thanks, Neema -- Posted via http://www.ruby-forum.com/. From j.mcguinness at bigpond.com Mon Apr 27 01:29:49 2009 From: j.mcguinness at bigpond.com (jmac) Date: Sun, 26 Apr 2009 22:29:49 -0700 (PDT) Subject: [rspec-users] automating and end to end functional test. In-Reply-To: <57c63afe0904250611r20aec29dhf7a12ad5e693874f@mail.gmail.com> References: <57c63afe0904250611r20aec29dhf7a12ad5e693874f@mail.gmail.com> Message-ID: Hi David, So I have a number of Java based web systems. The systems allow users to lodge applications for various products/services that my organisation provides. The applications usually have at least 4 or 5 pages, but may be longer depending on the info that is entered. There is alot of common page fragments between the two systems (eg most systems have a page with bio info: names, Birth dates, gender etc) but each system with have different fields in addition the common fields on each page fragment. So, what I wanted to do is create features for logon, features to deal with the common page fragments, like the bio stuff, features to deal with the unique parts, and chain these all together so that I can build up a test to test the end to end application process. I will be using either watir or selenium with rspec/cucumber. The organization currently uses commercial test automation tools, so I am looking at ditching these and going with a Ruby based solution. The cucumber examples I have seen usually are short: Given..something Wen .. I do something Then .. I expect this to happen Can they be longer like this: Given.. And.. And.. Then.. And.. And.. And.. And.. Then... Given.. And.. And.. Then.. etc. On Apr 25, 11:11?pm, David Chelimsky wrote: > On Sat, Apr 25, 2009 at 5:43 AM, jmac wrote: > > Hi, > > I am new to ruby and rspec. I would like to use ruby/rspec/cucumber to > > automate acceptance tests for a number of integrated systems at my > > work. I get the basics of cucumber features, but how do I chain these > > tests so that I can test a process from start to finish. Essentially, > > I want to use the features as components that I can plug together to > > create the different tests. Can cucumber/rspec be used this way. > > Can you give an example. Something simple, but just complex enough to > get your goal across. I have an idea of what you're after, but don't > want to waste my time writing or anybody else's time reading if I'm > wrong :) > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Mon Apr 27 02:30:06 2009 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Mon, 27 Apr 2009 08:30:06 +0200 Subject: [rspec-users] automating and end to end functional test. In-Reply-To: References: <57c63afe0904250611r20aec29dhf7a12ad5e693874f@mail.gmail.com> Message-ID: <2BEBC294-9DA3-4FDA-BBBF-202C284FF1E6@gmail.com> > Hi David, > > So I have a number of Java based web systems. The systems allow users > to lodge applications for various products/services that my > organisation provides. The applications usually have at least 4 or 5 > pages, but may be longer depending on the info that is entered. There > is alot of common page fragments between the two systems (eg most > systems have a page with bio info: names, Birth dates, gender etc) but > each system with have different fields in addition the common fields > on each page fragment. So, what I wanted to do is create features for > logon, features to deal with the common page fragments, like the bio > stuff, features to deal with the unique parts, and chain these all > together so that I can build up a test to test the end to end > application process. I will be using either watir or selenium with > rspec/cucumber. The organization currently uses commercial test > automation tools, so I am looking at ditching these and going with a > Ruby based solution. > > The cucumber examples I have seen usually are short: > Given..something > Wen .. I do something > Then .. I expect this to happen > > Can they be longer like this: > > Given.. > And.. > And.. > Then.. > And.. > And.. > And.. > And.. > Then... > Given.. > And.. > And.. > Then.. > Yes. The sky is the limit ;-) Aslak > etc. > On Apr 25, 11:11 pm, David Chelimsky wrote: >> On Sat, Apr 25, 2009 at 5:43 AM, jmac >> wrote: >>> Hi, >>> I am new to ruby and rspec. I would like to use ruby/rspec/ >>> cucumber to >>> automate acceptance tests for a number of integrated systems at my >>> work. I get the basics of cucumber features, but how do I chain >>> these >>> tests so that I can test a process from start to finish. >>> Essentially, >>> I want to use the features as components that I can plug together to >>> create the different tests. Can cucumber/rspec be used this way. >> >> Can you give an example. Something simple, but just complex enough to >> get your goal across. I have an idea of what you're after, but don't >> want to waste my time writing or anybody else's time reading if I'm >> wrong :) >> _______________________________________________ >> 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 matt at mattwynne.net Mon Apr 27 03:33:05 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 27 Apr 2009 08:33:05 +0100 Subject: [rspec-users] automating and end to end functional test. In-Reply-To: References: <57c63afe0904250611r20aec29dhf7a12ad5e693874f@mail.gmail.com> Message-ID: <787DCAB6-121D-4B8D-A25D-B9EBDFE8F520@mattwynne.net> On 27 Apr 2009, at 06:29, jmac wrote: > Hi David, > > So I have a number of Java based web systems. The systems allow users > to lodge applications for various products/services that my > organisation provides. The applications usually have at least 4 or 5 > pages, but may be longer depending on the info that is entered. There > is alot of common page fragments between the two systems (eg most > systems have a page with bio info: names, Birth dates, gender etc) but > each system with have different fields in addition the common fields > on each page fragment. So, what I wanted to do is create features for > logon, features to deal with the common page fragments, like the bio > stuff, features to deal with the unique parts, and chain these all > together so that I can build up a test to test the end to end > application process. I will be using either watir or selenium with > rspec/cucumber. The organization currently uses commercial test > automation tools, so I am looking at ditching these and going with a > Ruby based solution. > > The cucumber examples I have seen usually are short: > Given..something > Wen .. I do something > Then .. I expect this to happen > > Can they be longer like this: > > Given.. > And.. > And.. > Then.. > And.. > And.. > And.. > And.. > Then... > Given.. > And.. > And.. > Then.. This is possible, but not really advisable in such raw form - you'll end up with tests that, while they might make sense at the time you write them, are quite hard to read and therefore maintain. I'd always try to stick to a single Given / When / Then loop for a single scenario. Have a read of these: http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ Also these two Cucumber features can help: http://wiki.github.com/aslakhellesoy/cucumber/background http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines > > > etc. > On Apr 25, 11:11 pm, David Chelimsky wrote: >> On Sat, Apr 25, 2009 at 5:43 AM, jmac >> wrote: >>> Hi, >>> I am new to ruby and rspec. I would like to use ruby/rspec/ >>> cucumber to >>> automate acceptance tests for a number of integrated systems at my >>> work. I get the basics of cucumber features, but how do I chain >>> these >>> tests so that I can test a process from start to finish. >>> Essentially, >>> I want to use the features as components that I can plug together to >>> create the different tests. Can cucumber/rspec be used this way. >> >> Can you give an example. Something simple, but just complex enough to >> get your goal across. I have an idea of what you're after, but don't >> want to waste my time writing or anybody else's time reading if I'm >> wrong :) >> _______________________________________________ >> 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 rick.denatale at gmail.com Mon Apr 27 08:13:23 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 27 Apr 2009 08:13:23 -0400 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: <49F528C2.2070703@benmabey.com> References: <49F528C2.2070703@benmabey.com> Message-ID: On Sun, Apr 26, 2009 at 11:38 PM, Ben Mabey wrote: > Rick DeNatale wrote: >> >> I finally plunked down for the beta RSpec bundle and I'm working >> through the initial example. ?Although I'm a fairly experienced RSpec >> user, I'm stlll learning new tricks. >> >> Anyway, ?I'm going though the mastermind example, and everything is >> going well, except that I decided to also try out the Textmate bundle >> for Cucumber. ?I decided to use Ben Mabey's fork on github since it >> seems to be the most evolved. >> >> When I try to run a feature with cmd-R, instead of actually running I >> see something like: >> >> Running: cucumber >> /Users/rick/mastermind/features/codebreaker_starts_game.feature >> --format=html >> false >> >> Cucumber runs fine from bash. >> >> Am I missing some setup? >> >> > > Hmm.. that is odd. What version of Cucumber are you using? ?When you run > that exact command from the shell does it output the HTML report? I was runing 0.3.0 upgrading to 0.3.1 has the same result BUT If I run that exact command $ /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html -bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature: Permission denied It's trying to run the feature as an executable directly it's not running the cucumber executable! Why it be doin dat? -- 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 From dchelimsky at gmail.com Mon Apr 27 09:34:20 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 27 Apr 2009 08:34:20 -0500 Subject: [rspec-users] [cucumber] Setting a constant in step definition In-Reply-To: <88fd8ddc0904270500l486abde9x1482ff51e1cc92d@mail.gmail.com> References: <88fd8ddc0904270500l486abde9x1482ff51e1cc92d@mail.gmail.com> Message-ID: <57c63afe0904270634n4da00c92m158ed6a1ef710e7b@mail.gmail.com> On Mon, Apr 27, 2009 at 7:00 AM, Andrew Premdas wrote: > Currently I have a very simple constants implementation being loaded as a > Rails initialiser > > module MVOR > ? module Postage > ??? THRESHOLD = BigDecimal.new('6.99') > ??? RATE = BigDecimal.new('30.00') > ? end > end > > > My scenarios of my postage feature want to deal with two situations when the > THRESHOLD has been set to zero and to '6.99'. The question is how can I set > the threshold in my step_definition. So I want to implement > > ? Given the postage threshold is 0.00 > ? Given the postage threshold is 6.99 > > > ?I've considered a number of ideas, but seem to keep on getting into complex > solutions for what I assume is something very simple. If THRESHOLD can change, then it is not, by definition, a constant. It's just a global variable. I'd change it to a method and then stub that method for a given scenario (even though stubbing is a Cucumber no-no ;) ). WDYT? David > > TIA > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Mon Apr 27 09:47:43 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 27 Apr 2009 09:47:43 -0400 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: References: <49F528C2.2070703@benmabey.com> Message-ID: On Mon, Apr 27, 2009 at 8:13 AM, Rick DeNatale wrote: > On Sun, Apr 26, 2009 at 11:38 PM, Ben Mabey wrote: >> Rick DeNatale wrote: >>> >>> I finally plunked down for the beta RSpec bundle and I'm working >>> through the initial example. ?Although I'm a fairly experienced RSpec >>> user, I'm stlll learning new tricks. >>> >>> Anyway, ?I'm going though the mastermind example, and everything is >>> going well, except that I decided to also try out the Textmate bundle >>> for Cucumber. ?I decided to use Ben Mabey's fork on github since it >>> seems to be the most evolved. >>> >>> When I try to run a feature with cmd-R, instead of actually running I >>> see something like: >>> >>> Running: cucumber >>> /Users/rick/mastermind/features/codebreaker_starts_game.feature >>> --format=html >>> false >>> >>> Cucumber runs fine from bash. >>> >>> Am I missing some setup? >>> >>> >> >> Hmm.. that is odd. What version of Cucumber are you using? ?When you run >> that exact command from the shell does it output the HTML report? > > I was runing 0.3.0 upgrading to 0.3.1 has the same result BUT > > If I run that exact command > > $ /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html > -bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature: > Permission denied > > > It's trying to run the feature as an executable directly it's not > running the cucumber executable! > > Why it be doin dat? Actually, I was misreading the output in the run window, which was wrapping. $ cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html false /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in `Given': Multiple step definitions have the same Regexp: (Cucumber::Redundant) features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in `each' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in `Given' from ./features/step_definitions/mastermind.rb:13 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:79:in `require_files' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in `each' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in `require_files' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:34:in `execute!' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:20:in `execute' from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/cucumber:6 from /opt/local/bin/cucumber:19:in `load' from /opt/local/bin/cucumber:19 If I do this from the project directory: $ cucumber features/codebreaker_starts_game.feature Feature: Codebreaker starts game As a Codebreaker I want to start a game So that I can break the code Scenario: Start game # features/codebreaker_starts_game.feature:5 Given I am not yet playing # features/step_definitions/mastermind.rb:13 When I start a new game # features/step_definitions/mastermind.rb:24 Then the game should say "Welcome to Mastermind!" # features/step_definitions/mastermind.rb:28 And the game should say "Enter guess:" # features/step_definitions/mastermind.rb:28 1 scenario 4 passed steps Running under textmate, cucumber seems to be somehow convincing itself that features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' Duplicates itself?!? -- 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 From dchelimsky at gmail.com Mon Apr 27 10:30:19 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 27 Apr 2009 09:30:19 -0500 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly spe cing In-Reply-To: References: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> <1fb4df0904231240i47e1d39cv8c6f61e67f41bf8f@mail.gmail.com> Message-ID: <57c63afe0904270730o446b4739ub6fd85cfffdc9af@mail.gmail.com> On Sun, Apr 26, 2009 at 9:20 PM, Dan North wrote: > 2009/4/24 Stephen Eley >> >> On Thu, Apr 23, 2009 at 2:19 PM, Fernando Perez >> wrote: >> >> [...] >> >> # Assume an article with no comments and a params structure >> # have already been set up in before(:each) >> >> it "should make a new comment belonging to the article" do >> ?post :create, :comment => @my_valid_params >> ?@my_article.should have(1).comment >> end >> >> How clean is that? ?Now just a couple more specs for *invalid* params >> and for where the method directs to, and you're basically done. > > Amen to that. > >> >> > Mocking and stubbing is starting to get ugly now. >> >> That much is true. ?You'll notice I didn't mock or stub anything up >> there. ?I honestly think the controller code by the RSpec scaffold >> generator is the wrong approach; it's specing implementation, not >> behavior. ?Even worse, it's specing the implementation details of >> *model* code, which shouldn't even be a consideration here. ?My way >> breaks isolation (it hits the database) but it's a lot simpler and >> focuses on behavior. > > And amen to that too. > > Even within an rspec example I think of each line of code as a Given > (setup), When (event) or Then (outcome). Usually when I see a line doing > more than one of these - say calling a method and verifying its result - I > break it out into separate event and outcome lines. > > The reason for this is that the givens and outcomes can tinker with whatever > they want. They can create mocks, poke around in the database, wire up > models, whatever. The event lines though - the Whens - can only interact > with the object like client code would. In other words they can't know that > an object is a mock, or that a value got into a database because you poked > it there. > > Your example is great. You have an event line that interacts with the > controller through a regular HTTP POST, like a client would, and you verify > that by checking the database via the ActiveRecord model object. There is no > need for a mock here if your example is checking that data ends up in the > database (although that does make it more of an integration test than a > behavioural spec). Because of rails's evil insistence that a "model" is just > a persistence strategy, they are pretty much the same thing. > >> Is it possible to get behavior focus *and* isolation? > > Yes, but it only has value on a per-line-of-code-in-your-spec basis. Your > givens and outcomes shouldn't care about isolation - your events should only > be exercising behaviour that is available in the object you are describing. > > It gets more complicated when a single line of code both exercises behaviour > and does verification. I find breaking these out helps my sanity. > >> ?I started to >> think about that. ?And then I realized, in accordance with the "If >> it's hard to spec you're probably doing it wrong" principle, >> that...well, Rails is probably doing it wrong. ?Controllers in Rails >> are just doing the Wrong Thing. ?That's why specing them is so >> painful, and why so many of us skip trying. I've struggled with this bit myself, as I suspect many of us who did TDD before Rails have. RSpec's mocking/stubbing framework just got a contribution that allows you to do this in a controller spec: Thing.stub_chain(:all, :with_some_scope, :perhaps_another). and_return([stub_model(Thing)] This let's you stub a chain of named scopes, for example, in a rails controller. Similarly, with models: member.stub_chain(:addresses, :first, :zip_code) Admittedly, this can result in an excuse for poor design choices. In this example, the first address probably has some meaning that could be exposed through a method like primary_address() or some such. Even in that case, I think that allowing member.stub_chain(:primary_address, :zipcode) would be preferable over adding methods like primary_address_zipcode(). Of course, a little method_missing magic could solve that as well :) I guess it's good to have options. >> >> What's the right way? ?I'm still pondering. > > Me too! > >> >> Yeah, I'm a smartass. > > Well you seem to be on the right lines to me. > > Cheers, > Dan > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Mon Apr 27 11:13:17 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 27 Apr 2009 11:13:17 -0400 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> References: <49F528C2.2070703@benmabey.com> <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> Message-ID: On Mon, Apr 27, 2009 at 10:07 AM, aslak hellesoy wrote: > > > On Mon, Apr 27, 2009 at 3:47 PM, Rick DeNatale > wrote: >> >> On Mon, Apr 27, 2009 at 8:13 AM, Rick DeNatale >> wrote: >> > On Sun, Apr 26, 2009 at 11:38 PM, Ben Mabey wrote: >> >> Rick DeNatale wrote: >> >>> >> >>> I finally plunked down for the beta RSpec bundle and I'm working >> >>> through the initial example. ?Although I'm a fairly experienced RSpec >> >>> user, I'm stlll learning new tricks. >> >>> >> >>> Anyway, ?I'm going though the mastermind example, and everything is >> >>> going well, except that I decided to also try out the Textmate bundle >> >>> for Cucumber. ?I decided to use Ben Mabey's fork on github since it >> >>> seems to be the most evolved. >> >>> >> >>> When I try to run a feature with cmd-R, instead of actually running I >> >>> see something like: >> >>> >> >>> Running: cucumber >> >>> /Users/rick/mastermind/features/codebreaker_starts_game.feature >> >>> --format=html >> >>> false >> >>> >> >>> Cucumber runs fine from bash. >> >>> >> >>> Am I missing some setup? >> >>> >> >>> >> >> >> >> Hmm.. that is odd. What version of Cucumber are you using? ?When you >> >> run >> >> that exact command from the shell does it output the HTML report? >> > >> > I was runing 0.3.0 upgrading to 0.3.1 has the same result BUT >> > >> > If I run that exact command >> > >> > $ /Users/rick/mastermind/features/codebreaker_starts_game.feature >> > --format=html >> > -bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature: >> > Permission denied >> > >> > >> > It's trying to run the feature as an executable directly it's not >> > running the cucumber executable! >> > >> > Why it be doin dat? >> >> >> Actually, I was misreading the output in the run window, which was >> wrapping. >> >> $ ?cucumber >> /Users/rick/mastermind/features/codebreaker_starts_game.feature >> --format=html false >> >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in >> `Given': Multiple step definitions have the same Regexp: >> (Cucumber::Redundant) >> >> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >> >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in >> `each' >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in >> `Given' >> ? ? ? ?from ./features/step_definitions/mastermind.rb:13 >> ? ? ? ?from >> /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> ? ? ? ?from >> /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `polyglot_original_require' >> ? ? ? ?from >> /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `require' >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:79:in >> `require_files' >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in >> `each' >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in >> `require_files' >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:34:in >> `execute!' >> ? ? ? ?from >> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:20:in >> `execute' >> ? ? ? ?from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/cucumber:6 >> ? ? ? ?from /opt/local/bin/cucumber:19:in `load' >> ? ? ? ?from /opt/local/bin/cucumber:19 >> >> If I do this from the project directory: >> >> ?$ cucumber features/codebreaker_starts_game.feature >> Feature: Codebreaker starts game >> ?As a Codebreaker >> ?I want to start a game >> ?So that I can break the code >> >> ?Scenario: Start game ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# >> features/codebreaker_starts_game.feature:5 >> ? ?Given I am not yet playing ? ? ? ? ? ? ? ? ? ? ? ?# >> features/step_definitions/mastermind.rb:13 >> ? ?When I start a new game ? ? ? ? ? ? ? ? ? ? ? ? ? # >> features/step_definitions/mastermind.rb:24 >> ? ?Then the game should say "Welcome to Mastermind!" # >> features/step_definitions/mastermind.rb:28 >> ? ?And the game should say "Enter guess:" ? ? ? ? ? ?# >> features/step_definitions/mastermind.rb:28 >> >> 1 scenario >> 4 passed steps >> >> >> Running under textmate, cucumber seems to be somehow convincing itself >> that >> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >> >> Duplicates itself?!? > > What's happening is that the file containing step defs is being loaded > twice, and therefore you get dupe step defs. Not sure why that's happening > though... Yes, I figured it was somehing like that. On a little more trial and error, it appears that the bundle is adding false to the end of the command string which is causing that steps def to be required initially: $ cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html false -v Ruby files required: * /Users/rick/mastermind/features/support/env.rb * ./features/support/env.rb * ./lib/mastermind/game.rb * /Users/rick/mastermind/features/step_definitions/mastermind.rb /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in `Given': Multiple step definitions have the same Regexp: (Cucumber::Redundant) features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' Haven't yet figured out where that false is coming from, somewhere in runner.rb in the bundle -- 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 From ben at benmabey.com Mon Apr 27 11:20:37 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 27 Apr 2009 09:20:37 -0600 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: References: <49F528C2.2070703@benmabey.com> <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> Message-ID: <49F5CD45.3090206@benmabey.com> Rick DeNatale wrote: > On Mon, Apr 27, 2009 at 10:07 AM, aslak hellesoy > wrote: > >> On Mon, Apr 27, 2009 at 3:47 PM, Rick DeNatale >> wrote: >> >>> On Mon, Apr 27, 2009 at 8:13 AM, Rick DeNatale >>> wrote: >>> >>>> On Sun, Apr 26, 2009 at 11:38 PM, Ben Mabey wrote: >>>> >>>>> Rick DeNatale wrote: >>>>> >>>>>> I finally plunked down for the beta RSpec bundle and I'm working >>>>>> through the initial example. Although I'm a fairly experienced RSpec >>>>>> user, I'm stlll learning new tricks. >>>>>> >>>>>> Anyway, I'm going though the mastermind example, and everything is >>>>>> going well, except that I decided to also try out the Textmate bundle >>>>>> for Cucumber. I decided to use Ben Mabey's fork on github since it >>>>>> seems to be the most evolved. >>>>>> >>>>>> When I try to run a feature with cmd-R, instead of actually running I >>>>>> see something like: >>>>>> >>>>>> Running: cucumber >>>>>> /Users/rick/mastermind/features/codebreaker_starts_game.feature >>>>>> --format=html >>>>>> false >>>>>> >>>>>> Cucumber runs fine from bash. >>>>>> >>>>>> Am I missing some setup? >>>>>> >>>>>> >>>>>> >>>>> Hmm.. that is odd. What version of Cucumber are you using? When you >>>>> run >>>>> that exact command from the shell does it output the HTML report? >>>>> >>>> I was runing 0.3.0 upgrading to 0.3.1 has the same result BUT >>>> >>>> If I run that exact command >>>> >>>> $ /Users/rick/mastermind/features/codebreaker_starts_game.feature >>>> --format=html >>>> -bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature: >>>> Permission denied >>>> >>>> >>>> It's trying to run the feature as an executable directly it's not >>>> running the cucumber executable! >>>> >>>> Why it be doin dat? >>>> >>> Actually, I was misreading the output in the run window, which was >>> wrapping. >>> >>> $ cucumber >>> /Users/rick/mastermind/features/codebreaker_starts_game.feature >>> --format=html false >>> >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in >>> `Given': Multiple step definitions have the same Regexp: >>> (Cucumber::Redundant) >>> >>> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >>> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >>> >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in >>> `each' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in >>> `Given' >>> from ./features/step_definitions/mastermind.rb:13 >>> from >>> /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >>> `gem_original_require' >>> from >>> /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >>> `polyglot_original_require' >>> from >>> /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >>> `require' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:79:in >>> `require_files' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in >>> `each' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in >>> `require_files' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:34:in >>> `execute!' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:20:in >>> `execute' >>> from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/cucumber:6 >>> from /opt/local/bin/cucumber:19:in `load' >>> from /opt/local/bin/cucumber:19 >>> >>> If I do this from the project directory: >>> >>> $ cucumber features/codebreaker_starts_game.feature >>> Feature: Codebreaker starts game >>> As a Codebreaker >>> I want to start a game >>> So that I can break the code >>> >>> Scenario: Start game # >>> features/codebreaker_starts_game.feature:5 >>> Given I am not yet playing # >>> features/step_definitions/mastermind.rb:13 >>> When I start a new game # >>> features/step_definitions/mastermind.rb:24 >>> Then the game should say "Welcome to Mastermind!" # >>> features/step_definitions/mastermind.rb:28 >>> And the game should say "Enter guess:" # >>> features/step_definitions/mastermind.rb:28 >>> >>> 1 scenario >>> 4 passed steps >>> >>> >>> Running under textmate, cucumber seems to be somehow convincing itself >>> that >>> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >>> >>> Duplicates itself?!? >>> >> What's happening is that the file containing step defs is being loaded >> twice, and therefore you get dupe step defs. Not sure why that's happening >> though... >> > > Yes, I figured it was somehing like that. On a little more trial and > error, it appears that the bundle is adding false to the end of the > command string which is causing that steps def to be required > initially: > > $ cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature > --format=html false -v > Ruby files required: > * /Users/rick/mastermind/features/support/env.rb > * ./features/support/env.rb > * ./lib/mastermind/game.rb > * /Users/rick/mastermind/features/step_definitions/mastermind.rb > /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in > `Given': Multiple step definitions have the same Regexp: > (Cucumber::Redundant) > > features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' > features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' > > Haven't yet figured out where that false is coming from, somewhere in > runner.rb in the bundle > > > > I don't think the 'false' is part of the command. That is the exit code of the cucumber I think (well, the boolean representation of it). I'll take a look at it though. -Ben From ben at benmabey.com Mon Apr 27 11:42:32 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 27 Apr 2009 09:42:32 -0600 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: References: <49F528C2.2070703@benmabey.com> <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> Message-ID: <49F5D268.8070702@benmabey.com> Rick DeNatale wrote: > On Mon, Apr 27, 2009 at 10:07 AM, aslak hellesoy > wrote: > >> On Mon, Apr 27, 2009 at 3:47 PM, Rick DeNatale >> wrote: >> >>> On Mon, Apr 27, 2009 at 8:13 AM, Rick DeNatale >>> wrote: >>> >>>> On Sun, Apr 26, 2009 at 11:38 PM, Ben Mabey wrote: >>>> >>>>> Rick DeNatale wrote: >>>>> >>>>>> I finally plunked down for the beta RSpec bundle and I'm working >>>>>> through the initial example. Although I'm a fairly experienced RSpec >>>>>> user, I'm stlll learning new tricks. >>>>>> >>>>>> Anyway, I'm going though the mastermind example, and everything is >>>>>> going well, except that I decided to also try out the Textmate bundle >>>>>> for Cucumber. I decided to use Ben Mabey's fork on github since it >>>>>> seems to be the most evolved. >>>>>> >>>>>> When I try to run a feature with cmd-R, instead of actually running I >>>>>> see something like: >>>>>> >>>>>> Running: cucumber >>>>>> /Users/rick/mastermind/features/codebreaker_starts_game.feature >>>>>> --format=html >>>>>> false >>>>>> >>>>>> Cucumber runs fine from bash. >>>>>> >>>>>> Am I missing some setup? >>>>>> >>>>>> >>>>>> >>>>> Hmm.. that is odd. What version of Cucumber are you using? When you >>>>> run >>>>> that exact command from the shell does it output the HTML report? >>>>> >>>> I was runing 0.3.0 upgrading to 0.3.1 has the same result BUT >>>> >>>> If I run that exact command >>>> >>>> $ /Users/rick/mastermind/features/codebreaker_starts_game.feature >>>> --format=html >>>> -bash: /Users/rick/mastermind/features/codebreaker_starts_game.feature: >>>> Permission denied >>>> >>>> >>>> It's trying to run the feature as an executable directly it's not >>>> running the cucumber executable! >>>> >>>> Why it be doin dat? >>>> >>> Actually, I was misreading the output in the run window, which was >>> wrapping. >>> >>> $ cucumber >>> /Users/rick/mastermind/features/codebreaker_starts_game.feature >>> --format=html false >>> >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in >>> `Given': Multiple step definitions have the same Regexp: >>> (Cucumber::Redundant) >>> >>> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >>> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >>> >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in >>> `each' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:124:in >>> `Given' >>> from ./features/step_definitions/mastermind.rb:13 >>> from >>> /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >>> `gem_original_require' >>> from >>> /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in >>> `polyglot_original_require' >>> from >>> /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >>> `require' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:79:in >>> `require_files' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in >>> `each' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:77:in >>> `require_files' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:34:in >>> `execute!' >>> from >>> /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/cli/main.rb:20:in >>> `execute' >>> from /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/cucumber:6 >>> from /opt/local/bin/cucumber:19:in `load' >>> from /opt/local/bin/cucumber:19 >>> >>> If I do this from the project directory: >>> >>> $ cucumber features/codebreaker_starts_game.feature >>> Feature: Codebreaker starts game >>> As a Codebreaker >>> I want to start a game >>> So that I can break the code >>> >>> Scenario: Start game # >>> features/codebreaker_starts_game.feature:5 >>> Given I am not yet playing # >>> features/step_definitions/mastermind.rb:13 >>> When I start a new game # >>> features/step_definitions/mastermind.rb:24 >>> Then the game should say "Welcome to Mastermind!" # >>> features/step_definitions/mastermind.rb:28 >>> And the game should say "Enter guess:" # >>> features/step_definitions/mastermind.rb:28 >>> >>> 1 scenario >>> 4 passed steps >>> >>> >>> Running under textmate, cucumber seems to be somehow convincing itself >>> that >>> features/step_definitions/mastermind.rb:13:in `/^I am not yet playing$/' >>> >>> Duplicates itself?!? >>> >> What's happening is that the file containing step defs is being loaded >> twice, and therefore you get dupe step defs. Not sure why that's happening >> though... >> > > Yes, I figured it was somehing like that. On a little more trial and > error, it appears that the bundle is adding false to the end of the > command string which is causing that steps def to be required > initially: > > $ cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature > --format=html false -v > Ruby files required: > * /Users/rick/mastermind/features/support/env.rb > * ./features/support/env.rb > * ./lib/mastermind/game.rb > * /Users/rick/mastermind/features/step_definitions/mastermind.rb > /Users/rick/.gem/ruby/1.8/gems/cucumber-0.3.1/bin/../lib/cucumber/step_mother.rb:125:in > `Given': Multiple step definitions have the same Regexp: > (Cucumber::Redundant) > Do you happen to be explicitly requiring any of your step definitions from your env.rb or other files? What does your env.rb look like? -Ben From jirapong.nanta at gmail.com Mon Apr 27 11:54:28 2009 From: jirapong.nanta at gmail.com (jirapong.nanta at gmail.com) Date: Mon, 27 Apr 2009 22:54:28 +0700 Subject: [rspec-users] BDD for C#? In-Reply-To: <000601c9c6ea$a8a45a40$f9ed0ec0$@com> References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> <000101c9c605$e5be7450$b13b5cf0$@com> <8d961d900904260332s742e3e81x7d964dfb3d7beb6b@mail.gmail.com> <000601c9c6ea$a8a45a40$f9ed0ec0$@com> Message-ID: <40D2D825-796C-44DF-8A9C-4E8E9D5BAD73@gmail.com> for Acceptance testing, would you like to checkout Ben's article at - http://msdn.microsoft.com/en-us/magazine/dd453038.aspx -Jirapong On Apr 27, 2009, at 10: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 26, 2009 6:32 AM >> To: rspec-users >> Subject: Re: [rspec-users] BDD for C#? >> >> >> >> Cucumber has been working with .NET for a while: >> http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net >> >> IronRuby was really slow last time I tried (4-5 months ago), so >> unless >> it has improved its speed it will be too slow for practical use. On >> the >> other hand, if IronRuby matures, Cucumber should work well with .NET. >> It already does for Java (using JRuby). >> >> I recently added pure java support to Cucumber, meaning steps can be >> written in Java instead of Ruby. >> http://github.com/aslakhellesoy/cucumber_java/tree/master >> >> This obviously makes it easier to use for Java programmers. It should >> be fairly easy to implement similar pure C# support. But a quicker >> IronRuby is still needed. >> > > Thanks, that does look interesting. Does RSpec work along with it > though, or > are the step definitions written in C#? > > I might try it, if I can find a way to do acceptance tests for this > application. It might not be as hard as I thought. > > Brandon > >> Aslak >> >> >> >> Not port or link, replicate. It's only like ~10 features, right? >> I don't know C#, but I could do it in C++ in a couple days. >> >> -- >> Phlip >> http://flea.sourceforge.net/resume.html >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > www.perpetualseeker.com > Blog about college, programming, and other random things. > Follow me on Twitter: http://twitter.com/devbanana > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rick.denatale at gmail.com Mon Apr 27 13:33:25 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 27 Apr 2009 13:33:25 -0400 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: <49F5D268.8070702@benmabey.com> References: <49F528C2.2070703@benmabey.com> <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> <49F5D268.8070702@benmabey.com> Message-ID: On Mon, Apr 27, 2009 at 11:42 AM, Ben Mabey wrote: > > Do you happen to be explicitly requiring any of your step definitions from > your env.rb or other files? ?What does your env.rb look like? > Yes, env.rb is right out of the RSpec book B4.0 'printing' p 43 $: << File.join(File.dirname(__FILE__), "/../../lib" ) require 'spec/expectations' require 'mastermind' You are right that the false is being output by running the command, not the command line. I hacked the runner.rb file in the bundle to insert a between outputting and running the command. The mystery is why the same command running in Textmate reloads the spec definition, but not when invoked by bash? And when I add false to the end of the command in bash it does. Having just typed that I realize that I wasn't really sure that the reload WAS the problem running under textmate. So I hacked the run method in runner.rb in the bundle to show stderr as well as stdout: in_project_dir do @output << %Q{Running: #{full_command = "bash \"2>&1 #{command} #{@file.rake_task} #{argv.join(' ')}\""} \n} @output << "" @output << Kernel.system(full_command) end And this outputs: Running: bash "2>&1 cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html" bash: 2>&1 cucumber /Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html: No such file or directory false I'm guessing that the file it isn't finding is cucumber? Is there an environment variable I need to set in textmate? -- 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 From wayne.simacek at gmail.com Mon Apr 27 13:40:50 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Mon, 27 Apr 2009 10:40:50 -0700 (PDT) Subject: [rspec-users] uninitialized constant ActionController running Cucumber features in Aptana/RadRails IDE Message-ID: I'm just starting on BDD. I installed the gems for webrats and cucumber. I also ran the following in the Ruby shell: >rake gems:install RAILS_EN=test >script/generate cucumber These commands seemed to create the expected features and lib folders in my project. I'm using the eclipse framework with Aptana and RadRails as my IDE. However, when I run: >cucumber features -n from the Ruby shell, I get the following error: ./app/controllers/application.rb:4: uninitialized constant ActionController (NameError) from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' 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/cucumber-0.3.0/bin/../lib/ cucumber/cli/main.rb:79:in `require_files' from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ cucumber/cli/main.rb:77:in `each' from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ cucumber/cli/main.rb:77:in `require_files' from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ cucumber/cli/main.rb:34:in `execute!' from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ cucumber/cli/main.rb:20:in `execute' from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/cucumber:6 from C:/ruby/bin/cucumber:19:in `load' from C:/ruby/bin/cucumber:19 Any ideas on how I can initialize this constant ActionController or where the real error is coming from? Do I have to do some additional includes in some of my files? From BrianPatrickDunn at gmail.com Mon Apr 27 14:40:31 2009 From: BrianPatrickDunn at gmail.com (Higgaion) Date: Mon, 27 Apr 2009 11:40:31 -0700 (PDT) Subject: [rspec-users] describe 'a spec for a helper that takes a block' i.should need_to_do_this? Message-ID: i have a helper like this: def swf_upload_tag( upload_url, options = {}, &block) # irelavant stuff removed button_text = capture(&block) unless button_text.blank? options.merge!( :button_text => button_text ) end # irelavant stuff removed concat( content_tag( :div, '', :id => opts [:button_placeholder_id] ) << update_page_tag do |page| page.call "SWFUpload.init", recursive_options_for_javascript (opts) end, block.binding ) end to spec it i had to do this in my before block: before do helper.output_buffer = '' # wouldn't empty string make a good default? helper.instance_variable_set(:@template, helper ) # i probably shouldn't have to do this. end otherwise capture_helper.rb and prototype_helper.rb would raise. these things seem to be reasonable defaults: the output_buffer a blank screen, and @template set to the context of the helper... what do you all think? is there some reason *not* to always set these? From ben at benmabey.com Mon Apr 27 14:40:29 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 27 Apr 2009 12:40:29 -0600 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: References: <49F528C2.2070703@benmabey.com> <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> <49F5D268.8070702@benmabey.com> Message-ID: <49F5FC1D.6040203@benmabey.com> Rick DeNatale wrote: > On Mon, Apr 27, 2009 at 11:42 AM, Ben Mabey wrote: > >> Do you happen to be explicitly requiring any of your step definitions from >> your env.rb or other files? What does your env.rb look like? >> >> > > Yes, env.rb is right out of the RSpec book B4.0 'printing' p 43 > > $: << File.join(File.dirname(__FILE__), "/../../lib" ) > require 'spec/expectations' > require 'mastermind' > > You are right that the false is being output by running the command, > not the command line. I hacked the runner.rb file in the bundle to > insert a between outputting and running the command. > > The mystery is why the same command running in Textmate reloads the > spec definition, but not when invoked by bash? And when I add false > to the end of the command in bash it does. > > Having just typed that I realize that I wasn't really sure that the > reload WAS the problem running under textmate. So I hacked the run > method in runner.rb in the bundle to show stderr as well as stdout: > > in_project_dir do > @output << %Q{Running: #{full_command = "bash \"2>&1 > #{command} #{@file.rake_task} #{argv.join(' ')}\""} \n} > @output << "" > @output << Kernel.system(full_command) > end > > And this outputs: > > Running: bash "2>&1 cucumber > /Users/rick/mastermind/features/codebreaker_starts_game.feature > --format=html" > bash: 2>&1 cucumber > /Users/rick/mastermind/features/codebreaker_starts_game.feature > --format=html: No such file or directory false > > I'm guessing that the file it isn't finding is cucumber? Is there an > environment variable I need to set in textmate? > > > > Ahh, I've had similar issues with RSpec's bundle before. Basically, your PATH is not being used for all of your OSX applications. From the rspec site[1]: You may need to adjust the PATH in your ~/.MacOSX/environment.plist file to point to the directory where your ruby and spec executables live. For example: PATH /usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/usr/local/mysql/bin I will also add a TM_CUCUMBER_BIN constant option so if that is set it will use that instead of assuming 'cucumber' is in your path. I'll let you know when that is done. -Ben 1.http://rspec.info/documentation/tools/extensions/editors/textmate.html From ben at benmabey.com Mon Apr 27 15:00:39 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 27 Apr 2009 13:00:39 -0600 Subject: [rspec-users] Problems running features with Textmate Cucumber bundle In-Reply-To: <49F5FC1D.6040203@benmabey.com> References: <49F528C2.2070703@benmabey.com> <8d961d900904270707p56bad775gb01799a1304b0501@mail.gmail.com> <49F5D268.8070702@benmabey.com> <49F5FC1D.6040203@benmabey.com> Message-ID: <49F600D7.1040604@benmabey.com> Ben Mabey wrote: > Rick DeNatale wrote: >> On Mon, Apr 27, 2009 at 11:42 AM, Ben Mabey wrote: >> >>> Do you happen to be explicitly requiring any of your step >>> definitions from >>> your env.rb or other files? What does your env.rb look like? >>> >>> >> >> Yes, env.rb is right out of the RSpec book B4.0 'printing' p 43 >> >> $: << File.join(File.dirname(__FILE__), "/../../lib" ) >> require 'spec/expectations' >> require 'mastermind' >> >> You are right that the false is being output by running the command, >> not the command line. I hacked the runner.rb file in the bundle to >> insert a between outputting and running the command. >> >> The mystery is why the same command running in Textmate reloads the >> spec definition, but not when invoked by bash? And when I add false >> to the end of the command in bash it does. >> >> Having just typed that I realize that I wasn't really sure that the >> reload WAS the problem running under textmate. So I hacked the run >> method in runner.rb in the bundle to show stderr as well as stdout: >> >> in_project_dir do >> @output << %Q{Running: #{full_command = "bash \"2>&1 >> #{command} #{@file.rake_task} #{argv.join(' ')}\""} \n} >> @output << "" >> @output << Kernel.system(full_command) >> end >> >> And this outputs: >> >> Running: bash "2>&1 cucumber >> /Users/rick/mastermind/features/codebreaker_starts_game.feature >> --format=html" >> bash: 2>&1 cucumber >> /Users/rick/mastermind/features/codebreaker_starts_game.feature >> --format=html: No such file or directory false >> >> I'm guessing that the file it isn't finding is cucumber? Is there an >> environment variable I need to set in textmate? >> >> >> >> > > Ahh, I've had similar issues with RSpec's bundle before. Basically, > your PATH is not being used for all of your OSX applications. From the > rspec site[1]: > > You may need to adjust the PATH in your ~/.MacOSX/environment.plist > file to point to the directory > where your ruby and spec executables live. For example: > > PATH > /usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/usr/local/mysql/bin > > > > > I will also add a TM_CUCUMBER_BIN constant option so if that is set it > will use that instead of assuming 'cucumber' is in your path. I'll > let you know when that is done. http://github.com/bmabey/cucumber-tmbundle/commit/8516e1c40cf6181e35d45db943de374d7516fcc1 Try updating the bundle and defining a TM_CUCUMBER_BIN in Textmate (Textmate -> Preferences -> Advanced -> Shell Variables). Let me know how it goes. Thanks, Ben From dchelimsky at gmail.com Mon Apr 27 16:27:29 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 27 Apr 2009 15:27:29 -0500 Subject: [rspec-users] cucumber/webrat, need to set user in session, can't stub or mock. Fixtures? In-Reply-To: <50873a360904271309o68a38626va6f06deaad76e38e@mail.gmail.com> References: <50873a360904271309o68a38626va6f06deaad76e38e@mail.gmail.com> Message-ID: <57c63afe0904271327h50cddd6bpdde86b8cca714cbc@mail.gmail.com> On Mon, Apr 27, 2009 at 3:09 PM, doug livesey wrote: > Hi -- I'm assuming that there are excellent reasons for not enabling stubs & > mocks in cucumber, but I find myself in a bit of a pickle without them. Aslak and I were discussing this very thing earlier today. There are definitely good reasons not to use message expectations (mocks - see http://wiki.github.com/aslakhellesoy/cucumber/mocking-with-cucumber) in cucumber, but stubs are different and we're thinking there should be support for them. I haven't tried this, but you should be able to do what RSpec does to adapt to different mock/stub frameworks. To use rspec's, for example, you should be able to say: require 'spec/mocks/framework' require 'spec/mocks/extensions' World(Spec::Mocks::ExampleMethods) Before do $rspec_stubs ||= Spec::Mocks::Space.new end After do $rspec_stubs.reset_all end Now you *should* have the same mocking/stubbing methods you do in rspec examples in cucumber step definitions, and the stubs get cleared out after each scenario. See if that works, and then maybe we can figure out a way to generalize rspec's mock-framework-adapter framework so cucumber can use it as well (so you'd be able to stub w/ mocha, rr, flexmock, or any other). Cheers, David > Basically, I want to write a feature that has the home page displaying if > there is a logged in user (identified by a call to current_user, which in > turn checks session[:user_id]), and that displays an unauthorised access > page if there isn't. > I guess normally, I'd have webrat walk through my app, including logging in? > Unfortunately, the login doesn't happen in this application, though. It > happens in another that shares state with this one, so I can't do this. > Could someone advise how I can set up my scenario so that there is a valid > user either in the session, or stubbed from the current_user? > Would this be something to do with fixtures? > If so, could someone point me at some docs that show me how to use them with > cucumber? > Thanks for any & all help, > ?? Doug. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Apr 27 16:40:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 27 Apr 2009 15:40:54 -0500 Subject: [rspec-users] cucumber/webrat, need to set user in session, can't stub or mock. Fixtures? In-Reply-To: <50873a360904271339o1198a90asd2cf403abdaaf562@mail.gmail.com> References: <50873a360904271309o68a38626va6f06deaad76e38e@mail.gmail.com> <57c63afe0904271327h50cddd6bpdde86b8cca714cbc@mail.gmail.com> <50873a360904271339o1198a90asd2cf403abdaaf562@mail.gmail.com> Message-ID: <57c63afe0904271340x2c235251if86134fd799dd273@mail.gmail.com> On Mon, Apr 27, 2009 at 3:39 PM, doug livesey wrote: > Cheers for that -- I'll give it a try. > Would all of that be in the step file? Please be sure to clip the relevant parts when responding - "all of that" is only meaningful if I look at the other email in this thread. Easy on my desk top. Not so easy on my phone. Try support/env.rb. Cheers, David > (Total cucumber newbie, sorry!) > Cheers, > ?? Doug. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Apr 27 16:44:03 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 27 Apr 2009 22:44:03 +0200 Subject: [rspec-users] Cucumber - Testing ActionMailer Message-ID: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> I need some help with this. I have installed email-spec (courtesy of BMabey) and I have configure things thusly: Scenario: E-Mail Exchange Rates to notify parties Given a currency exchange feed from the Bank of Canada When the currency exchange retrieval script runs Then I should receive an email Then /should receive (an|\d+) e-?mails?/ do |amount| amount = 1 if amount == "an" unread_emails_for(current_email_address).size.should == amount.to_i end ../environments/test.rb # Tell ActionMailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test config.gem 'bmabey-email_spec', :lib => 'email_spec' class MailerPublic < ActionMailer::Base def forex_daily_notice(address,rates) rates_effective = Date.today.to_s(:db) recipients address.to_a from "ForexService at harte-lyne.ca" reply_to "support at harte-lyne.ca" subject "#{rates_effective} - Foreign Exchange Rates Notice" body :rates_effective => rates_effective, :rates => rates end end ./views/mailer_public/forex_daily_notice.text.plain.erb Canada Customs foreign currency exchange rates for currency conversion of shipments made on <%=@rates_effective%> When I run this ./bin/script.rb ... # Format and email the results. if fx_hash_array puts "got an array" send_to = 'test_email at example.com' MailerPublic.deliver_forex_daily_notice!(send_to,fx_hash_array) puts ActionMailer::Base.deliveries.length ActionMailer::Base.deliveries.each { |m| puts m } end Then I see this: got an array 0 This is my first attempt at using ActionMailer so no doubt I have overlooked something basic. Can anyone tell me what it is? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon Apr 27 16:52:59 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 27 Apr 2009 21:52:59 +0100 Subject: [rspec-users] [cucumber] Setting a constant in step definition In-Reply-To: <88fd8ddc0904271108k59af8bdfrcb156c20f8c332b0@mail.gmail.com> References: <88fd8ddc0904270500l486abde9x1482ff51e1cc92d@mail.gmail.com> <8d961d900904270632s5ec7fc0eifc32f54e8bafb445@mail.gmail.com> <88fd8ddc0904270742n365a97efu9263479ee97411f0@mail.gmail.com> <8d961d900904270933y28dc35c7j221cf3af60e09351@mail.gmail.com> <88fd8ddc0904271108k59af8bdfrcb156c20f8c332b0@mail.gmail.com> Message-ID: <14D3DC21-52EC-41AE-AC26-2F2DE7F4553A@mattwynne.net> On 27 Apr 2009, at 19:08, Andrew Premdas wrote: > Thankyou Aslak much appreciated Bear in mind that this trick will change the value of the constant FOR ALL REMAINING SCENARIOS - not just the current one. If that bothers you, have a read of this thread: http://www.nabble.com/AfterCurrentScenario-block-td23100686.html > > > Andrew > > 2009/4/27 aslak hellesoy > > Good question. One answer is that it can change, it just needs a > code change and application restart. > > Basic business case is that someone will set the postage threshold > before the application is deployed. However they could choose any > value. So I want to test what happens when the application is setup > with different values e.g. zero because all postage is free and ?30 > cos postage is free if you spend ?50 or more. > > Currently we do not want to do form based admin for this setting > (and similar ones) because such a change would be very infrequent, > so we are currently happy to redeploy to make the change. > > I would do something like this: http://gist.github.com/102586 > > > > 2009/4/27 aslak hellesoy > > > > On Mon, Apr 27, 2009 at 2:00 PM, Andrew Premdas > wrote: > Currently I have a very simple constants implementation being loaded > as a Rails initialiser > > module MVOR > module Postage > THRESHOLD = BigDecimal.new('6.99') > RATE = BigDecimal.new('30.00') > end > end > > > My scenarios of my postage feature want to deal with two situations > when the THRESHOLD has been set to zero and to '6.99'. The question > is how can I set the threshold in my step_definition. So I want to > implement > > Given the postage threshold is 0.00 > Given the postage threshold is 6.99 > > > Since it's a constant - how can it possibly change? And therefore - > why are you testing it with different values? > > > I've considered a number of ideas, but seem to keep on getting into > complex solutions for what I assume is something very simple. > > TIA > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Apr 27 16:53:14 2009 From: lists at ruby-forum.com (James Byrne) Date: Mon, 27 Apr 2009 22:53:14 +0200 Subject: [rspec-users] [cucumber] Where does STDOUT go? Message-ID: If one invokes a Ruby script from a cucumber step definition and that script contains "puts" statements then where does the output go? I have a script that when run from the command line displays "puts" output in the terminal session, but when run from a cucumber step definition produces no console output. It does however produce the expected output file in either case. -- Posted via http://www.ruby-forum.com/. From kero at chello.nl Mon Apr 27 17:23:25 2009 From: kero at chello.nl (Kero van Gelder) Date: Mon, 27 Apr 2009 23:23:25 +0200 Subject: [rspec-users] [Cucumber] gem missing dependencies In-Reply-To: <8d961d900904260734t24032535pbfc8d18812d3f3de@mail.gmail.com> References: <20090426121649.GA8422@bumblebee.m38c.nl> <8d961d900904260734t24032535pbfc8d18812d3f3de@mail.gmail.com> Message-ID: <20090427212325.GA13970@bumblebee.m38c.nl> Hi list & Clifford, > > Looks like installing hoe (which brings in rubyforge and rake) solved the problem below. > > I just fixed that: > http://github.com/aslakhellesoy/cucumber/commit/23cbc9b6c54ebe1ecf568610c2696762f22f0b06 Thanks Aslak, that was quick, but... I had to try that, and the 0.3.1 release made that very easy. Didn't help. looks like polyglot is the culprit, from some extra output I created from rubygems: #, @loaded_from="/var/lib/gems/1.8/specifications/polyglot-0.2.5.gemspec", @original_platform=nil, @post_install_message=nil, @description="Allows custom language loaders for specified file extensions to be hooked into require", @dependencies=[#=", #]]>, @type=:runtime>], @requirements=[], @test_files=["test/test_helper.rb", "test/test_polyglot.rb"], @require_paths=["lib"], @extra_rdoc_files=["History.txt", "License.txt", "Manifest.txt", "README.txt", "website/index.txt"], @date=Tue Mar 03 00:00:00 +0100 2009, @new_platform="ruby", @executables=[], @authors=["Clifford Heath"], @cert_chain=[], @name="polyglot", @required_rubygems_version=#=", #]]>, @files=["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "lib/polyglot.rb", "lib/polyglot/version.rb", "log/debug.log", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/test_helper.rb", "test/test_polyglot.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml"], @has_rdoc=true, @specification_version=2, @loaded=true, @signing_key=nil, @default_executable=nil, @email="cjheath at rubyforge.org", @required_ruby_version=#=", #]]>, @rdoc_options=["--main", "README.txt"], @bindir="bin", @rubygems_version="1.2.0", @homepage="http://polyglot.rubyforge.org", @platform="ruby", @autorequire=nil, @rubyforge_project="polyglot"> [#=", #]]>, @type=:runtime>] Clifford, let's take this off-list. Bye, Kero. > > fresh install of debian lenny, upgraded to unstable. > > > > $ ruby -v > > ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] > > $ gem -v > > 1.2.0 > > $ gem list > > > > *** LOCAL GEMS *** > > > > builder (2.1.2) > > cucumber (0.3.0) > > diff-lcs (1.1.2) > > polyglot (0.2.5) > > rspec (1.2.4) > > term-ansicolor (1.0.3) > > treetop (1.2.5) > > $ cucumber > > /usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find RubyGem hoe (>= 1.8.0) (Gem::LoadError) > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:134:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `each' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate' > > ? ? ? ?from /usr/lib/ruby/1.8/rubygems.rb:49:in `gem' > > ? ? ? ?from /var/lib/gems/1.8/bin/cucumber:18 ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From ben at benmabey.com Mon Apr 27 17:24:05 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 27 Apr 2009 15:24:05 -0600 Subject: [rspec-users] [cucumber] Where does STDOUT go? In-Reply-To: References: Message-ID: <49F62275.4020103@benmabey.com> James Byrne wrote: > If one invokes a Ruby script from a cucumber step definition and that > script contains "puts" statements then where does the output go? I have > a script that when run from the command line displays "puts" output in > the terminal session, but when run from a cucumber step definition > produces no console output. It does however produce the expected output > file in either case. > If you are running the command with the backticks it is simply being returned to that call. If you want to see that ouput you could add a puts.. for example: puts `some_command` If you are testing a CLI tool you may want to look how Cucumber's and RSpec's features capture and use the STDOUT and STDERR. http://github.com/aslakhellesoy/cucumber/blob/0e9f6066bbed0e0b73f4af0a18f186a7e13fea46/features/support/env.rb -Ben From wolfmanjm at gmail.com Mon Apr 27 17:32:38 2009 From: wolfmanjm at gmail.com (wolfmanjm) Date: Mon, 27 Apr 2009 14:32:38 -0700 (PDT) Subject: [rspec-users] Background and scenario outline interaction In-Reply-To: <88fd8ddc0904270511s476872bej54a8bd5b8d7eefda@mail.gmail.com> References: <1b13c4d1-7e7a-4f24-93cc-594ad1e39f05@x29g2000prf.googlegroups.com> <88fd8ddc0904270511s476872bej54a8bd5b8d7eefda@mail.gmail.com> Message-ID: <3a80622f-5b63-4d56-a936-8376f98fc0f7@y10g2000prc.googlegroups.com> Ahh no I'm still using 0.2.0 I was going to write up a gist as an example, I actually just stopped using background and put it in the scenario outline, but I'll try it on 0.3.0 Thanks On Apr 27, 5:11?am, Andrew Premdas wrote: > Is this with 0.3.0? If not this might have been recently fixed as I reported > a similar bug recently > > 2009/4/24 Jim Morris > > > Hi, > > > I was surprised by this so I suspect it may be a bug. > > > I have a Scenario Outline, and a Background in my Feature and nothing > > else, > > > The Background got executed 1 more time than expected. > > > Details are the Scenario Outline had 4 entries in the table, so I > > expected 4 scenarios to get executed, and the Background to get > > executed before each Scenario. > > > What happened was the Background got executed once initially, then > > once for each entry on the outline table, the After scenario hook got > > correctly executed after each of the 4 scenarios, but not after the > > first Background (understandably as there was no scenario executed). > > > Is this a bug or feature ;) > > _______________________________________________ > > 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 zach.dennis at gmail.com Mon Apr 27 17:34:12 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 27 Apr 2009 17:34:12 -0400 Subject: [rspec-users] cucumber/webrat, need to set user in session, can't stub or mock. Fixtures? In-Reply-To: <50873a360904271424j12623839xd5a933739e225d3b@mail.gmail.com> References: <50873a360904271309o68a38626va6f06deaad76e38e@mail.gmail.com> <57c63afe0904271327h50cddd6bpdde86b8cca714cbc@mail.gmail.com> <50873a360904271339o1198a90asd2cf403abdaaf562@mail.gmail.com> <57c63afe0904271340x2c235251if86134fd799dd273@mail.gmail.com> <50873a360904271404r51c507fcl2e377909ab1dd5af@mail.gmail.com> <50873a360904271408n1161d90dpacb25204da766136@mail.gmail.com> <50873a360904271418g50a999dah16144671f74237ec@mail.gmail.com> <50873a360904271424j12623839xd5a933739e225d3b@mail.gmail.com> Message-ID: <85d99afe0904271434k4a50aa63gdaadc35198db1618@mail.gmail.com> On Mon, Apr 27, 2009 at 5:24 PM, doug livesey wrote: > Refactoring the current_user method a little, then stubbing the find method > in there did it. > > # ApplicationController > def current_user > ? User.find( session[:user_id] ) rescue nil > end > > # Scenario step > Given /^that a user is logged in to the session$/ do > ? User.stub!( :find ).and_return( true ) > end You probably want to return a User, no? Returning true is entirely different than the normal find API w/ActiveRecord. It seems to be misleading and I can see where it would cause problems where controller or view code that relies on #current_user expects a User, > > Cheers, > ?? Doug. > > 2009/4/27 doug livesey >> >> Except I'm now struggling with how it should work, sorry. >> The step for the scenario looks like this: >> >> Given /^that a user is logged in to the session$/ do >> ? controller.stub!( :current_user ).and_return( true ) >> end >> >> However, when I try to puts the value of current_user as called from the >> ApplicationController#authorise method, it returns nil. >> I've tried just stubbing out the authorise method, too, but that doesn't >> seem to work, either. >> Am I approaching this the wrong way? >> & cheers again, >> ?? Doug. >> >> 2009/4/27 doug livesey >>> >>> & that nailed it, cheers man! >>> ?? Doug. >>> >>> 2009/4/27 doug livesey >>>> >>>> > Please be sure to clip the relevant parts when responding - "all of >>>> > that" is only meaningful if I look at the other email in this thread. >>>> > Easy on my desk top. Not so easy on my phone. >>>> >>>> Bit too used to gmail threads, sorry! >>>> ?? Doug. >>> >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter) From wolfmanjm at gmail.com Mon Apr 27 17:47:33 2009 From: wolfmanjm at gmail.com (wolfmanjm) Date: Mon, 27 Apr 2009 14:47:33 -0700 (PDT) Subject: [rspec-users] Background and scenario outline interaction In-Reply-To: <88fd8ddc0904270511s476872bej54a8bd5b8d7eefda@mail.gmail.com> References: <1b13c4d1-7e7a-4f24-93cc-594ad1e39f05@x29g2000prf.googlegroups.com> <88fd8ddc0904270511s476872bej54a8bd5b8d7eefda@mail.gmail.com> Message-ID: <5884397d-f0fc-4436-8534-a9b1013c0167@k19g2000prh.googlegroups.com> Ok there is a different bug with 0.3.0, I'll work up a gist, but it seems that background with scenario outline now has background run before the Before hook, or maybe the before hook is not being run. The docs say background runs after the before hook. I need to debug further to see what is actually happening On Apr 27, 5:11?am, Andrew Premdas wrote: > Is this with 0.3.0? If not this might have been recently fixed as I reported > a similar bug recently > > 2009/4/24 Jim Morris > > > Hi, > > > I was surprised by this so I suspect it may be a bug. > > > I have a Scenario Outline, and a Background in my Feature and nothing > > else, > > > The Background got executed 1 more time than expected. > > > Details are the Scenario Outline had 4 entries in the table, so I > > expected 4 scenarios to get executed, and the Background to get > > executed before each Scenario. > > > What happened was the Background got executed once initially, then > > once for each entry on the outline table, the After scenario hook got > > correctly executed after each of the 4 scenarios, but not after the > > first Background (understandably as there was no scenario executed). > > > Is this a bug or feature ;) > > _______________________________________________ > > 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 wolfmanjm at gmail.com Mon Apr 27 18:38:08 2009 From: wolfmanjm at gmail.com (wolfmanjm) Date: Mon, 27 Apr 2009 15:38:08 -0700 (PDT) Subject: [rspec-users] Background and scenario outline interaction In-Reply-To: <5884397d-f0fc-4436-8534-a9b1013c0167@k19g2000prh.googlegroups.com> References: <1b13c4d1-7e7a-4f24-93cc-594ad1e39f05@x29g2000prf.googlegroups.com> <88fd8ddc0904270511s476872bej54a8bd5b8d7eefda@mail.gmail.com> <5884397d-f0fc-4436-8534-a9b1013c0167@k19g2000prh.googlegroups.com> Message-ID: <9165289c-8236-4bd6-8677-435cc94e13d8@z23g2000prd.googlegroups.com> Ok I confirmed that the Before hook is not run the first time through when scenario outline and Background is used. The After hook is run though. In subsequent outlines before and after run as expected. gist is here... git clone git://gist.github.com/102789.git gist-102789 http://gist.github.com/gists/102789/download I am using cucumber (0.3.1) jruby 1.1.6 also same results with ruby 1.8.6 (2008-08-11 patchlevel 287) [i686- linux] On Apr 27, 2:47?pm, wolfmanjm wrote: > Ok there is a different bug with 0.3.0, I'll work up a gist, but it > seems that background with scenario outline now has background ?run > before the Before hook, or maybe the before hook is not being run. The > docs say background runs after the before hook. > > I need to debug further to see what is actually happening > > On Apr 27, 5:11?am, Andrew Premdas wrote: > > > Is this with 0.3.0? If not this might have been recently fixed as I reported > > a similar bug recently > > > 2009/4/24 Jim Morris > > > > Hi, > > > > I was surprised by this so I suspect it may be a bug. > > > > I have a Scenario Outline, and a Background in my Feature and nothing > > > else, > > > > The Background got executed 1 more time than expected. > > > > Details are the Scenario Outline had 4 entries in the table, so I > > > expected 4 scenarios to get executed, and the Background to get > > > executed before each Scenario. > > > > What happened was the Background got executed once initially, then > > > once for each entry on the outline table, the After scenario hook got > > > correctly executed after each of the 4 scenarios, but not after the > > > first Background (understandably as there was no scenario executed). > > > > Is this a bug or feature ;) > > > _______________________________________________ > > > 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-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From kero at chello.nl Mon Apr 27 19:14:13 2009 From: kero at chello.nl (Kero van Gelder) Date: Tue, 28 Apr 2009 01:14:13 +0200 Subject: [rspec-users] [Cucumber] gem missing dependencies In-Reply-To: <8d961d900904271454r4366ac8doe2a874ddbb5cb6bd@mail.gmail.com> References: <20090426121649.GA8422@bumblebee.m38c.nl> <8d961d900904260734t24032535pbfc8d18812d3f3de@mail.gmail.com> <20090427212325.GA13970@bumblebee.m38c.nl> <8d961d900904271454r4366ac8doe2a874ddbb5cb6bd@mail.gmail.com> Message-ID: <20090427231413.GC13970@bumblebee.m38c.nl> > This is the umpteenth time polyglot messes up. Polyglot is broken broken > broken. Cucumber doesn't use it, but can't escape it, because Treetop > *always* loads it. I have tried to lobby the Treetop developers to make it > optional. I have sent a patch (as a treetop fork). It's still in there. > > What else can I do? How far do you want to take it? We got gems, github. Think RPath, fedora spins, debian derivatives. Grab all stuff from rubyforge and publish your own gem-feed. Tweaked to fit your needs. But for that scheme to work, others should not lure us away from your feed with their own, that tweaks other gems. So I guess what you really need is a policy for gems on rubyforge. rubygems looking over some quality and cohesiveness, like (linux) distros check quality and make sure packages work together. The kind of check we'd want to do on polyglot is easy to automate. If it'd be done when creating the gem, as well as on rubyforge before it's put in the feed, I guess noone can complain. Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From programmer2188 at gmail.com Mon Apr 27 19:55:59 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Mon, 27 Apr 2009 19:55:59 -0400 Subject: [rspec-users] BDD for C#? In-Reply-To: <8d961d900904270851h6fdc91f1hb25d4952e910f18@mail.gmail.com> References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> <000101c9c605$e5be7450$b13b5cf0$@com> <8d961d900904260332s742e3e81x7d964dfb3d7beb6b@mail.gmail.com> <000601c9c6ea$a8a45a40$f9ed0ec0$@com> <8d961d900904270851h6fdc91f1hb25d4952e910f18@mail.gmail.com> Message-ID: <011301c9c793$b807f920$2817eb60$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of aslak hellesoy > Sent: Monday, April 27, 2009 11:51 AM > To: rspec-users > Subject: Re: [rspec-users] BDD for C#? > > > > I think you mean: "Does IronRuby work along with RSpec". The answer is > *maybe*. IronRuby doesn't work with most things yet. > For now, the answer appears to be no, unfortunately. I'll have to come back to it in a few months when it's hopefully more stable. NBehave looks really nice, but unfortunately there is really no documentation for it at all, except for a few examples of usage. I think it's either that or NUnit with naming conventions, but I really like the scenario support in NBehave. Brandon > Step definitions would have to be written in Ruby until I implement > something similar to cucumber_java (cucumber_dotnet), which would let > you write step definitions in any .NET language that supports an > annotation mechanism. > > Aslak > > > > > I might try it, if I can find a way to do acceptance tests for > this > application. It might not be as hard as I thought. > > Brandon > > > > Aslak > > > > > > > > Not port or link, replicate. It's only like ~10 features, > right? > > I don't know C#, but I could do it in C++ in a couple days. > > > > -- > > Phlip > > http://flea.sourceforge.net/resume.html > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > www.perpetualseeker.com > Blog about college, programming, and other random things. > Follow me on Twitter: http://twitter.com/devbanana > > > _______________________________________________ > > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > www.perpetualseeker.com Blog about college, programming, and other random things. Follow me on Twitter: http://twitter.com/devbanana From matt at mattwynne.net Mon Apr 27 20:17:20 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 28 Apr 2009 01:17:20 +0100 Subject: [rspec-users] [cucumber] Setting a constant in step definition In-Reply-To: <8d961d900904271448x5e310c20ud1e86a4e1d986bf3@mail.gmail.com> References: <88fd8ddc0904270500l486abde9x1482ff51e1cc92d@mail.gmail.com> <8d961d900904270632s5ec7fc0eifc32f54e8bafb445@mail.gmail.com> <88fd8ddc0904270742n365a97efu9263479ee97411f0@mail.gmail.com> <8d961d900904270933y28dc35c7j221cf3af60e09351@mail.gmail.com> <88fd8ddc0904271108k59af8bdfrcb156c20f8c332b0@mail.gmail.com> <14D3DC21-52EC-41AE-AC26-2F2DE7F4553A@mattwynne.net> <8d961d900904271448x5e310c20ud1e86a4e1d986bf3@mail.gmail.com> Message-ID: <072FEF5A-534A-49C7-9316-7C03E0054418@mattwynne.net> On 27 Apr 2009, at 22:48, aslak hellesoy wrote: > > > On 27 Apr 2009, at 19:08, Andrew Premdas wrote: > > Thankyou Aslak much appreciated > > Bear in mind that this trick will change the value of the constant > FOR ALL REMAINING SCENARIOS - not just the current one. > > I think you missed the After block. I stand corrected :) > If that bothers you, have a read of this thread: > http://www.nabble.com/AfterCurrentScenario-block-td23100686.html > > > > > Andrew > > 2009/4/27 aslak hellesoy > > Good question. One answer is that it can change, it just needs a > code change and application restart. > > Basic business case is that someone will set the postage threshold > before the application is deployed. However they could choose any > value. So I want to test what happens when the application is setup > with different values e.g. zero because all postage is free and ?30 > cos postage is free if you spend ?50 or more. > > Currently we do not want to do form based admin for this setting > (and similar ones) because such a change would be very infrequent, > so we are currently happy to redeploy to make the change. > > I would do something like this: http://gist.github.com/102586 > > > > 2009/4/27 aslak hellesoy > > > > On Mon, Apr 27, 2009 at 2:00 PM, Andrew Premdas > wrote: > Currently I have a very simple constants implementation being loaded > as a Rails initialiser > > module MVOR > module Postage > THRESHOLD = BigDecimal.new('6.99') > RATE = BigDecimal.new('30.00') > end > end > > > My scenarios of my postage feature want to deal with two situations > when the THRESHOLD has been set to zero and to '6.99'. The question > is how can I set the threshold in my step_definition. So I want to > implement > > Given the postage threshold is 0.00 > Given the postage threshold is 6.99 > > > Since it's a constant - how can it possibly change? And therefore - > why are you testing it with different values? > > > I've considered a number of ideas, but seem to keep on getting into > complex solutions for what I assume is something very simple. > > TIA > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > 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 Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Mon Apr 27 20:22:52 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 28 Apr 2009 02:22:52 +0200 Subject: [rspec-users] [cucumber] Where does STDOUT go? In-Reply-To: <49F62275.4020103@benmabey.com> References: <49F62275.4020103@benmabey.com> Message-ID: <7c33c768f23270a2969ec63db3d3ef14@ruby-forum.com> Ben Mabey wrote: > > If you are running the command with the backticks it is simply being > returned to that call. If you want to see that ouput you could add a > puts.. for example: > > puts `some_command` > Thanks -- Posted via http://www.ruby-forum.com/. From sfeley at gmail.com Mon Apr 27 20:50:07 2009 From: sfeley at gmail.com (Stephen Eley) Date: Mon, 27 Apr 2009 20:50:07 -0400 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly spe cing In-Reply-To: References: <2c7e61990904201240w72c4536ex7ea95c43f59ff44a@mail.gmail.com> <1fb4df0904231240i47e1d39cv8c6f61e67f41bf8f@mail.gmail.com> Message-ID: <1fb4df0904271750g6f63156ay6c646aae4150d12b@mail.gmail.com> On Sun, Apr 26, 2009 at 10:20 PM, Dan North wrote: > 2009/4/24 Stephen Eley >> >> Yeah, I'm a smartass. > > Well you seem to be on the right lines to me. Thank you! That means a great deal to me. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From julian at leviston.net Mon Apr 27 22:15:44 2009 From: julian at leviston.net (Julian Leviston) Date: Tue, 28 Apr 2009 12:15:44 +1000 Subject: [rspec-users] [cucumber] Where does STDOUT go? In-Reply-To: References: Message-ID: <15290D52-E855-414D-9CD1-27CDC302AE28@leviston.net> It produces console output for me. Julian. On 28/04/2009, at 6:53 AM, James Byrne wrote: > If one invokes a Ruby script from a cucumber step definition and that > script contains "puts" statements then where does the output go? I > have > a script that when run from the command line displays "puts" output in > the terminal session, but when run from a cucumber step definition > produces no console output. It does however produce the expected > output > file in either case. > -- > 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 Tue Apr 28 00:14:33 2009 From: programmer2188 at gmail.com (Brandon Olivares) Date: Tue, 28 Apr 2009 00:14:33 -0400 Subject: [rspec-users] BDD for C#? In-Reply-To: References: <000801c9c55d$63996f00$2acc4d00$@com> <49F2A99C.60701@benmabey.com> <000101c9c605$e5be7450$b13b5cf0$@com> <8d961d900904260332s742e3e81x7d964dfb3d7beb6b@mail.gmail.com> <000601c9c6ea$a8a45a40$f9ed0ec0$@com> <8d961d900904270851h6fdc91f1hb25d4952e910f18@mail.gmail.com> <011301c9c793$b807f920$2817eb60$@com> Message-ID: <002701c9c7b7$d6db03f0$84910bd0$@com> > -----Original Message----- > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > bounces at rubyforge.org] On Behalf Of Dan North > Sent: Monday, April 27, 2009 10:00 PM > To: rspec-users > Subject: Re: [rspec-users] BDD for C#? > > Hi Brandon. > > I already replied on the BDD list but can I suggest you give the > nbehave guys a poke, or even get involved in helping them out? > > If they started getting some releases out it would really help build > some momentum around it. > > Cheers, > Dan > Yeah, I think I will. It looks like the best right now, anyway. I'm not sure I could help much, though I could perhaps help with documentation if anything, but I will contact them. Thanks, Brandon > > 2009/4/28 Brandon Olivares > > > > > > > -----Original Message----- > > From: rspec-users-bounces at rubyforge.org [mailto:rspec-users- > > bounces at rubyforge.org] On Behalf Of aslak hellesoy > > > Sent: Monday, April 27, 2009 11:51 AM > > To: rspec-users > > Subject: Re: [rspec-users] BDD for C#? > > > > > > > > > I think you mean: "Does IronRuby work along with RSpec". The > answer is > > *maybe*. IronRuby doesn't work with most things yet. > > > > > For now, the answer appears to be no, unfortunately. I'll have to > come back > to it in a few months when it's hopefully more stable. > > NBehave looks really nice, but unfortunately there is really no > documentation for it at all, except for a few examples of usage. > I think > it's either that or NUnit with naming conventions, but I really > like the > scenario support in NBehave. > > Brandon > > > > Step definitions would have to be written in Ruby until I > implement > > something similar to cucumber_java (cucumber_dotnet), which > would let > > you write step definitions in any .NET language that supports > an > > annotation mechanism. > > > > Aslak > > > > > > > > > > I might try it, if I can find a way to do acceptance > tests for > > this > > application. It might not be as hard as I thought. > > > > Brandon > > > > > > > Aslak > > > > > > > > > > > > Not port or link, replicate. It's only like ~10 > features, > > right? > > > I don't know C#, but I could do it in C++ in a couple > days. > > > > > > -- > > > Phlip > > > http://flea.sourceforge.net/resume.html > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > > > www.perpetualseeker.com > > Blog about college, programming, and other random things. > > Follow me on Twitter: http://twitter.com/devbanana > > > > > > _______________________________________________ > > > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > www.perpetualseeker.com > Blog about college, programming, and other random things. > Follow me on Twitter: http://twitter.com/devbanana > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > www.perpetualseeker.com Blog about college, programming, and other random things. Follow me on Twitter: http://twitter.com/devbanana From ben at benmabey.com Tue Apr 28 00:51:09 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 27 Apr 2009 22:51:09 -0600 Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> Message-ID: <49F68B3D.6040007@benmabey.com> James Byrne wrote: > I need some help with this. I have installed email-spec (courtesy of > BMabey) and I have configure things thusly: > > Scenario: E-Mail Exchange Rates to notify parties > Given a currency exchange feed from the Bank of Canada > When the currency exchange retrieval script runs > Then I should receive an email > > Then /should receive (an|\d+) e-?mails?/ do |amount| > amount = 1 if amount == "an" > unread_emails_for(current_email_address).size.should == amount.to_i > end > > > ../environments/test.rb > # Tell ActionMailer not to deliver emails to the real world. > # The :test delivery method accumulates sent emails in the > # ActionMailer::Base.deliveries array. > config.action_mailer.delivery_method = :test > config.gem 'bmabey-email_spec', :lib => 'email_spec' > > > class MailerPublic < ActionMailer::Base > def forex_daily_notice(address,rates) > rates_effective = Date.today.to_s(:db) > recipients address.to_a > from "ForexService at harte-lyne.ca" > reply_to "support at harte-lyne.ca" > subject "#{rates_effective} - Foreign Exchange Rates Notice" > body :rates_effective => rates_effective, :rates => rates > end > end > > > ./views/mailer_public/forex_daily_notice.text.plain.erb > Canada Customs foreign currency exchange rates for > currency conversion of shipments made on <%=@rates_effective%> > > When I run this > > ./bin/script.rb > ... > # Format and email the results. > if fx_hash_array > puts "got an array" > send_to = 'test_email at example.com' > MailerPublic.deliver_forex_daily_notice!(send_to,fx_hash_array) > puts ActionMailer::Base.deliveries.length > ActionMailer::Base.deliveries.each { |m| puts m } > end > > Then I see this: > > got an array > 0 > > This is my first attempt at using ActionMailer so no doubt I have > overlooked something basic. Can anyone tell me what it is? > Looks right to me. To be honest though I have not used ActionMailer outside of Rails (where it just works out of the box). I don't see anything wrong with the approach you are taking. Maybe the rails mailing list could provide better advice. Sorry, I couldn't be of any help. -Ben From lists at ruby-forum.com Tue Apr 28 03:26:20 2009 From: lists at ruby-forum.com (Sarath Menon) Date: Tue, 28 Apr 2009 09:26:20 +0200 Subject: [rspec-users] Cucumber custome reports Message-ID: <9087056787e3df144e7736315e52601a@ruby-forum.com> Hi, I need to create a custom report based on cucumber output. I am thinking of two ways to do this. 1. Either I have to write a java application to fetch the values like execution time for each scenarios along with its name, status etc from cucumber in runtime. Is that possible? 2. Or write a xml formatter in cucumber and get the cucumber reports in xml format and fetch the values from this xml report. I would like to use the first option if such a support is available. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 28 03:56:23 2009 From: lists at ruby-forum.com (Sarath Menon) Date: Tue, 28 Apr 2009 09:56:23 +0200 Subject: [rspec-users] Cucumber custome reports In-Reply-To: <8d961d900904280037t693c5619m87ffb1f9ea298bdb@mail.gmail.com> References: <9087056787e3df144e7736315e52601a@ruby-forum.com> <8d961d900904280037t693c5619m87ffb1f9ea298bdb@mail.gmail.com> Message-ID: <8079f2042539979a5a53632ef6000343@ruby-forum.com> My actual question is, Is there any api that the cucumber offer which can be accessed to get the necessary data in the run time. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 28 05:11:32 2009 From: lists at ruby-forum.com (=?utf-8?Q?J=c3=a9r=c3=a9my_Kaz?=) Date: Tue, 28 Apr 2009 11:11:32 +0200 Subject: [rspec-users] [cucumber] Use of Scenario Outline for validation stuff ? Message-ID: <5bf32c0cece378069dfe66392b0f3b5b@ruby-forum.com> Hi there ! I was wondering if the way I test the validation of my forms is right or not. So here's a little example : Imagine you have a form with some validations designed to create some object. You want to test it using Scenario Outline and Examples. So you fill in the fields using , and press the create button. Then you "should see" (using webrat) the telling you - that the object has been well created - that some field isn't well filled And after that, in the objects list, you "should see" the created object in the list Assuming that the object has been created, you will see it in the list BUT if it has NOT been created, you won't. And, in my case, it will end in an error So my questions are : - Is it possible, using some trick, to use some conditions inside the .feature file ? - Do you think it's a good use of Scenario Outline ? Or you think I should have split it into 2 different scenarios (1 with working stuff, 1 with validation errors) I hope I'm clear. If I'm not, here's an example code of what I'm talking about :Scenario Outline: Create a VAT **************************************************************************************************** Given I am logged in as a SuperAdmin user When I go to the VATs page And I follow "New VAT" And I fill in "vat_caption" with "" And I fill in "vat_value" with "" And I press "Cr?er" Then I should see "" And the VAT "" should be present in the VAT list <==================== What it's all about, works if VAT added, but shouldn't be interpreted if VAT not added Examples: | caption | value | message | | Normal | 19.6 | VAT Normal well created | | | 19.6 | You are supposed to fill the caption field | | Normal | | You are supposed to fill the VAT field | | Normal | test | You are supposed to fill the VAT field with a numeric value | **************************************************************************************************** -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 28 05:15:08 2009 From: lists at ruby-forum.com (=?utf-8?Q?J=c3=a9r=c3=a9my_Kaz?=) Date: Tue, 28 Apr 2009 11:15:08 +0200 Subject: [rspec-users] [cucumber] Use of Scenario Outline for validation stuff ? In-Reply-To: <5bf32c0cece378069dfe66392b0f3b5b@ruby-forum.com> References: <5bf32c0cece378069dfe66392b0f3b5b@ruby-forum.com> Message-ID: <05bdf3db7ffb3c9c87b6e3e479b9c86f@ruby-forum.com> Sorry about bad formating, I pasted it and haven't checked ... Well, you may have understood that the "<====" thing is pointing to the 'And the VAT "" ...' line, the 1st col of 2nd line in the examples is a blank one, and the last line is cut into 2 -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 28 05:23:54 2009 From: lists at ruby-forum.com (=?utf-8?Q?J=c3=a9r=c3=a9my_Kaz?=) Date: Tue, 28 Apr 2009 11:23:54 +0200 Subject: [rspec-users] [cucumber] Use of Scenario Outline for validation stuff ? In-Reply-To: <05bdf3db7ffb3c9c87b6e3e479b9c86f@ruby-forum.com> References: <5bf32c0cece378069dfe66392b0f3b5b@ruby-forum.com> <05bdf3db7ffb3c9c87b6e3e479b9c86f@ruby-forum.com> Message-ID: Aheeeem .... Please someone delete this post, I didn't see my post is already present on the topic list, coming from the rubyforge rspec mailing list I guess. My apologies anyway ... -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Apr 28 06:13:47 2009 From: lists at ruby-forum.com (=?utf-8?Q?J=c3=a9r=c3=a9my_Kaz?=) Date: Tue, 28 Apr 2009 12:13:47 +0200 Subject: [rspec-users] [cucumber] Use of Scenario Outline for validation stuff ? In-Reply-To: <8d961d900904280224v6dda8738o41f1c5cf12e86f38@mail.gmail.com> References: <5bf32c0cece378069dfe66392b0f3b5b@ruby-forum.com> <05bdf3db7ffb3c9c87b6e3e479b9c86f@ruby-forum.com> <8d961d900904280224v6dda8738o41f1c5cf12e86f38@mail.gmail.com> Message-ID: Aslak Helles?y wrote: >> Sorry about bad formating, I pasted it and haven't checked ... >> >> Well, you may have understood that the "<====" thing is pointing to the >> 'And the VAT "" ...' line, the 1st col of 2nd line in the >> examples is a blank one, and the last line is cut into 2 > > > Sorry, I'm a little lost here. Was this supposed to be a reply to an > existing thread? Which one? Please use your email program's reply > button, or > your mails will appear outside the thread. > > Aslak This is not a reply to an existing thread, but a mistakenly reposted thread. The original one is here : http://www.ruby-forum.com/topic/185132#new My apologies again. -- Posted via http://www.ruby-forum.com/. From julian at leviston.net Tue Apr 28 09:11:43 2009 From: julian at leviston.net (Julian Leviston) Date: Tue, 28 Apr 2009 23:11:43 +1000 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> Message-ID: <7E784053-314D-4A4B-9082-0B7A86385CB3@leviston.net> Perhaps use background? Julian. On 28/04/2009, at 10:18 PM, doug livesey wrote: > Hi -- is it possible to set before and after blocks for individual > feature files? > I've tried putting them in step files, but they just get called > before everything, like they'd been declared in env.rb, which is > consistent with how I thought cucumber worked, but I thought I'd > best try it anyway. > Anyway, I have some features that require a specific state be set up > before they run -- is this possible to do, and how would I go about > doing it? > Thanks for any & all help, > Doug. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ashley.moran at patchspace.co.uk Tue Apr 28 09:12:07 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 28 Apr 2009 14:12:07 +0100 Subject: [rspec-users] [rspec] be_something accepts nils In-Reply-To: References: <6502C3C2-7404-49D1-8370-8E5E8F8CDE28@gmail.com> Message-ID: <7F5223E5-9334-48C0-99A4-127766EC09C5@patchspace.co.uk> On 13 Mar 2009, at 16:34, Matt Wynne wrote: > Like yoda sounds, that does Been implemented properly, it has :) http://blog.zenspider.com/2009/04/spec-yoda-will.html -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ http://twitter.com/ashleymoran From lists at ruby-forum.com Tue Apr 28 09:43:35 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 28 Apr 2009 15:43:35 +0200 Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <49F68B3D.6040007@benmabey.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> <49F68B3D.6040007@benmabey.com> Message-ID: <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> Ben Mabey wrote: > Sorry, I couldn't be of any help. > Actually, you were a great help, but on a different thread. The reason I was not seeing anything is that the default environment is "development" and I have things configured so that the deliveries array is only used in "test". Adding "puts" in front of the call to %x() in the step definition file showed that the email is generated as expected. I have something else wrong with my test, probably the address that I am checking for, -- Posted via http://www.ruby-forum.com/. From phlip2005 at gmail.com Tue Apr 28 09:56:40 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 28 Apr 2009 06:56:40 -0700 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> Message-ID: <49F70B18.6020706@gmail.com> Bump? >> Please explain how it doesn't work. Output, error etc. > > Same as before: I also get it from a rspec-rails case... From dchelimsky at gmail.com Tue Apr 28 10:09:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 28 Apr 2009 09:09:02 -0500 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: <49F70B18.6020706@gmail.com> References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> <49F70B18.6020706@gmail.com> Message-ID: <57c63afe0904280709w7c131872u4dcd2791c5c12c9e@mail.gmail.com> On Tue, Apr 28, 2009 at 8:56 AM, Phlip wrote: > Bump? > >>> Please explain how it doesn't work. Output, error etc. >> >> Same as before: > > I also get it from a rspec-rails case... Huh? What does this have to do w/ rspec-rails? This thread is about a NameError on _nt_scenario_outline_keyword. From lists at ruby-forum.com Tue Apr 28 10:43:01 2009 From: lists at ruby-forum.com (James Byrne) Date: Tue, 28 Apr 2009 16:43:01 +0200 Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> <49F68B3D.6040007@benmabey.com> <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> Message-ID: <5a353b250f4788ec641b3a26092fce9c@ruby-forum.com> I have reached this point in testing using email-spec: The code: # Format and email the results. if fx_hash_array send_to = 'email at example.com' MailerPublic.deliver_forex_daily_notice!(send_to,fx_hash_array) ActionMailer::Base.deliveries.each { |m| puts m } unless Rails.env.production? end The Feature Scenario: Scenario: E-Mail Exchange Rates to notify parties Given a currency exchange feed from the Bank of Canada And an empty email queue When the currency exchange retrieval script runs Then I should receive an email The Steps: Then /currency exchange retrieval script runs/ do stdout = %x(#{RAILS_ROOT}/bin/hll_forex_ca_feed.rb #{@xchg_source}) puts stdout puts current_email_address end ... local_email_steps Then /should receive (an|\d+) e-?mails?/ do |amount| amount = 1 if amount == "an" unread_emails_for(current_email_address).size.should == amount.to_i end The output: Scenario: E-Mail Exchange Rates to notify parties # features/app/models/currency_exchange_rates/ currency_exchange_rates.feature:19 xml source is: /home/byrnejb/Software/Development/Projects/proforma.git/doc/data/fx-noon-all-2009-04-15.xml Given a currency exchange feed from the Bank of Canada # features/app/models/currency_exchange_rates/step_definitions/ currency_exchange_rates_steps.rb:5 And an empty email queue # features/step_definitions/local_email_steps.rb:28 From: ForexService at harte-lyne.ca Reply-To: support at harte-lyne.ca To: email at example.com Subject: [ForEx] 2009-04-28 - Foreign Exchange Rates Notice Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=mimepart_49f713ebd7061_2d4d155c1a4737c82cd --mimepart_49f713ebd7061_2d4d155c1a4737c82cd Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: Quoted-printable Content-Disposition: inline Canada Customs foreign currency exchange rates for 2009-04-28: --mimepart_49f713ebd7061_2d4d155c1a4737c82cd-- email at example.com When the currency exchange retrieval script runs # features/app/models/currency_exchange_rates/step_definitions/ currency_exchange_rates_steps.rb:11 Then I should receive an email # features/step_definitions/local_email_steps.rb:49 expected: 1, got: 0 (using ==) Diff: @@ -1,2 +1,2 @@ -1 +0 (Spec::Expectations::ExpectationNotMetError) ./features/step_definitions/local_email_steps.rb:51:in `/should receive (an|\d+) e-?mails?/' features/app/models/currency_exchange_rates/currency_exchange_rates.feature:23:in `Then I should receive an email' The email To: header value and the current_email_address are the same insofar as I can tell. But the email_spec matcher is not finding that address in the deliveries array. Any ideas as to what I am missing? -- Posted via http://www.ruby-forum.com/. From akleak at gmail.com Tue Apr 28 11:32:04 2009 From: akleak at gmail.com (Arco) Date: Tue, 28 Apr 2009 08:32:04 -0700 (PDT) Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> Message-ID: I also would like a hook that executes a block once before running a feature file. In my testing i found that: - Background: executes before each scenario - Before executes before each scenario - Before('@tag') executes before each scenario Is there a way to execute a block once before each feature, but not before each scenario? On Apr 28, 7:08?am, aslak hellesoy wrote: > > Hi -- is it possible to set before and after blocks for individual feature > > files? > > Yes. Use tagged hooks:http://wiki.github.com/aslakhellesoy/cucumber/hooks > > Aslak > > > > > I've tried putting them in step files, but they just get called before > > everything, like they'd been declared in env.rb, which is consistent with > > how I thought cucumber worked, but I thought I'd best try it anyway. > > Anyway, I have some features that require a specific state be set up before > > they run -- is this possible to do, and how would I go about doing it? > > Thanks for any & all help, > > ? ?Doug. > > > _______________________________________________ > > 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 akleak at gmail.com Tue Apr 28 12:15:37 2009 From: akleak at gmail.com (Arco) Date: Tue, 28 Apr 2009 09:15:37 -0700 (PDT) Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> Message-ID: <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> OK - I found a workaround. I simply tag the first scenario with '@first', then do Before('@first') and i get what I want - executing a block once for the feature file. Except for one problem: most of my scenarios are done as scenario outlines, which are run multiple times - once for each row of my Example table. A workaround to that problem might be to put a 'dummy' scenario that is run before the other scenarios in my feature file... @first Scenario: Call a before block before running other scenarios... But this puts junk in my feature files. Is there a better, cleaner way?? On Apr 28, 8:32?am, Arco wrote: > I also would like a hook that executes a block once before running a > feature file. > > In my testing i found that: > - Background: executes before each scenario > - Before executes before each scenario > - Before('@tag') executes before each scenario > > Is there a way to execute a block once before each feature, but not > before each scenario? > > On Apr 28, 7:08?am, aslak hellesoy wrote: > > > > Hi -- is it possible to set before and after blocks for individual feature > > > files? > > > Yes. Use tagged hooks:http://wiki.github.com/aslakhellesoy/cucumber/hooks > > > Aslak > > > > I've tried putting them in step files, but they just get called before > > > everything, like they'd been declared in env.rb, which is consistent with > > > how I thought cucumber worked, but I thought I'd best try it anyway. > > > Anyway, I have some features that require a specific state be set up before > > > they run -- is this possible to do, and how would I go about doing it? > > > Thanks for any & all help, > > > ? ?Doug. > > > > _______________________________________________ > > > 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-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From phlip2005 at gmail.com Tue Apr 28 09:56:40 2009 From: phlip2005 at gmail.com (Phlip) Date: Tue, 28 Apr 2009 06:56:40 -0700 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: References: <8d961d900904250136t1577a7eay791bec65a38af132@mail.gmail.com> <75C2837B-F41F-415D-A375-D21AD809621E@gmail.com> Message-ID: <49F70B18.6020706@gmail.com> Bump? >> Please explain how it doesn't work. Output, error etc. > > Same as before: I also get it from a rspec-rails case... From wayne.simacek at gmail.com Tue Apr 28 10:25:27 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Tue, 28 Apr 2009 07:25:27 -0700 (PDT) Subject: [rspec-users] uninitialized constant ActionController running Cucumber features in Aptana/RadRails IDE In-Reply-To: <8d961d900904271446g65a7d7dco71b92ac338b7046c@mail.gmail.com> References: <8d961d900904271446g65a7d7dco71b92ac338b7046c@mail.gmail.com> Message-ID: <4dd2442f-80d8-4473-abf2-a9bd9173a6ca@z8g2000prd.googlegroups.com> I uninstalled rails-2.3.1 and rails-2.3.2 and then Successfully installed rails-2.3.2 ==>Same error message I think I'm going to try and lose the eclipse framework next. Just another layer giving me a headache. Thanks for your help, Wayne On Apr 27, 4:46?pm, aslak hellesoy wrote: > > I'm just starting on BDD. I installed the gems for webrats and > > cucumber. > > I also ran the following in the Ruby shell: > > > >rake gems:install RAILS_EN=test > > >script/generate cucumber > > > These commands seemed to create the expected features and lib folders > > in my project. > > > ?I'm using the eclipse framework with Aptana and RadRails as my IDE. > > However, when I run: > > > >cucumber features -n > > > from the Ruby shell, I get the following error: > > > ./app/controllers/application.rb:4: uninitialized constant > > ActionController (NameError) > > ? ? ? ?from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > > `gem_original_require' > > ? ? ? ?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/cucumber-0.3.0/bin/../lib/ > > cucumber/cli/main.rb:79:in `require_files' > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > cucumber/cli/main.rb:77:in `each' > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > cucumber/cli/main.rb:77:in `require_files' > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > cucumber/cli/main.rb:34:in `execute!' > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > cucumber/cli/main.rb:20:in `execute' > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/cucumber:6 > > ? ? ? ?from C:/ruby/bin/cucumber:19:in `load' > > ? ? ? ?from C:/ruby/bin/cucumber:19 > > > Any ideas on how I can initialize this constant ActionController or > > ActionController is part of Rails. It sounds like there is something wrong > with your Rails installation. > > Aslak > > > > > where the real error is coming from? Do I have to do some additional > > includes in some of my files? > > _______________________________________________ > > 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 itsme213 at hotmail.com Tue Apr 28 13:47:37 2009 From: itsme213 at hotmail.com (Sophie (itsme213)) Date: Tue, 28 Apr 2009 12:47:37 -0500 Subject: [rspec-users] Noob question Message-ID: Just getting started with cucumber on Mac 10.5.6. I have the default Ruby install (1.8). I'm not using Rails. I did a gem update cucumber and now have cucumber-0.3.1 in my gems. I also did a git clone and have a repo with cucumber 0.3.2. When I cd into my cucumber (git) directory and do: cucumber features I get /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- spec/expectations (LoadError) Failed to load ./cucumber/examples/selenium_webrat/features/support/env.rb from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `polyglot_original_require' from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in `require' from ./cucumber/examples/selenium_webrat/features/support/env.rb:1 ... Looks like I need a bunch more stuff than what the gem installs. Where can I find out what to install? Thanks! From akleak at gmail.com Tue Apr 28 14:12:46 2009 From: akleak at gmail.com (Arco) Date: Tue, 28 Apr 2009 11:12:46 -0700 (PDT) Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> Message-ID: I'd like to do this: Feature: user signup Before: Given I have a cleaned up database Scenario Outline: Sign Up Given I am on the signup page When I sign up using Then I should see Examples: |userid |message | |userX |successful signup | |userX |duplicate userid | "I have a cleaned up database" runs before every example, making the second example ('duplicate userid') fail. On Apr 28, 9:38?am, aslak hellesoy wrote: > On Tue, Apr 28, 2009 at 6:15 PM, Arco wrote: > > OK - I found a workaround. ?I simply tag the first scenario with > > '@first', then > > do Before('@first') and i get what I want - executing a block once for > > the feature file. > > > Except for one problem: ?most of my scenarios are done as scenario > > outlines, which > > are run multiple times - once for each row of my Example table. > > > A workaround to that problem might be to put a 'dummy' scenario that > > is run before the other scenarios in my feature file... > > > ?@first > > ?Scenario: Call a before block before running other scenarios... > > > But this puts junk in my feature files. ?Is there a better, cleaner > > way?? > > a) Why do you need one thing to happen before a feature? > b) Why can't you do it before each scenario? > > Aslak > > > > > On Apr 28, 8:32 am, Arco wrote: > > > I also would like a hook that executes a block once before running a > > > feature file. > > > > In my testing i found that: > > > - Background: executes before each scenario > > > - Before executes before each scenario > > > - Before('@tag') executes before each scenario > > > > Is there a way to execute a block once before each feature, but not > > > before each scenario? > > > > On Apr 28, 7:08 am, aslak hellesoy wrote: > > > > > > Hi -- is it possible to set before and after blocks for individual > > feature > > > > > files? > > > > > Yes. Use tagged hooks: > >http://wiki.github.com/aslakhellesoy/cucumber/hooks > > > > > Aslak > > > > > > I've tried putting them in step files, but they just get called > > before > > > > > everything, like they'd been declared in env.rb, which is consistent > > with > > > > > how I thought cucumber worked, but I thought I'd best try it anyway. > > > > > Anyway, I have some features that require a specific state be set up > > before > > > > > they run -- is this possible to do, and how would I go about doing > > it? > > > > > Thanks for any & all help, > > > > > ? ?Doug. > > > > > > _______________________________________________ > > > > > 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-us... at rubyforge.orghttp:// > > rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > > 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 ben at benmabey.com Tue Apr 28 14:28:51 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 28 Apr 2009 12:28:51 -0600 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> Message-ID: <49F74AE3.2060902@benmabey.com> Arco wrote: > I'd like to do this: > > Feature: user signup > Before: > Given I have a cleaned up database > Scenario Outline: Sign Up > Given I am on the signup page > When I sign up using > Then I should see > Examples: > |userid |message | > |userX |successful signup | > |userX |duplicate userid | > > "I have a cleaned up database" runs before every example, making the > second example ('duplicate userid') fail. > You could use Background and it would work just like you want it to: Feature: user signup Background: Given I have a cleaned up database Scenario Outline: Sign Up Given I am on the signup page When I sign up using Then I should see Examples: |userid |message | |userX |successful signup | |userX |duplicate userid | However, I would not encourage this. You should try to avoid using technical words, such as database, in your features. If anything you could say "Given no users exist" or something like that. Keeping your database clean is something you generally want for every scenario though. So I would suggest putting the code in your "Given I have a cleaned up database" code into a Before block. The wiki has a page on using the Before hook: http://wiki.github.com/aslakhellesoy/cucumber/hooks Basically, in your env.rb file you will add something like: Before do Database.clean! # or however you clean your DB end HTH, Ben > On Apr 28, 9:38 am, aslak hellesoy wrote: > >> On Tue, Apr 28, 2009 at 6:15 PM, Arco wrote: >> >>> OK - I found a workaround. I simply tag the first scenario with >>> '@first', then >>> do Before('@first') and i get what I want - executing a block once for >>> the feature file. >>> >>> Except for one problem: most of my scenarios are done as scenario >>> outlines, which >>> are run multiple times - once for each row of my Example table. >>> >>> A workaround to that problem might be to put a 'dummy' scenario that >>> is run before the other scenarios in my feature file... >>> >>> @first >>> Scenario: Call a before block before running other scenarios... >>> >>> But this puts junk in my feature files. Is there a better, cleaner >>> way?? >>> >> a) Why do you need one thing to happen before a feature? >> b) Why can't you do it before each scenario? >> >> Aslak >> >> >> >> >>> On Apr 28, 8:32 am, Arco wrote: >>> >>>> I also would like a hook that executes a block once before running a >>>> feature file. >>>> >>>> In my testing i found that: >>>> - Background: executes before each scenario >>>> - Before executes before each scenario >>>> - Before('@tag') executes before each scenario >>>> >>>> Is there a way to execute a block once before each feature, but not >>>> before each scenario? >>>> >>>> On Apr 28, 7:08 am, aslak hellesoy wrote: >>>> >>>>>> Hi -- is it possible to set before and after blocks for individual >>>>>> >>> feature >>> >>>>>> files? >>>>>> >>>>> Yes. Use tagged hooks: >>>>> >>> http://wiki.github.com/aslakhellesoy/cucumber/hooks >>> >>>>> Aslak >>>>> >>>>>> I've tried putting them in step files, but they just get called >>>>>> >>> before >>> >>>>>> everything, like they'd been declared in env.rb, which is consistent >>>>>> >>> with >>> >>>>>> how I thought cucumber worked, but I thought I'd best try it anyway. >>>>>> Anyway, I have some features that require a specific state be set up >>>>>> >>> before >>> >>>>>> they run -- is this possible to do, and how would I go about doing >>>>>> >>> it? >>> >>>>>> Thanks for any & all help, >>>>>> Doug. >>>>>> >>>>>> _______________________________________________ >>>>>> 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-us... at rubyforge.orghttp:// >>>> >>> rubyforge.org/mailman/listinfo/rspec-users >>> _______________________________________________ >>> 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 akleak at gmail.com Tue Apr 28 14:52:22 2009 From: akleak at gmail.com (Arco) Date: Tue, 28 Apr 2009 11:52:22 -0700 (PDT) Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <49F74AE3.2060902@benmabey.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> Message-ID: Thanks for your reply Ben. +1 on your wording recommendation - I understand and agree 100% However - for me - the Background block executes before each example in the table. Therefore, the database is cleared twice, and the second example ('duplicate userid') fails. (Cucumber 0.3.1 / ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]) Here are some snippets from a little workaround that i've employed... in env.rb: State = {'feature_file'=>'initialize'} in my_steps.rb: unless State['feature_file'] == @__cucumber_current_step.file_colon_line.split(':').first puts "CLEANUP CODE HERE - RUN ONCE PER FEATURE FILE --------" end State['feature_file'] = @__cucumber_current_step.file_colon_line.split(':').first I'm sure there must be a better way! I am still learning cucumber so any advice is welcome! ;-) On Apr 28, 11:28?am, Ben Mabey wrote: > Arco wrote: > > I'd like to do this: > > > ? Feature: user signup > > ? Before: > > ? ? Given I have a cleaned up database > > ? Scenario Outline: Sign Up > > ? ? Given I am on the signup page > > ? ? When I sign up using > > ? ? Then I should see > > ? ?Examples: > > ? ? |userid ? ? |message ? ? ? ? ? | > > ? ? |userX ? ? ?|successful signup | > > ? ? |userX ? ? ?|duplicate userid ?| > > > "I have a cleaned up database" runs before every example, making the > > second example ('duplicate userid') fail. > > You could use Background and it would work just like you want it to: > > ? Feature: user signup > ? Background: > ? ? Given I have a cleaned up database > ? Scenario Outline: Sign Up > ? ? Given I am on the signup page > ? ? When I sign up using > ? ? Then I should see > ? ?Examples: > ? ? |userid ? ? |message ? ? ? ? ? | > ? ? |userX ? ? ?|successful signup | > ? ? |userX ? ? ?|duplicate userid ?| > > However, I would not encourage this. ?You should try to avoid using technical words, such as database, in your features. ?If anything you could say "Given no users exist" or something like that. ?Keeping your database clean is something you generally want for every scenario though. ?So I would suggest putting the code in your "Given I have a cleaned up database" code into a Before block. ?The wiki has a page on using the Before hook:http://wiki.github.com/aslakhellesoy/cucumber/hooks > > Basically, in your env.rb file you will add something like: > > Before do > ? Database.clean! # or however you clean your DB > end > > HTH, > Ben > > > > > On Apr 28, 9:38 am, aslak hellesoy wrote: > > >> On Tue, Apr 28, 2009 at 6:15 PM, Arco wrote: > > >>> OK - I found a workaround. ?I simply tag the first scenario with > >>> '@first', then > >>> do Before('@first') and i get what I want - executing a block once for > >>> the feature file. > > >>> Except for one problem: ?most of my scenarios are done as scenario > >>> outlines, which > >>> are run multiple times - once for each row of my Example table. > > >>> A workaround to that problem might be to put a 'dummy' scenario that > >>> is run before the other scenarios in my feature file... > > >>> ?@first > >>> ?Scenario: Call a before block before running other scenarios... > > >>> But this puts junk in my feature files. ?Is there a better, cleaner > >>> way?? > > >> a) Why do you need one thing to happen before a feature? > >> b) Why can't you do it before each scenario? > > >> Aslak > > >>> On Apr 28, 8:32 am, Arco wrote: > > >>>> I also would like a hook that executes a block once before running a > >>>> feature file. > > >>>> In my testing i found that: > >>>> - Background: executes before each scenario > >>>> - Before executes before each scenario > >>>> - Before('@tag') executes before each scenario > > >>>> Is there a way to execute a block once before each feature, but not > >>>> before each scenario? > > >>>> On Apr 28, 7:08 am, aslak hellesoy wrote: > > >>>>>> Hi -- is it possible to set before and after blocks for individual > > >>> feature > > >>>>>> files? > > >>>>> Yes. Use tagged hooks: > > >>>http://wiki.github.com/aslakhellesoy/cucumber/hooks > > >>>>> Aslak > > >>>>>> I've tried putting them in step files, but they just get called > > >>> before > > >>>>>> everything, like they'd been declared in env.rb, which is consistent > > >>> with > > >>>>>> how I thought cucumber worked, but I thought I'd best try it anyway. > >>>>>> Anyway, I have some features that require a specific state be set up > > >>> before > > >>>>>> they run -- is this possible to do, and how would I go about doing > > >>> it? > > >>>>>> Thanks for any & all help, > >>>>>> ? ?Doug. > > >>>>>> _______________________________________________ > >>>>>> 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-us... at rubyforge.orghttp:// > > >>> rubyforge.org/mailman/listinfo/rspec-users > >>> _______________________________________________ > >>> 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-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 ben at benmabey.com Tue Apr 28 18:44:11 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 28 Apr 2009 16:44:11 -0600 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> Message-ID: <49F786BB.1040206@benmabey.com> Arco wrote: > Thanks for your reply Ben. +1 on your wording recommendation - I > understand and agree 100% > > However - for me - the Background block executes before each example > in the table. Therefore, the database is cleared twice, and the > second example ('duplicate userid') fails. > > (Cucumber 0.3.1 / ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]) > > Here are some snippets from a little workaround that i've employed... > in env.rb: > State = {'feature_file'=>'initialize'} > in my_steps.rb: > unless State['feature_file'] == > @__cucumber_current_step.file_colon_line.split(':').first > puts "CLEANUP CODE HERE - RUN ONCE PER FEATURE FILE --------" > end > State['feature_file'] = > @__cucumber_current_step.file_colon_line.split(':').first > > I'm sure there must be a better way! I am still learning cucumber so > any advice is welcome! > ;-) > While the above code is clever I would discourage its use. IMO, it looks like you are trying too hard to phrase your scenarios all within a single scenario outline. In this case I would not use tables but I would have separate scenarios. For example: Feature: user signup Scenario: success Given I am on the signup page When I enter valid registration information And I press "Register" Then I should see "You have signed up successfully!" Scenario: duplicate user with email # dunno, what really qualifies as duplicate for you... Given I am on the signup page And a user with email "foo at bar.com" exists When I enter valid registration information And I fill in "Email" with "foo at bar.com" And I press "Register" Then I should see "A user has already signed up with foo at bar.com" Does that make sense? Basically, whenever you feel the need to embed a conditional in your scenario it means you need a separate one. You can sometimes accomplish this by using scenario tables but that constrains you to the same setup steps. In your case you wanted additional context for one of your scenarios in the table... this means that you probably should have a whole new scenario like above. Your current solution obfuscates the additional context and therefore looses some of the documentation value that Cucumber offers. FWIW. Oh, and please try not to top-post in the future - it makes threads hard to follow. :) -Ben > > On Apr 28, 11:28 am, Ben Mabey wrote: > >> Arco wrote: >> >>> I'd like to do this: >>> >>> Feature: user signup >>> Before: >>> Given I have a cleaned up database >>> Scenario Outline: Sign Up >>> Given I am on the signup page >>> When I sign up using >>> Then I should see >>> Examples: >>> |userid |message | >>> |userX |successful signup | >>> |userX |duplicate userid | >>> >>> "I have a cleaned up database" runs before every example, making the >>> second example ('duplicate userid') fail. >>> >> You could use Background and it would work just like you want it to: >> >> Feature: user signup >> Background: >> Given I have a cleaned up database >> Scenario Outline: Sign Up >> Given I am on the signup page >> When I sign up using >> Then I should see >> Examples: >> |userid |message | >> |userX |successful signup | >> |userX |duplicate userid | >> >> However, I would not encourage this. You should try to avoid using technical words, such as database, in your features. If anything you could say "Given no users exist" or something like that. Keeping your database clean is something you generally want for every scenario though. So I would suggest putting the code in your "Given I have a cleaned up database" code into a Before block. The wiki has a page on using the Before hook:http://wiki.github.com/aslakhellesoy/cucumber/hooks >> >> Basically, in your env.rb file you will add something like: >> >> Before do >> Database.clean! # or however you clean your DB >> end >> >> HTH, >> Ben >> >> >> >> >>> On Apr 28, 9:38 am, aslak hellesoy wrote: >>> >>>> On Tue, Apr 28, 2009 at 6:15 PM, Arco wrote: >>>> >>>>> OK - I found a workaround. I simply tag the first scenario with >>>>> '@first', then >>>>> do Before('@first') and i get what I want - executing a block once for >>>>> the feature file. >>>>> >>>>> Except for one problem: most of my scenarios are done as scenario >>>>> outlines, which >>>>> are run multiple times - once for each row of my Example table. >>>>> >>>>> A workaround to that problem might be to put a 'dummy' scenario that >>>>> is run before the other scenarios in my feature file... >>>>> >>>>> @first >>>>> Scenario: Call a before block before running other scenarios... >>>>> >>>>> But this puts junk in my feature files. Is there a better, cleaner >>>>> way?? >>>>> >>>> a) Why do you need one thing to happen before a feature? >>>> b) Why can't you do it before each scenario? >>>> >>>> Aslak >>>> >>>>> On Apr 28, 8:32 am, Arco wrote: >>>>> >>>>>> I also would like a hook that executes a block once before running a >>>>>> feature file. >>>>>> >>>>>> In my testing i found that: >>>>>> - Background: executes before each scenario >>>>>> - Before executes before each scenario >>>>>> - Before('@tag') executes before each scenario >>>>>> >>>>>> Is there a way to execute a block once before each feature, but not >>>>>> before each scenario? >>>>>> >>>>>> On Apr 28, 7:08 am, aslak hellesoy wrote: >>>>>> >>>>>>>> Hi -- is it possible to set before and after blocks for individual >>>>>>>> >>>>> feature >>>>> >>>>>>>> files? >>>>>>>> >>>>>>> Yes. Use tagged hooks: >>>>>>> >>>>> http://wiki.github.com/aslakhellesoy/cucumber/hooks >>>>> >>>>>>> Aslak >>>>>>> >>>>>>>> I've tried putting them in step files, but they just get called >>>>>>>> >>>>> before >>>>> >>>>>>>> everything, like they'd been declared in env.rb, which is consistent >>>>>>>> >>>>> with >>>>> >>>>>>>> how I thought cucumber worked, but I thought I'd best try it anyway. >>>>>>>> Anyway, I have some features that require a specific state be set up >>>>>>>> >>>>> before >>>>> >>>>>>>> they run -- is this possible to do, and how would I go about doing >>>>>>>> >>>>> it? >>>>> >>>>>>>> Thanks for any & all help, >>>>>>>> Doug. >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> 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-us... at rubyforge.orghttp:// >>>>>> >>>>> rubyforge.org/mailman/listinfo/rspec-users >>>>> _______________________________________________ >>>>> 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-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 kero at chello.nl Tue Apr 28 19:11:22 2009 From: kero at chello.nl (Kero van Gelder) Date: Wed, 29 Apr 2009 01:11:22 +0200 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> Message-ID: <20090428231122.GD13970@bumblebee.m38c.nl> > I'd like to do this: > > Feature: user signup > Before: > Given I have a cleaned up database > Scenario Outline: Sign Up > Given I am on the signup page > When I sign up using > Then I should see > Examples: > |userid |message | > |userX |successful signup | > |userX |duplicate userid | Feature: user signup Scenario: succesful signup When I sign up using Kero Then I should see welcome Kero Scenario: failed signup of existing user Given there is a user Kero When I sign up using Kero Then I should see trying to impersonate someone else NB: yes, clean the database before every scenario Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From julian at leviston.net Tue Apr 28 21:51:20 2009 From: julian at leviston.net (Julian Leviston) Date: Wed, 29 Apr 2009 11:51:20 +1000 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <49F74AE3.2060902@benmabey.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> Message-ID: Hey Ben, It'd be kinda cool if there was a sort of before and after for a feature rather than each scenario. Is there? (Rails context) We often need this. It'd be really helpful for things like when we want to test about 15 things on a particular web page, and they don't require fresh data. We end up with a login and setup type background which gets run every time rather than simply once. I guess we could refactor it into a set of examples perhaps... would that work? It just strikes me as quite complicated. It'd be awesome if we had sub-scenarios (and they could be specified to levels) ;-) Perhaps I'm just being too complicated. I loved your rubyconf talk presentation, BTW. We kinda took exception to the bit where you said "Selenium just works", though. There are a number of things where the connection between selenium and webrat is a little tenuous and finicky about. Also we seem to be having timing issues for AJAX requests with Selenium. Webrat doesn't seem to want to wait until the AJAX request as finished before doing the next thing. Any ideas here? Julian. On 29/04/2009, at 4:28 AM, Ben Mabey wrote: > Arco wrote: >> I'd like to do this: >> >> Feature: user signup >> Before: >> Given I have a cleaned up database >> Scenario Outline: Sign Up >> Given I am on the signup page >> When I sign up using >> Then I should see >> Examples: >> |userid |message | >> |userX |successful signup | >> |userX |duplicate userid | >> >> "I have a cleaned up database" runs before every example, making the >> second example ('duplicate userid') fail. >> > > > You could use Background and it would work just like you want it to: > > Feature: user signup > Background: > Given I have a cleaned up database > Scenario Outline: Sign Up > Given I am on the signup page > When I sign up using > Then I should see > Examples: > |userid |message | > |userX |successful signup | > |userX |duplicate userid | > > > However, I would not encourage this. You should try to avoid using > technical words, such as database, in your features. If anything > you could say "Given no users exist" or something like that. > Keeping your database clean is something you generally want for > every scenario though. So I would suggest putting the code in your > "Given I have a cleaned up database" code into a Before block. The > wiki has a page on using the Before hook: http://wiki.github.com/aslakhellesoy/cucumber/hooks > > Basically, in your env.rb file you will add something like: > > Before do > Database.clean! # or however you clean your DB > end > > > > HTH, > Ben > > >> On Apr 28, 9:38 am, aslak hellesoy wrote: >> >>> On Tue, Apr 28, 2009 at 6:15 PM, Arco wrote: >>> >>>> OK - I found a workaround. I simply tag the first scenario with >>>> '@first', then >>>> do Before('@first') and i get what I want - executing a block >>>> once for >>>> the feature file. >>>> Except for one problem: most of my scenarios are done as >>>> scenario >>>> outlines, which >>>> are run multiple times - once for each row of my Example table. >>>> A workaround to that problem might be to put a 'dummy' >>>> scenario that >>>> is run before the other scenarios in my feature file... >>>> @first >>>> Scenario: Call a before block before running other scenarios... >>>> But this puts junk in my feature files. Is there a better, >>>> cleaner >>>> way?? >>>> >>> a) Why do you need one thing to happen before a feature? >>> b) Why can't you do it before each scenario? >>> >>> Aslak >>> >>> >>> >>> >>>> On Apr 28, 8:32 am, Arco wrote: >>>> >>>>> I also would like a hook that executes a block once before >>>>> running a >>>>> feature file. >>>>> In my testing i found that: >>>>> - Background: executes before each scenario >>>>> - Before executes before each scenario >>>>> - Before('@tag') executes before each scenario >>>>> Is there a way to execute a block once before each >>>>> feature, but not >>>>> before each scenario? >>>>> On Apr 28, 7:08 am, aslak hellesoy >>>>> wrote: >>>>> >>>>>>> Hi -- is it possible to set before and after blocks for >>>>>>> individual >>>>>>> >>>> feature >>>> >>>>>>> files? >>>>>>> >>>>>> Yes. Use tagged hooks: >>>>>> >>>> http://wiki.github.com/aslakhellesoy/cucumber/hooks >>>> >>>>>> Aslak >>>>>> >>>>>>> I've tried putting them in step files, but they just get called >>>>>>> >>>> before >>>> >>>>>>> everything, like they'd been declared in env.rb, which is >>>>>>> consistent >>>>>>> >>>> with >>>> >>>>>>> how I thought cucumber worked, but I thought I'd best try it >>>>>>> anyway. >>>>>>> Anyway, I have some features that require a specific state be >>>>>>> set up >>>>>>> >>>> before >>>> >>>>>>> they run -- is this possible to do, and how would I go about >>>>>>> doing >>>>>>> >>>> it? >>>> >>>>>>> Thanks for any & all help, >>>>>>> Doug. >>>>>>> _______________________________________________ >>>>>>> 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-us... at rubyforge.orghttp:// >>>>> >>>> rubyforge.org/mailman/listinfo/rspec-users >>>> _______________________________________________ >>>> 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 >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From sfeley at gmail.com Wed Apr 29 01:09:57 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 29 Apr 2009 01:09:57 -0400 Subject: [rspec-users] Current Evaluation of RSpec In-Reply-To: <632154f70904281957oa2c8b2aw82d506b94b3ab1c8@mail.gmail.com> References: <632154f70904281957oa2c8b2aw82d506b94b3ab1c8@mail.gmail.com> Message-ID: <1fb4df0904282209v3f14c47cnecc1d4ea6ec12747@mail.gmail.com> On Tue, Apr 28, 2009 at 10:57 PM, Nicholas Van Weerdenburg wrote: > Looking around outside of the book, reading reviews of RSpec on the web > seems tricky. Most reviews seem very dated, and as a result are misleading. > Is this an accurate assessment? I don't think so. The core syntax and sensibilities of RSpec haven't changed in any disruptive way. It's added new features, like those contexts and such, but there's no compulsion to use them. And to me they don't have much impact on the fundamental _flavor_ of RSpec. The only part of any old RSpec lore that's truly obsolete now is the story runner. Substitute "Cucumber" wherever you read "RSpec Story Runner" and substitute "beautiful" wherever you read "it's a pain." Otherwise the progress is all pretty much evolutionary, not revolutionary. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From ben at benmabey.com Wed Apr 29 01:47:13 2009 From: ben at benmabey.com (Ben Mabey) Date: Tue, 28 Apr 2009 23:47:13 -0600 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> Message-ID: <49F7E9E1.3080503@benmabey.com> Julian Leviston wrote: > Hey Ben, > > It'd be kinda cool if there was a sort of before and after for a > feature rather than each scenario. Is there? Nope. There is no before(:all) equivalent in cucumber. Just the Before and After hooks, which are for scenarios.. and Backgrounds which are just for scenarios on the given feature. > > (Rails context) We often need this. It'd be really helpful for things > like when we want to test about 15 things on a particular web page, > and they don't require fresh data. We end up with a login and setup > type background which gets run every time rather than simply once. In the context of webrat a before(:all) would not help you a whole lot since each scenario starts with a new session (so you have to login each time, for example). I understand the argument for complex data setup though. Having the same setup ran for each scenario can get costly. I haven't felt enough pain though to really justify adding something like that. Cleanup would be messy because we couldn't wrap it all in a transaction AFAIK, so you would have to have an after(:all) like method to clean up the feature. For complex data that I rely on all the time I tend to load it once with fixtures at boot up time within env.rb. This is usually for look-up data... but if you were really concerned about record creation you could do something similar. The question is if the additional complexity of keeping all that global state in your head worth the faster execution time. For me it generally is not. > > I guess we could refactor it into a set of examples perhaps... would > that work? It just strikes me as quite complicated. It'd be awesome if > we had sub-scenarios (and they could be specified to levels) ;-) > Perhaps I'm just being too complicated. I would need more context to really answer your question. However, can I ask if your scenarios are written in a declarative or imperative fashion[1]? If they are written declaratively, or at least partly, then you can specify a lot more behavior in a step without adding too much noise to the scenario. Another thing I should point out is that you don't need to, and you shouldn't, test everything on the Cucumber level. For complex views, for example, it may be easier to do RSpec examples (view specs) and just use Cucumber to test the basics. In general, I'm pretty wary about sub-scenarios and the like. They could be powerful, but they could very easily get complicated and turn scenarios into a giant mess that only programmers could understand. Feel free to share any ideas you have on the subject though and we'll see what the tradeoffs are. We love throwing new ideas around on the list. :) > > I loved your rubyconf talk presentation, BTW. We kinda took exception > to the bit where you said "Selenium just works", though. There are a > number of things where the connection between selenium and webrat is a > little tenuous and finicky about. Thanks! Yeah, the selenium adapter in webrat isn't nearly as mature as the rails adapter. :( I haven't had a lot of issues with it, but I try to use it as least as possible and have only really used it on simple things. And to be honest, I haven't used it since January. So, YMMV. > > Also we seem to be having timing issues for AJAX requests with > Selenium. Webrat doesn't seem to want to wait until the AJAX request > as finished before doing the next thing. Any ideas here? I think I have seen people in #webrat on irc.freenode.net talk about that and how they've had to add additional wait commands in. But, I really don't know any details. Sorry! Your best bet is to ask in #webrat, or on it's google group or lighthouse account. -Ben 1. http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ > > On 29/04/2009, at 4:28 AM, Ben Mabey wrote: > >> Arco wrote: >>> I'd like to do this: >>> >>> Feature: user signup >>> Before: >>> Given I have a cleaned up database >>> Scenario Outline: Sign Up >>> Given I am on the signup page >>> When I sign up using >>> Then I should see >>> Examples: >>> |userid |message | >>> |userX |successful signup | >>> |userX |duplicate userid | >>> >>> "I have a cleaned up database" runs before every example, making the >>> second example ('duplicate userid') fail. >>> >> >> >> You could use Background and it would work just like you want it to: >> >> Feature: user signup >> Background: >> Given I have a cleaned up database >> Scenario Outline: Sign Up >> Given I am on the signup page >> When I sign up using >> Then I should see >> Examples: >> |userid |message | >> |userX |successful signup | >> |userX |duplicate userid | >> >> >> However, I would not encourage this. You should try to avoid using >> technical words, such as database, in your features. If anything you >> could say "Given no users exist" or something like that. Keeping >> your database clean is something you generally want for every >> scenario though. So I would suggest putting the code in your "Given >> I have a cleaned up database" code into a Before block. The wiki has >> a page on using the Before hook: >> http://wiki.github.com/aslakhellesoy/cucumber/hooks >> >> Basically, in your env.rb file you will add something like: >> >> Before do >> Database.clean! # or however you clean your DB >> end >> >> >> >> HTH, >> Ben >> >> >>> On Apr 28, 9:38 am, aslak hellesoy wrote: >>> >>>> On Tue, Apr 28, 2009 at 6:15 PM, Arco wrote: >>>> >>>>> OK - I found a workaround. I simply tag the first scenario with >>>>> '@first', then >>>>> do Before('@first') and i get what I want - executing a block once >>>>> for >>>>> the feature file. >>>>> Except for one problem: most of my scenarios are done as >>>>> scenario >>>>> outlines, which >>>>> are run multiple times - once for each row of my Example table. >>>>> A workaround to that problem might be to put a 'dummy' >>>>> scenario that >>>>> is run before the other scenarios in my feature file... >>>>> @first >>>>> Scenario: Call a before block before running other scenarios... >>>>> But this puts junk in my feature files. Is there a better, >>>>> cleaner >>>>> way?? >>>>> >>>> a) Why do you need one thing to happen before a feature? >>>> b) Why can't you do it before each scenario? >>>> >>>> Aslak >>>> >>>> >>>> >>>> >>>>> On Apr 28, 8:32 am, Arco wrote: >>>>> >>>>>> I also would like a hook that executes a block once before running a >>>>>> feature file. >>>>>> In my testing i found that: >>>>>> - Background: executes before each scenario >>>>>> - Before executes before each scenario >>>>>> - Before('@tag') executes before each scenario >>>>>> Is there a way to execute a block once before each feature, >>>>>> but not >>>>>> before each scenario? >>>>>> On Apr 28, 7:08 am, aslak hellesoy >>>>>> wrote: >>>>>> >>>>>>>> Hi -- is it possible to set before and after blocks for individual >>>>>>>> >>>>> feature >>>>> >>>>>>>> files? >>>>>>>> >>>>>>> Yes. Use tagged hooks: >>>>>>> >>>>> http://wiki.github.com/aslakhellesoy/cucumber/hooks >>>>> >>>>>>> Aslak >>>>>>> >>>>>>>> I've tried putting them in step files, but they just get called >>>>>>>> >>>>> before >>>>> >>>>>>>> everything, like they'd been declared in env.rb, which is >>>>>>>> consistent >>>>>>>> >>>>> with >>>>> >>>>>>>> how I thought cucumber worked, but I thought I'd best try it >>>>>>>> anyway. >>>>>>>> Anyway, I have some features that require a specific state be >>>>>>>> set up >>>>>>>> >>>>> before >>>>> >>>>>>>> they run -- is this possible to do, and how would I go about doing >>>>>>>> >>>>> it? >>>>> >>>>>>>> Thanks for any & all help, >>>>>>>> Doug. >>>>>>>> _______________________________________________ >>>>>>>> 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-us... at rubyforge.orghttp:// >>>>>> >>>>> rubyforge.org/mailman/listinfo/rspec-users >>>>> _______________________________________________ >>>>> 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 >>> >> >> _______________________________________________ >> 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 marty at martyandrews.net Wed Apr 29 02:23:15 2009 From: marty at martyandrews.net (Marty Andrews) Date: Wed, 29 Apr 2009 16:23:15 +1000 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> Message-ID: <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> I'd like to load all of my examples into memory without actually running them, so I can traverse the object tree and get descriptions etc. ?I'm finding it tricky to figure out how to do that though. There seems to be an inherent assumption in the framework that that examples will actually run. So basically, I want to do something like this: examples = load_examples_without_running examples.each {|example| puts example.description} def load_examples_without_running ?# what goes here? end Does anyone have an idea about how I might do that? -- Marty Andrews From matt at mattwynne.net Wed Apr 29 02:27:28 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 29 Apr 2009 07:27:28 +0100 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> Message-ID: On 29 Apr 2009, at 07:23, Marty Andrews wrote: > I'd like to load all of my examples into memory without actually > running them, so I can traverse the object tree and get descriptions > etc. I'm finding it tricky to figure out how to do that though. > There seems to be an inherent assumption in the framework that that > examples will actually run. > > So basically, I want to do something like this: > > examples = load_examples_without_running > examples.each {|example| puts example.description} > > def load_examples_without_running > # what goes here? > end > > > Does anyone have an idea about how I might do that? Use the dry-run option? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From lists at ruby-forum.com Wed Apr 29 05:10:55 2009 From: lists at ruby-forum.com (Neema Cheriyath) Date: Wed, 29 Apr 2009 11:10:55 +0200 Subject: [rspec-users] Cucumber: Setting Dependency among scenarios In-Reply-To: <8d961d900904262305r3577cf9k6c156a54f2abfc01@mail.gmail.com> References: <16f256aba30adeaf75c586456a9901dd@ruby-forum.com> <8d961d900904262305r3577cf9k6c156a54f2abfc01@mail.gmail.com> Message-ID: Thank you Aslak. Let me see whether I can make use of Background for implementing the dependency issue that I mentioned. I think implementing hooks in cucumber_java will be useful for us, since we can make use of that to get a detailed report with all the required information while running the scenarios in cucumber. I will create a ticket to implement hooks in cucumber_java. Thanks, Neema -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Apr 29 05:34:04 2009 From: lists at ruby-forum.com (Neema Cheriyath) Date: Wed, 29 Apr 2009 11:34:04 +0200 Subject: [rspec-users] Cucumber: Setting Dependency among scenarios In-Reply-To: <8d961d900904290213t69813510u97804d83427613c1@mail.gmail.com> References: <16f256aba30adeaf75c586456a9901dd@ruby-forum.com> <8d961d900904262305r3577cf9k6c156a54f2abfc01@mail.gmail.com> <8d961d900904290213t69813510u97804d83427613c1@mail.gmail.com> Message-ID: Hi Aslak, I have created a new ticket in github for implementing hooks in cucumber_java. Please find the link: http://github.com/aslakhellesoy/cucumber_java/issues/#issue/2 Thanks, Neema -- Posted via http://www.ruby-forum.com/. From win at wincent.com Wed Apr 29 06:04:48 2009 From: win at wincent.com (Wincent Colaiuta) Date: Wed, 29 Apr 2009 12:04:48 +0200 Subject: [rspec-users] Cucumber/Webrat/Selenium + SSL? Message-ID: <5FB7882F-3CAF-40BE-B304-71807CF5DE71@wincent.com> Has anybody had any luck getting Cucumber, Webrat and Selenium to play nicely together for SSL sites? My test environment: - nginx front-end accepting SSL requests, proxying them to mongrel back-end - mongrel back-end accepting normal HTTP requests - application routes configured with ":protocol => 'https'" so that URLs generated with "_url" helpers will be SSL ones - application links basically all generated using "_path" helpers and not "_url" helpers, so the site can be tested by connected directly to the mongrel instance rather than having to go through the nginx proxy - Cucumber paths (in "features/support/paths.rb" defined using "_path" helpers, not "_url" helpers) The problem is that when I try to run my features through Selenium following the instructions here: http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium Selenium starts up and tries to access the site using HTTPS. This in turn throws up a warning dialog about the self-signed certificate (evidently a certificate for "localhost" can only ever be self-signed) which prevents the suite from running. You can go into the Firefox preferences and add an exception for the "localhost" domain but it won't persist because every time you run the suite Selenium launches a clean copy of Firefox with a blank profile. This page provides some tips on how to set up a Firefox profile containing the exception and force Selenium to use it: http://blog.thirstybear.co.uk/2008/05/selenium-and-https.html But that won't work when using Cucumber/Webrat, because as far as I can tell from the Webrat Selenium docs. http://github.com/brynary/webrat/blob/master/lib/webrat/selenium.rb Webrat will "automatically start the Selenium Java server process and an instance of Mongrel when a test is run". So there is no way that I can see to force Webrat to launch the Selenium server process with the custom Firefox profile. So I guess there are two possible options here: either find a way to make Webrat use the custom profile (most likely by hacking the code directly), or find a way to make Selenium connect to the Mongrel directly (via HTTP) instead of the nginx instance (via HTTPS). Not really sure how I would go about that one really, seeing as in my "features/support/paths.rb" file I am obviously specifying paths (no host specification) anyway. Has anyone had any success getting this to work? Until I can find a solution it basically means that all of the JavaScript/AJAX stuff in the app has no automated testing at all. I suppose I could dump Webrat and speak directly to Selenium, as demonstrated in the example: http://github.com/aslakhellesoy/cucumber/tree/master/examples/ selenium But, then I'll have a nasty division in my features between those that can use Webrat and those which can't. Any solutions? Cheers, Wincent From dchelimsky at gmail.com Wed Apr 29 06:54:20 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 29 Apr 2009 05:54:20 -0500 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> Message-ID: <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> On Wed, Apr 29, 2009 at 1:23 AM, Marty Andrews wrote: > I'd like to load all of my examples into memory without actually > running them, so I can traverse the object tree and get descriptions > etc. ?I'm finding it tricky to figure out how to do that though. > There seems to be an inherent assumption in the framework that that > examples will actually run. > > So basically, I want to do something like this: > > examples = load_examples_without_running > examples.each {|example| puts example.description} There is a --dry-run command line switch that will do this for you, but I've been considering deprecating it because it can't work consistently with matcher-generated descriptions: describe RSpec do it { should be_concise } end $ spec rspec_spec.rb RSpec should be concise In this case, the be_concise matcher generates the text "should be concise" when it is run. If you don't run it, there is no description. As this approach becomes more and more popular, the --dry-run not only becomes less useful, it actually becomes somewhat of a frustration. As for getting a handle on the objects, this is something that is not really baked into RSpec, but will definitely be baked into rspec-2.0. Work on this will start later this year (probably not until after the rspec book is off to print). Goals for it include a very clean separation of the DSL and the underlying object model and a very lightweight runner. So in the short run, your best option is to use --dry-run and understand that you only get value out of it if you write docstrings for all of your examples. Cheers, David > > def load_examples_without_running > ?# what goes here? > end > > > Does anyone have an idea about how I might do that? > > -- Marty Andrews > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From clifford.heath at gmail.com Tue Apr 28 21:54:08 2009 From: clifford.heath at gmail.com (Clifford Heath) Date: Wed, 29 Apr 2009 11:54:08 +1000 Subject: [rspec-users] [Cucumber] gem missing dependencies In-Reply-To: <20090427212325.GA13970@bumblebee.m38c.nl> References: <20090426121649.GA8422@bumblebee.m38c.nl> <8d961d900904260734t24032535pbfc8d18812d3f3de@mail.gmail.com> <20090427212325.GA13970@bumblebee.m38c.nl> Message-ID: <21283072-6294-412F-962A-B8EFD22ACD51@gmail.com> On 28/04/2009, at 7:23 AM, Kero van Gelder wrote: > Hi list & Clifford, >>> Looks like installing hoe (which brings in rubyforge and rake) >>> solved the problem below. >> I just fixed that: > Thanks Aslak, that was quick, but... > I had to try that, and the 0.3.1 release made that very easy. > Didn't help. > looks like polyglot is the culprit, from some extra output I created > from rubygems: > ... > Clifford, let's take this off-list. Kero, Thanks for taking a positive approach to helping me fix Polyglot. It's a breath of fresh air compared to Aslak's poisonous attitude. I've never been unwilling to fix it, but I need to be told what the problem is - not just that there is a problem. Also, I've been away from any computer for the last five weeks. Since I don't (yet) use Cucumber, I hadn't diagnosed the cause of the problem. If it's the hoe dependency, it can be fixed. Polyglot requires hoe because it's built using "newgem". It's a nuisance, and I'll be happy to remove it, or make hoe a dev-time dependency only if possible. I've contacted Dr Nic to ask how to proceed. In my view, using hoe shouldn't add a runtime dependency. BTW... why, if polyglot has a hoe dependency, doesn't hoe get installed when you install cucumber? I'm not saying that the dependency is a good thing, but shouldn't rubygems install it anyhow? Also, I think I'm the only one likely to publish a new Treetop gem. The forks of Treetop have resulted in no pull requests - they're just experimental. We have a list of feature requests we're thinking about, but Treetop is so nice and clean and we don't want to move forward unless we can keep it that way - we have however recently applied a github patch. I can easily remove Polyglot, but not for the sole reason that someone complains that it causes problems they're unwilling to describe, diagnose, or help fix. If a complaint comes with a bad attitude, I'll just continue to ignore it. Clifford Heath. From wayne.simacek at gmail.com Tue Apr 28 16:59:54 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Tue, 28 Apr 2009 13:59:54 -0700 (PDT) Subject: [rspec-users] uninitialized constant ActionController running Cucumber features in Aptana/RadRails IDE In-Reply-To: <4dd2442f-80d8-4473-abf2-a9bd9173a6ca@z8g2000prd.googlegroups.com> References: <8d961d900904271446g65a7d7dco71b92ac338b7046c@mail.gmail.com> <4dd2442f-80d8-4473-abf2-a9bd9173a6ca@z8g2000prd.googlegroups.com> Message-ID: That did the trick. I blew out eclipse and reinstalled my Aptana directly. Re-added my RadRails Plugin and gems Cucumber, RSpec, RSpec- rails and WebRat. There was one clue I found that said when using Cucumber with windows, I should insert the line 1 $KCODE=' ' into my features/support/env.rb file. It's a great into article at http://blog.rubyyot.com/2009/01/chores-a-test-driven-website/ Thanks all again for the help, Wayne On Apr 28, 9:25?am, WJSimacek wrote: > I uninstalled rails-2.3.1 and rails-2.3.2 and then > Successfully installed rails-2.3.2 > > ==>Same error message > > I think I'm going to try and lose the eclipse framework next. Just > another layer giving me a headache. > > Thanks for your help, > Wayne > > On Apr 27, 4:46?pm, aslak hellesoy wrote: > > > > I'm just starting on BDD. I installed the gems for webrats and > > > cucumber. > > > I also ran the following in the Ruby shell: > > > > >rake gems:install RAILS_EN=test > > > >script/generate cucumber > > > > These commands seemed to create the expected features and lib folders > > > in my project. > > > > ?I'm using the eclipse framework with Aptana and RadRails as my IDE. > > > However, when I run: > > > > >cucumber features -n > > > > from the Ruby shell, I get the following error: > > > > ./app/controllers/application.rb:4: uninitialized constant > > > ActionController (NameError) > > > ? ? ? ?from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > > > `gem_original_require' > > > ? ? ? ?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/cucumber-0.3.0/bin/../lib/ > > > cucumber/cli/main.rb:79:in `require_files' > > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > > cucumber/cli/main.rb:77:in `each' > > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > > cucumber/cli/main.rb:77:in `require_files' > > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > > cucumber/cli/main.rb:34:in `execute!' > > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/../lib/ > > > cucumber/cli/main.rb:20:in `execute' > > > ? ? ? ?from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/cucumber:6 > > > ? ? ? ?from C:/ruby/bin/cucumber:19:in `load' > > > ? ? ? ?from C:/ruby/bin/cucumber:19 > > > > Any ideas on how I can initialize this constant ActionController or > > > ActionController is part of Rails. It sounds like there is something wrong > > with your Rails installation. > > > Aslak > > > > where the real error is coming from? Do I have to do some additional > > > includes in some of my files? > > > _______________________________________________ > > > 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-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From wayne.simacek at gmail.com Tue Apr 28 17:02:56 2009 From: wayne.simacek at gmail.com (WJSimacek) Date: Tue, 28 Apr 2009 14:02:56 -0700 (PDT) Subject: [rspec-users] Noob question In-Reply-To: References: Message-ID: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> There's about 3 more gems you need to install. RSpec, RSpec-rails and WebRat. There's also a great introductory article I found on-line at http://blog.rubyyot.com/2009/01/chores-a-test-driven-website/ I'm only half-step ahead of you and feel your pain. Good luck, Wayne On Apr 28, 12:47?pm, "Sophie \(itsme213\)" wrote: > Just getting started with cucumber on Mac 10.5.6. > > I have the default Ruby install (1.8). I'm not using Rails. I did a > ? gem update cucumber > and now have cucumber-0.3.1 in my gems. > > I also did a > ? git clone > and have a repo with cucumber 0.3.2. > > When I cd into my cucumber (git) directory and do: > ? cucumber features > I get > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- spec/expectations > (LoadError) > Failed to load ./cucumber/examples/selenium_webrat/features/support/env.rb > from > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in > `polyglot_original_require' > ?from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in > `require' > ?from ./cucumber/examples/selenium_webrat/features/support/env.rb:1 > > ... > > Looks like I need a bunch more stuff than what the gem installs. Where can I > find out what to install? > > Thanks! > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From marty at martyandrews.net Wed Apr 29 07:09:35 2009 From: marty at martyandrews.net (Marty Andrews) Date: Wed, 29 Apr 2009 21:09:35 +1000 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> Message-ID: On 29/04/2009, at 8:54 PM, David Chelimsky wrote: > On Wed, Apr 29, 2009 at 1:23 AM, Marty Andrews > wrote: >> I'd like to load all of my examples into memory without actually >> running them, so I can traverse the object tree and get descriptions >> etc. I'm finding it tricky to figure out how to do that though. >> There seems to be an inherent assumption in the framework that that >> examples will actually run. >> >> So basically, I want to do something like this: >> >> examples = load_examples_without_running >> examples.each {|example| puts example.description} [snip] > As for getting a handle on the objects, this is something that is not > really baked into RSpec, but will definitely be baked into rspec-2.0. > Work on this will start later this year (probably not until after the > rspec book is off to print). Goals for it include a very clean > separation of the DSL and the underlying object model and a very > lightweight runner. > > So in the short run, your best option is to use --dry-run and > understand that you only get value out of it if you write docstrings > for all of your examples. Ok. It's actually a bit more complicate than that. Let me give you an insight into where I'm headed. I'm working into a big corporate in Australia, and they are demanding traceability of tests back to requirements. I'm already using Mingle to manage story cards, and I'm hoping to let the testers build in the traceability via code. So I've got a Mixin to the examples so that I can declare the id of the story that the test maps to. It looks something like this: describe FunctionalArea do it "automates some acceptance test declared on a story" do traces_to_story 35 # test implementation end end So now, I want to be able to walk the object tree, getting the descriptions *and* the story id's. Mingle has a nice RESTful API that I've already used to slurp up detail about stories. Now I just want to wire in this last bit of information to tick the traceability box without any human needing to do the work. I'll have a look at the --dry-run option and see where it gets me. If you've got any more tips, let me know. I'll send in a code snippet if I manage to get it going :) -- Marty From korny at sietsma.com Wed Apr 29 07:34:13 2009 From: korny at sietsma.com (Korny Sietsma) Date: Wed, 29 Apr 2009 21:34:13 +1000 Subject: [rspec-users] [Cucumber] call the (Treetop?) parser directly? In-Reply-To: References: Message-ID: <8e15872b0904290434sbeba8c3mf08cb920828b8a0c@mail.gmail.com> Just one comment - I went down this path a bit, and ended up finding it drastically easier to write a custom formatter. Take a look at http://wiki.github.com/aslakhellesoy/cucumber/custom-formatters - or see my post earlier at http://groups.google.com/group/rspec/browse_thread/thread/c8fde28e5f757758 I'm sure there are places where you'd want to call the parser directly; but everything I needed to do was handled more easily by writing a formatter and catching the events I care about. - Korny On Sat, Apr 25, 2009 at 2:07 PM, Phlip wrote: > Cucumberists: > > The sample code: > > require 'treetop' > require 'cucumber' > require 'cucumber/parser' > require 'cucumber/parser/treetop_ext' > ?# too many requires because fishing around! > > ?include Cucumber > ?include Parser > ?include Feature > > ?@parser = FeatureParser.new > ?exp = @parser.parse_or_fail(%{# My comment > Feature: hi > }) > > The error message: > > NameError: undefined local variable or method `_nt_scenario_outline_keyword' > for # > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in > `_nt_scenario_outline' > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in `_nt_feature' > ? ?cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in `loop' > ? ?... > > Okay, how do I just whip out the parser and have it parse raw Cuke code? > > -- > ?Phlip > ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- 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" From dchelimsky at gmail.com Wed Apr 29 07:41:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 29 Apr 2009 06:41:59 -0500 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> Message-ID: <57c63afe0904290441p7b5328cdx8b9c4909abfd89c3@mail.gmail.com> On Wed, Apr 29, 2009 at 6:09 AM, Marty Andrews wrote: > > On 29/04/2009, at 8:54 PM, David Chelimsky wrote: > >> On Wed, Apr 29, 2009 at 1:23 AM, Marty Andrews >> wrote: >>> >>> I'd like to load all of my examples into memory without actually >>> running them, so I can traverse the object tree and get descriptions >>> etc. ?I'm finding it tricky to figure out how to do that though. >>> There seems to be an inherent assumption in the framework that that >>> examples will actually run. >>> >>> So basically, I want to do something like this: >>> >>> examples = load_examples_without_running >>> examples.each {|example| puts example.description} > > [snip] > >> As for getting a handle on the objects, this is something that is not >> really baked into RSpec, but will definitely be baked into rspec-2.0. >> Work on this will start later this year (probably not until after the >> rspec book is off to print). Goals for it include a very clean >> separation of the DSL and the underlying object model and a very >> lightweight runner. >> >> So in the short run, your best option is to use --dry-run and >> understand that you only get value out of it if you write docstrings >> for all of your examples. > > Ok. ?It's actually a bit more complicate than that. ?Let me give you an > insight into where I'm headed. > > I'm working into a big corporate in Australia, and they are demanding > traceability of tests back to requirements. ?I'm already using Mingle to > manage story cards, and I'm hoping to let the testers build in the > traceability via code. ?So I've got a Mixin to the examples so that I can > declare the id of the story that the test maps to. ?It looks something like > this: > > describe FunctionalArea do > ?it "automates some acceptance test declared on a story" do > ? ?traces_to_story 35 > ? ?# test implementation > ?end > end > > So now, I want to be able to walk the object tree, getting the descriptions > *and* the story id's. ?Mingle has a nice RESTful API that I've already used > to slurp up detail about stories. ?Now I just want to wire in this last bit > of information to tick the traceability box without any human needing to do > the work. > > I'll have a look at the --dry-run option and see where it gets me. ?If > you've got any more tips, let me know. ?I'll send in a code snippet if I > manage to get it going :) There *is* something you can *almost* use for this, but it's incomplete at the moment. RSpec let's you write your own output formatters, which receive messages for every example group and example as they are run. Currently, the object passed to example_started (and a few other methods) is an ExampleGroupProxy, which includes an options hash passed to the example. So if you do this: it "automates some acceptance test declared on a story", :traces_to_story => 25 do # ... end Then you could do stuff like: def example_started(example_proxy) traces_to_story(example_proxy.options[:traces_to_story] end This should solve your problem assuming that you have docstrings for all of your examples. The big missing piece at this moment is that the ExampleGroupProxy (passed to example_group_started) doesn't include the options hash, but I'll happily add that tonight. To see this in action, try this: * in options_formatter.rb require 'spec/runner/formatter/base_text_formatter' class OptionsFormatter < Spec::Runner::Formatter::BaseTextFormatter def example_started(proxy) puts proxy.options.inspect unless proxy.options.empty? end end * in example_spec.rb require 'spec' describe "example" do it "supports options", :like => 'these' do # no need for anything here end end Now, on the command line: $ spec --require options_formatter.rb example_spec.rb --format OptionsFormatter {:like => 'these'} Formatter API is here: http://rspec.rubyforge.org/rspec/1.2.4/classes/Spec/Runner/Formatter/BaseFormatter.html Let me know if this is a good direction for you and I'll add the options hash to the example group proxy. Cheers, David > > -- Marty > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From korny at sietsma.com Wed Apr 29 07:42:20 2009 From: korny at sietsma.com (Korny Sietsma) Date: Wed, 29 Apr 2009 21:42:20 +1000 Subject: [rspec-users] Noob question In-Reply-To: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> Message-ID: <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> Presumably you only need these if you are *building* cucumber? If you just want to use cucumber, it should be as simple as "gem install cucumber", and it should get all the other dependencies. On my machine it seemed to install treetop, polyglot, and presumably a few others - but I don't have rspec-rails nor webrat. (On looking back at the original post, maybe I'm confused - presumably if you are cloning cucumber from git, you mean to build it yourself. But I'm not sure why someone calling themselves a "noob" would want to do that! :) ) - Korny On Wed, Apr 29, 2009 at 7:02 AM, WJSimacek wrote: > There's about 3 more gems you need to install. RSpec, RSpec-rails and > WebRat. There's also a great introductory article I found on-line at > http://blog.rubyyot.com/2009/01/chores-a-test-driven-website/ > > I'm only half-step ahead of you and feel your pain. > Good luck, > Wayne > > On Apr 28, 12:47?pm, "Sophie \(itsme213\)" > wrote: >> Just getting started with cucumber on Mac 10.5.6. >> >> I have the default Ruby install (1.8). I'm not using Rails. I did a >> ? gem update cucumber >> and now have cucumber-0.3.1 in my gems. >> >> I also did a >> ? git clone >> and have a repo with cucumber 0.3.2. >> >> When I cd into my cucumber (git) directory and do: >> ? cucumber features >> I get >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in >> `gem_original_require': no such file to load -- spec/expectations >> (LoadError) >> Failed to load ./cucumber/examples/selenium_webrat/features/support/env.rb >> from >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in >> `polyglot_original_require' >> ?from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in >> `require' >> ?from ./cucumber/examples/selenium_webrat/features/support/env.rb:1 >> >> ... >> >> Looks like I need a bunch more stuff than what the gem installs. Where can I >> find out what to install? >> >> Thanks! >> >> _______________________________________________ >> 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 > -- 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" From marty at martyandrews.net Wed Apr 29 07:50:27 2009 From: marty at martyandrews.net (Marty Andrews) Date: Wed, 29 Apr 2009 21:50:27 +1000 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <57c63afe0904290441p7b5328cdx8b9c4909abfd89c3@mail.gmail.com> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> <57c63afe0904290441p7b5328cdx8b9c4909abfd89c3@mail.gmail.com> Message-ID: <1C05CCB2-174C-4D46-AA93-D9C3CA854E68@martyandrews.net> On 29/04/2009, at 9:41 PM, David Chelimsky wrote: > On Wed, Apr 29, 2009 at 6:09 AM, Marty Andrews > wrote: >> >> On 29/04/2009, at 8:54 PM, David Chelimsky wrote: >> >>> On Wed, Apr 29, 2009 at 1:23 AM, Marty Andrews >> > >>> wrote: >>>> >>>> I'd like to load all of my examples into memory without actually >>>> running them, so I can traverse the object tree and get >>>> descriptions >>>> etc. I'm finding it tricky to figure out how to do that though. >>>> There seems to be an inherent assumption in the framework that that >>>> examples will actually run. >>>> >>>> So basically, I want to do something like this: >>>> >>>> examples = load_examples_without_running >>>> examples.each {|example| puts example.description} >> >> [snip] >> >>> As for getting a handle on the objects, this is something that is >>> not >>> really baked into RSpec, but will definitely be baked into >>> rspec-2.0. >>> Work on this will start later this year (probably not until after >>> the >>> rspec book is off to print). Goals for it include a very clean >>> separation of the DSL and the underlying object model and a very >>> lightweight runner. >>> >>> So in the short run, your best option is to use --dry-run and >>> understand that you only get value out of it if you write docstrings >>> for all of your examples. >> >> Ok. It's actually a bit more complicate than that. Let me give >> you an >> insight into where I'm headed. >> >> I'm working into a big corporate in Australia, and they are demanding >> traceability of tests back to requirements. I'm already using >> Mingle to >> manage story cards, and I'm hoping to let the testers build in the >> traceability via code. So I've got a Mixin to the examples so that >> I can >> declare the id of the story that the test maps to. It looks >> something like >> this: >> >> describe FunctionalArea do >> it "automates some acceptance test declared on a story" do >> traces_to_story 35 >> # test implementation >> end >> end >> >> So now, I want to be able to walk the object tree, getting the >> descriptions >> *and* the story id's. Mingle has a nice RESTful API that I've >> already used >> to slurp up detail about stories. Now I just want to wire in this >> last bit >> of information to tick the traceability box without any human >> needing to do >> the work. >> >> I'll have a look at the --dry-run option and see where it gets me. >> If >> you've got any more tips, let me know. I'll send in a code snippet >> if I >> manage to get it going :) > > There *is* something you can *almost* use for this, but it's > incomplete at the moment. RSpec let's you write your own output > formatters, which receive messages for every example group and example > as they are run. Currently, the object passed to example_started (and > a few other methods) is an ExampleGroupProxy, which includes an > options hash passed to the example. So if you do this: > > it "automates some acceptance test declared on a story", > :traces_to_story => 25 do > # ... > end > > Then you could do stuff like: > > def example_started(example_proxy) > traces_to_story(example_proxy.options[:traces_to_story] > end > > This should solve your problem assuming that you have docstrings for > all of your examples. The big missing piece at this moment is that the > ExampleGroupProxy (passed to example_group_started) doesn't include > the options hash, but I'll happily add that tonight. Yep - no problems there. I reckon about 98% have docstrings. I can easily add the remainders. > To see this in action, try this: > > * in options_formatter.rb > > require 'spec/runner/formatter/base_text_formatter' > > class OptionsFormatter < Spec::Runner::Formatter::BaseTextFormatter > def example_started(proxy) > puts proxy.options.inspect unless proxy.options.empty? > end > end > > * in example_spec.rb > > require 'spec' > > describe "example" do > it "supports options", :like => 'these' do > # no need for anything here > end > end > > Now, on the command line: > > $ spec --require options_formatter.rb example_spec.rb --format > OptionsFormatter > {:like => 'these'} > > Formatter API is here: > http://rspec.rubyforge.org/rspec/1.2.4/classes/Spec/Runner/Formatter/BaseFormatter.html > > Let me know if this is a good direction for you and I'll add the > options hash to the example group proxy. I reckon this would be great *if* it will still work with the --dry- run option. Most of the examples are actually integration tests that call out to other tools as they run, so the build is S..L..O..W (over an hour). I want to be able to generate the report without actually running the tests. -- Marty From aidy.lewis at googlemail.com Wed Apr 29 07:58:16 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 29 Apr 2009 12:58:16 +0100 Subject: [rspec-users] NetBeans with Cucumber module Message-ID: <7ac2300c0904290458q5b2b36b8g5d86e13eab6edf2b@mail.gmail.com> Hi, Aslak twittered this NetBeans Cucumber module : http://members.chello.at/server/modules.html I have tried to manually install it, but NetBeans in complaining about: "Missing required modules for Plugin Cucumber Features: Generic Languages Framework [module org.netbeans.modules.languages/0-1 > 1.90.1.1]" Automatic install is disabled (not sure why) and I cannot for the life of me find 'The Generic Languages Framework' -- Aidy blog: www.agiletester.co.uk twitter: http://twitter.com/aidy_lewis From aidy.lewis at googlemail.com Wed Apr 29 08:07:56 2009 From: aidy.lewis at googlemail.com (aidy lewis) Date: Wed, 29 Apr 2009 13:07:56 +0100 Subject: [rspec-users] NetBeans with Cucumber module In-Reply-To: <8d961d900904290503s24abc1d4gf7ae353c569ef9c7@mail.gmail.com> References: <7ac2300c0904290458q5b2b36b8g5d86e13eab6edf2b@mail.gmail.com> <8d961d900904290503s24abc1d4gf7ae353c569ef9c7@mail.gmail.com> Message-ID: <7ac2300c0904290507y56a979fdma5943de4509f619e@mail.gmail.com> Aslak, Will do, I just thought someone on the list may have tried it. Aidy 2009/4/29 aslak hellesoy : > >> Hi, >> >> Aslak twittered this NetBeans Cucumber module : >> http://members.chello.at/server/modules.html >> >> I have tried to manually install it, but NetBeans in complaining about: >> >> "Missing required modules for Plugin Cucumber Features: >> Generic Languages Framework [module org.netbeans.modules.languages/0-1 >> > 1.90.1.1]" >> >> Automatic install is disabled (not sure why) and I cannot for the life >> of me find 'The Generic Languages Framework' > > I have no idea. Ask the Netbeans folks. > > Aslak > >> >> -- >> Aidy >> blog: www.agiletester.co.uk >> twitter: http://twitter.com/aidy_lewis >> _______________________________________________ >> 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 > -- Aidy blog: www.agiletester.co.uk twitter: http://twitter.com/aidy_lewis From dchelimsky at gmail.com Wed Apr 29 08:15:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 29 Apr 2009 07:15:07 -0500 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <1C05CCB2-174C-4D46-AA93-D9C3CA854E68@martyandrews.net> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> <57c63afe0904290441p7b5328cdx8b9c4909abfd89c3@mail.gmail.com> <1C05CCB2-174C-4D46-AA93-D9C3CA854E68@martyandrews.net> Message-ID: <57c63afe0904290515y4da1abfdl7693b7bf44483f0a@mail.gmail.com> On Wed, Apr 29, 2009 at 6:50 AM, Marty Andrews wrote: > > On 29/04/2009, at 9:41 PM, David Chelimsky wrote: > >> On Wed, Apr 29, 2009 at 6:09 AM, Marty Andrews >> wrote: >>> >>> On 29/04/2009, at 8:54 PM, David Chelimsky wrote: >>> >>>> On Wed, Apr 29, 2009 at 1:23 AM, Marty Andrews >>>> wrote: >>>>> >>>>> I'd like to load all of my examples into memory without actually >>>>> running them, so I can traverse the object tree and get descriptions >>>>> etc. ?I'm finding it tricky to figure out how to do that though. >>>>> There seems to be an inherent assumption in the framework that that >>>>> examples will actually run. >>>>> >>>>> So basically, I want to do something like this: >>>>> >>>>> examples = load_examples_without_running >>>>> examples.each {|example| puts example.description} >>> >>> [snip] >>> >>>> As for getting a handle on the objects, this is something that is not >>>> really baked into RSpec, but will definitely be baked into rspec-2.0. >>>> Work on this will start later this year (probably not until after the >>>> rspec book is off to print). Goals for it include a very clean >>>> separation of the DSL and the underlying object model and a very >>>> lightweight runner. >>>> >>>> So in the short run, your best option is to use --dry-run and >>>> understand that you only get value out of it if you write docstrings >>>> for all of your examples. >>> >>> Ok. ?It's actually a bit more complicate than that. ?Let me give you an >>> insight into where I'm headed. >>> >>> I'm working into a big corporate in Australia, and they are demanding >>> traceability of tests back to requirements. ?I'm already using Mingle to >>> manage story cards, and I'm hoping to let the testers build in the >>> traceability via code. ?So I've got a Mixin to the examples so that I can >>> declare the id of the story that the test maps to. ?It looks something >>> like >>> this: >>> >>> describe FunctionalArea do >>> ?it "automates some acceptance test declared on a story" do >>> ? traces_to_story 35 >>> ? # test implementation >>> ?end >>> end >>> >>> So now, I want to be able to walk the object tree, getting the >>> descriptions >>> *and* the story id's. ?Mingle has a nice RESTful API that I've already >>> used >>> to slurp up detail about stories. ?Now I just want to wire in this last >>> bit >>> of information to tick the traceability box without any human needing to >>> do >>> the work. >>> >>> I'll have a look at the --dry-run option and see where it gets me. ?If >>> you've got any more tips, let me know. ?I'll send in a code snippet if I >>> manage to get it going :) >> >> There *is* something you can *almost* use for this, but it's >> incomplete at the moment. RSpec let's you write your own output >> formatters, which receive messages for every example group and example >> as they are run. Currently, the object passed to example_started (and >> a few other methods) is an ExampleGroupProxy, which includes an >> options hash passed to the example. So if you do this: >> >> it "automates some acceptance test declared on a story", >> ? :traces_to_story => 25 do >> # ... >> end >> >> Then you could do stuff like: >> >> def example_started(example_proxy) >> ?traces_to_story(example_proxy.options[:traces_to_story] >> end >> >> This should solve your problem assuming that you have docstrings for >> all of your examples. The big missing piece at this moment is that the >> ExampleGroupProxy (passed to example_group_started) doesn't include >> the options hash, but I'll happily add that tonight. > > Yep - no problems there. ?I reckon about 98% have docstrings. ?I can easily > add the remainders. > > > >> To see this in action, try this: >> >> * in options_formatter.rb >> >> require 'spec/runner/formatter/base_text_formatter' >> >> class OptionsFormatter < Spec::Runner::Formatter::BaseTextFormatter >> ?def example_started(proxy) >> ? puts proxy.options.inspect unless proxy.options.empty? >> ?end >> end >> >> * in example_spec.rb >> >> require 'spec' >> >> describe "example" do >> ?it "supports options", :like => 'these' do >> ? # no need for anything here >> ?end >> end >> >> Now, on the command line: >> >> $ spec --require options_formatter.rb example_spec.rb --format >> OptionsFormatter >> {:like => 'these'} >> >> Formatter API is here: >> >> http://rspec.rubyforge.org/rspec/1.2.4/classes/Spec/Runner/Formatter/BaseFormatter.html >> >> Let me know if this is a good direction for you and I'll add the >> options hash to the example group proxy. > > I reckon this would be great *if* it will still work with the --dry-run > option. ?Most of the examples are actually integration tests that call out > to other tools as they run, so the build is S..L..O..W (over an hour). ?I > want to be able to generate the report without actually running the tests. I'm really sorry about this, but I just couldn't wait for tonight to add this: http://github.com/dchelimsky/rspec/commit/a4b3aac62e940c50077bdeb7d9ad5ee11e02116d The release *will* have to wait for tonight, but you can easily build the gem locally: http://wiki.github.com/dchelimsky/rspec/edge Cheers, David > > -- Marty > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From marty at martyandrews.net Wed Apr 29 08:20:26 2009 From: marty at martyandrews.net (Marty Andrews) Date: Wed, 29 Apr 2009 22:20:26 +1000 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <57c63afe0904290515y4da1abfdl7693b7bf44483f0a@mail.gmail.com> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> <57c63afe0904290441p7b5328cdx8b9c4909abfd89c3@mail.gmail.com> <1C05CCB2-174C-4D46-AA93-D9C3CA854E68@martyandrews.net> <57c63afe0904290515y4da1abfdl7693b7bf44483f0a@mail.gmail.com> Message-ID: [snip] > I'm really sorry about this, but I just couldn't wait for tonight to > add this: > > http://github.com/dchelimsky/rspec/commit/a4b3aac62e940c50077bdeb7d9ad5ee11e02116d > > The release *will* have to wait for tonight, but you can easily build > the gem locally: http://wiki.github.com/dchelimsky/rspec/edge Thanks David :) I'm in Australia, and it's already getting late here. Your tonight will be during the day tomorrow for me. I'll give it a go then. -- Marty From brandtkurowski at gmail.com Wed Apr 29 09:37:39 2009 From: brandtkurowski at gmail.com (Brandt Kurowski) Date: Wed, 29 Apr 2009 06:37:39 -0700 (PDT) Subject: [rspec-users] Cucumber/Webrat/Selenium + SSL? In-Reply-To: <5FB7882F-3CAF-40BE-B304-71807CF5DE71@wincent.com> References: <5FB7882F-3CAF-40BE-B304-71807CF5DE71@wincent.com> Message-ID: <7887dead-713c-44be-89b4-aea1d0a463ce@w35g2000prg.googlegroups.com> On Apr 29, 6:04?am, Wincent Colaiuta wrote: > Webrat will "automatically start the Selenium Java server process and ? > an instance of Mongrel when a test is run". So there is no way that I ? > can see to force Webrat to launch the Selenium server process with the ? > custom Firefox profile. You can tell webrat to not launch Selenium RC and to instead connect to an already running instance by setting the selenium_server_address configuration variable. It's not well documented (it was originally added to support Selenium Grid) and is perhaps not an ideal solution to the problem you face, but it might be preferable to monkey-patching webrat. From lists at ruby-forum.com Wed Apr 29 10:08:59 2009 From: lists at ruby-forum.com (James Byrne) Date: Wed, 29 Apr 2009 16:08:59 +0200 Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <5a353b250f4788ec641b3a26092fce9c@ruby-forum.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> <49F68B3D.6040007@benmabey.com> <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> <5a353b250f4788ec641b3a26092fce9c@ruby-forum.com> Message-ID: <531734da2f7e3dbc67318c15d68479a9@ruby-forum.com> James Byrne wrote: > I have reached this point in testing using email-spec: ... > The email To: header value and the current_email_address are the same > insofar as I can tell. But the email_spec matcher is not finding that > address in the deliveries array. Any ideas as to what I am missing? I have determined what the problem is. I just do not know how to fix it. What is happening is that I am testing a standalone (outside of a Rails instance) Ruby script that requires ActionMailer. I call this script from inside the step definition using the %x alias for Kernel#`. When this runs it picks up the test environment and directs email output into ActionMailer::Base.deliveries. However, this array only exists during the script's existence and naturally disappears when he script terminates. In consequence, the results are not available for testing. I have, up to now, simply accepted the magic of injecting test methods into classes and using the results. Now I need to have explained how I get this to magic work with stand alone scripts. How do I get ActionMailer::Base.deliveries created by ActionMailer in the script to remain available to cucumber/email-spec? -- Posted via http://www.ruby-forum.com/. From nabble.35r at gishpuppy.com Wed Apr 29 10:24:39 2009 From: nabble.35r at gishpuppy.com (Jean-Michel Garnier) Date: Wed, 29 Apr 2009 07:24:39 -0700 (PDT) Subject: [rspec-users] Is it possible to have autotest running *only* the features not the specs Message-ID: <23296018.post@talk.nabble.com> Hi, I am joining a project which is using Rails 2.0.2, Rspec as a plugin 1.1.4 The problem is specs take 10 minutes to run and I have no time to optimize them now. I am adding cucumber features and would like to run them with autotest (ZenTest 4.0.0). Is there a way to have autotest running *only* the features not the specs? It would save a LOT of time ... In the past, I think I managed to do it with a /script/autofeatures_only looking like: #!/usr/bin/env ruby ENV['AUTOFEATURE'] = 'true' # run only cucumber features ENV['RSPEC'] = 'false' # ONLY the features, not the spec! NOT allows autotest to discover rspec system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) || $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH") My rspec/lib/autotest/discover.rb looks like: Autotest.add_discovery do "rspec" if File.directory?('spec') && ENV['RSPEC'] == true end Does anyone have a similar set up with different versions of RSpec? I am planning to upgrade Rails and RSpec in the coming months. Thanks, JM -- View this message in context: http://www.nabble.com/Is-it-possible-to-have-autotest-running-*only*-the-features-not-the-specs-tp23296018p23296018.html Sent from the rspec-users mailing list archive at Nabble.com. From ben at benmabey.com Wed Apr 29 10:37:22 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 29 Apr 2009 08:37:22 -0600 Subject: [rspec-users] Cucumber - Testing ActionMailer In-Reply-To: <531734da2f7e3dbc67318c15d68479a9@ruby-forum.com> References: <927c9b495371346bbb4b569ae767ec33@ruby-forum.com> <49F68B3D.6040007@benmabey.com> <93ecab56af647631a9be4b0a4b8de281@ruby-forum.com> <5a353b250f4788ec641b3a26092fce9c@ruby-forum.com> <531734da2f7e3dbc67318c15d68479a9@ruby-forum.com> Message-ID: <49F86622.8030007@benmabey.com> James Byrne wrote: > James Byrne wrote: > >> I have reached this point in testing using email-spec: >> > ... > >> The email To: header value and the current_email_address are the same >> insofar as I can tell. But the email_spec matcher is not finding that >> address in the deliveries array. Any ideas as to what I am missing? >> > > I have determined what the problem is. I just do not know how to fix it. > > What is happening is that I am testing a standalone (outside of a Rails > instance) Ruby script that requires ActionMailer. I call this script > from inside the step definition using the %x alias for Kernel#`. When > this runs it picks up the test environment and directs email output into > ActionMailer::Base.deliveries. However, this array only exists during > the script's existence and naturally disappears when he script > terminates. In consequence, the results are not available for testing. > > I have, up to now, simply accepted the magic of injecting test methods > into classes and using the results. Now I need to have explained how I > get this to magic work with stand alone scripts. How do I get > ActionMailer::Base.deliveries created by ActionMailer in the script to > remain available to cucumber/email-spec? > I have plans to make email-spec work with any SMTP mailer and thereby making it more "black-box"y and allow for external processes to be easily tested... However, that is not done yet. As it stands now you have two options: a) have the test execution and script in the same process or b) Use ARMailer[1] in your testing environment. ARMailer places the messages in a database for queuing. So instead of checking the in-memory array EmailSpec will check the queue on the database. Since this is just for testing then you could use a lightweight sqlite3 db to store this. -Ben 1. http://github.com/seattlerb/ar_mailer/tree/master From jean-michel at 21croissants.com Wed Apr 29 10:56:41 2009 From: jean-michel at 21croissants.com (Jean-Michel Garnier) Date: Wed, 29 Apr 2009 07:56:41 -0700 (PDT) Subject: [rspec-users] NetBeans with Cucumber module In-Reply-To: <7ac2300c0904290458q5b2b36b8g5d86e13eab6edf2b@mail.gmail.com> References: <7ac2300c0904290458q5b2b36b8g5d86e13eab6edf2b@mail.gmail.com> Message-ID: <23296101.post@talk.nabble.com> http://www.pmamediagroup.com/2009/04/what-netbeans-651-can-now-recognize-my-cucumber-feature-files/ is another plugin and works well on Nb 6.5.1 JM aidy_lewis wrote: > > Hi, > > Aslak twittered this NetBeans Cucumber module : > http://members.chello.at/server/modules.html > > I have tried to manually install it, but NetBeans in complaining about: > > "Missing required modules for Plugin Cucumber Features: > Generic Languages Framework [module org.netbeans.modules.languages/0-1 >> 1.90.1.1]" > > Automatic install is disabled (not sure why) and I cannot for the life > of me find 'The Generic Languages Framework' > > > -- > Aidy > blog: www.agiletester.co.uk > twitter: http://twitter.com/aidy_lewis > _______________________________________________ > 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/NetBeans-with-Cucumber-module-tp23295929p23296101.html Sent from the rspec-users mailing list archive at Nabble.com. From idokan at gmail.com Wed Apr 29 11:09:23 2009 From: idokan at gmail.com (ik) Date: Wed, 29 Apr 2009 18:09:23 +0300 Subject: [rspec-users] Cucumber localization Message-ID: Hello, I'm trying to localize Cucumber to work with Hebrew. I have added the needed translation to languages.yml I converted the division.feature properly. but when I used the addition.feature cucumber gives me the following error message: $ ../../../bin/cucumber --language=he features/addition.feature ../../../bin/../lib/cucumber/parser/treetop_ext.rb:81:in `parse_or_fail': features/addition.feature:6:28: Parse error, expected one of "????", "????", "??", "\n", "\r", "#", "???????", "@", "?????", "????? ?????". (Cucumber::Parser::SyntaxError) from ../../../bin/../lib/cucumber/parser/treetop_ext.rb:68:in `parse_file' from ../../../bin/../lib/cucumber/parser/treetop_ext.rb:73:in `open' from ../../../bin/../lib/cucumber/parser/treetop_ext.rb:73:in `parse_file' from ../../../bin/../lib/cucumber/cli/main.rb:55:in `load_plain_text_features' from ../../../bin/../lib/cucumber/cli/main.rb:54:in `each' from ../../../bin/../lib/cucumber/cli/main.rb:54:in `load_plain_text_features' from ../../../bin/../lib/cucumber/cli/main.rb:37:in `execute!' from ../../../bin/../lib/cucumber/cli/main.rb:20:in `execute' from ../../../bin/cucumber:6 ????? ????? is the equal of scenario_outline . I have noticed that if I reverse the name to ????? ????? in the addition.feature it does seems to be accepted. What am I doing wrong ? Thanks, Ido -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: addition.feature Type: application/octet-stream Size: 693 bytes Desc: not available URL: From akleak at gmail.com Wed Apr 29 11:45:43 2009 From: akleak at gmail.com (Arco) Date: Wed, 29 Apr 2009 08:45:43 -0700 (PDT) Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <8d961d900904282313h1286d178u22920ceb21d3facd@mail.gmail.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <8d961d900904282313h1286d178u22920ceb21d3facd@mail.gmail.com> Message-ID: <86d7bfca-323c-4873-b483-5aa5608ff615@v35g2000pro.googlegroups.com> After some consideration, I agree with Aslak's and Ben's advice against keeping context across an entire feature. But I am still not convinced that it makes sense for create a new context for each row of an example table. As a newbie, I expected the Before: block would be run once before the scenario, not once before every row of the example table. (so did Ben initially...) Approach A ----------------------- Before: Given I have a clean database Scenario Outline: Signup Scenarios Given I start on the login page When I signup as Then I should see Examples: | userid | message | | userA | successful signup | | userA | error: duplicate userid | Approach B ------------------------ Before: Given I have a clean database Scenario: Successful Signup Given I start on the login page When I signup as "userA" Then I should see "successful signup" Scenario: Failure - Duplicate Userid Given I start on the login page When I signup as "userA" And I signup again as "userA" Then I should see "error: duplicate userid" OK I will use Approach B, but ideally would prefer to use Approach A, and personally find it easier to read and understand. Thanks again for your feedback! :) On Apr 28, 11:13?pm, aslak hellesoy wrote: > > Hey Ben, > > > It'd be kinda cool if there was a sort of before and after for a feature > > rather than each scenario. Is there? > > I think that would be particularly *un*cool actually, because people would > start using it without understanding the implications. > Implications: Coupled, brittle scenarios. > > Why do you think it would be useful? > > Aslak > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From rick.denatale at gmail.com Wed Apr 29 12:47:42 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 29 Apr 2009 12:47:42 -0400 Subject: [rspec-users] Current Evaluation of RSpec In-Reply-To: <1fb4df0904282209v3f14c47cnecc1d4ea6ec12747@mail.gmail.com> References: <632154f70904281957oa2c8b2aw82d506b94b3ab1c8@mail.gmail.com> <1fb4df0904282209v3f14c47cnecc1d4ea6ec12747@mail.gmail.com> Message-ID: On Wed, Apr 29, 2009 at 1:09 AM, Stephen Eley wrote: > On Tue, Apr 28, 2009 at 10:57 PM, Nicholas Van Weerdenburg > wrote: >> Looking around outside of the book, reading reviews of RSpec on the web >> seems tricky. Most reviews seem very dated, and as a result are misleading. >> Is this an accurate assessment? > > I don't think so. ?The core syntax and sensibilities of RSpec haven't > changed in any disruptive way. ?It's added new features, like those > contexts and such, but there's no compulsion to use them. ?And to me > they don't have much impact on the fundamental _flavor_ of RSpec. > Well it depends on how far back you go, and how old those reviews are. When RSpec first appeared the syntax was a bit different, and it added a lot of methods to Kernel/Object. Some of the folks who looked at it in it's early days had a negative reaction to that. Some folks blogged about that reaction back then. I kept my powder dry IIRC. About a year later, after seeing David C's presentation at RubyConf 2007, and talking to him I decided to give it another look. I wrote this article: http://talklikeaduck.denhaven2.com/2008/01/29/why-i-dont-mind-using-rspec-in-fact-ive-come-to-love-it And I haven't looked back since. I know that some well known Ruby/Rails personalities and companies continued to disdain RSpec after the initial impression, For example here's the article by my friend Rob Sanheim, which prompted me to write that article. http://robsanheim.com/2008/01/25/why-i-use-testspec-over-rspec/ (It seems to be down right now, try googling for sanheim rspec and check the cached version) But that seems to be changing. Rob wrote this more recently: http://blog.thinkrelevance.com/2009/3/26/introducing-micronaut-a-lightweight-bdd-framework -- 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 From andrew at avit.ca Wed Apr 29 13:11:50 2009 From: andrew at avit.ca (Andrew Vit) Date: Wed, 29 Apr 2009 10:11:50 -0700 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <86d7bfca-323c-4873-b483-5aa5608ff615@v35g2000pro.googlegroups.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <8d961d900904282313h1286d178u22920ceb21d3facd@mail.gmail.com> <86d7bfca-323c-4873-b483-5aa5608ff615@v35g2000pro.googlegroups.com> Message-ID: <2F30CABB-C545-42EE-B2D2-D93FBF27ADEF@avit.ca> On Apr 29, 2009, at 8:45 AM, Arco wrote: > But I am still not convinced that it makes sense for create a new > context for each row of an example table. As a newbie, I expected the > Before: block would be run once before the scenario, not once before > every row of the example table. (so did Ben initially...) > > Approach A ----------------------- > Before: > Given I have a clean database > Scenario Outline: Signup Scenarios > Given I start on the login page > When I signup as > Then I should see > Examples: > | userid | message | > | userA | successful signup | > | userA | error: duplicate userid | To me, "Examples" means separate, independent items. If these are to be run under the same scenario in sequence, then the table should be called something else, maybe "Sequence:" or "Steps:" There might be other use cases for such a feature... I don't have any to suggest at the moment, just brainstorming. Andrew Vit From rick.denatale at gmail.com Wed Apr 29 14:45:58 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 29 Apr 2009 14:45:58 -0400 Subject: [rspec-users] Current Evaluation of RSpec In-Reply-To: <632154f70904291104y4e71f3a6s397d8096776afbd4@mail.gmail.com> References: <632154f70904281957oa2c8b2aw82d506b94b3ab1c8@mail.gmail.com> <1fb4df0904282209v3f14c47cnecc1d4ea6ec12747@mail.gmail.com> <632154f70904291104y4e71f3a6s397d8096776afbd4@mail.gmail.com> Message-ID: On Wed, Apr 29, 2009 at 2:04 PM, Nicholas Van Weerdenburg wrote: > Thanks. That's what I'm trying to parse- a lot of people are inspired to > blog when something is new, but less so later on, so there is a lot of > 2007/early 2008 posts from basic google searches. > The evolution of RSpec is fascinating- very organic and collaborative. For another recent barometer reading of how much ReSPECt RSpec gets these days, have a look at http://rubytrends.com/ -- 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 From john.ivanoff at gmail.com Wed Apr 29 15:45:41 2009 From: john.ivanoff at gmail.com (John Ivanoff) Date: Wed, 29 Apr 2009 12:45:41 -0700 (PDT) Subject: [rspec-users] Noob question In-Reply-To: References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> Message-ID: the book The RSpec book has an example where they build an app with just ruby. ("Describing Application Behaviour with Cucumber") You can download some sample chapters. http://www.pragprog.com/titles/achbd/the-rspec-book This has been a big help for me. also Railscast (http://railscasts.com/) has some screen cast with cucumber but it is rails related. John -- Support me on my MS 150 ride May 2-3, 2009 Frisco to Fort Worth http://main.nationalmssociety.org/site/TR?px=5933747&fr_id=10662&pg=personal training - http://www.dailymile.com/people/john_ivanoff On Apr 29, 7:42?am, Chris Flipse wrote: > On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma wrote: > > Presumably you only need these if you are *building* cucumber? > > > If you just want to use cucumber, it should be as simple as "gem > > install cucumber", and it should get all the other dependencies. ?On > > my machine it seemed to install treetop, polyglot, and presumably a > > few others - but I don't have rspec-rails nor webrat. > > rspec(-rails) and webrat aren't actually *required* by Cucumber -- you can > use it without them, which is why they're not force-installed. ?However, > nearly every example you're going to find of Cucumber run against a rails > app is going to be using webrat and rspec-rails ... > > -- > // anything worth taking seriously is worth making fun of > //http://blog.devcaffeine.com/ > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From korny at sietsma.com Wed Apr 29 17:17:19 2009 From: korny at sietsma.com (Korny Sietsma) Date: Thu, 30 Apr 2009 07:17:19 +1000 Subject: [rspec-users] Noob question In-Reply-To: References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> Message-ID: <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> True, but cucumber is useful for lots of different kinds of projects. I'm currently using it to build a java webapp, so I don't need much beyond cucumber, selenium, and selenium-client. But agreed, if I was in rails-land (sigh) then I'd want webrat and rspec-rails. - Korny p.s. I'm aware webrat works without rails, but when I looked it didn't seem a big boost for our kind of app. On Wed, Apr 29, 2009 at 10:42 PM, Chris Flipse wrote: > On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma wrote: >> >> Presumably you only need these if you are *building* cucumber? >> >> If you just want to use cucumber, it should be as simple as "gem >> install cucumber", and it should get all the other dependencies. ?On >> my machine it seemed to install treetop, polyglot, and presumably a >> few others - but I don't have rspec-rails nor webrat. > > rspec(-rails) and webrat aren't actually *required* by Cucumber -- you can > use it without them, which is why they're not force-installed.? However, > nearly every example you're going to find of Cucumber run against a rails > app is going to be using webrat and rspec-rails ... > > > > -- > // anything worth taking seriously is worth making fun of > // http://blog.devcaffeine.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- 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" From bcolfer at shopping.com Wed Apr 29 17:47:35 2009 From: bcolfer at shopping.com (Colfer, Brian) Date: Wed, 29 Apr 2009 15:47:35 -0600 Subject: [rspec-users] Separation of duties Cucumber and Rspec ... RE: Noob question In-Reply-To: <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com><8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> Message-ID: <5A95EAE4A3FE1645992FAF868AD6DCDC09D0B73D@DEN-EXM-06.corp.ebay.com> Cucumber is not built to do rapid BDD ... It is an integration and acceptance specification exercise system. Rspec is for development ... Mocks are an integral part of the BDD process. The idea is to partition the system component behaviors so that you can focuss on the implementing the behavior that you are working on. This minimizes the "Yak Shaving " http://en.wiktionary.org/wiki/yak_shaving You can focus on the task at hand ... For example if you are building a system that connects to a remote system to send a data feed ... And get a confirmation that the transmission was successful. When you are developing you don't want to be stalled by the connectivity issues so you mock the external system's behavior in respect to your system. Cucumber's flow is to expect that the step definitions connect to real systems and not mocks. This is how I understand the relation the separation of duties. Brian Colfer -----Original Message----- From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] On Behalf Of Korny Sietsma Sent: Wednesday, April 29, 2009 2:17 PM To: rspec-users Subject: Re: [rspec-users] Noob question True, but cucumber is useful for lots of different kinds of projects. I'm currently using it to build a java webapp, so I don't need much beyond cucumber, selenium, and selenium-client. But agreed, if I was in rails-land (sigh) then I'd want webrat and rspec-rails. - Korny p.s. I'm aware webrat works without rails, but when I looked it didn't seem a big boost for our kind of app. On Wed, Apr 29, 2009 at 10:42 PM, Chris Flipse wrote: > On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma wrote: >> >> Presumably you only need these if you are *building* cucumber? >> >> If you just want to use cucumber, it should be as simple as "gem >> install cucumber", and it should get all the other dependencies. ?On >> my machine it seemed to install treetop, polyglot, and presumably a >> few others - but I don't have rspec-rails nor webrat. > > rspec(-rails) and webrat aren't actually *required* by Cucumber -- you > can use it without them, which is why they're not force-installed.? > However, nearly every example you're going to find of Cucumber run > against a rails app is going to be using webrat and rspec-rails ... > > > > -- > // anything worth taking seriously is worth making fun of // > http://blog.devcaffeine.com/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- 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" _______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users From kero at chello.nl Wed Apr 29 17:59:41 2009 From: kero at chello.nl (Kero van Gelder) Date: Wed, 29 Apr 2009 23:59:41 +0200 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> Message-ID: <20090429215941.GE13970@bumblebee.m38c.nl> >>> So basically, I want to do something like this: >>> >>> examples = load_examples_without_running >>> examples.each {|example| puts example.description} [snip] > I'm working into a big corporate in Australia, and they are demanding > traceability of tests back to requirements. I'm already using Mingle to > manage story cards, and I'm hoping to let the testers build in the > traceability via code. So I've got a Mixin to the examples so that I > can declare the id of the story that the test maps to. It looks > something like this: > > describe FunctionalArea do > it "automates some acceptance test declared on a story" do > traces_to_story 35 > # test implementation > end > end I would have expected Cucumber to map stories to scenarios/examples by having them in the same file (and a @tag if someone insists that a number referrring an external doc is better for tracability). I would have expected RSpec to cover a lower level that is of no interest to the person wanting traceability, as that person can not judge whether the code works anyway (YMMV). Besides, a spec can apply to more than one requirement; or to no particular requirement at all. I'm expecting this from regulations that deal with medical devices. Validation has to happen on story level; risk mitigation may apply to lower levels, though. Our department is working on several projects that'll result in medical devices and we are learning how regulations, audits and things work for real. So I'd like to hear why you are trying to do what you do. There can be other requirements for other reasons. What traceability are you looking for in these tests? Why do you look at the RSpec level? Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From seatmanu at gmail.com Wed Apr 29 18:11:27 2009 From: seatmanu at gmail.com (Manu) Date: Wed, 29 Apr 2009 15:11:27 -0700 Subject: [rspec-users] Change in API 0.3.1 clarification Message-ID: <5937E3CC-2D72-486E-AC0B-5B8F5BE9D5B0@gmail.com> Hi I am looking at the change in the API in the history.txt and looks like 3 visitor method are now gone. They are replaced by one. Also for Table, the status is not passed anymore... Looking at the current HTML formatter in 0.3.1, the 3 methods are still present and so is the code . I had a slight modify version of the formatter compare to the one in cucumber and was relying on the status to be passed for the table and I am not sure how to go about to get that state to properly colorize my table, can you please clarify what you mean by using @state? Also, for the 3 methods that not official anymore, are you meaning that they are deprecated? If so do you have an example on how to use the new way? Thanks Emmanuel From marty at martyandrews.net Wed Apr 29 18:29:43 2009 From: marty at martyandrews.net (Marty Andrews) Date: Thu, 30 Apr 2009 08:29:43 +1000 Subject: [rspec-users] [rspec] loading specs as an object model without running them In-Reply-To: <20090429215941.GE13970@bumblebee.m38c.nl> References: <46b68e880904282307o314b4b5dy2e0d09a53fad9090@mail.gmail.com> <46b68e880904282323g61840220j1f062dce9c06382@mail.gmail.com> <57c63afe0904290354o50d25aaayebfed856a444654f@mail.gmail.com> <20090429215941.GE13970@bumblebee.m38c.nl> Message-ID: <17967E8F-F13D-4CA7-830A-C21D39861E5A@martyandrews.net> On 30/04/2009, at 7:59 AM, Kero van Gelder wrote: >>>> So basically, I want to do something like this: >>>> >>>> examples = load_examples_without_running >>>> examples.each {|example| puts example.description} > > [snip] > >> I'm working into a big corporate in Australia, and they are demanding >> traceability of tests back to requirements. I'm already using >> Mingle to >> manage story cards, and I'm hoping to let the testers build in the >> traceability via code. So I've got a Mixin to the examples so that I >> can declare the id of the story that the test maps to. It looks >> something like this: >> >> describe FunctionalArea do >> it "automates some acceptance test declared on a story" do >> traces_to_story 35 >> # test implementation >> end >> end > > I would have expected Cucumber to map stories to scenarios/examples > by having them in the same file (and a @tag if someone insists that > a number referrring an external doc is better for tracability). > > I would have expected RSpec to cover a lower level that is of no > interest to the person wanting traceability, as that person can not > judge whether the code works anyway (YMMV). Besides, a spec can > apply to more than one requirement; or to no particular requirement > at all. > > I'm expecting this from regulations that deal with medical devices. > Validation has to happen on story level; risk mitigation may apply > to lower levels, though. Our department is working on several projects > that'll result in medical devices and we are learning how regulations, > audits and things work for real. > > So I'd like to hear why you are trying to do what you do. Sure. > There can be other requirements for other reasons. What traceability > are you looking for in these tests? Why do you look at the RSpec > level? I don't necessarily disagree with what you are saying, but the project was going long before cucumber existed, and we already had a heavy investment in tests using rspec. It's a data warehousing project, so there's little or no UI to speak of. We built a DSL on top of RSpec to allow us to manipulate data and verify results after ETL jobs run. Most of tests set up data, run the ETL job (calling out to an external tool) and then verify that the results look the way they're supposed to. So to us, RSpec isn't a 'lower level'. Perhaps if the project was starting now, I'd consider cucumber. Our investment in a DSL on RSpec is reasonably heavy though, and is working really well for us. I'd rather enhance that a bit further than switch frameworks for the sake of one feature. -- Marty From ben at benmabey.com Wed Apr 29 19:32:02 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 29 Apr 2009 17:32:02 -0600 Subject: [rspec-users] Noob question In-Reply-To: <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> Message-ID: <49F8E372.6030303@benmabey.com> Korny Sietsma wrote: > True, but cucumber is useful for lots of different kinds of projects. > I'm currently using it to build a java webapp, so I don't need much > beyond cucumber, selenium, and selenium-client. > I'm curious, with your current setup do you insert data directly into your database (i.e. in Given steps) or do you always use the selenium to enter in data. Meaning, if you needed a user to exist so you could have them log in.. do you use ActiveRecord, or something similar, to create the user or do you use the webforms to create the user? Also, how do you handle cleaning the database after each scenario? Sorry, for the questions, but I'm curious how you've solved these problems when using Cucumber to test a non-ruby webapp. Thanks, Ben > But agreed, if I was in rails-land (sigh) then I'd want webrat and rspec-rails. > > - Korny > p.s. I'm aware webrat works without rails, but when I looked it didn't > seem a big boost for our kind of app. > > On Wed, Apr 29, 2009 at 10:42 PM, Chris Flipse wrote: > >> On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma wrote: >> >>> Presumably you only need these if you are *building* cucumber? >>> >>> If you just want to use cucumber, it should be as simple as "gem >>> install cucumber", and it should get all the other dependencies. On >>> my machine it seemed to install treetop, polyglot, and presumably a >>> few others - but I don't have rspec-rails nor webrat. >>> >> rspec(-rails) and webrat aren't actually *required* by Cucumber -- you can >> use it without them, which is why they're not force-installed. However, >> nearly every example you're going to find of Cucumber run against a rails >> app is going to be using webrat and rspec-rails ... >> >> >> >> -- >> // anything worth taking seriously is worth making fun of >> // http://blog.devcaffeine.com/ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > From korny at sietsma.com Wed Apr 29 22:05:41 2009 From: korny at sietsma.com (Korny Sietsma) Date: Thu, 30 Apr 2009 12:05:41 +1000 Subject: [rspec-users] Noob question In-Reply-To: <49F8E372.6030303@benmabey.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> <49F8E372.6030303@benmabey.com> Message-ID: <8e15872b0904291905t59f8f53aj7257b435dba8a69d@mail.gmail.com> We are actively debating this very topic :) For most stuff, we create data through the UI. We have a "Before" block that prunes the database back to a known state before each scenario, using the ruby 'sequel' library. It's pretty fast, but it does mean we have to be careful in our selenium, that we wait for the database as seen by the app to catch up with the database session committed by the ruby code. And then our scenarios have stuff like "Given a top-level node called "Foo" exists" - which creates the node via selenium. However there are some areas where this is just too slow, and we have created some 'Given' steps that use ruby-sequel code that build up data directly in the database. This does mean duplicating some of our Java domain in the ruby code, but it seemed to be a pragmatic solution to the problem. Currently we are debating whether to make more 'Given' steps directly push data into the database - there are pros and cons either way; using the UI gives us more confidence in our app (and less fragility if our domain changes) and requires less code (we can reuse 'when' steps from some scenarios as 'given' steps for others) but it's slower - and the accumulated effect of slow builds can be terrible. - Korny On Thu, Apr 30, 2009 at 9:32 AM, Ben Mabey wrote: > Korny Sietsma wrote: >> >> True, but cucumber is useful for lots of different kinds of projects. >> I'm currently using it to build a java webapp, so I don't need much >> beyond cucumber, selenium, and selenium-client. >> > > I'm curious, with your current setup do you insert data directly into your > database (i.e. in Given steps) or do you always use the selenium to enter in > data. ?Meaning, if you needed a user to exist so you could have them log > in.. do you use ActiveRecord, or something similar, to create the user or do > you use the webforms to create the user? ?Also, how do you handle cleaning > the database after each scenario? ?Sorry, for the questions, but I'm curious > how you've solved these problems when using Cucumber to test a non-ruby > webapp. > > Thanks, > Ben > > >> But agreed, if I was in rails-land (sigh) then I'd want webrat and >> rspec-rails. >> >> - Korny >> p.s. I'm aware webrat works without rails, but when I looked it didn't >> seem a big boost for our kind of app. >> >> On Wed, Apr 29, 2009 at 10:42 PM, Chris Flipse wrote: >> >>> >>> On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma wrote: >>> >>>> >>>> Presumably you only need these if you are *building* cucumber? >>>> >>>> If you just want to use cucumber, it should be as simple as "gem >>>> install cucumber", and it should get all the other dependencies. ?On >>>> my machine it seemed to install treetop, polyglot, and presumably a >>>> few others - but I don't have rspec-rails nor webrat. >>>> >>> >>> rspec(-rails) and webrat aren't actually *required* by Cucumber -- you >>> can >>> use it without them, which is why they're not force-installed. ?However, >>> nearly every example you're going to find of Cucumber run against a rails >>> app is going to be using webrat and rspec-rails ... >>> >>> >>> >>> -- >>> // anything worth taking seriously is worth making fun of >>> // http://blog.devcaffeine.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 > -- 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" From dchelimsky at gmail.com Wed Apr 29 23:55:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 29 Apr 2009 22:55:11 -0500 Subject: [rspec-users] [ANN] rspec 1.2.5 Released Message-ID: <57c63afe0904292055w5ba91fcel9bbcc60a885ba453@mail.gmail.com> rspec version 1.2.5 has been released! * * * * Behaviour Driven Development for Ruby. Changes: ### Version 1.2.5 / 2009-04-29 * enhancements * name argument to mock/stub is now optional (closes #782) * you can do mock(:foo => "woo", :bar => "car") * expect { this_block }.to change{this.expression}.from(old_value).to(new_value) * expect { this_block }.to raise_error * better failiure messages for equal matcher (James Byrne). Closes #804. * add stub_chain method * also alias_method :stub, :stub!, so you can stub with less bang * added options to example_group_proxy * bug fixes * ensure correct handling of ordered message expectations with duplicate expectations (NigelThorne). Closes #793. * get matcher backwards compat working w/ ruby 19 * don't define instance_exec unless it is not defined * was doing a version check, but turns out that didn't cover alternative implementations like JRuby * fix bug where in some circumstances, loading lib/spec/interop/test.rb raised an error (tsechingho). Closes #803. * make sure specs only run against spec server when using drb (patch from Chuck Grindel). Closes #797. * remove deprecation warning in example_pending when using FailingExamplesFormatter. Closes #794. * Access explicit subject from nested groups of arbitrary depth. Closes #756. * * * * From dchelimsky at gmail.com Wed Apr 29 23:55:17 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 29 Apr 2009 22:55:17 -0500 Subject: [rspec-users] [ANN] rspec-rails 1.2.5 Released Message-ID: <57c63afe0904292055q1ee060dhf17327359b0f5e6e@mail.gmail.com> rspec-rails version 1.2.5 has been released! * * * * * Behaviour Driven Development for Ruby on Rails. Changes: ### Version 1.2.5 / 2009-04-29 * enhancements * support :xml and :strict config options for have_tag matcher (patch from Peer Allan and Max Murphy). Closes #783. * bug fixes * Fixed a small typo that makes rake stats fail (Jos? Valim). Closes #802. * link_to and friends are available to ViewExampleGroup again (J.B. Rainsberger). Closes #787. * spec_server works correctly with rails 2.3 again (Neil Buckley). Closes #759. * * * * * From ben at benmabey.com Thu Apr 30 00:22:18 2009 From: ben at benmabey.com (Ben Mabey) Date: Wed, 29 Apr 2009 22:22:18 -0600 Subject: [rspec-users] Noob question In-Reply-To: <8e15872b0904291905t59f8f53aj7257b435dba8a69d@mail.gmail.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> <49F8E372.6030303@benmabey.com> <8e15872b0904291905t59f8f53aj7257b435dba8a69d@mail.gmail.com> Message-ID: <49F9277A.5050009@benmabey.com> Korny Sietsma wrote: > We are actively debating this very topic :) > > For most stuff, we create data through the UI. > > We have a "Before" block that prunes the database back to a known > state before each scenario, using the ruby 'sequel' library. It's > pretty fast, but it does mean we have to be careful in our selenium, > that we wait for the database as seen by the app to catch up with the > database session committed by the ruby code. > > And then our scenarios have stuff like "Given a top-level node called > "Foo" exists" - which creates the node via selenium. > > However there are some areas where this is just too slow, and we have > created some 'Given' steps that use ruby-sequel code that build up > data directly in the database. This does mean duplicating some of our > Java domain in the ruby code, but it seemed to be a pragmatic solution > to the problem. > Have you considered running Cucumber with JRuby so you can leverage your Java code to insert records into the DB? Just an idea. > Currently we are debating whether to make more 'Given' steps directly > push data into the database - there are pros and cons either way; > using the UI gives us more confidence in our app (and less fragility > if our domain changes) and requires less code (we can reuse 'when' > steps from some scenarios as 'given' steps for others) but it's slower > - and the accumulated effect of slow builds can be terrible. > As far as the confidence aspect goes, it seems that you should gain enough confidence by having Cucumber fill out each form once then insert the data directly the other times. That is at least how I approach things in webrat world. But you are right about all of the trade-offs and that is why I am curious on how you are solving them. Thanks for sharing! -Ben > > On Thu, Apr 30, 2009 at 9:32 AM, Ben Mabey wrote: > >> Korny Sietsma wrote: >> >>> True, but cucumber is useful for lots of different kinds of projects. >>> I'm currently using it to build a java webapp, so I don't need much >>> beyond cucumber, selenium, and selenium-client. >>> >>> >> I'm curious, with your current setup do you insert data directly into your >> database (i.e. in Given steps) or do you always use the selenium to enter in >> data. Meaning, if you needed a user to exist so you could have them log >> in.. do you use ActiveRecord, or something similar, to create the user or do >> you use the webforms to create the user? Also, how do you handle cleaning >> the database after each scenario? Sorry, for the questions, but I'm curious >> how you've solved these problems when using Cucumber to test a non-ruby >> webapp. >> >> Thanks, >> Ben >> >> >> >>> But agreed, if I was in rails-land (sigh) then I'd want webrat and >>> rspec-rails. >>> >>> - Korny >>> p.s. I'm aware webrat works without rails, but when I looked it didn't >>> seem a big boost for our kind of app. >>> >>> On Wed, Apr 29, 2009 at 10:42 PM, Chris Flipse wrote: >>> >>> >>>> On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma wrote: >>>> >>>> >>>>> Presumably you only need these if you are *building* cucumber? >>>>> >>>>> If you just want to use cucumber, it should be as simple as "gem >>>>> install cucumber", and it should get all the other dependencies. On >>>>> my machine it seemed to install treetop, polyglot, and presumably a >>>>> few others - but I don't have rspec-rails nor webrat. >>>>> >>>>> >>>> rspec(-rails) and webrat aren't actually *required* by Cucumber -- you >>>> can >>>> use it without them, which is why they're not force-installed. However, >>>> nearly every example you're going to find of Cucumber run against a rails >>>> app is going to be using webrat and rspec-rails ... >>>> >>>> >>>> >>>> -- >>>> // anything worth taking seriously is worth making fun of >>>> // http://blog.devcaffeine.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 korny at sietsma.com Thu Apr 30 00:37:30 2009 From: korny at sietsma.com (Korny Sietsma) Date: Thu, 30 Apr 2009 14:37:30 +1000 Subject: [rspec-users] Noob question In-Reply-To: <49F9277A.5050009@benmabey.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> <49F8E372.6030303@benmabey.com> <8e15872b0904291905t59f8f53aj7257b435dba8a69d@mail.gmail.com> <49F9277A.5050009@benmabey.com> Message-ID: <8e15872b0904292137w8ceeb82we554c24d433de65f@mail.gmail.com> We did think about using JRuby to write data through the domain - unfortunately it looked fiddly, especially as there are quite a few things our ruby code wants to do that the domain doesn't cover. For example, mass deleting data - in the domain, almost everything is soft-deleted, and everything generates audit logs; in our tests, we want do disable constraints and then delete everything in the underlying tables, with no auditing. Mostly, though, we started with really simple stuff that was easier to do in ruby, and as usual things grew as we went along. Moving to using the real domain might be something we tackle as a refactoring at a later date. Also some parts of our database are legacy stuff that doesn't really have a good domain layer - it'd be good to add one, but it's a big chunk of work I should throw in a quick plug here - the ruby sequel library ( http://sequel.rubyforge.org/ ) , despite having a sucky name, is *great* for this sort of thing - manipulating tables, one-off migration scripts, and the like. If you need to manipulate data, but don't want a full ORM, give it a look. - Korny On Thu, Apr 30, 2009 at 2:22 PM, Ben Mabey wrote: > Korny Sietsma wrote: >> >> We are actively debating this very topic :) >> >> For most stuff, we create data through the UI. >> >> We have a "Before" block that prunes the database back to a known >> state before each scenario, using the ruby 'sequel' library. ?It's >> pretty fast, but it does mean we have to be careful in our selenium, >> that we wait for the database as seen by the app to catch up with the >> database session committed by the ruby code. >> >> And then our scenarios have stuff like "Given a top-level node called >> "Foo" exists" - which creates the node via selenium. >> >> However there are some areas where this is just too slow, and we have >> created some 'Given' steps that use ruby-sequel code that build up >> data directly in the database. ?This does mean duplicating some of our >> Java domain in the ruby code, but it seemed to be a pragmatic solution >> to the problem. >> > > Have you considered running Cucumber with JRuby so you can leverage your > Java code to insert records into the DB? ?Just an idea. >> >> Currently we are debating whether to make more 'Given' steps directly >> push data into the database - there are pros and cons either way; >> using the UI gives us more confidence in our app (and less fragility >> if our domain changes) and requires less code (we can reuse 'when' >> steps from some scenarios as 'given' steps for others) but it's slower >> - and the accumulated effect of slow builds can be terrible. >> > > As far as the confidence aspect goes, it seems that you should gain enough > confidence by having Cucumber fill out each form once then insert the data > directly the other times. ?That is at least how I approach things in webrat > world. ?But you are right about all of the trade-offs and that is why I am > curious on how you are solving them. ?Thanks for sharing! > > -Ben >> >> On Thu, Apr 30, 2009 at 9:32 AM, Ben Mabey wrote: >> >>> >>> Korny Sietsma wrote: >>> >>>> >>>> True, but cucumber is useful for lots of different kinds of projects. >>>> I'm currently using it to build a java webapp, so I don't need much >>>> beyond cucumber, selenium, and selenium-client. >>>> >>>> >>> >>> I'm curious, with your current setup do you insert data directly into >>> your >>> database (i.e. in Given steps) or do you always use the selenium to enter >>> in >>> data. ?Meaning, if you needed a user to exist so you could have them log >>> in.. do you use ActiveRecord, or something similar, to create the user or >>> do >>> you use the webforms to create the user? ?Also, how do you handle >>> cleaning >>> the database after each scenario? ?Sorry, for the questions, but I'm >>> curious >>> how you've solved these problems when using Cucumber to test a non-ruby >>> webapp. >>> >>> Thanks, >>> Ben >>> >>> >>> >>>> >>>> But agreed, if I was in rails-land (sigh) then I'd want webrat and >>>> rspec-rails. >>>> >>>> - Korny >>>> p.s. I'm aware webrat works without rails, but when I looked it didn't >>>> seem a big boost for our kind of app. >>>> >>>> On Wed, Apr 29, 2009 at 10:42 PM, Chris Flipse >>>> wrote: >>>> >>>> >>>>> >>>>> On Wed, Apr 29, 2009 at 7:42 AM, Korny Sietsma >>>>> wrote: >>>>> >>>>> >>>>>> >>>>>> Presumably you only need these if you are *building* cucumber? >>>>>> >>>>>> If you just want to use cucumber, it should be as simple as "gem >>>>>> install cucumber", and it should get all the other dependencies. ?On >>>>>> my machine it seemed to install treetop, polyglot, and presumably a >>>>>> few others - but I don't have rspec-rails nor webrat. >>>>>> >>>>>> >>>>> >>>>> rspec(-rails) and webrat aren't actually *required* by Cucumber -- you >>>>> can >>>>> use it without them, which is why they're not force-installed. >>>>> ?However, >>>>> nearly every example you're going to find of Cucumber run against a >>>>> rails >>>>> app is going to be using webrat and rspec-rails ... >>>>> >>>>> >>>>> >>>>> -- >>>>> // anything worth taking seriously is worth making fun of >>>>> // http://blog.devcaffeine.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 > -- 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" From lists at ruby-forum.com Thu Apr 30 03:19:25 2009 From: lists at ruby-forum.com (Donald Duck) Date: Thu, 30 Apr 2009 09:19:25 +0200 Subject: [rspec-users] rake spec - no output Message-ID: rake spec does not seem to be doing anything. Could it be a problem with ruby 1.9? Here is what I did: rails rspec-test cd rspec-test test.rb: config.gem "rspec", :lib => false, :version => ">= 1.2.0" test.rb: config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0" ruby script/generate rspec ruby script/generate rspec_scaffold Movie title:string number:integer rake db:create:all rake db:migrate remove --colour in spec.opts rake spec This should return a bunch of passed tests, but doesn't. Environment: Ubuntu 9.04 Rails 2.3.2 ruby 1.9.1p0 rspec 1.2.4 as gem rspec-rails 1.2 4 as gem rake spec --trace (in /home/tick/work/rspec-test) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute spec tick at ubuntu:~/work/rspec-test$ -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Apr 30 03:52:10 2009 From: lists at ruby-forum.com (Rainer Kuhn) Date: Thu, 30 Apr 2009 09:52:10 +0200 Subject: [rspec-users] rake spec - no output In-Reply-To: References: Message-ID: <45bc469565a18a34024ef002f11e8a82@ruby-forum.com> Solved. Uninstalled test-unit 2.0.2 and installed test-unit-1.2.3. -- Posted via http://www.ruby-forum.com/. From jean-michel at 21croissants.com Thu Apr 30 06:08:51 2009 From: jean-michel at 21croissants.com (Jean-Michel Garnier) Date: Thu, 30 Apr 2009 03:08:51 -0700 (PDT) Subject: [rspec-users] [RSPEC] [CUCUMBER] have autotest running *only* the features In-Reply-To: References: Message-ID: <23313297.post@talk.nabble.com> I'll reply to my own question as I have found an "hacked" solution. In Autotest::Rspec (rspec/lib/autotest/rspec-rb) I redefined make_test_cmd like this: def make_test_cmd(files_to_test) # FIXME JM HACK! if ENV['AUTOFEATURE'] =~ /true/i return "#{ruby} -S #{spec_command} #{add_options_if_present} spec/truth_spec.rb" else return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}" end end truth_spec is a dummy spec : describe "Truth" do it "should be true" do true.should be_true end end Doing this, autotest with AUTOFEATURE= true first runs the "specs" but only finds truth_spec which takes about 1s to run and then run the features. Jean-Michel Garnier wrote: > > Hi, > > I am joining a project which is using Rails 2.0.2, Rspec as a plugin 1.1.4 > The problem is specs take 10 minutes to run and I have no time to optimize > them now. > > I am adding cucumber features and would like to run them with autotest > (ZenTest 4.0.0). > Is there a way to have autotest running *only* the features? It would > save > me a LOT of time ... > > In the past, I think I managed to do it with a /script/autofeatures_only > looking like: > #!/usr/bin/env ruby > > ENV['AUTOFEATURE'] = 'true' # run only cucumber features > ENV['RSPEC'] = 'false' # ONLY the features, not the spec! NOT allows > autotest to discover rspec > system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), > *ARGV) || > $stderr.puts("Unable to find autotest. Please install ZenTest or fix > your > PATH") > > My rspec/lib/autotest/discover.rb looks like: > Autotest.add_discovery do > "rspec" if File.directory?('spec') && ENV['RSPEC'] == true > end > > Does anyone have a similar set up with different versions of RSpec? I am > planning to upgrade Rails and RSpec in the coming months. > > Thanks, > > JM > > _______________________________________________ > 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---CUCUMBER--have-autotest-running-*only*-the-features-tp23299036p23313297.html Sent from the rspec-users mailing list archive at Nabble.com. From rick.denatale at gmail.com Thu Apr 30 06:32:48 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 30 Apr 2009 06:32:48 -0400 Subject: [rspec-users] Separation of duties Cucumber and Rspec ... RE: Noob question In-Reply-To: <5A95EAE4A3FE1645992FAF868AD6DCDC09D0B73D@DEN-EXM-06.corp.ebay.com> References: <34832bd1-fe39-4558-a195-e551156f0bc3@w31g2000prd.googlegroups.com> <8e15872b0904290442t60906a23tb95f9c7f2e284174@mail.gmail.com> <8e15872b0904291417s450bd6dby340500bf84bad519@mail.gmail.com> <5A95EAE4A3FE1645992FAF868AD6DCDC09D0B73D@DEN-EXM-06.corp.ebay.com> Message-ID: On Wed, Apr 29, 2009 at 5:47 PM, Colfer, Brian wrote: > Cucumber is not built to do rapid BDD ... It is an integration and acceptance specification exercise system. ? Rspec is for development ?... Mocks are an integral part of the BDD process. ?The idea is to partition the system component behaviors so that you can focuss on the implementing the behavior that you are working on. ?This minimizes the "Yak Shaving " http://en.wiktionary.org/wiki/yak_shaving While many might see Cucumber as a an "integration and acceptance specification exercise system," and it certainly is a great tool for expressing executable acceptance tests, it's actually also quite powerful in doing rapid BDD. The term "outside-in" development is gaining popularity for a process which uses Cucumber (or a similar tool I guess) and RSpec (or similar) together to do iterative development using two nested iteration cycles. The process goes something like: 1. Pick a story 2. Write a failing cucumber scenario for the story. 3. If, as is likely to happen the scenario exposes the need for new classes, or new class behavior then: 4. Use RSpec to design/code the new class(es) and behaviours writing failing examples, then making them work. 5. When the scenario succeeds, consider whether refactoring (in the context of the overall system) is desirable in order to manage technical debt. 6. Repeat from 1 Using cucumber scenarios to keep you on the track of doing the next thing that NEEDS to be done is a very good way to stave off the desire to shave yaks. -- 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 From dchelimsky at gmail.com Thu Apr 30 08:59:32 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 07:59:32 -0500 Subject: [rspec-users] shoud error In-Reply-To: <632154f70904300551t2b3e98c1o50e49f56e77653b9@mail.gmail.com> References: <632154f70904300551t2b3e98c1o50e49f56e77653b9@mail.gmail.com> Message-ID: <57c63afe0904300559i580c2eb9wec567ff8b59d772e@mail.gmail.com> On Thu, Apr 30, 2009 at 7:51 AM, Nicholas Van Weerdenburg wrote: > Hi, > I had some tests where I accidently used ".shoud" instead of ".should". > There was no error, and all tests passed no matter what. Is the the correct > behaviour or should there be an error if you mispell should? Normally there would be an error, but if the object that you're sending shoud to is a stub set to ignore calls it doesn't understand, then it would just ignore it. If that's not the problem, please show us some code. David > Thanks, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Apr 30 09:24:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 08:24:02 -0500 Subject: [rspec-users] script/general rspec_* In-Reply-To: <632154f70904300619o4987d05ake1ca1804a4dfc1b4@mail.gmail.com> References: <632154f70904300619o4987d05ake1ca1804a4dfc1b4@mail.gmail.com> Message-ID: <57c63afe0904300624n714d353i57c32db7a402e0a2@mail.gmail.com> On Thu, Apr 30, 2009 at 8:19 AM, Nicholas Van Weerdenburg wrote: > I have started using rspec after generating much of my applications models > and controllers. Much of the code is plain vanilla scaffolding. > I accept that this is not very BDD, but I'm building a tool that required I > do this. > Is there a quick way to generate the test stubs- i.e. the equivalent of the > Test::Unit ones I now have? Can I run "script/generate rspec_model " > and the same for controllers on over-top of things? $ script/generate .... Installed Generators Rubygems: acts_as_taggable_on_migration, cucumber, feature, install_rubigen_scripts, rspec, rspec_controller, rspec_model, rspec_scaffold, session Builtin: controller, helper, integration_test, mailer, metal, migration, model, observer, performance_test, plugin, resource, scaffold, session_migration Note rspec_controller, rspec_model, rspec_scaffold Cheers, David > Thanks, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jose.valim at gmail.com Thu Apr 30 10:10:54 2009 From: jose.valim at gmail.com (=?UTF-8?Q?Jos=C3=A9_Valim?=) Date: Thu, 30 Apr 2009 07:10:54 -0700 (PDT) Subject: [rspec-users] [Cucumber 0.2] Failure to use should In-Reply-To: References: <8d961d900903190813p6fcb51a3o754db54a6317c125@mail.gmail.com> <2c7e61990903190859g4aca06bbk3d3009b2ddd08f37@mail.gmail.com> Message-ID: <23316997.post@talk.nabble.com> Just for reference, whoever have problem with rspec, remarkable and cucumber, try this installation settings: # config/environments/test.rb config.gem "rspec", :lib => false config.gem "rspec-rails", :lib => false config.gem "remarkable_rails", :lib => false # spec/spec_helper.rb require "spec/rails" require "remarkable_rails" If you still have problems, be sure to open a ticket on Remarkable bug tracking: http://carlosbrando.lighthouseapp.com/projects/19775-remarkable/tickets?q=all Cheers, -- Jos? Valim http://josevalim.blogspot.com/ http://github.com/josevalim/ Yi Wen wrote: > > Just did a little bit exploration. Found out > http://github.com/carlosbrando/remarkable/tree/master plugin I use > actually > cause the problem. This plugin also broke spec:server:start rake task as > well. :-( > > On Thu, Mar 19, 2009 at 5:03 PM, Yi wrote: > >> I thought be_something is actually handled by rspec class Be. be_blank >> essentially asks the object blank? predicate. Not that there is a >> "be_blank" >> method declared anywhere. >> >> Anyway, require 'spec/expectations' doesn't solve the problem. I will >> look >> into this. Thanks >> >> Yi >> >> >> On Thu, Mar 19, 2009 at 10:59 AM, Pat Maddox >> wrote: >> >>> Right, you need to add >>> require 'spec/expectations' >>> >>> because Cucumber doesn't know about RSpec's matchers by default. >>> >>> Pat >>> >>> 2009/3/19 Yi : >>> > This is my env.rb >>> > >>> > # Sets up the Rails environment for Cucumber >>> > ENV["RAILS_ENV"] ||= "test" >>> > require File.expand_path(File.dirname(__FILE__) + >>> > '/../../config/environment') >>> > require 'cucumber/rails/world' >>> > require 'cucumber/formatters/unicode' # Comment out this line if you >>> don't >>> > want Cucumber Unicode support >>> > Cucumber::Rails.use_transactional_fixtures >>> > >>> > require 'webrat' >>> > >>> > Webrat.configure do |config| >>> > config.mode = :rails >>> > config.application_address= "myapp.local" >>> > end >>> > >>> > require 'cucumber/rails/rspec' >>> > require 'webrat/core/matchers' >>> > >>> > >>> > The only thing different is: >>> > config.application_address= "myapp.local" >>> > >>> > I tried to comment out this line and it didn't help anyway. >>> > >>> > I did script/generate cucumber and it didn't help. :( >>> > >>> > Yi >>> > >>> > 2009/3/19 aslak hellesoy >>> >> >>> >> >>> >> 2009/3/19 Yi >>> >>> >>> >>> I have a step definition like this: >>> >>> >>> >>> Then "the account should be created" do >>> >>> account = Account.find_by_name("my shiny new account") >>> >>> p account.class >>> >>> account.should_not be_blank >>> >>> end >>> >>> >>> >>> When running this step, I got the error message: >>> >>> >>> >>> Account(id: integer, name: string, state: string, next_renewal_at: >>> date, >>> >>> created_at: datetime, updated_at: datetime, full_domain: string, >>> deleted_at: >>> >>> datetime, subscription_discount_id: integer, subscription_plan_id: >>> integer) >>> >>> >>> >>> And the account should be created # >>> >>> features/step_definitions/create_account_steps.rb:31 >>> >>> undefined method `be_blank' for >>> >>> # (NoMethodError) >>> >>> features/create_account.feature:10:in `And the account should >>> be >>> >>> created' >>> >> >>> >> The #be_blank method is defined by a module under 'rspec/matchers'. >>> This >>> >> module is automatically included in >>> ActionController::Integration::Session >>> >> if you have the following in your env.rb: >>> >> >>> >> require 'spec/expectations' >>> >> >>> >> Do you? If you just upgraded to Cucumber 0.2 you should probably >>> >> rebootstrap Cucumber with: >>> >> >>> >> script/generate cucumber >>> >> >>> >> Aslak >>> >> >>> >>> >>> >>> I print out the account class, which is a AR::B. Why cucumber tells >>> me >>> it >>> >>> is a ActionController::Integration::Session? >>> >>> >>> >>> I use cucumber 0.2 and rspec 1.2 with Rails 2.3.2 >>> >>> >>> >>> Thanks >>> >>> >>> >>> Yi >>> >>> -- >>> >>> http://yiwenandsoftware.wordpress.com >>> >>> >>> >>> _______________________________________________ >>> >>> rspec-users mailing list >>> >>> rspec-users at rubyforge.org >>> >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >>> >> >>> >> >>> >> -- >>> >> Aslak (::) >>> >> >>> >> _______________________________________________ >>> >> rspec-users mailing list >>> >> rspec-users at rubyforge.org >>> >> http://rubyforge.org/mailman/listinfo/rspec-users >>> > >>> > >>> > >>> > -- >>> > http://yiwenandsoftware.wordpress.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 >>> >> >> >> >> -- >> http://yiwenandsoftware.wordpress.com >> > > > > -- > http://yiwenandsoftware.wordpress.com > > _______________________________________________ > 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/-Cucumber-0.2--Failure-to-use-should-tp22601600p23316997.html Sent from the rspec-users mailing list archive at Nabble.com. From andrew at andrewtimberlake.com Thu Apr 30 10:44:49 2009 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Thu, 30 Apr 2009 16:44:49 +0200 Subject: [rspec-users] Help with some basics Message-ID: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> I'm suddenly getting an error on my specs /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:24:in `description': No description supplied for example declared on /home/andrew/dev/rhythm/website/spec/models/product_template_spec.rb:4 (Spec::Example::NoDescriptionError) from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:51:in `execute' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:207:in `run_examples' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in `each' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in `run_examples' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:103:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:23:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in `each' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/options.rb:119:in `run_examples' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/command_line.rb:9:in `run' from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/bin/spec:4 from /usr/local/bin/spec:19:in `load' from /usr/local/bin/spec:19 The spec is as follows (using Remarkable) require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ProductTemplate do it { should belong_to(:account) } it { should validate_presence_of(:account) } it { should validate_presence_of(:name) } it { should validate_presence_of(:cost) } it { should validate_length_of(:name).within(1..100) } it { should validate_uniqueness_of(:name) } end I've just updated to the latest versions of rspec, rspec-rails and remarkable Not sure what I'm doing wrong here. Thanks Andrew From dchelimsky at gmail.com Thu Apr 30 10:53:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 09:53:47 -0500 Subject: [rspec-users] Partitioning Specs In-Reply-To: <632154f70904300733u3927d85o5fcdb3423f96ddbd@mail.gmail.com> References: <632154f70904300700r6af74f1by105f1de61a013bdb@mail.gmail.com> <6ffb72010904300702u6a69d7c6i2d81849d296afcbb@mail.gmail.com> <632154f70904300733u3927d85o5fcdb3423f96ddbd@mail.gmail.com> Message-ID: <57c63afe0904300753i11119b38l56baa99f58bf8508@mail.gmail.com> On Thu, Apr 30, 2009 at 9:33 AM, Nicholas Van Weerdenburg wrote: > I saw that a couple of days ago- very nice. Will that be added to RSpec? Sooner or later, yes, but it will be managed through the hash passed to the declarations: describe "something", :tags => [:a,:b] do it "does something", :tags > [:c] do etc You can already access that options hash in custom formatters, so you can use this to control reporting. Next step is to use it to control what actually gets run. But this won't be right away. > Also, I suppose I'd have to add tags to the framework myself unless they > included it. > Thanks, > Nick > > On Thu, Apr 30, 2009 at 10:02 AM, Ben Lovell > wrote: >> >> >> On Thu, Apr 30, 2009 at 3:00 PM, Nicholas Van Weerdenburg >> wrote: >>> >>> Hi, >>> I installed Restful Authentication and it placed a lot of specs and >>> features in cucumber and rspec directories. >>> Is there a way frameworks can partition there tests so that "rake spec" >>> doesn't run all their tests? >>> I've actually switched to authlogic because of this, but was curious. >>> Thanks, >>> Nick >> >> Take a look at tags: >> >> http://wiki.github.com/aslakhellesoy/cucumber/tags >> >> Regards, >> 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 dchelimsky at gmail.com Thu Apr 30 10:59:39 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 09:59:39 -0500 Subject: [rspec-users] Help with some basics In-Reply-To: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> References: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> Message-ID: <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> On Thu, Apr 30, 2009 at 9:44 AM, Andrew Timberlake wrote: > I'm suddenly getting an error on my specs > > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:24:in > `description': No description supplied for example declared on > /home/andrew/dev/rhythm/website/spec/models/product_template_spec.rb:4 > (Spec::Example::NoDescriptionError) > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:51:in > `execute' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:207:in > `run_examples' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in > `each' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in > `run_examples' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:103:in > `run' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:23:in > `run' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in > `each' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in > `run' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/options.rb:119:in > `run_examples' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/command_line.rb:9:in > `run' > ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/bin/spec:4 > ? ? ? ?from /usr/local/bin/spec:19:in `load' > ? ? ? ?from /usr/local/bin/spec:19 > > > The spec is as follows (using Remarkable) > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe ProductTemplate do > ?it { should belong_to(:account) } > > ?it { should validate_presence_of(:account) } > ?it { should validate_presence_of(:name) } > ?it { should validate_presence_of(:cost) } > > ?it { should validate_length_of(:name).within(1..100) } > > ?it { should validate_uniqueness_of(:name) } > end > > I've just updated to the latest versions of rspec, rspec-rails and remarkable > > > Not sure what I'm doing wrong here. That happens when a matcher doesn't supply a description (which is required), but it looks like the remarkable matchers do, so I'm not sure what's up with that. How are you running it? What command? > > Thanks > > Andrew > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lee.hambley at gmail.com Thu Apr 30 08:15:25 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Thu, 30 Apr 2009 13:15:25 +0100 Subject: [rspec-users] [cucumber] Bug introduced in 0.3.1 Message-ID: Hi All, I'm new to the list, but a happy cucumber user with a few weeks experience now... a bit of a shock this morning when someone upgraded here and happened to jump up to 0.3.1, we're seeing the following output.. I haven't had chance to investigate more, but I will try to.. this goes away if we roll back to 0.3.0. - http://gist.github.com/104429 I also listed the relevant local gems as far as I can see, I'll post back here if I come up with anything, pointers or suggestions would be welcomed! Thank you, Lee Hambley -------------- next part -------------- An HTML attachment was scrubbed... URL: From amos.l.king at gmail.com Thu Apr 30 14:26:27 2009 From: amos.l.king at gmail.com (Amos King) Date: Thu, 30 Apr 2009 13:26:27 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues Message-ID: I started a brand new rails app and then ran the following. %>git submodule add git://github.com/aslakhellesoy/cucumber.git vendor/plugins/cucumber %>git submodule add git://github.com/brynary/webrat.git vendor/plugins/webrat %>git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec %>git submodule add git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec-rails %>script/generate rspec %>rake spec Then I have the following output: rake aborted! ******************************************************************************** * You are trying to run an rspec rake task defined in * /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, * but rspec can not be found in vendor/gems, vendor/plugins or system gems. ******************************************************************************** Here is the trace if I run it too. /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in `initialize' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in `invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in `invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in `invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in `standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in `standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 Am I missing something? -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From dchelimsky at gmail.com Thu Apr 30 14:31:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 13:31:59 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: References: Message-ID: <57c63afe0904301131n7757c78dk16333902729c5c89@mail.gmail.com> On Thu, Apr 30, 2009 at 1:26 PM, Amos King wrote: > I started a brand new rails app and then ran the following. > > %>git submodule add git://github.com/aslakhellesoy/cucumber.git > vendor/plugins/cucumber > %>git submodule add git://github.com/brynary/webrat.git vendor/plugins/webrat > %>git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec > %>git submodule add git://github.com/dchelimsky/rspec-rails.git > vendor/plugins/rspec-rails > %>script/generate rspec > %>rake spec > > Then I have the following output: > > rake aborted! > > ******************************************************************************** > * ?You are trying to run an rspec rake task defined in > * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, > * ?but rspec can not be found in vendor/gems, vendor/plugins or system gems. > ******************************************************************************** > > > Here is the trace if I run it too. > > /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in `initialize' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in > `invoke_with_call_chain' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in > `synchronize' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in `invoke_task' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 > > > > Am I missing something? See https://rspec.lighthouseapp.com/projects/5645/tickets/807 > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From scott at railsnewbie.com Thu Apr 30 14:33:37 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Thu, 30 Apr 2009 14:33:37 -0400 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: References: Message-ID: On Apr 30, 2009, at 2:26 PM, Amos King wrote: > I started a brand new rails app and then ran the following. > > %>git submodule add git://github.com/aslakhellesoy/cucumber.git > vendor/plugins/cucumber > %>git submodule add git://github.com/brynary/webrat.git vendor/ > plugins/webrat > %>git submodule add git://github.com/dchelimsky/rspec.git vendor/ > plugins/rspec > %>git submodule add git://github.com/dchelimsky/rspec-rails.git > vendor/plugins/rspec-rails > %>script/generate rspec > %>rake spec Did you run "git submodule update --init" ? Scott > > > Then I have the following output: > > rake aborted! > > ******************************************************************************** > * You are trying to run an rspec rake task defined in > * /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, > * but rspec can not be found in vendor/gems, vendor/plugins or > system gems. > ******************************************************************************** > > > Here is the trace if I run it too. > > /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in > `initialize' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in > `invoke_with_call_chain' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > 1.8/monitor.rb:242:in > `synchronize' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in > `invoke_with_call_chain' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in > `invoke_task' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in > `standard_exception_handling' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' > /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 > > > > Am I missing something? > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From amos.l.king at gmail.com Thu Apr 30 15:21:07 2009 From: amos.l.king at gmail.com (Amos King) Date: Thu, 30 Apr 2009 14:21:07 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: References: Message-ID: yes, but when you add it does it. On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor wrote: > > On Apr 30, 2009, at 2:26 PM, Amos King wrote: > >> I started a brand new rails app and then ran the following. >> >> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >> vendor/plugins/cucumber >> %>git submodule add git://github.com/brynary/webrat.git >> vendor/plugins/webrat >> %>git submodule add git://github.com/dchelimsky/rspec.git >> vendor/plugins/rspec >> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >> vendor/plugins/rspec-rails >> %>script/generate rspec >> %>rake spec > > Did you run "git submodule update --init" ? > > Scott > >> >> >> Then I have the following output: >> >> rake aborted! >> >> >> ******************************************************************************** >> * ?You are trying to run an rspec rake task defined in >> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >> gems. >> >> ******************************************************************************** >> >> >> Here is the trace if I run it too. >> >> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >> `initialize' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >> `invoke_with_call_chain' >> >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >> `synchronize' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> `invoke_with_call_chain' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in `invoke_task' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> `standard_exception_handling' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> `standard_exception_handling' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >> >> >> >> Am I missing something? >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.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 > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From amos.l.king at gmail.com Thu Apr 30 15:34:51 2009 From: amos.l.king at gmail.com (Amos King) Date: Thu, 30 Apr 2009 14:34:51 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: References: Message-ID: So why am I required to install rspec as a frozen/system gem to work with rails? I would be happy with that if the support for rails gems was a little better. I'm stuck to the published gem at that point, or I have to jump through hoops on every deployment or build box. On Thu, Apr 30, 2009 at 2:21 PM, Amos King wrote: > yes, but when you add it does it. > > On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor wrote: >> >> On Apr 30, 2009, at 2:26 PM, Amos King wrote: >> >>> I started a brand new rails app and then ran the following. >>> >>> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >>> vendor/plugins/cucumber >>> %>git submodule add git://github.com/brynary/webrat.git >>> vendor/plugins/webrat >>> %>git submodule add git://github.com/dchelimsky/rspec.git >>> vendor/plugins/rspec >>> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >>> vendor/plugins/rspec-rails >>> %>script/generate rspec >>> %>rake spec >> >> Did you run "git submodule update --init" ? >> >> Scott >> >>> >>> >>> Then I have the following output: >>> >>> rake aborted! >>> >>> >>> ******************************************************************************** >>> * ?You are trying to run an rspec rake task defined in >>> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >>> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >>> gems. >>> >>> ******************************************************************************** >>> >>> >>> Here is the trace if I run it too. >>> >>> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >>> `initialize' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >>> `invoke_with_call_chain' >>> >>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >>> `synchronize' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >>> `invoke_with_call_chain' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in `invoke_task' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>> `standard_exception_handling' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>> `standard_exception_handling' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >>> >>> >>> >>> Am I missing something? >>> >>> -- >>> Amos King >>> http://dirtyInformation.com >>> http://github.com/Adkron >>> -- >>> Looking for something to do? Visit http://ImThere.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 >> > > > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From andrew at andrewtimberlake.com Thu Apr 30 15:55:07 2009 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Thu, 30 Apr 2009 21:55:07 +0200 Subject: [rspec-users] Help with some basics In-Reply-To: <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> References: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> Message-ID: <62ad3e390904301255j6c7193c6mdf94c7c12dfc368@mail.gmail.com> It gives me the same error when I run rake spec spec specs/ or autospec It also gives the same error with specs like it { should_not be_nil } and it { should respond_to(:name) } On Thursday, April 30, 2009, David Chelimsky wrote: > On Thu, Apr 30, 2009 at 9:44 AM, Andrew Timberlake > wrote: >> I'm suddenly getting an error on my specs >> >> /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:24:in >> `description': No description supplied for example declared on >> /home/andrew/dev/rhythm/website/spec/models/product_template_spec.rb:4 >> (Spec::Example::NoDescriptionError) >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:51:in >> `execute' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:207:in >> `run_examples' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in >> `each' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in >> `run_examples' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:103:in >> `run' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:23:in >> `run' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in >> `each' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in >> `run' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/options.rb:119:in >> `run_examples' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/command_line.rb:9:in >> `run' >> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/bin/spec:4 >> ? ? ? ?from /usr/local/bin/spec:19:in `load' >> ? ? ? ?from /usr/local/bin/spec:19 >> >> >> The spec is as follows (using Remarkable) >> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> >> describe ProductTemplate do >> ?it { should belong_to(:account) } >> >> ?it { should validate_presence_of(:account) } >> ?it { should validate_presence_of(:name) } >> ?it { should validate_presence_of(:cost) } >> >> ?it { should validate_length_of(:name).within(1..100) } >> >> ?it { should validate_uniqueness_of(:name) } >> end >> >> I've just updated to the latest versions of rspec, rspec-rails and remarkable >> >> >> Not sure what I'm doing wrong here. > > That happens when a matcher doesn't supply a description (which is > required), but it looks like the remarkable matchers do, so I'm not > sure what's up with that. > > How are you running it? What command? > >> >> Thanks >> >> Andrew >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain From dchelimsky at gmail.com Thu Apr 30 16:04:28 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 15:04:28 -0500 Subject: [rspec-users] Help with some basics In-Reply-To: <62ad3e390904301255j6c7193c6mdf94c7c12dfc368@mail.gmail.com> References: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> <62ad3e390904301255j6c7193c6mdf94c7c12dfc368@mail.gmail.com> Message-ID: <57c63afe0904301304g4bf15482k3fb13186af9cb434@mail.gmail.com> On Thu, Apr 30, 2009 at 2:55 PM, Andrew Timberlake wrote: > It gives me the same error when I run > rake spec > spec specs/ > or > autospec > > It also gives the same error with specs like > it { should_not be_nil } > and > it { should respond_to(:name) } Those are internal to rspec and I can assure you they have descriptions. I'm mystified. Anybody else on this list have a similar experience? > > > On Thursday, April 30, 2009, David Chelimsky wrote: >> On Thu, Apr 30, 2009 at 9:44 AM, Andrew Timberlake >> wrote: >>> I'm suddenly getting an error on my specs >>> >>> /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:24:in >>> `description': No description supplied for example declared on >>> /home/andrew/dev/rhythm/website/spec/models/product_template_spec.rb:4 >>> (Spec::Example::NoDescriptionError) >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_methods.rb:51:in >>> `execute' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:207:in >>> `run_examples' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in >>> `each' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:205:in >>> `run_examples' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/example/example_group_methods.rb:103:in >>> `run' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:23:in >>> `run' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in >>> `each' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/example_group_runner.rb:22:in >>> `run' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/options.rb:119:in >>> `run_examples' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/lib/spec/runner/command_line.rb:9:in >>> `run' >>> ? ? ? ?from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.5/bin/spec:4 >>> ? ? ? ?from /usr/local/bin/spec:19:in `load' >>> ? ? ? ?from /usr/local/bin/spec:19 >>> >>> >>> The spec is as follows (using Remarkable) >>> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >>> >>> describe ProductTemplate do >>> ?it { should belong_to(:account) } >>> >>> ?it { should validate_presence_of(:account) } >>> ?it { should validate_presence_of(:name) } >>> ?it { should validate_presence_of(:cost) } >>> >>> ?it { should validate_length_of(:name).within(1..100) } >>> >>> ?it { should validate_uniqueness_of(:name) } >>> end >>> >>> I've just updated to the latest versions of rspec, rspec-rails and remarkable >>> >>> >>> Not sure what I'm doing wrong here. >> >> That happens when a matcher doesn't supply a description (which is >> required), but it looks like the remarkable matchers do, so I'm not >> sure what's up with that. >> >> How are you running it? What command? >> >>> >>> Thanks >>> >>> Andrew >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -- > Andrew Timberlake > http://ramblingsonrails.com > http://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twain > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Thu Apr 30 17:43:33 2009 From: ben at benmabey.com (Ben Mabey) Date: Thu, 30 Apr 2009 15:43:33 -0600 Subject: [rspec-users] [cucumber] Bug introduced in 0.3.1 In-Reply-To: References: Message-ID: <49FA1B85.1020007@benmabey.com> Lee Hambley wrote: > Hi All, > > I'm new to the list, but a happy cucumber user with a few weeks > experience now... a bit of a shock this morning when someone upgraded > here and happened to jump up to 0.3.1, we're seeing the following > output.. > > I haven't had chance to investigate more, but I will try to.. this > goes away if we roll back to 0.3.0. > > * http://gist.github.com/104429 > > I also listed the relevant local gems as far as I can see, I'll post > back here if I come up with anything, pointers or suggestions would be > welcomed! > > Thank you, > > Lee Hambley What is your rails environment file? (test.rb) -Ben From lee.hambley at gmail.com Thu Apr 30 17:46:59 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Thu, 30 Apr 2009 22:46:59 +0100 Subject: [rspec-users] [cucumber] Bug introduced in 0.3.1 In-Reply-To: <49FA1B85.1020007@benmabey.com> References: <49FA1B85.1020007@benmabey.com> Message-ID: Hi Ben, Please see this Gist http://gist.github.com/104711 - note also that it doesn't seem to matter about the dependencies I've got in that file now, they're a recent addition and don't seem to affect this behavior. - Thanks, Lee 2009/4/30 Ben Mabey > Lee Hambley wrote: > >> Hi All, >> >> I'm new to the list, but a happy cucumber user with a few weeks experience >> now... a bit of a shock this morning when someone upgraded here and happened >> to jump up to 0.3.1, we're seeing the following output.. >> I haven't had chance to investigate more, but I will try to.. this goes >> away if we roll back to 0.3.0. >> >> * http://gist.github.com/104429 >> >> I also listed the relevant local gems as far as I can see, I'll post back >> here if I come up with anything, pointers or suggestions would be welcomed! >> >> Thank you, >> >> Lee Hambley >> > > > What is your rails environment file? (test.rb) > > -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 julian at leviston.net Thu Apr 30 22:32:49 2009 From: julian at leviston.net (Julian Leviston) Date: Fri, 1 May 2009 12:32:49 +1000 Subject: [rspec-users] Before and After blocks for individual feature files? In-Reply-To: <49F7E9E1.3080503@benmabey.com> References: <50873a360904280518l7bd1d2a8v634b2dd03ca5b1c0@mail.gmail.com> <8d961d900904280708x4e634442q11778258ed20df48@mail.gmail.com> <03969310-0675-49b1-9127-901987e9f295@z16g2000prd.googlegroups.com> <8d961d900904280938x3632012jc2b69a9f0df9b831@mail.gmail.com> <49F74AE3.2060902@benmabey.com> <49F7E9E1.3080503@benmabey.com> Message-ID: <74E120B8-50D1-4368-90EE-60D21EA407DD@leviston.net> Hey ben, Selenium is slow, and we have a lot of Ajax, so I'm just looking at ways to speed it up. Tags will be my first port of call and splitting out between automated and simulated. It irks me we can't then simply run all our tests with one simple cucumber command -we need two. It'd be nice if webrat could switch between browser types per scenario or per feature. Sigh. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 29/04/2009, at 3:47 PM, Ben Mabey wrote: > Julian Leviston wrote: >> Hey Ben, >> >> It'd be kinda cool if there was a sort of before and after for a >> feature rather than each scenario. Is there? > > Nope. There is no before(:all) equivalent in cucumber. Just the > Before and After hooks, which are for scenarios.. and Backgrounds > which are just for scenarios on the given feature. >> >> (Rails context) We often need this. It'd be really helpful for >> things like when we want to test about 15 things on a particular >> web page, and they don't require fresh data. We end up with a login >> and setup type background which gets run every time rather than >> simply once. > In the context of webrat a before(:all) would not help you a whole > lot since each scenario starts with a new session (so you have to > login each time, for example). I understand the argument for > complex data setup though. Having the same setup ran for each > scenario can get costly. I haven't felt enough pain though to > really justify adding something like that. Cleanup would be messy > because we couldn't wrap it all in a transaction AFAIK, so you would > have to have an after(:all) like method to clean up the feature. > For complex data that I rely on all the time I tend to load it once > with fixtures at boot up time within env.rb. This is usually for > look-up data... but if you were really concerned about record > creation you could do something similar. The question is if the > additional complexity of keeping all that global state in your head > worth the faster execution time. For me it generally is not. >> >> I guess we could refactor it into a set of examples perhaps... >> would that work? It just strikes me as quite complicated. It'd be >> awesome if we had sub-scenarios (and they could be specified to >> levels) ;-) Perhaps I'm just being too complicated. > > I would need more context to really answer your question. However, > can I ask if your scenarios are written in a declarative or > imperative fashion[1]? If they are written declaratively, or at > least partly, then you can specify a lot more behavior in a step > without adding too much noise to the scenario. Another thing I > should point out is that you don't need to, and you shouldn't, test > everything on the Cucumber level. For complex views, for example, > it may be easier to do RSpec From amos.l.king at gmail.com Thu Apr 30 22:55:09 2009 From: amos.l.king at gmail.com (Amos King) Date: Thu, 30 Apr 2009 21:55:09 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: <632154f70904301305s326cf506p8ec49ec3372db599@mail.gmail.com> References: <632154f70904301305s326cf506p8ec49ec3372db599@mail.gmail.com> Message-ID: frozen as gems and still the same problems. On Thu, Apr 30, 2009 at 3:05 PM, Nicholas Van Weerdenburg wrote: > On Thu, Apr 30, 2009 at 3:34 PM, Amos King wrote: >> >> So why am I required to install rspec as a frozen/system gem to work >> with rails? ?I would be happy with that if the support for rails gems >> was a little better. ?I'm stuck to the published gem at that point, or >> I have to jump through hoops on every deployment or build box. >> >> On Thu, Apr 30, 2009 at 2:21 PM, Amos King wrote: >> > yes, but when you add it does it. >> > >> > On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor >> > wrote: >> >> >> >> On Apr 30, 2009, at 2:26 PM, Amos King wrote: >> >> >> >>> I started a brand new rails app and then ran the following. >> >>> >> >>> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >> >>> vendor/plugins/cucumber >> >>> %>git submodule add git://github.com/brynary/webrat.git >> >>> vendor/plugins/webrat >> >>> %>git submodule add git://github.com/dchelimsky/rspec.git >> >>> vendor/plugins/rspec >> >>> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >> >>> vendor/plugins/rspec-rails >> >>> %>script/generate rspec >> >>> %>rake spec >> >> >> >> Did you run "git submodule update --init" ? >> >> >> >> Scott >> >> >> >>> >> >>> >> >>> Then I have the following output: >> >>> >> >>> rake aborted! >> >>> >> >>> >> >>> >> >>> ******************************************************************************** >> >>> * ?You are trying to run an rspec rake task defined in >> >>> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >> >>> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >> >>> gems. >> >>> >> >>> >> >>> ******************************************************************************** >> >>> >> >>> >> >>> Here is the trace if I run it too. >> >>> >> >>> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >> >>> `initialize' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >> >>> `invoke_with_call_chain' >> >>> >> >>> >> >>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >> >>> `synchronize' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >> >>> `invoke_with_call_chain' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >> >>> `invoke_task' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> >>> `standard_exception_handling' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >> >>> `standard_exception_handling' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >> >>> >> >>> >> >>> >> >>> Am I missing something? >> >>> >> >>> -- >> >>> Amos King >> >>> http://dirtyInformation.com >> >>> http://github.com/Adkron >> >>> -- >> >>> Looking for something to do? Visit http://ImThere.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 >> >> >> > >> > >> > >> > -- >> > Amos King >> > http://dirtyInformation.com >> > http://github.com/Adkron >> > -- >> > Looking for something to do? Visit http://ImThere.com >> > >> >> >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.com >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > It doesn't have to be a frozen gem. That's simply if you want to manage > dependencies via git, etc. for deployment. > I use it as a regular gem. > The current issue is plugins not being supported on latest release. > Regards, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From dchelimsky at gmail.com Thu Apr 30 23:04:33 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 22:04:33 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: References: <632154f70904301305s326cf506p8ec49ec3372db599@mail.gmail.com> Message-ID: <57c63afe0904302004r1689fb11t93d9de7df84aeb2f@mail.gmail.com> On Thu, Apr 30, 2009 at 9:55 PM, Amos King wrote: > frozen as gems and still the same problems. The 1.2.6 release should work as a plugin again. > > On Thu, Apr 30, 2009 at 3:05 PM, Nicholas Van Weerdenburg > wrote: >> On Thu, Apr 30, 2009 at 3:34 PM, Amos King wrote: >>> >>> So why am I required to install rspec as a frozen/system gem to work >>> with rails? ?I would be happy with that if the support for rails gems >>> was a little better. ?I'm stuck to the published gem at that point, or >>> I have to jump through hoops on every deployment or build box. >>> >>> On Thu, Apr 30, 2009 at 2:21 PM, Amos King wrote: >>> > yes, but when you add it does it. >>> > >>> > On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor >>> > wrote: >>> >> >>> >> On Apr 30, 2009, at 2:26 PM, Amos King wrote: >>> >> >>> >>> I started a brand new rails app and then ran the following. >>> >>> >>> >>> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >>> >>> vendor/plugins/cucumber >>> >>> %>git submodule add git://github.com/brynary/webrat.git >>> >>> vendor/plugins/webrat >>> >>> %>git submodule add git://github.com/dchelimsky/rspec.git >>> >>> vendor/plugins/rspec >>> >>> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >>> >>> vendor/plugins/rspec-rails >>> >>> %>script/generate rspec >>> >>> %>rake spec >>> >> >>> >> Did you run "git submodule update --init" ? >>> >> >>> >> Scott >>> >> >>> >>> >>> >>> >>> >>> Then I have the following output: >>> >>> >>> >>> rake aborted! >>> >>> >>> >>> >>> >>> >>> >>> ******************************************************************************** >>> >>> * ?You are trying to run an rspec rake task defined in >>> >>> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >>> >>> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >>> >>> gems. >>> >>> >>> >>> >>> >>> ******************************************************************************** >>> >>> >>> >>> >>> >>> Here is the trace if I run it too. >>> >>> >>> >>> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >>> >>> `initialize' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >>> >>> `invoke_with_call_chain' >>> >>> >>> >>> >>> >>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >>> >>> `synchronize' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >>> >>> `invoke_with_call_chain' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >>> >>> `invoke_task' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>> >>> `standard_exception_handling' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>> >>> `standard_exception_handling' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >>> >>> >>> >>> >>> >>> >>> >>> Am I missing something? >>> >>> >>> >>> -- >>> >>> Amos King >>> >>> http://dirtyInformation.com >>> >>> http://github.com/Adkron >>> >>> -- >>> >>> Looking for something to do? Visit http://ImThere.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 >>> >> >>> > >>> > >>> > >>> > -- >>> > Amos King >>> > http://dirtyInformation.com >>> > http://github.com/Adkron >>> > -- >>> > Looking for something to do? Visit http://ImThere.com >>> > >>> >>> >>> >>> -- >>> Amos King >>> http://dirtyInformation.com >>> http://github.com/Adkron >>> -- >>> Looking for something to do? Visit http://ImThere.com >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> It doesn't have to be a frozen gem. That's simply if you want to manage >> dependencies via git, etc. for deployment. >> I use it as a regular gem. >> The current issue is plugins not being supported on latest release. >> Regards, >> Nick >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From amos.l.king at gmail.com Thu Apr 30 23:05:55 2009 From: amos.l.king at gmail.com (Amos King) Date: Thu, 30 Apr 2009 22:05:55 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: <57c63afe0904302004r1689fb11t93d9de7df84aeb2f@mail.gmail.com> References: <632154f70904301305s326cf506p8ec49ec3372db599@mail.gmail.com> <57c63afe0904302004r1689fb11t93d9de7df84aeb2f@mail.gmail.com> Message-ID: should I go with the plugin. It doesn't work as a gem now? On Thu, Apr 30, 2009 at 10:04 PM, David Chelimsky wrote: > On Thu, Apr 30, 2009 at 9:55 PM, Amos King wrote: >> frozen as gems and still the same problems. > > The 1.2.6 release should work as a plugin again. > >> >> On Thu, Apr 30, 2009 at 3:05 PM, Nicholas Van Weerdenburg >> wrote: >>> On Thu, Apr 30, 2009 at 3:34 PM, Amos King wrote: >>>> >>>> So why am I required to install rspec as a frozen/system gem to work >>>> with rails? ?I would be happy with that if the support for rails gems >>>> was a little better. ?I'm stuck to the published gem at that point, or >>>> I have to jump through hoops on every deployment or build box. >>>> >>>> On Thu, Apr 30, 2009 at 2:21 PM, Amos King wrote: >>>> > yes, but when you add it does it. >>>> > >>>> > On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor >>>> > wrote: >>>> >> >>>> >> On Apr 30, 2009, at 2:26 PM, Amos King wrote: >>>> >> >>>> >>> I started a brand new rails app and then ran the following. >>>> >>> >>>> >>> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >>>> >>> vendor/plugins/cucumber >>>> >>> %>git submodule add git://github.com/brynary/webrat.git >>>> >>> vendor/plugins/webrat >>>> >>> %>git submodule add git://github.com/dchelimsky/rspec.git >>>> >>> vendor/plugins/rspec >>>> >>> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >>>> >>> vendor/plugins/rspec-rails >>>> >>> %>script/generate rspec >>>> >>> %>rake spec >>>> >> >>>> >> Did you run "git submodule update --init" ? >>>> >> >>>> >> Scott >>>> >> >>>> >>> >>>> >>> >>>> >>> Then I have the following output: >>>> >>> >>>> >>> rake aborted! >>>> >>> >>>> >>> >>>> >>> >>>> >>> ******************************************************************************** >>>> >>> * ?You are trying to run an rspec rake task defined in >>>> >>> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >>>> >>> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >>>> >>> gems. >>>> >>> >>>> >>> >>>> >>> ******************************************************************************** >>>> >>> >>>> >>> >>>> >>> Here is the trace if I run it too. >>>> >>> >>>> >>> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >>>> >>> `initialize' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >>>> >>> `invoke_with_call_chain' >>>> >>> >>>> >>> >>>> >>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >>>> >>> `synchronize' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >>>> >>> `invoke_with_call_chain' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >>>> >>> `invoke_task' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>>> >>> `standard_exception_handling' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>>> >>> `standard_exception_handling' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >>>> >>> >>>> >>> >>>> >>> >>>> >>> Am I missing something? >>>> >>> >>>> >>> -- >>>> >>> Amos King >>>> >>> http://dirtyInformation.com >>>> >>> http://github.com/Adkron >>>> >>> -- >>>> >>> Looking for something to do? Visit http://ImThere.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 >>>> >> >>>> > >>>> > >>>> > >>>> > -- >>>> > Amos King >>>> > http://dirtyInformation.com >>>> > http://github.com/Adkron >>>> > -- >>>> > Looking for something to do? Visit http://ImThere.com >>>> > >>>> >>>> >>>> >>>> -- >>>> Amos King >>>> http://dirtyInformation.com >>>> http://github.com/Adkron >>>> -- >>>> Looking for something to do? Visit http://ImThere.com >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> It doesn't have to be a frozen gem. That's simply if you want to manage >>> dependencies via git, etc. for deployment. >>> I use it as a regular gem. >>> The current issue is plugins not being supported on latest release. >>> Regards, >>> Nick >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.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 > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com From dchelimsky at gmail.com Thu Apr 30 23:10:44 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 30 Apr 2009 22:10:44 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: References: <632154f70904301305s326cf506p8ec49ec3372db599@mail.gmail.com> <57c63afe0904302004r1689fb11t93d9de7df84aeb2f@mail.gmail.com> Message-ID: <57c63afe0904302010l5dd2f096g1a18b395ec61237@mail.gmail.com> On Thu, Apr 30, 2009 at 10:05 PM, Amos King wrote: > should I go with the plugin. ?It doesn't work as a gem now? I didn't say that :) It still works as a gem (I don't understand why it's not working for you as a gem), *and* I fixed the problem using it as a plugin, so you should be able to use it either way now. > > On Thu, Apr 30, 2009 at 10:04 PM, David Chelimsky wrote: >> On Thu, Apr 30, 2009 at 9:55 PM, Amos King wrote: >>> frozen as gems and still the same problems. >> >> The 1.2.6 release should work as a plugin again. >> >>> >>> On Thu, Apr 30, 2009 at 3:05 PM, Nicholas Van Weerdenburg >>> wrote: >>>> On Thu, Apr 30, 2009 at 3:34 PM, Amos King wrote: >>>>> >>>>> So why am I required to install rspec as a frozen/system gem to work >>>>> with rails? ?I would be happy with that if the support for rails gems >>>>> was a little better. ?I'm stuck to the published gem at that point, or >>>>> I have to jump through hoops on every deployment or build box. >>>>> >>>>> On Thu, Apr 30, 2009 at 2:21 PM, Amos King wrote: >>>>> > yes, but when you add it does it. >>>>> > >>>>> > On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor >>>>> > wrote: >>>>> >> >>>>> >> On Apr 30, 2009, at 2:26 PM, Amos King wrote: >>>>> >> >>>>> >>> I started a brand new rails app and then ran the following. >>>>> >>> >>>>> >>> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >>>>> >>> vendor/plugins/cucumber >>>>> >>> %>git submodule add git://github.com/brynary/webrat.git >>>>> >>> vendor/plugins/webrat >>>>> >>> %>git submodule add git://github.com/dchelimsky/rspec.git >>>>> >>> vendor/plugins/rspec >>>>> >>> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >>>>> >>> vendor/plugins/rspec-rails >>>>> >>> %>script/generate rspec >>>>> >>> %>rake spec >>>>> >> >>>>> >> Did you run "git submodule update --init" ? >>>>> >> >>>>> >> Scott >>>>> >> >>>>> >>> >>>>> >>> >>>>> >>> Then I have the following output: >>>>> >>> >>>>> >>> rake aborted! >>>>> >>> >>>>> >>> >>>>> >>> >>>>> >>> ******************************************************************************** >>>>> >>> * ?You are trying to run an rspec rake task defined in >>>>> >>> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >>>>> >>> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >>>>> >>> gems. >>>>> >>> >>>>> >>> >>>>> >>> ******************************************************************************** >>>>> >>> >>>>> >>> >>>>> >>> Here is the trace if I run it too. >>>>> >>> >>>>> >>> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >>>>> >>> `initialize' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >>>>> >>> `invoke_with_call_chain' >>>>> >>> >>>>> >>> >>>>> >>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >>>>> >>> `synchronize' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >>>>> >>> `invoke_with_call_chain' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >>>>> >>> `invoke_task' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>>>> >>> `standard_exception_handling' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>>>> >>> `standard_exception_handling' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >>>>> >>> >>>>> >>> >>>>> >>> >>>>> >>> Am I missing something? >>>>> >>> >>>>> >>> -- >>>>> >>> Amos King >>>>> >>> http://dirtyInformation.com >>>>> >>> http://github.com/Adkron >>>>> >>> -- >>>>> >>> Looking for something to do? Visit http://ImThere.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 >>>>> >> >>>>> > >>>>> > >>>>> > >>>>> > -- >>>>> > Amos King >>>>> > http://dirtyInformation.com >>>>> > http://github.com/Adkron >>>>> > -- >>>>> > Looking for something to do? Visit http://ImThere.com >>>>> > >>>>> >>>>> >>>>> >>>>> -- >>>>> Amos King >>>>> http://dirtyInformation.com >>>>> http://github.com/Adkron >>>>> -- >>>>> Looking for something to do? Visit http://ImThere.com >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> It doesn't have to be a frozen gem. That's simply if you want to manage >>>> dependencies via git, etc. for deployment. >>>> I use it as a regular gem. >>>> The current issue is plugins not being supported on latest release. >>>> Regards, >>>> Nick >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> >>> >>> -- >>> Amos King >>> http://dirtyInformation.com >>> http://github.com/Adkron >>> -- >>> Looking for something to do? Visit http://ImThere.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 >> > > > > -- > Amos King > http://dirtyInformation.com > http://github.com/Adkron > -- > Looking for something to do? Visit http://ImThere.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From andrew at andrewtimberlake.com Thu Apr 30 23:21:54 2009 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Fri, 1 May 2009 05:21:54 +0200 Subject: [rspec-users] Help with some basics In-Reply-To: <57c63afe0904301304g4bf15482k3fb13186af9cb434@mail.gmail.com> References: <62ad3e390904300744p4ae54451h421574c0d8139325@mail.gmail.com> <57c63afe0904300759t1aa0bad6o6fa433f8145c339a@mail.gmail.com> <62ad3e390904301255j6c7193c6mdf94c7c12dfc368@mail.gmail.com> <57c63afe0904301304g4bf15482k3fb13186af9cb434@mail.gmail.com> Message-ID: <62ad3e390904302021m45a0777ajb1dcba17b2ed3a26@mail.gmail.com> On Thu, Apr 30, 2009 at 10:04 PM, David Chelimsky wrote: > On Thu, Apr 30, 2009 at 2:55 PM, Andrew Timberlake > wrote: >> It gives me the same error when I run >> rake spec >> spec specs/ >> or >> autospec >> >> It also gives the same error with specs like >> it { should_not be_nil } >> and >> it { should respond_to(:name) } > > Those are internal to rspec and I can assure you they have descriptions. > > I'm mystified. Anybody else on this list have a similar experience? > > Managed to find the problem, the class ProductTemplate wasn't being loaded so "it" wasn't working on an object. The error is not very useful in this situation but I'm moving forward again. Thanks for the help Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain From amos.l.king at gmail.com Thu Apr 30 23:23:54 2009 From: amos.l.king at gmail.com (Amos King) Date: Thu, 30 Apr 2009 22:23:54 -0500 Subject: [rspec-users] submodule rspec and rspec-rails issues In-Reply-To: <57c63afe0904302010l5dd2f096g1a18b395ec61237@mail.gmail.com> References: <632154f70904301305s326cf506p8ec49ec3372db599@mail.gmail.com> <57c63afe0904302004r1689fb11t93d9de7df84aeb2f@mail.gmail.com> <57c63afe0904302010l5dd2f096g1a18b395ec61237@mail.gmail.com> Message-ID: I went back to a plugin. The gem isn't working right now, and their were some others in the irc channel that had the same issue when they uninstalled the system gem. If I change the frozen directory to not have the version number it works, but rails complains. So I did just change the plugin loadpath to load from gems/rspec-1.2.6 That worked. Now I'm back to plugin since it works really well for staying on the edge of the commits, and all around plugins are easier to handle than rails frozen gems. Thanks for your help. Amos On Thu, Apr 30, 2009 at 10:10 PM, David Chelimsky wrote: > On Thu, Apr 30, 2009 at 10:05 PM, Amos King wrote: >> should I go with the plugin. ?It doesn't work as a gem now? > > I didn't say that :) It still works as a gem (I don't understand why > it's not working for you as a gem), *and* I fixed the problem using it > as a plugin, so you should be able to use it either way now. > > >> >> On Thu, Apr 30, 2009 at 10:04 PM, David Chelimsky wrote: >>> On Thu, Apr 30, 2009 at 9:55 PM, Amos King wrote: >>>> frozen as gems and still the same problems. >>> >>> The 1.2.6 release should work as a plugin again. >>> >>>> >>>> On Thu, Apr 30, 2009 at 3:05 PM, Nicholas Van Weerdenburg >>>> wrote: >>>>> On Thu, Apr 30, 2009 at 3:34 PM, Amos King wrote: >>>>>> >>>>>> So why am I required to install rspec as a frozen/system gem to work >>>>>> with rails? ?I would be happy with that if the support for rails gems >>>>>> was a little better. ?I'm stuck to the published gem at that point, or >>>>>> I have to jump through hoops on every deployment or build box. >>>>>> >>>>>> On Thu, Apr 30, 2009 at 2:21 PM, Amos King wrote: >>>>>> > yes, but when you add it does it. >>>>>> > >>>>>> > On Thu, Apr 30, 2009 at 1:33 PM, Scott Taylor >>>>>> > wrote: >>>>>> >> >>>>>> >> On Apr 30, 2009, at 2:26 PM, Amos King wrote: >>>>>> >> >>>>>> >>> I started a brand new rails app and then ran the following. >>>>>> >>> >>>>>> >>> %>git submodule add git://github.com/aslakhellesoy/cucumber.git >>>>>> >>> vendor/plugins/cucumber >>>>>> >>> %>git submodule add git://github.com/brynary/webrat.git >>>>>> >>> vendor/plugins/webrat >>>>>> >>> %>git submodule add git://github.com/dchelimsky/rspec.git >>>>>> >>> vendor/plugins/rspec >>>>>> >>> %>git submodule add git://github.com/dchelimsky/rspec-rails.git >>>>>> >>> vendor/plugins/rspec-rails >>>>>> >>> %>script/generate rspec >>>>>> >>> %>rake spec >>>>>> >> >>>>>> >> Did you run "git submodule update --init" ? >>>>>> >> >>>>>> >> Scott >>>>>> >> >>>>>> >>> >>>>>> >>> >>>>>> >>> Then I have the following output: >>>>>> >>> >>>>>> >>> rake aborted! >>>>>> >>> >>>>>> >>> >>>>>> >>> >>>>>> >>> ******************************************************************************** >>>>>> >>> * ?You are trying to run an rspec rake task defined in >>>>>> >>> * ?/Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake, >>>>>> >>> * ?but rspec can not be found in vendor/gems, vendor/plugins or system >>>>>> >>> gems. >>>>>> >>> >>>>>> >>> >>>>>> >>> ******************************************************************************** >>>>>> >>> >>>>>> >>> >>>>>> >>> Here is the trace if I run it too. >>>>>> >>> >>>>>> >>> /Users/amos/workspace/akingsoftware/hops/lib/tasks/rspec.rake:18:in >>>>>> >>> `initialize' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in >>>>>> >>> `invoke_with_call_chain' >>>>>> >>> >>>>>> >>> >>>>>> >>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in >>>>>> >>> `synchronize' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in >>>>>> >>> `invoke_with_call_chain' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in >>>>>> >>> `invoke_task' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>>>>> >>> `standard_exception_handling' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in >>>>>> >>> `standard_exception_handling' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run' >>>>>> >>> /Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31 >>>>>> >>> >>>>>> >>> >>>>>> >>> >>>>>> >>> Am I missing something? >>>>>> >>> >>>>>> >>> -- >>>>>> >>> Amos King >>>>>> >>> http://dirtyInformation.com >>>>>> >>> http://github.com/Adkron >>>>>> >>> -- >>>>>> >>> Looking for something to do? Visit http://ImThere.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 >>>>>> >> >>>>>> > >>>>>> > >>>>>> > >>>>>> > -- >>>>>> > Amos King >>>>>> > http://dirtyInformation.com >>>>>> > http://github.com/Adkron >>>>>> > -- >>>>>> > Looking for something to do? Visit http://ImThere.com >>>>>> > >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Amos King >>>>>> http://dirtyInformation.com >>>>>> http://github.com/Adkron >>>>>> -- >>>>>> Looking for something to do? Visit http://ImThere.com >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>>> It doesn't have to be a frozen gem. That's simply if you want to manage >>>>> dependencies via git, etc. for deployment. >>>>> I use it as a regular gem. >>>>> The current issue is plugins not being supported on latest release. >>>>> Regards, >>>>> Nick >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> >>>> >>>> >>>> -- >>>> Amos King >>>> http://dirtyInformation.com >>>> http://github.com/Adkron >>>> -- >>>> Looking for something to do? Visit http://ImThere.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 >>> >> >> >> >> -- >> Amos King >> http://dirtyInformation.com >> http://github.com/Adkron >> -- >> Looking for something to do? Visit http://ImThere.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 > -- Amos King http://dirtyInformation.com http://github.com/Adkron -- Looking for something to do? Visit http://ImThere.com