warden 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,40 +9,40 @@ describe Warden::Config do
9
9
 
10
10
  it "should behave like a hash" do
11
11
  @config[:foo] = :bar
12
- @config[:foo].should == :bar
12
+ expect(@config[:foo]).to eq(:bar)
13
13
  end
14
14
 
15
15
  it "should provide hash accessors" do
16
16
  @config.failure_app = :foo
17
- @config[:failure_app].should == :foo
17
+ expect(@config[:failure_app]).to eq(:foo)
18
18
  @config[:failure_app] = :bar
19
- @config.failure_app.should == :bar
19
+ expect(@config.failure_app).to eq(:bar)
20
20
  end
21
21
 
22
22
  it "should allow to read and set default strategies" do
23
23
  @config.default_strategies :foo, :bar
24
- @config.default_strategies.should == [:foo, :bar]
24
+ expect(@config.default_strategies).to eq([:foo, :bar])
25
25
  end
26
26
 
27
27
  it "should allow to silence missing strategies" do
28
28
  @config.silence_missing_strategies!
29
- @config.silence_missing_strategies?.should be_true
29
+ expect(@config.silence_missing_strategies?).to eq(true)
30
30
  end
31
31
 
32
32
  it "should set the default_scope" do
33
- @config.default_scope.should == :default
33
+ expect(@config.default_scope).to eq(:default)
34
34
  @config.default_scope = :foo
35
- @config.default_scope.should == :foo
35
+ expect(@config.default_scope).to eq(:foo)
36
36
  end
37
37
 
38
38
  it "should merge given options on initialization" do
39
- Warden::Config.new(:foo => :bar)[:foo].should == :bar
39
+ expect(Warden::Config.new(:foo => :bar)[:foo]).to eq(:bar)
40
40
  end
41
41
 
42
42
  it "should setup defaults with the scope_defaults method" do
43
43
  c = Warden::Config.new
44
44
  c.scope_defaults :foo, :strategies => [:foo, :bar], :store => false
45
- c.default_strategies(:scope => :foo).should == [:foo, :bar]
46
- c.scope_defaults(:foo).should == {:store => false}
45
+ expect(c.default_strategies(:scope => :foo)).to eq([:foo, :bar])
46
+ expect(c.scope_defaults(:foo)).to eq(store: false)
47
47
  end
48
48
  end
@@ -8,40 +8,40 @@ describe Warden::Proxy::Errors do
8
8
  end
9
9
 
10
10
  it "should report that it is empty on first creation" do
11
- @errors.empty?.should == true
11
+ expect(@errors).to be_empty
12
12
  end
13
13
 
14
14
  it "should continue to report that it is empty even after being checked" do
15
15
  @errors.on(:foo)
16
- @errors.empty?.should == true
16
+ expect(@errors).to be_empty
17
17
  end
18
18
 
19
19
  it "should add an error" do
20
20
  @errors.add(:login, "Login or password incorrect")
21
- @errors[:login].should == ["Login or password incorrect"]
21
+ expect(@errors[:login]).to eq(["Login or password incorrect"])
22
22
  end
23
23
 
24
24
  it "should allow many errors to be added to the same field" do
25
25
  @errors.add(:login, "bad 1")
26
26
  @errors.add(:login, "bad 2")
27
- @errors.on(:login).should == ["bad 1", "bad 2"]
27
+ expect(@errors.on(:login)).to eq(["bad 1", "bad 2"])
28
28
  end
29
29
 
30
30
  it "should give the full messages for an error" do
31
31
  @errors.add(:login, "login wrong")
32
32
  @errors.add(:password, "password wrong")
33
33
  ["password wrong", "login wrong"].each do |msg|
34
- @errors.full_messages.should include(msg)
34
+ expect(@errors.full_messages).to include(msg)
35
35
  end
36
36
  end
37
37
 
38
38
  it "should return the error for a specific field / label" do
39
39
  @errors.add(:login, "wrong")
40
- @errors.on(:login).should == ["wrong"]
40
+ expect(@errors.on(:login)).to eq(["wrong"])
41
41
  end
42
42
 
43
43
  it "should return nil for a specific field if it's not been set" do
44
- @errors.on(:not_there).should be_nil
44
+ expect(@errors.on(:not_there)).to be_nil
45
45
  end
46
46
 
47
47
  end
