ruby-on-railsrspeccucumberrspec-expectations

Cucumber undefined methods


I'm using cucumber with capybara

I've got several similar errors.

For step:

Then /I should see movies of rating 'PG' or 'R'/ do
  page.body.should match(/<td>PG<\/td>/)
  page.body.should match(/<td>R<\/td>/)
end

Cucumber error:

undefined method `match' for #<Cucumber::Rails::World:...> (NoMethodError)
./features/step_definitions/movie_steps.rb:37:in 
   `/I should see movies of rating 'PG' or 'R'/'

For step:

Then /I should see an empty table/ do
  page.body.scan(/<tr>/).length.should == 0
end

Cucumber error:

undefined method `should' for 1:Fixnum (NoMethodError)
./features/step_definitions/movie_steps.rb:46:in 
      `/I should see an empty table/'

And for step:

Then /I should see all of the movies/ do
  Movie.find(:all).length.should page.body.scan(/<tr>/).length
end

undefined method `should' for 10:Fixnum (NoMethodError)
./features/step_definitions/movie_steps.rb:59:in 
    `/I should see all of the movies/'

The whole file of steps is here

As you can see these errors are quite similar but I can't understand what cause this problem.


Solution

  • It looks to me like you are having problems with the rspec-expectations. Try to add

    require 'rspec/expectations'
    

    to your env.rb and the equivalent to your Gemfile.