Created
July 4, 2019 15:27
-
-
Save floehopper/f0609f9f233a0add69bf54e592dbc838 to your computer and use it in GitHub Desktop.
Testing before_filter in controller spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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