[rspec-users] 'it' duplicate example: BUG

Scott Taylor mailing_lists at railsnewbie.com
Sun Nov 25 13:54:18 EST 2007

On Nov 25, 2007, at 7:35 AM, David Chelimsky wrote:

> On Nov 24, 2007 7:47 PM, Scott Taylor  
> <mailing_lists at railsnewbie.com> wrote:
>> On Nov 21, 2007, at 3:17 PM, aslak hellesoy wrote:
>>> On 11/21/07, Chad Humphries <chad at spicycode.com> wrote:
>>>> One of the recent trunk changesets modified the default  
>>>> behaviour to
>>>> fail fast if duplicate examples are detected within a single
>>>> behaviour/
>>>> example group.   This is basically letting you know you have to  
>>>> "it"
>>>> blocks in the behaviour with the same description.
>>> This is correct. It's not a bug - it's by design and documented in
>>> The reason I put it in has an interesting explanation. Over the past
>>> few days our coverage dropped from 100% to 99.9% and we couldn't
>>> understand why. RCov reported that some code wasn't being  
>>> covered, but
>>> I *knew* there were examples covering it.
>>> Something was fishy.
>>> Then I remembered that Brian a few days ago did a change to the
>>> internals - every it block now creates a method with the same  
>>> name as
>>> the description, and later calls that method to run the example.
>>> Nothing wrong with that, but it had some sideeffects we didn't think
>>> about: If there were duplicates, the last one would simply overwrite
>>> (monkey patch!) the previous one with the same name. And as a result
>>> never get run.
>>> Since I'm a fail fast kind of guy I made RSpec do that.
>> In light of the duplicate examples which would come about with the
>> following:
>> it do
>>    foo.should == bar
>> end
>> - how about providing the behaviour described above as an option to
>> the runner?
> I'm not sure what you mean. Please give an example.

I was saying that we should have the --no-duplicate options to the  
runner, which would raise an error when it encountered a duplicate  
example.  It might be useful occasionally (for my test suite of 1400  
specs, it found three duplicates, which would be pretty hard to fish  
out otherwise).


More information about the rspec-users mailing list