[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
       end
     ensure
       @xdoc = waz_xdoc
     end

     attr_accessor :failure_message

The same error message for a stray nil:


1)
'/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
./spec/views/users/new.html.erb_spec.rb:50:

line 50 is just this one:

     response.body.should be_xml_with do

and yes the response.body is populated...

-- 
   Phlip



More information about the rspec-users mailing list