What is the best way to handle testing of concerns when used in Rails 4 controllers? Say I have a trivial concern Citations
.
module Citations
ex
Simplifying on method 2 from the most voted answer.
I prefer the anonymous controller
supported in rspec http://www.relishapp.com/rspec/rspec-rails/docs/controller-specs/anonymous-controller
You will do:
describe ApplicationController, type: :controller do
controller do
include MyControllerConcern
def index; end
end
describe 'GET index' do
it 'will work' do
get :index
end
end
end
Note that you need to describe the ApplicationController
and set the type in case this does not happen by default.