Skip to content

Instantly share code, notes, and snippets.

@dbarrionuevo
Created August 7, 2013 14:35
Show Gist options
  • Save dbarrionuevo/6174611 to your computer and use it in GitHub Desktop.
Save dbarrionuevo/6174611 to your computer and use it in GitHub Desktop.
Workflow to ensure correct catch of Omniauth login failure. Specs included.
OmniAuth.config.on_failure = Proc.new { |env|
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}
get 'auth/failure', to: 'sessions#failure'
def failure
redirect_to root_path, aler: "There was an error while authenticating"
end
feature "Sign in with Facebook" do
context "with invalid data" do
scenario "doesn't create an user" do
OmniAuth.config.mock_auth[:facebook] = fb_invalid_data
visit root_path
click_on "Connect"
expect(User.count).to be_zero
end
scenario "redirects if a failure is found" do
OmniAuth.config.mock_auth[:facebook] = :invalid_credentials
visit root_path
click_on "Connect"
expect(current_path).to eql root_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment