Skip to content

Instantly share code, notes, and snippets.

@frankpinto
Last active September 11, 2015 02:28
Show Gist options
  • 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: '[email protected]'
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