@@ -21,13 +21,13 @@ describe "standard authentication hooks" do
21
21
  RAM.after_set_user do |user, auth, opts|
22
22
  "boo"
23
23
  end
24
- RAM._after_set_user.should have(1).item
24
+ expect(RAM._after_set_user.length).to eq(1)
25
25
  end
26
26
 
27
27
  it "should allow me to add multiple after_set_user hooks" do
28
28
  RAM.after_set_user{|user, auth, opts| "foo"}
29
29
  RAM.after_set_user{|u,a| "bar"}
30
- RAM._after_set_user.should have(2).items
30
+ expect(RAM._after_set_user.length).to eq(2)
31
31
  end
32
32
 
33
33
  it "should run each after_set_user hook after the user is set" do
@@ -40,9 +40,9 @@ describe "standard authentication hooks" do
40
40
  end
41
41
  env = env_with_params
42
42
  setup_rack(app).call(env)
43
- env['warden'].user.should be_nil
44
- env['warden.spec.hook.foo'].should == "run foo"
45
- env['warden.spec.hook.bar'].should == "run bar"
43
+ expect(env['warden'].user).to be_nil
44
+ expect(env['warden.spec.hook.foo']).to eq("run foo")
45
+ expect(env['warden.spec.hook.bar']).to eq("run bar")
46
46
  end
47
47
 
48
48
  it "should not run the event specified with except" do
@@ -76,22 +76,22 @@ describe "standard authentication hooks" do
76
76
  end
77
77
  env = env_with_params
78
78
  setup_rack(app).call(env)
79
- env['warden.spec.order'].should == [1,2,3]
79
+ expect(env['warden.spec.order']).to eq([1,2,3])
80
80
  end
81
81
 
82
82
  context "after_authentication" do
83
83
  it "should be a wrapper to after_set_user behavior" do
84
84
  RAM.after_authentication{|u,a,o| a.env['warden.spec.hook.baz'] = "run baz"}
85
85
  RAM.after_authentication{|u,a,o| a.env['warden.spec.hook.paz'] = "run paz"}
86
- RAM.after_authentication{|u,a,o| o[:event].should == :authentication }
86
+ RAM.after_authentication{|u,a,o| expect(o[:event]).to eq(:authentication) }
87
87
  app = lambda do |e|
88
88
  e['warden'].authenticate(:pass)
89
89
  valid_response
90
90
  end
91
91
  env = env_with_params
92
92
  setup_rack(app).call(env)
93
- env['warden.spec.hook.baz'].should == 'run baz'
94
- env['warden.spec.hook.paz'].should == 'run paz'
93
+ expect(env['warden.spec.hook.baz']).to eq('run baz')
94
+ expect(env['warden.spec.hook.paz']).to eq('run paz')
95
95
  end
96
96
 
97
97
  it "should not be invoked on default after_set_user scenario" do
@@ -115,7 +115,7 @@ describe "standard authentication hooks" do
115
115
  end
116
116
  env = env_with_params
117
117
  setup_rack(app).call(env)
118
- env['warden.spec.order'].should == [1,2,3]
118
+ expect(env['warden.spec.order']).to eq([1,2,3])
119
119
  end
120
120
 
121
121
  it "should allow me to log out a user in an after_set_user block" do
@@ -127,7 +127,7 @@ describe "standard authentication hooks" do
127
127
  end
128
128
  env = env_with_params
129
129
  setup_rack(app).call(env)
130
- env['warden'].authenticated?.should be_false
130
+ expect(env['warden']).not_to be_authenticated
131
131
  end
132
132
  end
133
133
 
@@ -135,13 +135,13 @@ describe "standard authentication hooks" do
135
135
  it "should be a wrapper to after_set_user behavior" do
136
136
  RAM.after_fetch{|u,a,o| a.env['warden.spec.hook.baz'] = "run baz"}
137
137
  RAM.after_fetch{|u,a,o| a.env['warden.spec.hook.paz'] = "run paz"}
138
- RAM.after_fetch{|u,a,o| o[:event].should == :fetch }
138
+ RAM.after_fetch{|u,a,o| expect(o[:event]).to eq(:fetch) }
139
139
  env = env_with_params
140
140
  setup_rack(lambda { |e| valid_response }).call(env)
141
141
  env['rack.session']['warden.user.default.key'] = "Foo"
142
- env['warden'].user.should == "Foo"
143
- env['warden.spec.hook.baz'].should == 'run baz'
144
- env['warden.spec.hook.paz'].should == 'run paz'
142
+ expect(env['warden'].user).to eq("Foo")
143
+ expect(env['warden.spec.hook.baz']).to eq('run baz')
144
+ expect(env['warden.spec.hook.paz']).to eq('run paz')
145
145
  end
146
146
 
147
147
  it "should not be invoked on default after_set_user scenario" do
@@ -159,7 +159,7 @@ describe "standard authentication hooks" do
159
159
  env = env_with_params
160
160
  setup_rack(lambda { |e| valid_response }).call(env)
161
161
  env['rack.session']['warden.user.default.key'] = nil
162
- env['warden'].user.should be_nil
162
+ expect(env['warden'].user).to be_nil
163
163
  end
164
164
 
165
165
  it "should run filters in the given order" do
@@ -174,7 +174,7 @@ describe "standard authentication hooks" do
174
174
  end
175
175
  env = env_with_params
176
176
  setup_rack(app).call(env)
177
- env['warden.spec.order'].should == [1,2,3]
177
+ expect(env['warden.spec.order']).to eq([1,2,3])
178
178
  end
179
179
  end
180
180
  end
@@ -195,7 +195,7 @@ describe "standard authentication hooks" do
195
195
  env = env_with_params
196
196
  setup_rack(lambda { |e| valid_response }).call(env)
197
197
  env['rack.session']['warden.user.default.key'] = "Foo"
198
- env['warden'].user.should == "Foo"
198
+ expect(env['warden'].user).to eq("Foo")
199
199
  end
200
200
 
201
201
  it "should be called if fetched user is nil" do
@@ -203,8 +203,8 @@ describe "standard authentication hooks" do
203
203
  RAM.after_failed_fetch{|u,a,o| calls += 1 }
204
204
  env = env_with_params
205
205
  setup_rack(lambda { |e| valid_response }).call(env)
206
- env['warden'].user.should be_nil
207
- calls.should == 1
206
+ expect(env['warden'].user).to be_nil
207
+ expect(calls).to eq(1)
208
208
  end
209
209
  end
210
210
 
@@ -220,13 +220,13 @@ describe "standard authentication hooks" do
220
220
 
221
221
  it "should allow me to add a before_failure hook" do
222
222
  RAM.before_failure{|env, opts| "foo"}
223
- RAM._before_failure.should have(1).item
223
+ expect(RAM._before_failure.length).to eq(1)
224
224
  end
225
225
 
226
226
  it "should allow me to add multiple before_failure hooks" do
227
227
  RAM.before_failure{|env, opts| "foo"}
228
228
  RAM.before_failure{|env, opts| "bar"}
229
- RAM._before_failure.should have(2).items
229
+ expect(RAM._before_failure.length).to eq(2)
230
230
  end
231
231
 
232
232
  it "should run each before_failure hooks before failing" do
@@ -235,8 +235,8 @@ describe "standard authentication hooks" do
235
235
  app = lambda{|e| e['warden'].authenticate!(:failz); valid_response}
236
236
  env = env_with_params
237
237
  setup_rack(app).call(env)
238
- env['warden.spec.before_failure.foo'].should == "foo"
239
- env['warden.spec.before_failure.bar'].should == "bar"
238
+ expect(env['warden.spec.before_failure.foo']).to eq("foo")
239
+ expect(env['warden.spec.before_failure.bar']).to eq("bar")
240
240
  end
241
241
 
242
242
  it "should run filters in the given order" do
@@ -250,7 +250,7 @@ describe "standard authentication hooks" do
250
250
  end
251
251
  env = env_with_params
252
252
  setup_rack(app).call(env)
253
- env['warden.spec.order'].should == [1,2,3]
253
+ expect(env['warden.spec.order']).to eq([1,2,3])
254
254
  end
255
255
  end
256
256
 
@@ -266,13 +266,13 @@ describe "standard authentication hooks" do
266
266
 
267
267
  it "should allow me to add an before_logout hook" do
268
268
  RAM.before_logout{|user, auth, scopes| "foo"}
269
- RAM._before_logout.should have(1).item
269
+ expect(RAM._before_logout.length).to eq(1)
270
270
  end
