Created
June 24, 2010 21:13
-
-
Save aimeerivers/451992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'haml' | |
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib') | |
require 'oauth.rb' | |
enable :sessions | |
get '/' do | |
if authenticated? | |
redirect '/contacts' | |
else | |
haml :index | |
end | |
end | |
def authenticated? | |
!session[:authentication].nil? | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/spec_helper' | |
describe "Deborah" do | |
include Rack::Test::Methods | |
def app | |
@app ||= Sinatra::Application | |
end | |
describe 'home page' do | |
context 'when not authenticated' do | |
it 'renders the page' do | |
get '/' | |
last_response.should be_ok | |
end | |
end | |
context 'when authenticated' do | |
it 'redirects to the contacts page' do | |
app.stub!(:authenticated? => true) # DOES NOT WORK??!! | |
get '/' | |
last_response.should be_redirect | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment