From ff2522f976ac02f956e49a396f77e924cd6cdd47 Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Sat, 22 May 2010 15:13:03 +0200 Subject: [PATCH] Add session tests --- test/app_sessions.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/app_sessions.rb diff --git a/test/app_sessions.rb b/test/app_sessions.rb new file mode 100644 index 00000000..0869b9a9 --- /dev/null +++ b/test/app_sessions.rb @@ -0,0 +1,46 @@ +require File.dirname(__FILE__) + '/test_helper' +require 'camping' +require 'camping/session' + +Camping.goes :Sessions + +module Sessions + include Camping::Session +end + +module Sessions::Controllers + class One + def get + @state.clear + @state.one = 42 + redirect R(Two) + end + end + + class Two + def get + @state.two = 56 + redirect R(Three) + end + end + + class Three + def get + @state.three = 99 + @state.values_at("one", "two", "three").inspect + end + end +end + +class Sessions::Test < TestCase + def test_session + get '/one' + follow_redirect! + + get '/two' + follow_redirect! + + get '/three' + assert_body "[42, 56, 99]" + end +end