271
271
 
272
272
  it "should allow me to add multiple after_authentication hooks" do
273
273
  RAM.before_logout{|u,a,o| "bar"}
274
274
  RAM.before_logout{|u,a,o| "baz"}
275
- RAM._before_logout.should have(2).items
275
+ expect(RAM._before_logout.length).to eq(2)
276
276
  end
277
277
 
278
278
  it "should run each before_logout hook before logout is run" do
@@ -282,8 +282,8 @@ describe "standard authentication hooks" do
282
282
  env = env_with_params
283
283
  setup_rack(app).call(env)
284
284
  env['warden'].logout
285
- env['warden.spec.hook.lorem'].should == 'run lorem'
286
- env['warden.spec.hook.ipsum'].should == 'run ipsum'
285
+ expect(env['warden.spec.hook.lorem']).to eq('run lorem')
286
+ expect(env['warden.spec.hook.ipsum']).to eq('run ipsum')
287
287
  end
288
288
 
289
289
  it "should run before_logout hook for a specified scope" do
@@ -301,12 +301,12 @@ describe "standard authentication hooks" do
301
301
  setup_rack(app).call(env)
302
302
 
303
303
  env['warden'].logout(:scope1)
304
- env['warden.spec.hook.a'].should == [:scope1]
305
- env['warden.spec.hook.b'].should == []
304
+ expect(env['warden.spec.hook.a']).to eq([:scope1])
305
+ expect(env['warden.spec.hook.b']).to eq([])
306
306
 
307
307
  env['warden'].logout(:scope2)
308
- env['warden.spec.hook.a'].should == [:scope1]
309
- env['warden.spec.hook.b'].should == [:scope2]
308
+ expect(env['warden.spec.hook.a']).to eq([:scope1])
309
+ expect(env['warden.spec.hook.b']).to eq([:scope2])
310
310
  end
311
311
 
312
312
  it "should run filters in the given order" do
@@ -321,14 +321,14 @@ describe "standard authentication hooks" do
321
321
  end
322
322
  env = env_with_params
323
323
  setup_rack(app).call(env)
324
- env['warden.spec.order'].should == [1,2,3]
324
+ expect(env['warden.spec.order']).to eq([1,2,3])
325
325
  end
326
326
  end
327
327
 
328
328
  describe "on_request" do
329
329
  before(:each) do
330
- @old_on_request = RAM._on_request.dup
331
330
  RAM = Warden::Manager unless defined?(RAM)
331
+ @old_on_request = RAM._on_request.dup
332
332
  RAM._on_request.clear
333
333
  end
334
334
 
@@ -339,13 +339,13 @@ describe "standard authentication hooks" do
339
339
 
340
340
  it "should allow me to add an on_request hook" do
341
341
  RAM.on_request{|proxy| "foo"}
342
- RAM._on_request.should have(1).item
342
+ expect(RAM._on_request.length).to eq(1)
343
343
  end
344
344
 
345
345
  it "should allow me to add multiple on_request hooks" do
346
346
  RAM.on_request{|proxy| "foo"}
347
347
  RAM.on_request{|proxy| "bar"}
348
- RAM._on_request.should have(2).items
348
+ expect(RAM._on_request.length).to eq(2)
349
349
  end
350
350
 
351
351
  it "should run each on_request hooks when initializing" do
@@ -354,8 +354,8 @@ describe "standard authentication hooks" do
354
354
  app = lambda{|e| valid_response}
355
355
  env = env_with_params
356
356
  setup_rack(app).call(env)
357
- env['warden.spec.on_request.foo'].should == "foo"
358
- env['warden.spec.on_request.bar'].should == "bar"
357
+ expect(env['warden.spec.on_request.foo']).to eq("foo")
358
+ expect(env['warden.spec.on_request.bar']).to eq("bar")
359
359
  end
360
360
 
361
361
  it "should run filters in the given order" do
@@ -367,7 +367,7 @@ describe "standard authentication hooks" do
367
367
  end
368
368
  env = Rack::MockRequest.env_for("/", "warden.spec.order" => [])
369
369
  setup_rack(app).call(env)
370
- env['warden.spec.order'].should == [1,2,3]
370
+ expect(env['warden.spec.order']).to eq([1,2,3])
371
371
  end
372
372
  end
373
373
  end
@@ -10,7 +10,7 @@ describe Warden::Manager do
10
10
  it "should insert a Proxy object into the rack env" do
11
11
  env = env_with_params
12
12
  setup_rack(success_app).call(env)
13
- env["warden"].should be_an_instance_of(Warden::Proxy)
13
+ expect(env["warden"]).to be_an_instance_of(Warden::Proxy)
14
14
  end
15
15
 
16
16
  describe "thrown auth" do
@@ -30,22 +30,32 @@ describe Warden::Manager do
30
30
  describe "Failure" do
31
31
  it "should respond with a 401 response if the strategy fails authentication" do
32
32
  env = env_with_params("/", :foo => "bar")
33
- app = lambda do |env|
34
- env['warden'].authenticate(:failz)
33
+ app = lambda do |_env|
34
+ _env['warden'].authenticate(:failz)
35
35
  throw(:warden, :action => :unauthenticated)
36
36
  end
37
- result = setup_rack(app, :failure_app => @fail_app).call(env)
38
- result.first.should == 401
37
+ result = setup_rack(app, :failure_app => @fail_app).call(env) # TODO: What is @fail_app?
38
+ expect(result.first).to eq(401)
39
39
  end
40
40
 
41
41
  it "should use the failure message given to the failure method" do
42
42
  env = env_with_params("/", {})
43
- app = lambda do |env|
44
- env['warden'].authenticate(:failz)
43
+ app = lambda do |_env|
44
+ _env['warden'].authenticate(:failz)
45
45
  throw(:warden)
46
46
  end
47
- result = setup_rack(app, :failure_app => @fail_app).call(env)
48
- result.last.should == ["You Fail!"]
47
+ result = setup_rack(app, :failure_app => @fail_app).call(env) # TODO: What is @fail_app?
48
+ expect(result.last).to eq(["You Fail!"])
49
+ end
50
+
51
+ it "should set the message from the winning strategy in warden.options hash" do
52
+ env = env_with_params("/", {})
53
+ app = lambda do |_env|
54
+ _env['warden'].authenticate(:failz)
55
+ throw(:warden)
56
+ end
57
+ setup_rack(app, :failure_app => @fail_app).call(env) # TODO: What is @fail_app?
58
+ expect(env["warden.options"][:message]).to eq("The Fails Strategy Has Failed You")
49
59
  end
50
60
 
51
61
  it "should render the failure app when there's a failure" do
@@ -56,29 +66,29 @@ describe Warden::Manager do
56
66
  [401, {"Content-Type" => "text/plain"}, ["Failure App"]]
57
67
  end
58
68
  result = setup_rack(app, :failure_app => fail_app).call(env_with_params)
59
- result.last.should == ["Failure App"]
69
+ expect(result.last).to eq(["Failure App"])
60
70
  end
61
71
 
62
72
  it "should call failure app if warden is thrown even after successful authentication" do
63
73
  env = env_with_params("/", {})
64
- app = lambda do |env|
65
- env['warden'].authenticate(:pass)
74
+ app = lambda do |_env|
75
+ _env['warden'].authenticate(:pass)
66
76
  throw(:warden)
67
77
  end
68
78
  result = setup_rack(app, :failure_app => @fail_app).call(env)
69
- result.first.should == 401
70
- result.last.should == ["You Fail!"]
79
+ expect(result.first).to eq(401)
80
+ expect(result.last).to eq(["You Fail!"])
71
81
  end
72
82
 
73
83
  it "should set the attempted url in warden.options hash" do
74
84
  env = env_with_params("/access/path", {})
75
- app = lambda do |env|
76
- env['warden'].authenticate(:pass)
85
+ app = lambda do |_env|
86
+ _env['warden'].authenticate(:pass)
77
87
  throw(:warden)
78
88
  end
79
- result = setup_rack(app, :failure_app => @fail_app).call(env)
80
- result.first.should == 401
81
- env["warden.options"][:attempted_path].should == "/access/path"
89
+ result = setup_rack(app, :failure_app => @fail_app).call(env) # TODO: What is @fail_app?
90
+ expect(result.first).to eq(401)
91
+ expect(env["warden.options"][:attempted_path]).to eq("/access/path")
82
92
  end
83
93
 
84
94
  it "should catch a resubmitted request" do
@@ -122,21 +132,21 @@ describe Warden::Manager do
122
132
  end
