[rspec-users] response.should have_content("1 movie") does not seem to work for me

Joshua Muheim lists at ruby-forum.com
Thu Jun 14 07:40:14 UTC 2012

Hey everybody

I have worked quite to near the end of The RSpec Book, but now I'm
having some troubles.

I'm trying to get the last few Cucumber steps to work, which are:

Then /^Caddyshack should be in the Comedy genre$/ do
  visit genres_path
  click_link "Comedy"
  response.should have_content("1 movie")
  response.should have_content("Caddyshack")

So far everything's working, but the have_content("1 movie") doesn't,
although I have hard-coded the string into the view, and when displaying
what Webrat sees using save_and_open_page, the string definitely is

Name: Comedy

Contains 1 movie
Edit | Back

This is what Cucumber tells me:

  Scenario: Create movie in genre                        #
    Given a genre named Comedy                           #
    When I create a movie Caddyshack in the Comedy genre #
    Then Caddyshack should be in the Comedy genre        #
      expected there to be content "1 movie" in ""
      ./features/step_definitions/movie_steps.rb:14:in `/^Caddyshack
should be in the Comedy genre$/'
      features/create_movie.feature:10:in `Then Caddyshack should be in
the Comedy genre'

I'm sort of confused anyway, because in the RSpec book I'm told to use
contains("1 movie"), but this method is not found!

  undefined method `contains' for
#<Cucumber::Rails::World:0x007fb114028010> (NoMethodError)

After some searching on Google I got the hint to use should_contain("1
movie"), and this method seems to be available, but it doesn't seem to
work. Anyways, I'm a bit confused now, because should_contain() was
claimed to be a Capybara thing, and not a Webrat thing, but I never read
something about Capybara in the book, only about Webrat. So what am I
using now, and why?? Is it because the book is a bit old already, and
nowadays Rails uses Capybara by default? Because when removing

gem "webrat"

from my Gemfile, Cucumber doesn't complain!

Please also see my other post about this question (I'm sorry for having
two posts, I didn't realize they both would be about the same thing):


Thanks a lot for help,

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

More information about the rspec-users mailing list