[rspec-users] alias method spec?

Scott Taylor mailing_lists at railsnewbie.com
Tue Mar 20 20:38:30 EDT 2007


On Mar 20, 2007, at 12:52 PM, Bryan Helmkamp wrote:

> On 3/20/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>> On 3/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>>>
>>> Well honestly I just wanted a method which could be called in the
>>> plural or singular, something like:
>>>
>>> column_name :a_col
>>>
>>> or
>>>
>>> columns_names :a_first_col, :a_second_col
>>>
>>> but I want it to be the same method, and I want it to work the same
>>> way.  (namely to return an array or a hash, and/or possibly set an
>>> instance variable)
>>>
>>> That's what led me to the idea in the first place, that I should  
>>> test
>>> them in separate contexts, but assuring that they were indeed the
>>> same method in one of the contexts...
>>
>> What benefit is there to knowing they are the same method, as long as
>> they both do the same thing?
>
> I've experienced a similar situation before. The reason I looked at
> testing that they are the same method is that it seemed more DRY to do
> that than to copy/paste the specs for that method and replace the
> name. WDYT?

Actually I wasn't going for DRY, specifically.  I wanted it more for  
an annotation, or documentation to my code.

Scott



More information about the rspec-users mailing list