Howdy, Just an observation, hope it's helpful...
>> I can work around it, but I'll end up with 2 different 'Then' calls that do >> nothing but call a common method Not sure this is necessary. If you provide all the arguments in the one step then you can test them for value ( blank?) in the one method. -- Tim 2 2009/3/30 aslak hellesoy <[email protected]>: > > > On Mon, Mar 30, 2009 at 9:00 PM, Tim Hart <[email protected]> wrote: >> >> List, >> >> Given a Cucumber script like >> >> Then /^the (?:(first|second|third|fourth) line of the )?(.*) section of >> the (.*) should be (.*)$/ do |*args| >> #... >> end >> >> Cucumber errors with >> expected 0 block argument(s), got 4 (Cucumber::ArityMismatchError) >> >> While it's perfectly legal in generic ruby to do this >> >> def foo(&block) >> block.call 1,2,3,4,5 >> end >> >> foo do |*args| >> #... >> End >> >> Is this an intended limitation? I can work around it, but I'll end up with >> 2 different 'Then' calls that do nothing but call a common method > > It's intended. Let me explain with an example: > > http://gist.github.com/87890 > > Ruby 1.8 doesn't know how to distinguish between a Proc with no args (and no > pipes) and a Proc with varargs. They both have arity -1. This means Cucumber > (while running on Ruby 1.8) can't really tell whether you forgot to define > any args or if you're deliberately using varargs. Since the first case is > more likely than the second, this is what Cucumber assumes. > > I don't want to sacrifice this aide just so people can use varargs. The > benefit of getting help when you forget to define prog args outweighs the > drawback of not being able to use varargs. > > That said, I'd like to make Cucumber smart enough to accept varargs on Ruby > 1.9. > > Does this sound like an OK compromise? > > Aslak > >> >> -- >> Tim Hart >> Senior Software Engineer >> PICA Group >> 615-713-9956 :cell >> timothyjhart :Y! >> [email protected] :AIM >> >> >> ***************************************************************************** >> >> Disclaimer: This electronic message may contain information that is >> Confidential or legally privileged. It is intended only for the use of the >> individual(s) and entity named in the message. If you are not an intended >> recipient of this message, please notify the sender immediately and delete >> the material from your computer. Do not deliver, distribute or copy this >> message and do not disclose its contents or take any action in reliance on >> the information it contains. >> >> >> ***************************************************************************** >> >> >> _______________________________________________ >> rspec-users mailing list >> [email protected] >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
