[rspec-users] first cut at blockless given/when/then

Wincent Colaiuta win at wincent.com
Fri Oct 19 07:48:46 EDT 2007


El 19/10/2007, a las 0:41, "David Chelimsky" <dchelimsky at gmail.com>  
escribió:

> On 10/18/07, Wincent Colaiuta <win at wincent.com> wrote:
>> El 18/10/2007, a las 18:42, "David Chelimsky" <dchelimsky at gmail.com>
>> escribió:
>>
>>> Easier to type, sure. I'm not in love w/ the names yet though  
>>> because
>>> they sound like verb phrases - "given matcher", "when matcher",  
>>> "then
>>> matcher".
>>>
>>> How about something like match_given, match_when, match_then?
>>
>> That would be fine too. I mainly just wanted to avoid having to
>> manually pass the symbol in.
>>
>> Another alternative combining your suggestion with what Pat  
>> mentioned:
>>
>> step_matchers do |match|
>>    match.given ...
>>    match.when ...
>>    match.then ...
>> end
>
> That's nice, except we don't want methods named when and then as they
> are keywords :(

Even so, it still works. Ruby is smart enough to figure out that when  
"when" and "then" appear after a period, then they're actually  
message sends:

   irb> class Foo
   irb>   def when
   irb>     puts "hello world"
   irb>   end
   irb> end
   => nil
   irb> Foo.new.when
   hello world
   => nil

Or is there some other complication that I'm not aware of?

Cheers,
Wincent




More information about the rspec-users mailing list