Skip to content

Instantly share code, notes, and snippets.

@garrensmith
Created March 31, 2010 14:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrensmith/350381 to your computer and use it in GitHub Desktop.
Save garrensmith/350381 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
before do
@username = session[:username]
p session
end
get '/' do
"Hello" + @username.to_s
end
require 'sample' # <-- your sinatra app
require 'spec'
require 'rack/test'
set :environment, :test
set :sessions, true
describe 'The HelloWorld App' do
include Rack::Test::Methods
def app
Sinatra::Application
end
it "should say hello using sessions attempt one" do
get '/', {}, :sessions => {:username => "garren"}
last_response.should be_ok
last_response.body.should == 'Hello garren'
end
it "should say hello using sessions attempt one" do
get '/', {}, { "rack.session" => { :username => 'garren'}}
last_response.should be_ok
last_response.body.should == 'Hello garren'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment