开发者

Undefined Method error 'has_content?' with rspec/capybara/rails3

I am getting an undefined method 'has_content?' error on an rspec controller_spec file.

I found a thread with similar issues though that thread said the issue was fixed in rspec2.0beta (it开发者_运维问答 was a fairly old thread) but I'm getting this with a more recent version. Some threads on rspec shows that capybara doesn't work in view specs, but I'm working in the controller specs so that shouldn't be the issue...

My Gemfile info looks like this:

rspec-rails+ dependecies 2.6.0.rc6
capybara 0.4.1.2
rails 3.0.7

I am trying to do a simple assert like

response.body.should have_content("Project A")

Thanks for the response, Tony


Capybara is only included in Rspec request specs by default. Change this file to a be a request spec (put it in the request specs directory, change the title of it...)

Read the capybara Readme section 'Using Capybara with RSpec'

https://github.com/jnicklas/capybara

Also, if these are the types of asserts you're looking to do, this qualifies as a request spec more than it is a controller spec.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