crumbs 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,270 +8,527 @@ class WithLastTest < ActionDispatch::IntegrationTest
8
8
 
9
9
  test 'last request in same path' do
10
10
  get '/'
11
- assert_equal [
12
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
13
- ], session[:referers]
14
- assert_select 'a', count: 1
15
- assert_select 'a[href="/"]', 'Home'
16
-
11
+ assert_equal(
12
+ [
13
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
14
+ ],
15
+ session[:referers]
16
+ )
17
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
18
+ assert_select 'a', 1
19
+ assert_select 'a[href="/"]:contains("Home")'
20
+ else
21
+ assert_select 'a', count: 1
22
+ assert_select 'a[href="/"]', 'Home'
23
+ end
24
+
17
25
  get '/static'
18
- assert_equal [
19
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
20
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' }
21
- ], session[:referers]
22
- assert_select 'a', count: 2
23
- assert_select 'a[href="/"]', 'Home'
24
- assert_select 'a[href="/static"]', 'Static'
26
+ assert_equal(
27
+ [
28
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
29
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' }
30
+ ],
31
+ session[:referers]
32
+ )
33
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
34
+ assert_select 'a', 2
35
+ assert_select 'a[href="/"]:contains("Home")'
36
+ assert_select 'a[href="/static"]:contains("Static")'
37
+ else
38
+ assert_select 'a', count: 2
39
+ assert_select 'a[href="/"]', 'Home'
40
+ assert_select 'a[href="/static"]', 'Static'
41
+ end
25
42
 
26
43
  get '/static/nested'
