Browse files

Add basic integration spec testing authentication.

  • Loading branch information...
1 parent 68fb8b6 commit f0f7723e59311032537b4c77082b03c5b93dd629 @twe4ked committed May 13, 2012
Showing with 38 additions and 0 deletions.
  1. +30 −0 spec/integration/tmpfollow_spec.rb
  2. +8 −0 spec/spec_helper.rb
View
30 spec/integration/tmpfollow_spec.rb
@@ -0,0 +1,30 @@
+require_relative '../spec_helper'
+
+describe TmpFollow do
+ describe 'authenticating' do
+ include Capybara::DSL
+
+ before do
+ Capybara.app = TmpFollow
+ end
+
+ it 'signs in with twitter', :type => :request do
+ visit '/'
+ click_link 'Authenticate with Twitter'
+
+ page.should have_content 'Authenticated successfully.'
+ page.should_not have_content 'Authenticate with Twitter'
+ end
+
+ it 'returns an error from twitter' do
+ OmniAuth.config.mock_auth[:twitter] = :invalid_login
+
+ visit '/'
+ click_link 'Authenticate with Twitter'
+
+ page.should have_content 'Authentication failed.'
+ page.should have_content 'Authenticate with Twitter'
+ page.should_not have_content 'Authenticated successfully.'
+ end
+ end
+end
View
8 spec/spec_helper.rb
@@ -9,6 +9,14 @@
require 'rack/test'
require './tmpfollow'
+OmniAuth.config.test_mode = true
+OmniAuth.config.logger = Logger.new('/dev/null')
+OmniAuth.config.mock_auth[:twitter] = {
+ credentials: {
+ token: '1234',
+ secret: '5678'
+ }
+}
def app
TmpFollow

0 comments on commit f0f7723

Please sign in to comment.