Skip to content

Commit 2fd71b1

Browse files
committed
convert to block style
1 parent 3a3c0fc commit 2fd71b1

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

test/test_integration.rb

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,28 @@ def fetch(url, body = nil, headers = nil, limit = nil)
5454

5555
OpenID.fetcher = MockFetcher.new(RotsApp)
5656

57+
module RackTestHelpers
58+
private
59+
60+
def process(*args)
61+
env = Rack::MockRequest.env_for(*args)
62+
@response = Rack::MockResponse.new(*@app.call(env))
63+
end
64+
65+
def follow_redirect!
66+
assert @response
67+
assert_equal 303, @response.status
68+
69+
env = Rack::MockRequest.env_for(@response.headers['Location'])
70+
_status, headers, _body = RotsApp.call(env)
71+
72+
uri = URI(headers['Location'])
73+
process("#{uri.path}?#{uri.query}")
74+
end
75+
end
76+
5777
describe "headers" do
58-
def test_build_header
78+
it "builds header" do
5979
assert_equal 'OpenID identity="http://example.com/"',
6080
Rack::OpenID.build_header(:identity => "http://example.com/")
6181
assert_equal 'OpenID identity="http://example.com/?foo=bar"',
@@ -72,7 +92,7 @@ def test_build_header
7292
assert_match(/required="nickname,email"/, header)
7393
end
7494

