[rspec-users] Cucumber ".should contain(expected) does but fails anyway

Pat Maddox pat.maddox at gmail.com
Fri Apr 24 12:12:40 EDT 2009


On Wed, Apr 22, 2009 at 12:18 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Wed, Apr 22, 2009 at 2:09 PM, James Byrne <lists at ruby-forum.com> wrote:
>> David Chelimsky wrote:
>>> On Wed, Apr 22, 2009 at 1:45 PM, James Byrne <lists at ruby-forum.com>
>>> wrote:
>>>> this worked:
>>>> I am not throwing out RSpec or using it any less. �I just had to get
>>>> � � � � � � got "<title>Bank of Canada: Noon Foreign Exchange
>>>> Rates</title>"
>>>>
>>>> � � �(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 "<title>Bank of Canada: Noon Foreign Exchange
>> Rates</title>"
>>             got "<title>Bank of Canada: Noon Foreign Exchange
>> Rates</title>"
>>
>> An equal? failure probably should return the metaclass like:
>>
>>        expected "#<Class:#<String:0x2b6950315300>>"
>>             got "#<Class:#<String:0x2b695026e898>>"
>>
>> 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 "#<String:0x2b6950315300> (Four score and seven years...)"
            got "#<String:0x2b695026e898> (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


More information about the rspec-users mailing list