123
133
 
124
134
  result = builder.to_app.call(env)
125
- result[0].should == 401
126
- result[2].body.should == ["Bad"]
127
- $throw_count.should == 2
135
+ expect(result[0]).to eq(401)
136
+ expect(result[2].body).to eq(["Bad"])
137
+ expect($throw_count).to eq(2)
128
138
  end
129
139
 
130
140
  it "should use the default scopes action when a bare throw is used" do
131
141
  env = env_with_params("/", :foo => "bar")
132
142
  action = nil
133
143
 
134
- failure = lambda do |env|
135
- action = env['PATH_INFO']
144
+ failure = lambda do |_env|
145
+ action = _env['PATH_INFO']
136
146
  [401, {}, ['fail']]
137
147
  end
138
148
 
139
- app = lambda do |env|
149
+ app = lambda do |_env|
140
150
  throw(:warden)
141
151
  end
142
152
  result = setup_rack(app,
@@ -144,8 +154,8 @@ describe Warden::Manager do
144
154
  :configurator => lambda{ |c| c.scope_defaults(:default, :action => 'my_action', :strategies => [:password]) }
145
155
  ).call(env)
146
156
 
147
- action.should == "/my_action"
148
- result.first.should == 401
157
+ expect(action).to eq("/my_action")
158
+ expect(result.first).to eq(401)
149
159
  end
150
160
  end # failure
151
161
  end
@@ -169,9 +179,9 @@ describe Warden::Manager do
169
179
  end
170
180
  end
171
181
  result = @app.call(env_with_params)
172
- result[0].should == 302
173
- result[1]["Location"].should == "/foo/bar?foo=bar"
174
- result[2].should == ["custom redirection message"]
182
+ expect(result[0]).to be(302)
183
+ expect(result[1]["Location"]).to eq("/foo/bar?foo=bar")
184
+ expect(result[2]).to eq(["custom redirection message"])
175
185
  end
176
186
 
177
187
  it "should redirect with a default message" do
@@ -181,9 +191,9 @@ describe Warden::Manager do
181
191
  end
182
192
  end
183
193
  result = @app.call(env_with_params)
184
- result[0].should == 302
185
- result[1]['Location'].should == "/foo/bar?foo=bar"
186
- result[2].should == ["You are being redirected to /foo/bar?foo=bar"]
194
+ expect(result[0]).to eq(302)
195
+ expect(result[1]['Location']).to eq("/foo/bar?foo=bar")
196
+ expect(result[2]).to eq(["You are being redirected to /foo/bar?foo=bar"])
187
197
  end
188
198
 
189
199
  it "should redirect with a permanent redirect" do
@@ -193,7 +203,7 @@ describe Warden::Manager do
193
203
  end
194
204
  end
195
205
  result = @app.call(env_with_params)
196
- result[0].should == 301
206
+ expect(result[0]).to eq(301)
197
207
  end
198
208
 
199
209
  it "should redirect with a content type" do
@@ -203,9 +213,9 @@ describe Warden::Manager do
203
213
  end
204
214
  end
205
215
  result = @app.call(env_with_params)
206
- result[0].should == 302
207
- result[1]["Location"].should == "/foo/bar?foo=bar"
208
- result[1]["Content-Type"].should == "text/xml"
216
+ expect(result[0]).to eq(302)
217
+ expect(result[1]["Location"]).to eq("/foo/bar?foo=bar")
218
+ expect(result[1]["Content-Type"]).to eq("text/xml")
209
219
  end
210
220
 
211
221
  it "should redirect with a default content type" do
@@ -215,9 +225,9 @@ describe Warden::Manager do
215
225
  end
216
226
  end
217
227
  result = @app.call(env_with_params)
218
- result[0].should == 302
219
- result[1]["Location"].should == "/foo/bar?foo=bar"
220
- result[1]["Content-Type"].should == "text/plain"
228
+ expect(result[0]).to eq(302)
229
+ expect(result[1]["Location"]).to eq("/foo/bar?foo=bar")
230
+ expect(result[1]["Content-Type"]).to eq("text/plain")
221
231
  end
222
232
  end
223
233
 
@@ -230,9 +240,9 @@ describe Warden::Manager do
230
240
  end
231
241
  env = env_with_params
232
242
  result = @app.call(env)
