undefined method `has_tag?' for #<String:0x10390d810>

355 views
Skip to first unread message

Rob Aldred

unread,
Nov 4, 2009, 10:16:51 AM11/4/09
to Cukes
Hey I'm using cucumber, webrat(selenium mode) & sinatra
for the most part it works great but it appears to be having some
trouble when using matchers
eg.
`response.body.should have_tag('form#form_id')`

This fails with the following error:
`undefined method `has_tag?' for #<String:0x10390d810> (NoMethodError)
`

Here is my world... http://gist.github.com/226121
is it possible im not loading something correctly.
or is the handling of have_tag only for Cucumber::Rails::World

I have another project where the matchers work fine but that project
uses webrat(selenium mode) & rails

Thanks

Jeroen van Dijk

unread,
Nov 4, 2009, 4:04:30 PM11/4/09
to cu...@googlegroups.com
On Wed, Nov 4, 2009 at 4:16 PM, Rob Aldred <ral...@gmail.com> wrote:

Hey I'm using cucumber, webrat(selenium mode) & sinatra
for the most part it works great but it appears to be having some
trouble when using matchers
eg.
`response.body.should have_tag('form#form_id')`

This fails with the following error:
`undefined method `has_tag?' for #<String:0x10390d810> (NoMethodError)
`


You need to use webrat's matcher #have_selector.
http://gitrdoc.com/rdoc/brynary/webrat/273e8c541a82ddacf91f4f68ab6166c16ffdc9c5/classes/Webrat/Selenium/Matchers.html#M000040


You get the undefined method has_tag? because rspec does something clever. It will do that on any method e.g.
response.body.should have_foo(...) will look for a method has_foo? etc.

 
Here is my world... http://gist.github.com/226121
is it possible im not loading something correctly.
or is the handling of have_tag only for Cucumber::Rails::World

I have another project where the matchers work fine but that project
uses webrat(selenium mode) & rails


It might have an older version of webrat?

 
Thanks



Jeroen van Dijk

unread,
Nov 4, 2009, 4:07:37 PM11/4/09
to cu...@googlegroups.com

Oh I forgot to mention you have an outdated env.rb file. Update the cucumber gem and run script/generate cucumber to see what you are missing. At least your missing the "require 'webrat/core/matchers'



 
Reply all
Reply to author
Forward
0 new messages