Created
March 21, 2014 22:30
-
-
Save myobie/9697834 to your computer and use it in GitHub Desktop.
My methods I am accumulating for testing sinatra applications.
This file contains 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
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