233
- result[0].should == 401
234
- result[2].should == ["You Fail!"]
235
- env['PATH_INFO'].should == "/unauthenticated"
243
+ expect(result[0]).to eq(401)
244
+ expect(result[2]).to eq(["You Fail!"])
245
+ expect(env['PATH_INFO']).to eq("/unauthenticated")
236
246
  end
237
247
 
238
248
  it "should allow you to customize the response" do
@@ -242,8 +252,8 @@ describe Warden::Manager do
242
252
  end
243
253
  env = env_with_params
244
254
  result = setup_rack(app).call(env)
245
- result[0].should == 401
246
- result[2].should == ["Fail From The App"]
255
+ expect(result[0]).to eq(401)
256
+ expect(result[2]).to eq(["Fail From The App"])
247
257
  end
248
258
 
249
259
  it "should allow you to customize the response without the explicit call to custom_failure! if not intercepting 401" do
@@ -252,8 +262,8 @@ describe Warden::Manager do
252
262
  end
253
263
  env = env_with_params
254
264
  result = setup_rack(app, :intercept_401 => false).call(env)
255
- result[0].should == 401
256
- result[2].should == ["Fail From The App"]
265
+ expect(result[0]).to eq(401)
266
+ expect(result[2]).to eq(["Fail From The App"])
257
267
  end
258
268
 
259
269
  it "should render the failure application for a 401 if no custom_failure flag is set" do
@@ -261,8 +271,8 @@ describe Warden::Manager do
261
271
  [401,{'Content-Type' => 'text/plain'},["Fail From The App"]]
262
272
  end
263
273
  result = setup_rack(app).call(env_with_params)
264
- result[0].should == 401
265
- result[2].should == ["You Fail!"]
274
+ expect(result[0]).to eq(401)
275
+ expect(result[2]).to eq(["You Fail!"])
266
276
  end
267
277
 
268
278
  end # failing
@@ -275,9 +285,23 @@ describe Warden::Manager do
275
285
  end
276
286
  end
277
287
  result = @app.call(env_with_params)
278
- result[0].should == 523
279
- result[1]["Custom-Header"].should == "foo"
280
- result[2].should == ["Custom Stuff"]
288
+ expect(result[0]).to be(523)
289
+ expect(result[1]["Custom-Header"]).to eq("foo")
290
+ expect(result[2]).to eq(["Custom Stuff"])
291
+ end
292
+ end
293
+
294
+ describe "app returns Rack::Response" do
295
+ it "should return it" do
296
+ RAS.add(:foobar) do
297
+ def authenticate!
298
+ custom!(Rack::Response.new(['body'], 201, {"Content-Type" => "text/plain"}))
299
+ end
300
+ end
301
+ result = @app.call(env_with_params)
302
+ expect(result.status).to eq(201)
303
+ expect(result.body).to eq(['body'])
304
+ expect(result.header['Content-Type']).to eq('text/plain')
281
305
  end
282
306
  end
283
307
 
@@ -290,8 +314,8 @@ describe Warden::Manager do
290
314
  end
291
315
  env = env_with_params
292
316
  result = @app.call(env)
293
- result[0].should == 200
294
- result[2].should == ["Foo Is A Winna"]
317
+ expect(result[0]).to eq(200)
318
+ expect(result[2]).to eq(["Foo Is A Winna"])
295
319
  end
296
320
  end
297
321
  end # integrated strategies
@@ -299,9 +323,9 @@ describe Warden::Manager do
299
323
  it "should allow me to set a different default scope for warden" do
300
324
  Rack::Builder.new do
301
325
  use Warden::Manager, :default_scope => :default do |manager|
302
- manager.default_scope.should == :default
326
+ expect(manager.default_scope).to eq(:default)
303
327
  manager.default_scope = :other
304
- manager.default_scope.should == :other
328
+ expect(manager.default_scope).to eq(:other)
305
329
  end
306
330
  end
307
331
  end
@@ -309,7 +333,7 @@ describe Warden::Manager do
309
333
  it "should allow me to access strategies through manager" do
310
334
  Rack::Builder.new do
311
335
  use Warden::Manager do |manager|
312
- manager.strategies.should == Warden::Strategies
336
+ expect(manager.strategies).to eq(Warden::Strategies)
313
337
  end
314
338
  end
315
339
  end