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

James Byrne lists at ruby-forum.com
Wed Apr 22 14:45:30 EDT 2009


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)


-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list