kurenn / market_place_api

The API on Rails tutorial application
142 stars 68 forks source link

respond_with error #43

Closed erikjenks closed 9 years ago

erikjenks commented 9 years ago
1) Api::V1::UsersController GET #show 
     Failure/Error: it { should respond_with 200 }
     NoMethodError:
       undefined method `respond_with' for #<RSpec::ExampleGroups::ApiV1UsersController::GETShow:0x007f86a721ac70>
     # /Users/jenks/.gem/ruby/2.2.2/gems/actionpack-4.2.4/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing'
     # ./spec/controllers/api/v1/users_controller_spec.rb:15:in `block (3 levels) in <top (required)>'

Receiving this error when trying to run the tests for the Users controller. I am using Rspec-rails 3.0 and shoulda-matchers 3.0. Any idea of why this is failing?

erikjenks commented 9 years ago

Never mind. I forgot a config block in my spec_helper

SpacyRicochet commented 8 years ago

@erikjenks What did you miss specifically? I'm having the exact same issue currently.

https://github.com/kurenn/market_place_api/commit/59daf641120b75fa79dd064a07d80fdc31d3bc1e#commitcomment-15067079

erikjenks commented 8 years ago

Hey @SpacyRicochet I didnt have all of this in my spec_helper.rb file. Once I added that I think the tests passed. It was a while ago so I am trying to remember.

  config.infer_spec_type_from_file_location!
  config.include Request::JsonHelpers, :type => :controller
  config.include Request::HeadersHelpers, :type => :controller
  config.include Devise::TestHelpers, :type => :controller

  config.before(:each, type: :controller) do
    include_default_accept_headers
  end
SpacyRicochet commented 8 years ago

Hmm, after adding those lines it complains about uninitialized constant Request (NameError). Also, those lines don't actually exist in the commit right after that test.

kurenn commented 8 years ago

Are you requiring the files from the support directory?

SpacyRicochet commented 8 years ago

In the end I fixed it as mentioned in #56. I'll check what the support directory does, though. Thanks.

kurenn commented 8 years ago

Sweet!