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

David Chelimsky dchelimsky at gmail.com
Wed Apr 22 14:49:10 EDT 2009


On Wed, Apr 22, 2009 at 1:45 PM, James Byrne <lists at ruby-forum.com> wrote:
> David Chelimsky wrote:
>>
>>
>> The original issue you posted is with the contain matcher, which is in
>> webrat, not rspec. Why it's not working, I'm not quite sure, but if
>> you're going to throw out the baby with the bath water, you might
>> consider figuring out who the parents are :)
>>
>
> Yes, I figured out that #contain was the culprit when I discovered that
> this worked:
>
> fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \
>                ==(expected)
>
> Ugly, to me, but it works so the problem is not RSpec.  Strangely,
> however, this construct also failed:
>
> fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').to_s.should \
>                =~(expected)
>
> I am not throwing out RSpec or using it any less.  I just had to get
> around a specific problem and took the first route I found that worked.
>
>> In the mean time, I'm not sure what better message we can give beyond
>> "compared using .equal?" without getting into a long treatise on
>> equality in Ruby, which seems out of place in a failure message.
>
> How about:
>
>        expected "<title>Bank of Canada: Noon Foreign Exchange
> Rates</title>"
>             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.

>
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list