problem with rspec test, undefined method 'post' problem with rspec test, undefined method 'post' ruby-on-rails ruby-on-rails

problem with rspec test, undefined method 'post'


If the spec file is not under spec/controllers, methods like get and post will not be automatically made available by rspec-rails.

You either need to tag your spec:

describe MyController, type: :controller do  # ...end

or include the module:

describe MyController do  include RSpec::Rails::ControllerExampleGroup  # ...end

See the relevant code in rspec-rails.


  1. Make sure you have gem spec-rails in your Gemfile
  2. Your mashup_controller_rspec.rb should be under spec/controllers


I used gem rspec-rails instead of gem spec-rails.