I can't figure out the right way to test controller concern methods. What 
kind of spec should it be, - controller or other?
Here is a concern I'd like to test:

#controllers/concerns/response.rb


module Response
  extend ActiveSupport::Concern


  def json_response(object, status = :ok, opts = {})
    response = {json: object, status: status}.merge(opts)
    render response
  end


  def respond_with_errors(object)
    render json: { errors: ErrorSerializer.serialize(object) }, status: :
unprocessable_entity
  end


  def paginated_response_status(collection)
    collection.size > WillPaginate.per_page ? :partial_content : :ok
  end
end


The ApplicationController includes the above concern as follows:

#controllers/application_controller.rb

class ApplicationController < ActionController::API
  include Response
...
end


Thank you!

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/1813664e-5f19-446f-95f3-300692be9955%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to