From 9402f6eb5e2a6b3159bb19f6a8cd1e32b21c8122 Mon Sep 17 00:00:00 2001 From: "James A. Rosen" Date: Fri, 18 Jun 2010 20:54:46 -0400 Subject: [PATCH] added OmniAuth::Test package with PhonySession for test support --- oa-core/lib/omniauth/core.rb | 1 + oa-core/lib/omniauth/test.rb | 10 ++++++++++ oa-core/lib/omniauth/test/phony_session.rb | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 oa-core/lib/omniauth/test.rb create mode 100644 oa-core/lib/omniauth/test/phony_session.rb diff --git a/oa-core/lib/omniauth/core.rb b/oa-core/lib/omniauth/core.rb index aa10a75..4dacde6 100644 --- a/oa-core/lib/omniauth/core.rb +++ b/oa-core/lib/omniauth/core.rb @@ -6,6 +6,7 @@ module OmniAuth autoload :Builder, 'omniauth/builder' autoload :Strategy, 'omniauth/strategy' + autoload :Test, 'omniauth/test' module Strategies autoload :Password, 'omniauth/strategies/password' diff --git a/oa-core/lib/omniauth/test.rb b/oa-core/lib/omniauth/test.rb new file mode 100644 index 0000000..ea810e4 --- /dev/null +++ b/oa-core/lib/omniauth/test.rb @@ -0,0 +1,10 @@ +module OmniAuth + + # Support for testing OmniAuth strategies. + module Test + + autoload :PhonySession, 'omniauth/test/phony_session' + + end + +end diff --git a/oa-core/lib/omniauth/test/phony_session.rb b/oa-core/lib/omniauth/test/phony_session.rb new file mode 100644 index 0000000..768fa74 --- /dev/null +++ b/oa-core/lib/omniauth/test/phony_session.rb @@ -0,0 +1,8 @@ +class OmniAuth::Test::PhonySession + def initialize(app); @app = app end + def call(env) + @session ||= (env['rack.session'] || {}) + env['rack.session'] = @session + @app.call(env) + end +end