Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floehopper/f0609f9f233a0add69bf54e592dbc838 to your computer and use it in GitHub Desktop.
Save floehopper/f0609f9f233a0add69bf54e592dbc838 to your computer and use it in GitHub Desktop.
Testing before_filter in controller spec
require 'rails_helper'
RSpec.describe MyController do
describe 'GET #any_action' do
controller do
def any_action
head :ok
end
end
before do
routes.draw { get 'testing' => 'my_controller#any_action' }
end
it 'is protected by a before filter' do
get :any_action
# expect side effect of before filter
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment