rspec-rails: Failure/Error: Unable to find matching line from backtrace

I’m trying to test my API

The controller I’m testing is under api > v1 > controller.rb

and the following is the rspec test code I use

let(:user) { FactoryGirl.create(:user, email: "test1@test.com") }

describe "with valid token", validToken: true do
  before(:each) { authWithUser(user) }

  describe "POST #create" do
    before(:each) { post :create, {test: "test data" } 

    it "returns the information for one model" do
      expect(json).to have_key('info')
    end
  end
end

I got this error

 Failure/Error: Unable to find matching line from backtrace
 NoMethodError:
   undefined method `request=' for #<Model:0x000000070e9988>

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Hello @kimohashem

Are you using RSpec 3? If so: I believe you need to add the spec metadata :controller => true to your spec. See this documentation for more information: https://www.relishapp.com/rspec/rspec-rails/docs/directory-structure