Skip to content

Instantly share code, notes, and snippets.

@frankpinto
Last active September 11, 2015 02:28
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 frankpinto/5c7d56128d54741dfce4 to your computer and use it in GitHub Desktop.
Save frankpinto/5c7d56128d54741dfce4 to your computer and use it in GitHub Desktop.
Stubbing devise with mocha
# rspec-mocks -> mocha + https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs
class StoresControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
user = stub email: 'blah@hello.com'
warden.stubs(:authenticate!).returns user
@controller.stubs(:current_user).returns user
end
def test_should_get_index
get :index
assert_response :success
# All good!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment