Skip to content

Instantly share code, notes, and snippets.

@aimeerivers
Created June 24, 2010 21:13
Show Gist options
  • Save aimeerivers/451992 to your computer and use it in GitHub Desktop.
Save aimeerivers/451992 to your computer and use it in GitHub Desktop.
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
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