sinatra-sessionography 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/sinatra/sessionography.rb +3 -1
- data/sinatra-sessionography.gemspec +1 -1
- data/spec/sessionography_spec.rb +6 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -24,9 +24,11 @@ module Sinatra
|
|
24
24
|
# empty hash or to the contents of 'rack.session' if you don't do this.)
|
25
25
|
#
|
26
26
|
# @param [Hash] val The hash to use as the session. Note that we clone the object; we don't maintain
|
27
|
-
# a live link to the same hash.
|
27
|
+
# a live link to the same hash. Objects that can't be cloned (such as nil) will set the session to nil.
|
28
28
|
def self.session=(val)
|
29
29
|
@session = val.clone
|
30
|
+
rescue TypeError # Nil doesn't respond to clone
|
31
|
+
@session = nil
|
30
32
|
end
|
31
33
|
|
32
34
|
# Replaces Sinatra's #session helper to completely bypass Rack::Session, thus mocking out
|
data/spec/sessionography_spec.rb
CHANGED
@@ -27,6 +27,12 @@ describe Sinatra::Sessionography do
|
|
27
27
|
last_response.body.should == "{:sheep=>:baa}"
|
28
28
|
end
|
29
29
|
|
30
|
+
it "returns an empty hash when set to nil" do
|
31
|
+
Sinatra::Sessionography.session = nil
|
32
|
+
get "/session"
|
33
|
+
last_response.body.should == "{}"
|
34
|
+
end
|
35
|
+
|
30
36
|
it "persists state across requests" do
|
31
37
|
post "/session", {:snail=>:slurp, :monkey=>:howl, :deer=>'Shoot me!'}
|
32
38
|
post "/session", {:cow=>:moo, :deer=>nil}
|