Skip to content

Instantly share code, notes, and snippets.

@myobie
Created March 21, 2014 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myobie/9697834 to your computer and use it in GitHub Desktop.
Save myobie/9697834 to your computer and use it in GitHub Desktop.
My methods I am accumulating for testing sinatra applications.
module MySinatraTestMethods
def self.included(other)
other.send :include, Rack::Test::Methods
end
def app
Sinatra::Application.new
end
def session
current_session.rack_session
end
end
module Rack
module Test
class Session
alias old_env_for env_for
def rack_session
@rack_session ||= {}
end
def rack_session=(hash)
@rack_session = hash
end
def env_for(path, env)
old_env_for(path, env).merge({'rack.session' => rack_session})
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment