warden 1.2.3 → 1.2.4

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.
@@ -31,25 +31,25 @@ describe Warden::Manager do
31
31
  end
32
32
 
33
33
  it "should respond to :serialize" do
34
- serializer_respond_to?(:serialize).should == true
34
+ serializer_respond_to?(:serialize).should be_true
35
35
  end
36
36
 
37
37
  it "should respond to :deserialize" do
38
- serializer_respond_to?(:deserialize).should == true
38
+ serializer_respond_to?(:deserialize).should be_true
39
39
  end
40
40
 
41
41
  it "should respond to {scope}_deserialize if Manager.serialize_from_session is called with scope" do
42
42
  Rack::Builder.new do
43
43
  Warden::Manager.serialize_from_session ( :admin ) { |n| n }
44
44
  end
45
- serializer_respond_to?(:admin_deserialize).should == true
45
+ serializer_respond_to?(:admin_deserialize).should be_true
46
46
  end
47
47
 
48
48
  it "should respond to {scope}_serialize if Manager.serialize_into_session is called with scope" do
49
49
  Rack::Builder.new do
50
50
  Warden::Manager.serialize_into_session(:admin) { |n| n }
51
51
  end
52
- serializer_respond_to?(:admin_serialize).should == true
52
+ serializer_respond_to?(:admin_serialize).should be_true
53
53
  end
54
54
 
55
55
  def initialize_with_scope(scope, &block)
@@ -66,11 +66,11 @@ describe Warden::Manager do
66
66
  end
67
67
  serializer = Warden::SessionSerializer.new(@env)
68
68
  serializer.store("user", :admin)
69
- serialized_object.should == "user"
69
+ serialized_object.should eq("user")
70
70
  end
71
71
 
72
72
  it "should not have a {scope}_serialize by default" do
73
- serializer_respond_to?(:admin_serialize).should == false
73
+ serializer_respond_to?(:admin_serialize).should be_false
74
74
  end
75
75
 
76
76
  it "should execute {scope}_serialize when calling store with a scope" do
@@ -82,7 +82,7 @@ describe Warden::Manager do
82
82
 
83
83
  serializer = Warden::SessionSerializer.new(@env)
84
84
  serializer.store("user", :admin)
85
- serialized_object.should == "user"
85
+ serialized_object.should eq("user")
86
86
  end
87
87
 
88
88
 
@@ -100,7 +100,7 @@ describe Warden::Manager do
100
100
  @env['rack.session'][serializer.key_for(:admin)] = "test"
101
101
  serializer.fetch(:admin)
102
102
 
103
- serialized_object.should == "test"
103
+ serialized_object.should eq("test")
104
104
  end
105
105
 
106
106
  it "should execute deserialize if {scope}_deserialize is not present" do
@@ -117,7 +117,7 @@ describe Warden::Manager do
117
117
  @env['rack.session'][serializer.key_for(:admin)] = "test"
118
118
  serializer.fetch(:admin)
119
119
 
120
- serialized_object.should == "test"
120
+ serialized_object.should eq("test")
121
121
  end
122
122
 
123
123
  end
@@ -10,44 +10,44 @@ describe Warden::SessionSerializer do
10
10
 
11
11
  it "should store data for the default scope" do
12
12
  @session.store("user", :default)
13
- @env['rack.session'].should == { "warden.user.default.key"=>"user" }
13
+ expect(@env['rack.session']).to eq({ "warden.user.default.key"=>"user" })
14
14
  end
15
15
 
16
16
  it "should check if a data is stored or not" do
17
- @session.should_not be_stored(:default)
17
+ expect(@session).not_to be_stored(:default)
18
18
  @session.store("user", :default)
19
- @session.should be_stored(:default)
19
+ expect(@session).to be_stored(:default)
20
20
  end
21
21
 
22
22
  it "should load an user from store" do
23
- @session.fetch(:default).should be_nil
23
+ expect(@session.fetch(:default)).to be_nil
24
24
  @session.store("user", :default)
25
- @session.fetch(:default).should == "user"
25
+ expect(@session.fetch(:default)).to eq("user")
26
26
  end
27
27
 
28
28
  it "should store data based on the scope" do
29
29
  @session.store("user", :default)
30
- @session.fetch(:default).should == "user"
31
- @session.fetch(:another).should be_nil
30
+ expect(@session.fetch(:default)).to eq("user")
31
+ expect(@session.fetch(:another)).to be_nil
32
32
  end
33
33
 
34
34
  it "should delete data from store" do
35
35
  @session.store("user", :default)
36
- @session.fetch(:default).should == "user"
36
+ expect(@session.fetch(:default)).to eq("user")
37
37
  @session.delete(:default)
38
- @session.fetch(:default).should be_nil
38
+ expect(@session.fetch(:default)).to be_nil
39
39
  end
40
40
 
41
41
  it "should delete information from store if user cannot be retrieved" do
42
42
  @session.store("user", :default)
43
- @env['rack.session'].should have_key("warden.user.default.key")
44
- @session.instance_eval "def deserialize(key); nil; end"
43
+ expect(@env['rack.session']).to have_key("warden.user.default.key")
44
+ allow(@session).to receive(:deserialize).and_return(nil)
45
45
  @session.fetch(:default)
46
- @env['rack.session'].should_not have_key("warden.user.default.key")
46
+ expect(@env['rack.session']).not_to have_key("warden.user.default.key")
47
47
  end
48
48
 
49
49
  it "should support a nil session store" do
50
50
  @env['rack.session'] = nil
51
- @session.fetch(:default).should be_nil
51
+ expect(@session.fetch(:default)).to be_nil
52
52
  end
53
53
  end
@@ -17,7 +17,7 @@ describe Warden::Strategies::Base do
17
17
  end
18
18
  strategy = Warden::Strategies[:foo].new(env_with_params)
19
19
  strategy._run!
20
- strategy.headers["foo"].should == "bar"
20
+ expect(strategy.headers["foo"]).to eq("bar")
21
21
  end
22
22
 
23
23
  it "should allow us to clear the headers" do
@@ -28,9 +28,9 @@ describe Warden::Strategies::Base do
28
28
  end
29
29
  strategy = Warden::Strategies[:foo].new(env_with_params)
30
30
  strategy._run!
31
- strategy.headers["foo"].should == "bar"
31
+ expect(strategy.headers["foo"]).to eq("bar")
32
32
  strategy.headers.clear
33
- strategy.headers.should be_empty
33
+ expect(strategy.headers).to be_empty
34
34
  end
35
35
  end
36
36
 
@@ -42,7 +42,7 @@ describe Warden::Strategies::Base do
42
42
  end
43
43
  strategy = RAS[:foobar].new(env_with_params)
44
44
  strategy._run!
45
- strategy.user.should == "foo"
45
+ expect(strategy.user).to eq("foo")
46
46
  end
47
47
 
48
48
  it "should be performed after run" do
@@ -50,20 +50,20 @@ describe Warden::Strategies::Base do
50
50
  def authenticate!; end
51
51
  end
52
52
  strategy = RAS[:foobar].new(env_with_params)
53
- strategy.should_not be_performed
53
+ expect(strategy).not_to be_performed
54
54
  strategy._run!
55
- strategy.should be_performed
55
+ expect(strategy).to be_performed
56
56
  strategy.clear!
57
- strategy.should_not be_performed
57
+ expect(strategy).not_to be_performed
58
58
  end
59
59
 
60
60
  it "should set the scope" do
61
61
  RAS.add(:foobar) do
62
62
  def authenticate!
63
- self.scope.should == :user
63
+ expect(self.scope).to eq(:user) # TODO: Not being called at all. What's this?
64
64
  end
65
65
  end
66
- strategy = RAS[:foobar].new(env_with_params, :user)
66
+ _strategy = RAS[:foobar].new(env_with_params, :user)
67
67
  end
68
68
 
69
69
  it "should allow you to set a message" do
@@ -74,7 +74,7 @@ describe Warden::Strategies::Base do
74
74
  end
75
75
  strategy = RAS[:foobar].new(env_with_params)
76
76
  strategy._run!
77
- strategy.message.should == "foo message"
77
+ expect(strategy.message).to eq("foo message")
78
78
  end
79
79
 
80
80
  it "should provide access to the errors" do
@@ -87,7 +87,7 @@ describe Warden::Strategies::Base do
87
87
  env['warden'] = Warden::Proxy.new(env, Warden::Manager.new({}))
88
88
  strategy = RAS[:foobar].new(env)
89
89
  strategy._run!
90
- strategy.errors.on(:foo).should == ["foo has an error"]
90
+ expect(strategy.errors.on(:foo)).to eq(["foo has an error"])
91
91
  end
92
92
 
93
93
  describe "halting" do
@@ -99,7 +99,7 @@ describe Warden::Strategies::Base do
99
99
  end
100
100
  str = RAS[:foobar].new(env_with_params)
101
101
  str._run!
102
- str.should be_halted
102
+ expect(str).to be_halted
103
103
  end
104
104
 
105
105
  it "should not be halted if halt was not called" do
@@ -110,7 +110,7 @@ describe Warden::Strategies::Base do
110
110
  end
111
111
  str = RAS[:foobar].new(env_with_params)
112
112
  str._run!
113
- str.should_not be_halted
113
+ expect(str).not_to be_halted
114
114
  end
115
115
 
116
116
  end
@@ -124,8 +124,8 @@ describe Warden::Strategies::Base do
124
124
  end
125
125
  str = RAS[:foobar].new(env_with_params)
126
126
  str._run!
127
- str.should_not be_halted
128
- str.user.should be_nil
127
+ expect(str).not_to be_halted
128
+ expect(str.user).to be_nil
129
129
  end
130
130
  end
131
131
 
@@ -138,7 +138,7 @@ describe Warden::Strategies::Base do
138
138
  end
139
139
  str = RAS[:foobar].new(env_with_params)
140
140
  str._run!
141
- str.user.should be_nil
141
+ expect(str.user).to be_nil
142
142
  end
143
143
 
144
144
  it "should mark the strategy as halted when redirecting" do
@@ -149,7 +149,7 @@ describe Warden::Strategies::Base do
149
149
  end
150
150
  str = RAS[:foobar].new(env_with_params)
151
151
  str._run!
152
- str.should be_halted
152
+ expect(str).to be_halted
153
153
  end
154
154
 
155
155
  it "should escape redirected url parameters" do
@@ -160,7 +160,7 @@ describe Warden::Strategies::Base do
160
160
  end
161
161
  str = RAS[:foobar].new(env_with_params)
162
162
  str._run!
163
- str.headers["Location"].should == "/foo/bar?foo=bar"
163
+ expect(str.headers["Location"]).to eq("/foo/bar?foo=bar")
164
164
  end
165
165
 
166
166
  it "should allow you to set a message" do
@@ -171,8 +171,8 @@ describe Warden::Strategies::Base do
171
171
  end
172
172
  str = RAS[:foobar].new(env_with_params)
173
173
  str._run!
174
- str.headers["Location"].should == "/foo/bar?foo=bar"
175
- str.message.should == "You are being redirected foo"
174
+ expect(str.headers["Location"]).to eq("/foo/bar?foo=bar")
175
+ expect(str.message).to eq("You are being redirected foo")
176
176
  end
177
177
 
178
178
  it "should set the action as :redirect" do
@@ -183,7 +183,7 @@ describe Warden::Strategies::Base do
183
183
  end
184
184
  str = RAS[:foobar].new(env_with_params)
185
185
  str._run!
186
- str.result.should == :redirect
186
+ expect(str.result).to be(:redirect)
187
187
  end
188
188
  end
189
189
 
@@ -207,42 +207,42 @@ describe Warden::Strategies::Base do
207
207
 
208
208
  it "should allow you to fail hard" do
209
209
  @hard._run!
210
- @hard.user.should be_nil
210
+ expect(@hard.user).to be_nil
211
211
  end
212
212
 
213
213
  it "should halt the strategies when failing hard" do
214
214
  @hard._run!
215
- @hard.should be_halted
215
+ expect(@hard).to be_halted
216
216
  end
217
217
 
218
218
  it "should allow you to set a message when failing hard" do
219
219
  @hard._run!
220
- @hard.message.should == "You are not cool enough"
220
+ expect(@hard.message).to eq("You are not cool enough")
221
221
  end
222
222
 
223
223
  it "should set the action as :failure when failing hard" do
224
224
  @hard._run!
225
- @hard.result.should == :failure
225
+ expect(@hard.result).to be(:failure)
226
226
  end
227
227
 
228
228
  it "should allow you to fail soft" do
229
229
  @soft._run!
230
- @soft.user.should be_nil
230
+ expect(@soft.user).to be_nil
231
231
  end
232
232
 
233
233
  it "should not halt the strategies when failing soft" do
234
234
  @soft._run!
235
- @soft.should_not be_halted
235
+ expect(@soft).not_to be_halted
236
236
  end
237
237
 
238
238
  it "should allow you to set a message when failing soft" do
239
239
  @soft._run!
240
- @soft.message.should == "You are too soft"
240
+ expect(@soft.message).to eq("You are too soft")
241
241
  end
242
242
 
243
243
  it "should set the action as :failure when failing soft" do
244
244
  @soft._run!
245
- @soft.result.should == :failure
245
+ expect(@soft.result).to be(:failure)
246
246
  end
247
247
  end
248
248
 
@@ -262,22 +262,22 @@ describe Warden::Strategies::Base do
262
262
 
263
263
  it "should be authenticated after success" do
264
264
  @str._run!
265
- @str.user.should_not be_nil
265
+ expect(@str.user).not_to be_nil
266
266
  end
267
267
 
268
268
  it "should allow you to set a message when succeeding" do
269
269
  @str._run!
270
- @str.message.should == "Welcome to the club!"
270
+ expect(@str.message).to eq("Welcome to the club!")
271
271
  end
272
272
 
273
273
  it "should store the user" do
274
274
  @str._run!
275
- @str.user.should == "Foo User"
275
+ expect(@str.user).to eq("Foo User")
276
276
  end
277
277
 
278
278
  it "should set the action as :success" do
279
279
  @str._run!
280
- @str.result.should == :success
280
+ expect(@str.result).to be(:success)
281
281
  end
282
282
  end
283
283
 
@@ -293,20 +293,20 @@ describe Warden::Strategies::Base do
293
293
  end
294
294
 
295
295
  it "should allow me to set a custom rack response" do
296
- @str.user.should be_nil
296
+ expect(@str.user).to be_nil
297
297
  end
298
298
 
299
299
  it "should halt the strategy" do
300
- @str.should be_halted
300
+ expect(@str).to be_halted
301
301
  end
302
302
 
303
303
  it "should provide access to the custom rack response" do
304
- @str.custom_response.should == [521, {"foo" => "bar"}, ["BAD"]]
304
+ expect(@str.custom_response).to eq([521, {"foo" => "bar"}, ["BAD"]])
305
305
  end
306
306
 
307
307
  it "should set the action as :custom" do
308
308
  @str._run!
309
- @str.result.should == :custom
309
+ expect(@str.result).to eq(:custom)
310
310
  end
311
311
  end
312
312
 
@@ -8,14 +8,14 @@ describe Warden::Strategies do
8
8
  success("foo")
9
9
  end
10
10
  end
11
- Warden::Strategies[:strategy1].ancestors.should include(Warden::Strategies::Base)
11
+ expect(Warden::Strategies[:strategy1].ancestors).to include(Warden::Strategies::Base)
12
12
  end
13
13
 
14
14
  it "should raise an error if I add a strategy via a block, that does not have an authenticate! method" do
15
- lambda do
15
+ expect {
16
16
  Warden::Strategies.add(:strategy2) do
17
17
  end
18
- end.should raise_error
18
+ }.to raise_error(NoMethodError)
19
19
  end
20
20
 
21
21
  it "should raise an error if I add a strategy that does not extend Warden::Strategies::Base" do
@@ -33,25 +33,26 @@ describe Warden::Strategies do
33
33
  def authenticate!; end
34
34
  end
35
35
  strategy = Warden::Strategies[:strategy3]
36
- strategy.should_not be_nil
37
- strategy.ancestors.should include(Warden::Strategies::Base)
36
+ expect(strategy).not_to be_nil
37
+ expect(strategy.ancestors).to include(Warden::Strategies::Base)
38
38
  end
39
39
 
40
40
  it "should allow me to add a strategy with the required methods" do
41
41
  class MyStrategy < Warden::Strategies::Base
42
42
  def authenticate!; end
43
43
  end
44
- lambda do
44
+
45
+ expect {
45
46
  Warden::Strategies.add(:strategy4, MyStrategy)
46
- end.should_not raise_error
47
+ }.not_to raise_error
47
48
  end
48
49
 
49
50
  it "should not allow a strategy that does not have an authenticate! method" do
50
51
  class MyOtherStrategy
51
52
  end
52
- lambda do
53
+ expect {
53
54
  Warden::Strategies.add(:strategy5, MyOtherStrategy)
54
- end.should raise_error
55
+ }.to raise_error(NoMethodError)
55
56
  end
56
57
 
57
58
  it "should allow me to change a class when providing a block and class" do
@@ -62,7 +63,7 @@ describe Warden::Strategies do
62
63
  def authenticate!; end
63
64
  end
64
65
 
65
- Warden::Strategies[:foo].ancestors.should include(MyStrategy)
66
+ expect(Warden::Strategies[:foo].ancestors).to include(MyStrategy)
66
67
  end
67
68
 
68
69
  it "should allow me to update a previously given strategy" do
@@ -77,7 +78,7 @@ describe Warden::Strategies do
77
78
  include new_module
78
79
  end
79
80
 
80
- Warden::Strategies[:strategy6].ancestors.should include(new_module)
81
+ expect(Warden::Strategies[:strategy6].ancestors).to include(new_module)
81
82
  end
82
83
 
83
84
  it "should allow me to clear the strategies" do
@@ -86,8 +87,8 @@ describe Warden::Strategies do
86
87
  :foo
87
88
  end
88
89
  end
89
- Warden::Strategies[:foobar].should_not be_nil
90
+ expect(Warden::Strategies[:foobar]).not_to be_nil
90
91
  Warden::Strategies.clear!
91
- Warden::Strategies[:foobar].should be_nil
92
+ expect(Warden::Strategies[:foobar]).to be_nil
92
93
  end
93
94
  end