[rspec-users] how to write nested XPath matchers

Phlip phlip2005 at gmail.com
Mon Feb 16 21:21:38 EST 2009

David Chelimsky wrote:

> When RSpec is used as customer facing, they see the docstrings
> (strings passed to describe() and it()), not the internal code. That's
> for developers.

Then why the .should stuff? I'm a developer - technically - and I never needed it!

But enough sophistry: Back to business...

> Take a look at http://github.com/dchelimsky/rspec/blob/f6c75b1417d9178d4dcaaf9e892e23474d340ff6/lib/spec/matchers/wrap_expectation.rb,
> I think it'll solve this problem.

This gives the same issue:

   class BeXmlWith

     def matches?(stwing, &block)
       waz_xdoc = @xdoc

       @scope.wrap_expectation self do
         @scope.assert_xhtml stwing
         return (block || @block || proc{}).call
       @xdoc = waz_xdoc

     attr_accessor :failure_message

The same error message for a stray nil:

'/users/new should have xpathic tags' FAILED
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.first

line 50 is just this one:

     response.body.should be_xml_with do

and yes the response.body is populated...


More information about the rspec-users mailing list