Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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