Skip to content

Instantly share code, notes, and snippets.

@chatman-media
Created April 4, 2014 22:37
Show Gist options
  • Select an option

  • Save chatman-media/9984431 to your computer and use it in GitHub Desktop.

Select an option

Save chatman-media/9984431 to your computer and use it in GitHub Desktop.
class TestController < ApplicationController
before_action :authenticate_user!
def custom
render text: 'response'
end
end
describe TestController do
describe "authenticate_user!" do
context "when user not logged in" do
before do
subject.send(:current_user=, nil)
routes.draw { get 'custom' => 'test#custom' }
get 'custom'
end
it { should respond_with :unauthorized }
it "returns nothing" do
expect(response.body).to be_blank
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment