sinatra-sessionography 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-sessionography}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stephen Eley"]
@@ -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}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Stephen Eley