27
- assert_equal [
28
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
29
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' },
30
- { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested' }
31
- ], session[:referers]
32
- assert_select 'a', count: 3
33
- assert_select 'a[href="/"]', 'Home'
34
- assert_select 'a[href="/static"]', 'Static'
35
- assert_select 'a[href="/static/nested"]', 'Nested'
44
+ assert_equal(
45
+ [
46
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
47
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' },
48
+ { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested' }
49
+ ],
50
+ session[:referers]
51
+ )
52
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
53
+ assert_select 'a', 3
54
+ assert_select 'a[href="/"]:contains("Home")'
55
+ assert_select 'a[href="/static"]:contains("Static")'
56
+ assert_select 'a[href="/static/nested"]:contains("Nested")'
57
+ else
58
+ assert_select 'a', count: 3
59
+ assert_select 'a[href="/"]', 'Home'
60
+ assert_select 'a[href="/static"]', 'Static'
61
+ assert_select 'a[href="/static/nested"]', 'Nested'
62
+ end
36
63
 
37
64
  get '/'
38
- assert_equal [
39
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
40
- ], session[:referers]
41
- assert_select 'a', count: 1
42
- assert_select 'a[href="/"]', 'Home'
65
+ assert_equal(
66
+ [
67
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
68
+ ],
69
+ session[:referers]
70
+ )
71
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
72
+ assert_select 'a', 1
73
+ assert_select 'a[href="/"]:contains("Home")'
74
+ else
75
+ assert_select 'a', count: 1
76
+ assert_select 'a[href="/"]', 'Home'
77
+ end
43
78
  end
44
79
 
45
80
  test 'remember last request with parameters in the same path' do
46
81
  get '/?p1=p1'
47
- assert_equal [
48
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
49
- ], session[:referers]
50
- assert_select 'a', count: 1
51
- assert_select 'a[href="/?p1=p1"]', 'Home'
52
-
82
+ assert_equal(
83
+ [
84
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
85
+ ],
86
+ session[:referers]
87
+ )
88
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
89
+ assert_select 'a', 1
90
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
91
+ else
92
+ assert_select 'a', count: 1
93
+ assert_select 'a[href="/?p1=p1"]', 'Home'
94
+ end
95
+
53
96
  get '/static?p2=p2'
54
- assert_equal [
55
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
56
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' }
57
- ], session[:referers]
58
- assert_select 'a', count: 2
59
- assert_select 'a[href="/?p1=p1"]', 'Home'
60
- assert_select 'a[href="/static?p2=p2"]', 'Static'
97
+ assert_equal(
98
+ [
99
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
100
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' }
101
+ ],
102
+ session[:referers]
103
+ )
104
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
105
+ assert_select 'a', 2
106
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
107
+ assert_select 'a[href="/static?p2=p2"]:contains("Static")'
108
+ else
109
+ assert_select 'a', count: 2
110
+ assert_select 'a[href="/?p1=p1"]', 'Home'
111
+ assert_select 'a[href="/static?p2=p2"]', 'Static'
112
+ end
61
113
 
62
114
  get '/static/nested?p3=p3'
63
- assert_equal [
64
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
65
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' },
66
- { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
67
- ], session[:referers]
68
- assert_select 'a', count: 3
69
- assert_select 'a[href="/?p1=p1"]', 'Home'
70
- assert_select 'a[href="/static?p2=p2"]', 'Static'
71
- assert_select 'a[href="/static/nested?p3=p3"]', 'Nested'
115
+ assert_equal(
116
+ [
117
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
118
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' },
119
+ { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
120
+ ],
121
+ session[:referers]
122
+ )
123
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
124
+ assert_select 'a', 3
125
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
126
+ assert_select 'a[href="/static?p2=p2"]:contains("Static")'
127
+ assert_select 'a[href="/static/nested?p3=p3"]:contains("Nested")'
128
+ else
129
+ assert_select 'a', count: 3
130
+ assert_select 'a[href="/?p1=p1"]', 'Home'
131
+ assert_select 'a[href="/static?p2=p2"]', 'Static'
132
+ assert_select 'a[href="/static/nested?p3=p3"]', 'Nested'
133
+ end
72
134
 
73
135
  get '/'
74
- assert_equal [
75
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
76
- ], session[:referers]
77
- assert_select 'a', count: 1
78
- assert_select 'a[href="/"]', 'Home'
136
+ assert_equal(
137
+ [
138
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
139
+ ],
140
+ session[:referers]
141
+ )
142
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
143
+ assert_select 'a', 1
144
+ assert_select 'a[href="/"]:contains("Home")'
145
+ else
146
+ assert_select 'a', count: 1
147
+ assert_select 'a[href="/"]', 'Home'
148
+ end
79
149
  end
80
150
 
81
151
  test 'gaps not cause any error and generate crumbs either' do
82
152
  get '/?p1=p1'
83
- assert_equal [
84
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
85
- ], session[:referers]
86
- assert_select 'a', count: 1
87
- assert_select 'a[href="/?p1=p1"]', 'Home'
88
-
153
+ assert_equal(
154
+ [
155
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
156
+ ],
157
+ session[:referers]
158
+ )
159
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
160
+ assert_select 'a', 1
161
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
162
+ else
163
+ assert_select 'a', count: 1
164
+ assert_select 'a[href="/?p1=p1"]', 'Home'
165
+ end
166
+
89
167
  get '/static/nested?p3=p3'
90
- assert_equal [
91
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
92
- { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
93
- ], session[:referers]
94
- assert_select 'a', count: 3
95
- assert_select 'a[href="/?p1=p1"]', 'Home'
96
- assert_select 'a[href="/static"]', 'Static'
97
- assert_select 'a[href="/static/nested?p3=p3"]', 'Nested'
168
+ assert_equal(
169
+ [
170
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
171
+ { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
172
+ ],
173
+ session[:referers]
174
+ )
175
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
176
+ assert_select 'a', 3
177
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
178
+ assert_select 'a[href="/static"]:contains("Static")'
179
+ assert_select 'a[href="/static/nested?p3=p3"]:contains("Nested")'
180
+ else
181
+ assert_select 'a', count: 3
182
+ assert_select 'a[href="/?p1=p1"]', 'Home'
183
+ assert_select 'a[href="/static"]', 'Static'
184
+ assert_select 'a[href="/static/nested?p3=p3"]', 'Nested'
185
+ end
98
186
 
99
187
  get '/'
100
- assert_equal [
101
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
102
- ], session[:referers]
103
- assert_select 'a', count: 1
104
- assert_select 'a[href="/"]', 'Home'
188
+ assert_equal(
189
+ [
190
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
191
+ ],
192
+ session[:referers]
193
+ )
194
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
195
+ assert_select 'a', 1
196
+ assert_select 'a[href="/"]:contains("Home")'
197
+ else
198
+ assert_select 'a', count: 1
199
+ assert_select 'a[href="/"]', 'Home'
200
+ end
105
201
  end
106
202
 
107
203
  test 'empty crumbs not cause any error and not generate crumbs' do
108
204
  get '/?p1=p1'
109
- assert_equal [
110
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
111
- ], session[:referers]
112
- assert_select 'a', count: 1
113
- assert_select 'a[href="/?p1=p1"]', 'Home'
205
+ assert_equal(
206
+ [
207
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
208
+ ],
209
+ session[:referers]
210
+ )
211
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
212
+ assert_select 'a', 1
213
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
214
+ else
215
+ assert_select 'a', count: 1
216
+ assert_select 'a[href="/?p1=p1"]', 'Home'
217
+ end
114
218
 
115
219
  get '/empty?p2=p2'
116
- assert_equal [
117
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
118
- { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' }
119
- ], session[:referers]
120
- assert_select 'a', count: 1
121
- assert_select 'a[href="/?p1=p1"]', 'Home'
220
+ assert_equal(
221
+ [
222
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
223
+ { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' }
224
+ ],
225
+ session[:referers]
226
+ )
227
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
228
+ assert_select 'a', 1
229
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
230
+ else
231
+ assert_select 'a', count: 1
232
+ assert_select 'a[href="/?p1=p1"]', 'Home'
233
+ end
122
234
 
123
235
  get '/empty/nested?p3=p3'
124
- assert_equal [
125
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
126
- { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' },
127
- { base_url: 'http://www.example.com', path: '/empty/nested', fullpath: '/empty/nested?p3=p3' }
128
- ], session[:referers]
129
- assert_select 'a', count: 2
130
- assert_select 'a[href="/?p1=p1"]', 'Home'
131
- assert_select 'a[href="/empty/nested?p3=p3"]', 'Nested'
236
+ assert_equal(
237
+ [
238
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
239
+ { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' },
240
+ { base_url: 'http://www.example.com', path: '/empty/nested', fullpath: '/empty/nested?p3=p3' }
241
+ ],
242
+ session[:referers]
243
+ )
244
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
245
+ assert_select 'a', 2
246
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
247
+ assert_select 'a[href="/empty/nested?p3=p3"]:contains("Nested")'
248
+ else
249
+ assert_select 'a', count: 2
250
+ assert_select 'a[href="/?p1=p1"]', 'Home'
251
+ assert_select 'a[href="/empty/nested?p3=p3"]', 'Nested'
252
+ end
132
253
 
133
254
  get '/'
134
- assert_equal [
135
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
136
- ], session[:referers]
137
- assert_select 'a', count: 1
138
- assert_select 'a[href="/"]', 'Home'
255
+ assert_equal(
256
+ [
257
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
258
+ ],
259
+ session[:referers]
260
+ )
261
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
262
+ assert_select 'a', 1
263
+ assert_select 'a[href="/"]:contains("Home")'
264
+ else
265
+ assert_select 'a', count: 1
266
+ assert_select 'a[href="/"]', 'Home'
267
+ end
139
268
  end
140
269
 
141
270
  test 'params not cause any error and can be use alter crumb name' do
142
271
  get '/?p1=p1'
143
- assert_equal [
144
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
145
- ], session[:referers]
146
- assert_select 'a', count: 1
147
- assert_select 'a[href="/?p1=p1"]', 'Home'
148
-
272
+ assert_equal(
273
+ [
274
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
275
+ ],
276
+ session[:referers]
277
+ )
278
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
279
+ assert_select 'a', 1
280
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
281
+ else
282
+ assert_select 'a', count: 1
283
+ assert_select 'a[href="/?p1=p1"]', 'Home'
284
+ end
285
+
149
286
  get '/param?p2=p2'
150
- assert_equal [
151
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
152
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
153
- ], session[:referers]
154
- assert_select 'a', count: 2
155
- assert_select 'a[href="/?p1=p1"]', 'Home'
156
- assert_select 'a[href="/param?p2=p2"]', 'Param'
287
+ assert_equal(
288
+ [
289
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
290
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
291
+ ],
292
+ session[:referers]
293
+ )
294
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
295
+ assert_select 'a', 2
296
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
297
+ assert_select 'a[href="/param?p2=p2"]:contains("Param")'
298
+ else
299
+ assert_select 'a', count: 2
300
+ assert_select 'a[href="/?p1=p1"]', 'Home'
301
+ assert_select 'a[href="/param?p2=p2"]', 'Param'
302
+ end
157
303
 
158
304
  get '/param/1?p3=p3'
159
- assert_equal [
160
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
161
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
162
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
163
- ], session[:referers]
164
- assert_select 'a', count: 3
165
- assert_select 'a[href="/?p1=p1"]', 'Home'
166
- assert_select 'a[href="/param?p2=p2"]', 'Param'
167
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
305
+ assert_equal(
306
+ [
307
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
308
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
309
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
310
+ ],
311
+ session[:referers]
312
+ )
313
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
314
+ assert_select 'a', 3
315
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
316
+ assert_select 'a[href="/param?p2=p2"]:contains("Param")'
317
+ assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
318
+ else
319
+ assert_select 'a', count: 3
320
+ assert_select 'a[href="/?p1=p1"]', 'Home'
321
+ assert_select 'a[href="/param?p2=p2"]', 'Param'
322
+ assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
323
+ end
168
324
 
169
325
  get '/param/1/nested?p4=p4'
170
- assert_equal [
171
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
172
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
173
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
174
- { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
175
- ], session[:referers]
176
- assert_select 'a', count: 4
177
- assert_select 'a[href="/?p1=p1"]', 'Home'
178
- assert_select 'a[href="/param?p2=p2"]', 'Param'
179
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
180
- assert_select 'a[href="/param/1/nested?p4=p4"]', 'Nested'
326
+ assert_equal(
327
+ [
328
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
329
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
330
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
331
+ { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
332
+ ],
333
+ session[:referers]
334
+ )
335
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
336
+ assert_select 'a', 4
337
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
338
+ assert_select 'a[href="/param?p2=p2"]:contains("Param")'
339
+ assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
340
+ assert_select 'a[href="/param/1/nested?p4=p4"]:contains("Nested")'
341
+ else
342
+ assert_select 'a', count: 4
343
+ assert_select 'a[href="/?p1=p1"]', 'Home'
344
+ assert_select 'a[href="/param?p2=p2"]', 'Param'
345
+ assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
346
+ assert_select 'a[href="/param/1/nested?p4=p4"]', 'Nested'
347
+ end
181
348
 
182
349
  get '/'
183
- assert_equal [
184
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
185
- ], session[:referers]
186
- assert_select 'a', count: 1
187
- assert_select 'a[href="/"]', 'Home'
350
+ assert_equal(
351
+ [
352
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
353
+ ],
354
+ session[:referers]
355
+ )
356
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
357
+ assert_select 'a', 1
358
+ assert_select 'a[href="/"]:contains("Home")'
359
+ else
360
+ assert_select 'a', count: 1
361
+ assert_select 'a[href="/"]', 'Home'
362
+ end
188
363
  end
189
364
 
190
365
  test 'going back not cause any error and retain history' do
191
366
  get '/?p1=p1'
192
- assert_equal [
193
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
194
- ], session[:referers]
195
- assert_select 'a', count: 1
196
- assert_select 'a[href="/?p1=p1"]', 'Home'
197
-
367
+ assert_equal(
368
+ [
369
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
370
+ ],
371
+ session[:referers]
372
+ )
373
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
374
+ assert_select 'a', 1
375
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
376
+ else
377
+ assert_select 'a', count: 1
378
+ assert_select 'a[href="/?p1=p1"]', 'Home'
379
+ end
380
+
198
381
  get '/param?p2=p2'
199
- assert_equal [
200
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
201
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
202
- ], session[:referers]
203
- assert_select 'a', count: 2
204
- assert_select 'a[href="/?p1=p1"]', 'Home'
205
- assert_select 'a[href="/param?p2=p2"]', 'Param'
382
+ assert_equal(
383
+ [
384
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
385
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
386
+ ],
387
+ session[:referers]
388
+ )
389
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
390
+ assert_select 'a', 2
391
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
392
+ assert_select 'a[href="/param?p2=p2"]:contains("Param")'
393
+ else
394
+ assert_select 'a', count: 2
395
+ assert_select 'a[href="/?p1=p1"]', 'Home'
396
+ assert_select 'a[href="/param?p2=p2"]', 'Param'
397
+ end
206
398
 
207
399
  get '/param/1?p3=p3'
208
- assert_equal [
209
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
210
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
211
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
212
- ], session[:referers]
213
- assert_select 'a', count: 3
214
- assert_select 'a[href="/?p1=p1"]', 'Home'
215
- assert_select 'a[href="/param?p2=p2"]', 'Param'
216
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
400
+ assert_equal(
401
+ [
402
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
403
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
404
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
405
+ ],
406
+ session[:referers]
407
+ )
408
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
409
+ assert_select 'a', 3
410
+ assert_select 'a[href="/?p1=p1"]:contains("Hom")'
411
+ assert_select 'a[href="/param?p2=p2"]:contains("Param")'
412
+ assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
413
+ else
414
+ assert_select 'a', count: 3
415
+ assert_select 'a[href="/?p1=p1"]', 'Home'
416
+ assert_select 'a[href="/param?p2=p2"]', 'Param'
417
+ assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
418
+ end
217
419
 
218
420
  get '/param/1/nested?p4=p4'
219
- assert_equal [
220
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
221
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
222
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
223
- { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
224
- ], session[:referers]
225
- assert_select 'a', count: 4
226
- assert_select 'a[href="/?p1=p1"]', 'Home'
227
- assert_select 'a[href="/param?p2=p2"]', 'Param'
228
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
229
- assert_select 'a[href="/param/1/nested?p4=p4"]', 'Nested'
421
+ assert_equal(
422
+ [
423
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
424
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
425
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
426
+ { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
427
+ ],
428
+ session[:referers]
429
+ )
430
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
431
+ assert_select 'a', 4
432
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
433
+ assert_select 'a[href="/param?p2=p2"]:contains("Param")'
434
+ assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
435
+ assert_select 'a[href="/param/1/nested?p4=p4"]:contains("Nested")'
436
+ else
437
+ assert_select 'a', count: 4
438
+ assert_select 'a[href="/?p1=p1"]', 'Home'
439
+ assert_select 'a[href="/param?p2=p2"]', 'Param'
440
+ assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
441
+ assert_select 'a[href="/param/1/nested?p4=p4"]', 'Nested'
442
+ end
230
443
 
231
444
  get '/param'
232
- assert_equal [
233
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
234
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param' }
235
- ], session[:referers]
236
- assert_select 'a', count: 2
237
- assert_select 'a[href="/?p1=p1"]', 'Home'
238
- assert_select 'a[href="/param"]', 'Param'
445
+ assert_equal(
446
+ [
447
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
448
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param' }
449
+ ],
450
+ session[:referers]
451
+ )
452
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
453
+ assert_select 'a', 2
454
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
455
+ assert_select 'a[href="/param"]:contains("Param")'
456
+ else
457
+ assert_select 'a', count: 2
458
+ assert_select 'a[href="/?p1=p1"]', 'Home'
459
+ assert_select 'a[href="/param"]', 'Param'
460
+ end
239
461
  end
240
462
 
241
463
  test 'translations not cause any error' do
242
464
  get '/?p1=p1'
243
- assert_equal [
244
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
245
- ], session[:referers]
246
- assert_select 'a', count: 1
247
- assert_select 'a[href="/?p1=p1"]', 'Home'
465
+ assert_equal(
466
+ [
467
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
468
+ ],
469
+ session[:referers]
470
+ )
471
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
472
+ assert_select 'a', 1
473
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
474
+ else
475
+ assert_select 'a', count: 1
476
+ assert_select 'a[href="/?p1=p1"]', 'Home'
477
+ end
248
478
 
249
479
  get '/i18n?p2=p2'
250
- assert_equal [
251
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
252
- { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' }
253
- ], session[:referers]
254
- assert_select 'a', count: 2
255
- assert_select 'a[href="/?p1=p1"]', 'Home'
256
- assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
480
+ assert_equal(
481
+ [
482
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
483
+ { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' }
484
+ ],
485
+ session[:referers]
486
+ )
487
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
488
+ assert_select 'a', 2
489
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
490
+ assert_select 'a[href="/i18n?p2=p2"]:contains("Hello world")'
491
+ else
492
+ assert_select 'a', count: 2
493
+ assert_select 'a[href="/?p1=p1"]', 'Home'
494
+ assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
495
+ end
257
496
 
258
497
  get '/i18n/nested?p3=p3'
259
- assert_equal [
260
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
261
- { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' },
262
- { base_url: 'http://www.example.com', path: '/i18n/nested', fullpath: '/i18n/nested?p3=p3' }
263
- ], session[:referers]
264
- assert_select 'a', count: 3
265
- assert_select 'a[href="/?p1=p1"]', 'Home'
266
- assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
267
- assert_select 'a[href="/i18n/nested?p3=p3"]', 'Nested'
498
+ assert_equal(
499
+ [
500
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
501
+ { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' },
502
+ { base_url: 'http://www.example.com', path: '/i18n/nested', fullpath: '/i18n/nested?p3=p3' }
503
+ ],
504
+ session[:referers]
505
+ )
506
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
507
+ assert_select 'a', 3
508
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
509
+ assert_select 'a[href="/i18n?p2=p2"]:contains("Hello world")'
510
+ assert_select 'a[href="/i18n/nested?p3=p3"]:contains("Nested")'
511
+ else
512
+ assert_select 'a', count: 3
513
+ assert_select 'a[href="/?p1=p1"]', 'Home'
514
+ assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
515
+ assert_select 'a[href="/i18n/nested?p3=p3"]', 'Nested'
516
+ end
268
517
 
269
518
  get '/?p1=p1'
270
- assert_equal [
271
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
272
- ], session[:referers]
273
- assert_select 'a', count: 1
274
- assert_select 'a[href="/?p1=p1"]', 'Home'
519
+ assert_equal(
520
+ [
521
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
522
+ ],
523
+ session[:referers]
524
+ )
525
+ if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
526
+ assert_select 'a', 1
527
+ assert_select 'a[href="/?p1=p1"]:contains("Home")'
528
+ else
529
+ assert_select 'a', count: 1
530
+ assert_select 'a[href="/?p1=p1"]', 'Home'
531
+ end
275
532
  end
276
533
 
277
534
  end