75-
def test_parse_header
95+
it "parses header" do
7696
assert_equal({"identity" => "http://example.com/"},
7797
Rack::OpenID.parse_header('OpenID identity="http://example.com/"'))
7898
assert_equal({"identity" => "http://example.com/?foo=bar"},
@@ -88,30 +108,10 @@ def test_parse_header
88108
end
89109
end
90110

91-
module RackTestHelpers
92-
private
93-
94-
def process(*args)
95-
env = Rack::MockRequest.env_for(*args)
96-
@response = Rack::MockResponse.new(*@app.call(env))
97-
end
98-
99-
def follow_redirect!
100-
assert @response
101-
assert_equal 303, @response.status
102-
103-
env = Rack::MockRequest.env_for(@response.headers['Location'])
104-
_status, headers, _body = RotsApp.call(env)
105-
106-
uri = URI(headers['Location'])
107-
process("#{uri.path}?#{uri.query}")
108-
end
109-
end
110-
111111
describe "openid" do
112112
include RackTestHelpers
113113

114-
def test_with_get
114+
it "with_get" do
115115
@app = app
116116
process('/', :method => 'GET')
117117
follow_redirect!
@@ -121,7 +121,7 @@ def test_with_get
121121
assert_equal 'success', @response.body
122122
end
123123

124-
def test_with_deprecated_identity
124+
it "with_deprecated_identity" do
125125
@app = app
126126
process('/', :method => 'GET', :identity => "#{RotsServerUrl}/john.doe?openid.success=true")
127127
follow_redirect!
@@ -131,7 +131,7 @@ def test_with_deprecated_identity
131131
assert_equal 'success', @response.body
132132
end
133133

134-
def test_with_post_method
134+
it "with_post_method" do
135135
@app = app
136136
process('/', :method => 'POST')
137137
follow_redirect!
@@ -141,7 +141,7 @@ def test_with_post_method
141141
assert_equal 'success', @response.body
142142
end
143143

144-
def test_with_custom_return_to
144+
it "with_custom_return_to" do
145145
@app = app(:return_to => 'http://example.org/complete')
146146
process('/', :method => 'GET')
147147
follow_redirect!
@@ -151,7 +151,7 @@ def test_with_custom_return_to
151151
assert_equal 'success', @response.body
152152
end
153153

154-
def test_with_get_nested_params_custom_return_to
154+
it "with_get_nested_params_custom_return_to" do
155155
url = 'http://example.org/complete?user[remember_me]=true'
156156
@app = app(:return_to => url)
157157
process('/', :method => 'GET')
@@ -163,7 +163,7 @@ def test_with_get_nested_params_custom_return_to
163163
assert_match(/remember_me/, @response.headers['X-Query-String'])
164164
end
165165

166-
def test_with_post_nested_params_custom_return_to
166+
it "with_post_nested_params_custom_return_to" do
167167
url = 'http://example.org/complete?user[remember_me]=true'
168168
@app = app(:return_to => url)
169169
process('/', :method => 'POST')
@@ -182,7 +182,7 @@ def test_with_post_nested_params_custom_return_to
182182
assert_match(/remember_me/, @response.headers['X-Query-String'])
183183
end
184184

185-
def test_with_post_method_custom_return_to
185+
it "with_post_method_custom_return_to" do
186186
@app = app(:return_to => 'http://example.org/complete')
187187
process('/', :method => 'POST')
188188
follow_redirect!
@@ -192,7 +192,7 @@ def test_with_post_method_custom_return_to
192192
assert_equal 'success', @response.body
193193
end
194194

195-
def test_with_custom_return_method
195+
it "with_custom_return_method" do
196196
@app = app(:method => 'put')
197197
process('/', :method => 'GET')
198198
follow_redirect!
@@ -202,7 +202,7 @@ def test_with_custom_return_method
202202
assert_equal 'success', @response.body
203203
end
204204

205-
def test_with_simple_registration_fields
205+
it "with_simple_registration_fields" do
206206
@app = app(:required => ['nickname', 'email'], :optional => 'fullname')
207207
process('/', :method => 'GET')
208208
follow_redirect!
@@ -212,7 +212,7 @@ def test_with_simple_registration_fields
212212
assert_equal 'success', @response.body
213213
end
214214

215-
def test_with_attribute_exchange
215+
it "with_attribute_exchange" do
216216
@app = app(
217217
:required => ['http://axschema.org/namePerson/friendly', 'http://axschema.org/contact/email'],
218218
:optional => 'http://axschema.org/namePerson')
@@ -224,7 +224,7 @@ def test_with_attribute_exchange
224224
assert_equal 'success', @response.body
225225
end
226226

227-
def test_with_oauth
227+
it "with_oauth" do
228228
@app = app(
229229
:'oauth[consumer]' => 'www.example.com',
230230
:'oauth[scope]' => ['http://docs.google.com/feeds/', 'http://spreadsheets.google.com/feeds/']
@@ -242,7 +242,7 @@ def test_with_oauth
242242
assert_equal 'success', @response.body
243243
end
244244

245-
def test_with_pape
245+
it "with_pape" do
246246
@app = app(
247247
:'pape[preferred_auth_policies]' => ['test_policy1', 'test_policy2'],
248248
:'pape[max_auth_age]' => 600
@@ -260,7 +260,7 @@ def test_with_pape
260260
assert_equal 'success', @response.body
261261
end
262262

263-
def test_with_immediate_mode_setup_needed
263+
it "with_immediate_mode_setup_needed" do
264264
skip do
265265
@app = app(:identifier => "#{RotsServerUrl}/john.doe?openid.success=false", :immediate => true)
266266
process('/', :method => 'GET')
@@ -277,7 +277,7 @@ def test_with_immediate_mode_setup_needed
277277
end
278278
end
279279

280-
def test_with_realm_wildcard
280+
it "with_realm_wildcard" do
281281
@app = app(
282282
:realm_domain => "*.example.org"
283283
)
@@ -290,7 +290,7 @@ def test_with_realm_wildcard
290290
assert_equal 200, @response.status
291291
end
292292

293-
def test_with_inferred_realm
293+
it "with_inferred_realm" do
294294
@app = app
295295
process('/', :method => 'GET')
296296

@@ -301,7 +301,7 @@ def test_with_inferred_realm
301301
assert_equal 200, @response.status
302302
end
303303

304-
def test_with_missing_id
304+
it "with_missing_id" do
305305
@app = app(:identifier => "#{RotsServerUrl}/john.doe")
306306
process('/', :method => 'GET')
307307
follow_redirect!
@@ -311,7 +311,7 @@ def test_with_missing_id
311311
assert_equal 'cancel', @response.body
312312
end
313313

314-
def test_with_timeout
314+
it "with_timeout" do
315315
@app = app(:identifier => RotsServerUrl)
316316
process('/', :method => "GET")
317317
assert_equal 400, @response.status
@@ -320,7 +320,7 @@ def test_with_timeout
320320
assert_equal 'missing', @response.body
321321
end
322322

323-
def test_sanitize_query_string
323+
it "sanitize_query_string" do
324324
@app = app
325325
process('/', :method => 'GET')
326326
follow_redirect!
@@ -329,7 +329,7 @@ def test_sanitize_query_string
329329
assert_equal '', @response.headers['X-Query-String']
330330
end
331331

332-
def test_passthrough_standard_http_basic_auth
332+
it "passthrough_standard_http_basic_auth" do
333333
@app = app
334334
process('/', :method => 'GET', "MOCK_HTTP_BASIC_AUTH" => '1')
335335
assert_equal 401, @response.status
@@ -368,7 +368,7 @@ def app(options = {})
368368
describe "simple auth" do
369369
include RackTestHelpers
370370

371-
def test_successful_login
371+
it "can login" do
372372
@app = app "#{RotsServerUrl}/john.doe?openid.success=true"
373373

374374
process '/dashboard'
@@ -383,7 +383,7 @@ def test_successful_login
383383
assert_equal 'Hello', @response.body
384384
end
385385

386-
def test_failed_login
386+
it "fails login" do
387387
@app = app "#{RotsServerUrl}/john.doe"
388388

389389
process '/dashboard'

0 commit comments

Comments
 (0)