On Jun 14, 2012, at 1:40 AM, Joshua Muheim wrote:
> 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"
> save_and_open_page
> response.should have_content("1 movie")
> response.should have_content("Caddyshack")
> end
>
> 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
> there!
>
> Name: Comedy
>
> Contains 1 movie
> Edit | Back
>
> This is what Cucumber tells me:
>
> Scenario: Create movie in genre #
> features/create_movie.feature:7
> Given a genre named Comedy #
> features/step_definitions/genre_steps.rb:1
> When I create a movie Caddyshack in the Comedy genre #
> features/step_definitions/movie_steps.rb:1
> Then Caddyshack should be in the Comedy genre #
> features/step_definitions/movie_steps.rb:10
> expected there to be content "1 movie" in ""
> (RSpec::Expectations::ExpectationNotMetError)
> ./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):
>
> http://www.ruby-forum.com/topic/4402795
>
> Thanks a lot for help,
> Josh
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
For Capybara, you want: page.should have_content
For Webrat, I _think_ you want: response.should have_text
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users