Rspec-rails: Testing 'get' request with query params and format specified ignores specified format

Created on 15 Apr 2014  路  1Comment  路  Source: rspec/rspec-rails

The follow request spec:
get :index, {: }, format: :json

results in 'text/html' being set for the response.content_type. The same get method without the query parameters sets the content type to 'application/json' as it should.

Most helpful comment

Format needs to be in your query parameters, your currently setting a header.

Use:

get :index, your_params.merge(format: :json)

>All comments

Format needs to be in your query parameters, your currently setting a header.

Use:

get :index, your_params.merge(format: :json)
Was this page helpful?
0 / 5 - 0 ratings