spob_browser_detector 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1425 @@
1
+ require 'test_helper'
2
+
3
+ class DetectorTest < Test::Unit::TestCase
4
+ context "The detector" do
5
+ setup do
6
+ @user_agents = {
7
+ :ie55 => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)',
8
+ :ie60 => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
9
+ :ie70 => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
10
+ :ie80 => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
11
+ :firefox2 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17',
12
+ :firefox3 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.11',
13
+ :firefox35 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3',
14
+ :firefox35win => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)',
15
+ :opera10 => 'Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00',
16
+ :safari403 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.8 Safari/532.2',
17
+ :iphone3 => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7C144 Safari/528.16',
18
+ :iphone2 => 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A535b Safari/419.3',
19
+ :chrome3 => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0',
20
+ :chrome4 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.8 Safari/532.2'
21
+ }
22
+ end
23
+
24
+ should "know all of its known browser ids" do
25
+ assert_equal BrowserDetector::Detector.all_browsers.sort.join( ' ' ), "chrome firefox ie55 ie60 ie70 ie80 konqueror netscape opera safari"
26
+ end
27
+
28
+ should "know all of its known mobile browser ids" do
29
+ assert_equal BrowserDetector::Detector.all_mobile_browsers.sort.join( ' ' ), "ie_ce4 iphone"
30
+ end
31
+
32
+ should "have correct sample user agents for known browsers" do
33
+ @user_agents.each { |key, value| assert_equal value, BrowserDetector::Detector.user_agents[key] }
34
+ end
35
+
36
+ context "when given anil user agent" do
37
+ setup do
38
+ @detector = BrowserDetector::Detector.new( nil )
39
+ assert @detector.ua.nil?
40
+ end
41
+
42
+ should "agree that the browser name is 'unknown" do
43
+ assert_equal 'unknown', @detector.browser_name
44
+ end
45
+ end
46
+
47
+ context "when given Firefox 2.0 user agent" do
48
+ setup do
49
+ @detector = BrowserDetector::Detector.new( @user_agents[:firefox2] )
50
+ assert !@detector.ua.nil?
51
+ end
52
+
53
+ should "agree that the browser name is 'firefox'" do
54
+ assert_equal @detector.browser_name, 'firefox'
55
+ end
56
+
57
+ should "agree that the browser version is '2.0.0.17'" do
58
+ assert_equal @detector.browser_version, '2.0.0.17'
59
+ end
60
+
61
+ should "agree that the browser major version is '2'" do
62
+ assert_equal @detector.browser_version_major, '2'
63
+ end
64
+
65
+ should "agree that the browser minor version is '0'" do
66
+ assert_equal @detector.browser_version_minor, '0'
67
+ end
68
+
69
+ should "agree that the browser build version is '0'" do
70
+ assert_equal @detector.browser_version_build, '0'
71
+ end
72
+
73
+ should "agree that the browser revision version is '17'" do
74
+ assert_equal @detector.browser_version_revision, '17'
75
+ end
76
+
77
+ should "have a browser id of 'firefox20017'" do
78
+ assert_equal @detector.browser_id, 'firefox20017'
79
+ end
80
+
81
+ should "have a browser full name of 'Firefox 2.0.0.17'" do
82
+ assert_equal @detector.browser_full_name, 'Firefox 2.0.0.17'
83
+ end
84
+
85
+ should "be able to use a png" do
86
+ assert @detector.can_use_png?
87
+ end
88
+
89
+ should "agree that the browser is :browser => 'firefox'" do
90
+ assert @detector.browser_is?( :name => 'firefox' )
91
+ end
92
+
93
+ should "agree that the browser is :browser => :firefox" do
94
+ assert @detector.browser_is?( :name => :firefox )
95
+ end
96
+
97
+ should "agree that the browser is :version => '2.0.0.17'" do
98
+ assert @detector.browser_is?( :version => '2.0.0.17' )
99
+ end
100
+
101
+ should "agree that the browser is :name => 'firefox' and :version => '2.0.0.17'" do
102
+ assert @detector.browser_is?( :name => 'firefox', :version => '2.0.0.17' )
103
+ end
104
+
105
+ should "agree that the browser is :name => :firefox and :version => '2.0.0.17'" do
106
+ assert @detector.browser_is?( :name => :firefox, :version => '2.0.0.17' )
107
+ end
108
+
109
+ should "agree that the browser is :major_version => '2'" do
110
+ assert @detector.browser_is?( :major_version => '2' )
111
+ end
112
+
113
+ should "agree that the browser is :minor_version => '0'" do
114
+ assert @detector.browser_is?( :minor_version => '0' )
115
+ end
116
+
117
+ should "agree that the browser is :build_version => '0'" do
118
+ assert @detector.browser_is?( :build_version => '0' )
119
+ end
120
+
121
+ should "agree that the browser is :revision_version => '17'" do
122
+ assert @detector.browser_is?( :revision_version => '17' )
123
+ end
124
+
125
+ should "agree that the browser is :major_version => '2', :minor_version => '0'" do
126
+ assert @detector.browser_is?( :major_version => '2', :minor_version => '0' )
127
+ end
128
+
129
+ should "agree that the browser is :major_version => '2', :minor_version => '0', :build_version => '0'" do
130
+ assert @detector.browser_is?( :major_version => '2', :minor_version => '0', :build_version => '0' )
131
+ end
132
+
133
+ should "agree that the browser is :major_version => '2', :minor_version => '0', :build_version => '0', :revision_version => '17'" do
134
+ assert @detector.browser_is?( :major_version => '2', :minor_version => '0', :build_version => '0', :revision_version => '17' )
135
+ end
136
+
137
+ should "agree that the browser is :name => 'firefox', :major_version => '2'" do
138
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '2' )
139
+ end
140
+
141
+ should "agree that the browser is :name => 'firefox', :minor_version => '0'" do
142
+ assert @detector.browser_is?( :name => 'firefox', :minor_version => '0' )
143
+ end
144
+
145
+ should "agree that the browser is :name => 'firefox', :build_version => '0'" do
146
+ assert @detector.browser_is?( :name => 'firefox', :build_version => '0' )
147
+ end
148
+
149
+ should "agree that the browser is :name => 'firefox', :revision_version => '17'" do
150
+ assert @detector.browser_is?( :name => 'firefox', :revision_version => '17' )
151
+ end
152
+
153
+ should "agree that the browser is :name => 'firefox', :major_version => 2" do
154
+ assert @detector.browser_is?( :name => 'firefox', :major_version => 2 )
155
+ end
156
+
157
+ should "agree that the browser is :name => 'firefox', :minor_version => 0" do
158
+ assert @detector.browser_is?( :name => 'firefox', :minor_version => 0 )
159
+ end
160
+
161
+ should "agree that the browser is :name => 'firefox', :build_version => 0" do
162
+ assert @detector.browser_is?( :name => 'firefox', :build_version => 0 )
163
+ end
164
+
165
+ should "agree that the browser is :name => 'firefox', :revision_version => 17" do
166
+ assert @detector.browser_is?( :name => 'firefox', :revision_version => 17 )
167
+ end
168
+
169
+ should "agree that the browser is :name => 'firefox', :major_version => '2', :minor_version => '0'" do
170
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '2', :minor_version => '0' )
171
+ end
172
+
173
+ should "agree that the browser is :name => 'firefox', :major_version => '2', :minor_version => '0', :build_version => '0'" do
174
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '2', :minor_version => '0', :build_version => '0' )
175
+ end
176
+
177
+ should "agree that the browser is :name => 'firefox', :major_version => '2', :minor_version => '0', :build_version => '0', :revision_version => '17'" do
178
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '2', :minor_version => '0', :build_version => '0', :revision_version => '17' )
179
+ end
180
+ end
181
+
182
+ context "when given Firefox 3.0 user agent" do
183
+ setup do
184
+ @detector = BrowserDetector::Detector.new( @user_agents[:firefox3] )
185
+ assert !@detector.ua.nil?
186
+ end
187
+
188
+ should "agree that the browser name is 'firefox'" do
189
+ assert_equal @detector.browser_name, 'firefox'
190
+ end
191
+
192
+ should "agree that the browser version is '3.0.11'" do
193
+ assert_equal @detector.browser_version, '3.0.11'
194
+ end
195
+
196
+ should "agree that the browser major version is '3'" do
197
+ assert_equal @detector.browser_version_major, '3'
198
+ end
199
+
200
+ should "agree that the browser minor version is '0'" do
201
+ assert_equal @detector.browser_version_minor, '0'
202
+ end
203
+
204
+ should "agree that the browser build version is '11'" do
205
+ assert_equal @detector.browser_version_build, '11'
206
+ end
207
+
208
+ should "agree that the browser revision version is '0'" do
209
+ assert_equal @detector.browser_version_revision, '0'
210
+ end
211
+
212
+ should "have a browser id of 'firefox3011'" do
213
+ assert_equal @detector.browser_id, 'firefox3011'
214
+ end
215
+
216
+ should "have a browser full name of 'Firefox 3.0.11'" do
217
+ assert_equal @detector.browser_full_name, 'Firefox 3.0.11'
218
+ end
219
+
220
+ should "be able to use a png" do
221
+ assert @detector.can_use_png?
222
+ end
223
+
224
+ should "agree that the browser is :browser => 'firefox'" do
225
+ assert @detector.browser_is?( :name => 'firefox' )
226
+ end
227
+
228
+ should "agree that the browser is :browser => :firefox" do
229
+ assert @detector.browser_is?( :name => :firefox )
230
+ end
231
+
232
+ should "agree that the browser is :version => '3.0.11'" do
233
+ assert @detector.browser_is?( :version => '3.0.11' )
234
+ end
235
+
236
+ should "agree that the browser is :name => 'firefox' and :version => '3.0.11'" do
237
+ assert @detector.browser_is?( :name => 'firefox', :version => '3.0.11' )
238
+ end
239
+
240
+ should "agree that the browser is :name => :firefox and :version => '3.0.11'" do
241
+ assert @detector.browser_is?( :name => :firefox, :version => '3.0.11' )
242
+ end
243
+
244
+ should "agree that the browser is :major_version => '3'" do
245
+ assert @detector.browser_is?( :major_version => '3' )
246
+ end
247
+
248
+ should "agree that the browser is :minor_version => '0'" do
249
+ assert @detector.browser_is?( :minor_version => '0' )
250
+ end
251
+
252
+ should "agree that the browser is :build_version => '11'" do
253
+ assert @detector.browser_is?( :build_version => '11' )
254
+ end
255
+
256
+ should "agree that the browser is :revision_version => '0'" do
257
+ assert @detector.browser_is?( :revision_version => '0' )
258
+ end
259
+
260
+ should "agree that the browser is :major_version => 3" do
261
+ assert @detector.browser_is?( :major_version => 3 )
262
+ end
263
+
264
+ should "agree that the browser is :minor_version => 0" do
265
+ assert @detector.browser_is?( :minor_version => 0 )
266
+ end
267
+
268
+ should "agree that the browser is :build_version => 11" do
269
+ assert @detector.browser_is?( :build_version => 11 )
270
+ end
271
+
272
+ should "agree that the browser is :revision_version => 0" do
273
+ assert @detector.browser_is?( :revision_version => 0 )
274
+ end
275
+
276
+ should "agree that the browser is :major_version => '3', :minor_version => '0'" do
277
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '0' )
278
+ end
279
+
280
+ should "agree that the browser is :major_version => '3', :minor_version => '0', :build_version => '11'" do
281
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '0', :build_version => '11' )
282
+ end
283
+
284
+ should "agree that the browser is :major_version => '3', :minor_version => '0', :build_version => '11', :revision_version => '0'" do
285
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '0', :build_version => '11', :revision_version => '0' )
286
+ end
287
+
288
+ should "agree that the browser is :name => 'firefox', :major_version => '3'" do
289
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3' )
290
+ end
291
+
292
+ should "agree that the browser is :name => 'firefox', :minor_version => '0'" do
293
+ assert @detector.browser_is?( :name => 'firefox', :minor_version => '0' )
294
+ end
295
+
296
+ should "agree that the browser is :name => 'firefox', :build_version => '11'" do
297
+ assert @detector.browser_is?( :name => 'firefox', :build_version => '11' )
298
+ end
299
+
300
+ should "agree that the browser is :name => 'firefox', :revision_version => '0'" do
301
+ assert @detector.browser_is?( :name => 'firefox', :revision_version => '0' )
302
+ end
303
+
304
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '0'" do
305
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '0' )
306
+ end
307
+
308
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '0', :build_version => '11'" do
309
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '0', :build_version => '11' )
310
+ end
311
+
312
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '0', :build_version => '11', :revision_version => '0'" do
313
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '0', :build_version => '11', :revision_version => '0' )
314
+ end
315
+ end
316
+
317
+ context "when given Firefox 3.5 user agent" do
318
+ setup do
319
+ @detector = BrowserDetector::Detector.new( @user_agents[:firefox35] )
320
+ assert !@detector.ua.nil?
321
+ end
322
+
323
+ should "agree that the browser name is 'firefox'" do
324
+ assert_equal @detector.browser_name, 'firefox'
325
+ end
326
+
327
+ should "agree that the browser version is '3.5.3'" do
328
+ assert_equal @detector.browser_version, '3.5.3'
329
+ end
330
+
331
+ should "agree that the browser major version is '3'" do
332
+ assert_equal @detector.browser_version_major, '3'
333
+ end
334
+
335
+ should "agree that the browser minor version is '5'" do
336
+ assert_equal @detector.browser_version_minor, '5'
337
+ end
338
+
339
+ should "agree that the browser build version is '3'" do
340
+ assert_equal @detector.browser_version_build, '3'
341
+ end
342
+
343
+ should "agree that the browser revision version is '0'" do
344
+ assert_equal @detector.browser_version_revision, '0'
345
+ end
346
+
347
+ should "have a browser id of 'firefox353'" do
348
+ assert_equal @detector.browser_id, 'firefox353'
349
+ end
350
+
351
+ should "have a browser full name of 'Firefox 3.5.3'" do
352
+ assert_equal @detector.browser_full_name, 'Firefox 3.5.3'
353
+ end
354
+
355
+ should "be able to use a png" do
356
+ assert @detector.can_use_png?
357
+ end
358
+
359
+ should "agree that the browser is :browser => 'firefox'" do
360
+ assert @detector.browser_is?( :name => 'firefox' )
361
+ end
362
+
363
+ should "agree that the browser is :browser => :firefox" do
364
+ assert @detector.browser_is?( :name => :firefox )
365
+ end
366
+
367
+ should "agree that the browser is :version => '3.5.3'" do
368
+ assert @detector.browser_is?( :version => '3.5.3' )
369
+ end
370
+
371
+ should "agree that the browser is :name => 'firefox' and :version => '3.5.3'" do
372
+ assert @detector.browser_is?( :name => 'firefox', :version => '3.5.3' )
373
+ end
374
+
375
+ should "agree that the browser is :name => :firefox and :version => '3.5.3'" do
376
+ assert @detector.browser_is?( :name => :firefox, :version => '3.5.3' )
377
+ end
378
+
379
+ should "agree that the browser is :major_version => '3'" do
380
+ assert @detector.browser_is?( :major_version => '3' )
381
+ end
382
+
383
+ should "agree that the browser is :minor_version => 5'" do
384
+ assert @detector.browser_is?( :minor_version => '5' )
385
+ end
386
+
387
+ should "agree that the browser is :build_version => '3'" do
388
+ assert @detector.browser_is?( :build_version => '3' )
389
+ end
390
+
391
+ should "agree that the browser is :revision_version => '0'" do
392
+ assert @detector.browser_is?( :revision_version => '0' )
393
+ end
394
+
395
+ should "agree that the browser is :major_version => 3" do
396
+ assert @detector.browser_is?( :major_version => 3 )
397
+ end
398
+
399
+ should "agree that the browser is :minor_version => 5" do
400
+ assert @detector.browser_is?( :minor_version => 5 )
401
+ end
402
+
403
+ should "agree that the browser is :build_version => 3" do
404
+ assert @detector.browser_is?( :build_version => 3 )
405
+ end
406
+
407
+ should "agree that the browser is :revision_version => 0" do
408
+ assert @detector.browser_is?( :revision_version => 0 )
409
+ end
410
+
411
+ should "agree that the browser is :major_version => '3', :minor_version => '5'" do
412
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '5' )
413
+ end
414
+
415
+ should "agree that the browser is :major_version => '3', :minor_version => '5', :build_version => '3'" do
416
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '5', :build_version => '3' )
417
+ end
418
+
419
+ should "agree that the browser is :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0'" do
420
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0' )
421
+ end
422
+
423
+ should "agree that the browser is :name => 'firefox', :major_version => '3'" do
424
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3' )
425
+ end
426
+
427
+ should "agree that the browser is :name => 'firefox', :minor_version => '5'" do
428
+ assert @detector.browser_is?( :name => 'firefox', :minor_version => '5' )
429
+ end
430
+
431
+ should "agree that the browser is :name => 'firefox', :build_version => '3'" do
432
+ assert @detector.browser_is?( :name => 'firefox', :build_version => '3' )
433
+ end
434
+
435
+ should "agree that the browser is :name => 'firefox', :revision_version => '0'" do
436
+ assert @detector.browser_is?( :name => 'firefox', :revision_version => '0' )
437
+ end
438
+
439
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '5'" do
440
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '5' )
441
+ end
442
+
443
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3'" do
444
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3' )
445
+ end
446
+
447
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0'" do
448
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0' )
449
+ end
450
+ end
451
+
452
+ context "when given Firefox 3.5 Windows user agent" do
453
+ setup do
454
+ @detector = BrowserDetector::Detector.new( @user_agents[:firefox35win] )
455
+ assert !@detector.ua.nil?
456
+ end
457
+
458
+ should "agree that the browser name is 'firefox'" do
459
+ assert_equal @detector.browser_name, 'firefox'
460
+ end
461
+
462
+ should "agree that the browser version is '3.5.3'" do
463
+ assert_equal @detector.browser_version, '3.5.3'
464
+ end
465
+
466
+ should "agree that the browser major version is '3'" do
467
+ assert_equal @detector.browser_version_major, '3'
468
+ end
469
+
470
+ should "agree that the browser minor version is '5'" do
471
+ assert_equal @detector.browser_version_minor, '5'
472
+ end
473
+
474
+ should "agree that the browser build version is '3'" do
475
+ assert_equal @detector.browser_version_build, '3'
476
+ end
477
+
478
+ should "agree that the browser revision version is '0'" do
479
+ assert_equal @detector.browser_version_revision, '0'
480
+ end
481
+
482
+ should "have a browser id of 'firefox353'" do
483
+ assert_equal @detector.browser_id, 'firefox353'
484
+ end
485
+
486
+ should "have a browser full name of 'Firefox 3.5.3'" do
487
+ assert_equal @detector.browser_full_name, 'Firefox 3.5.3'
488
+ end
489
+
490
+ should "be able to use a png" do
491
+ assert @detector.can_use_png?
492
+ end
493
+
494
+ should "agree that the browser is :browser => 'firefox'" do
495
+ assert @detector.browser_is?( :name => 'firefox' )
496
+ end
497
+
498
+ should "agree that the browser is :browser => :firefox" do
499
+ assert @detector.browser_is?( :name => :firefox )
500
+ end
501
+
502
+ should "agree that the browser is :version => '3.5.3'" do
503
+ assert @detector.browser_is?( :version => '3.5.3' )
504
+ end
505
+
506
+ should "agree that the browser is :name => 'firefox' and :version => '3.5.3'" do
507
+ assert @detector.browser_is?( :name => 'firefox', :version => '3.5.3' )
508
+ end
509
+
510
+ should "agree that the browser is :name => :firefox and :version => '3.5.3'" do
511
+ assert @detector.browser_is?( :name => :firefox, :version => '3.5.3' )
512
+ end
513
+
514
+ should "agree that the browser is :major_version => '3'" do
515
+ assert @detector.browser_is?( :major_version => '3' )
516
+ end
517
+
518
+ should "agree that the browser is :minor_version => 5'" do
519
+ assert @detector.browser_is?( :minor_version => '5' )
520
+ end
521
+
522
+ should "agree that the browser is :build_version => '3'" do
523
+ assert @detector.browser_is?( :build_version => '3' )
524
+ end
525
+
526
+ should "agree that the browser is :revision_version => '0'" do
527
+ assert @detector.browser_is?( :revision_version => '0' )
528
+ end
529
+
530
+ should "agree that the browser is :major_version => 3" do
531
+ assert @detector.browser_is?( :major_version => 3 )
532
+ end
533
+
534
+ should "agree that the browser is :minor_version => 5" do
535
+ assert @detector.browser_is?( :minor_version => 5 )
536
+ end
537
+
538
+ should "agree that the browser is :build_version => 3" do
539
+ assert @detector.browser_is?( :build_version => 3 )
540
+ end
541
+
542
+ should "agree that the browser is :revision_version => 0" do
543
+ assert @detector.browser_is?( :revision_version => 0 )
544
+ end
545
+
546
+ should "agree that the browser is :major_version => '3', :minor_version => '5'" do
547
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '5' )
548
+ end
549
+
550
+ should "agree that the browser is :major_version => '3', :minor_version => '5', :build_version => '3'" do
551
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '5', :build_version => '3' )
552
+ end
553
+
554
+ should "agree that the browser is :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0'" do
555
+ assert @detector.browser_is?( :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0' )
556
+ end
557
+
558
+ should "agree that the browser is :name => 'firefox', :major_version => '3'" do
559
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3' )
560
+ end
561
+
562
+ should "agree that the browser is :name => 'firefox', :minor_version => '5'" do
563
+ assert @detector.browser_is?( :name => 'firefox', :minor_version => '5' )
564
+ end
565
+
566
+ should "agree that the browser is :name => 'firefox', :build_version => '3'" do
567
+ assert @detector.browser_is?( :name => 'firefox', :build_version => '3' )
568
+ end
569
+
570
+ should "agree that the browser is :name => 'firefox', :revision_version => '0'" do
571
+ assert @detector.browser_is?( :name => 'firefox', :revision_version => '0' )
572
+ end
573
+
574
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '5'" do
575
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '5' )
576
+ end
577
+
578
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3'" do
579
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3' )
580
+ end
581
+
582
+ should "agree that the browser is :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0'" do
583
+ assert @detector.browser_is?( :name => 'firefox', :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0' )
584
+ end
585
+ end
586
+
587
+ context "when given Opera 10.0 user agent" do
588
+ setup do
589
+ @detector = BrowserDetector::Detector.new( @user_agents[:opera10] )
590
+ assert !@detector.ua.nil?
591
+ end
592
+
593
+ should "agree that the browser name is 'opera'" do
594
+ assert_equal @detector.browser_name, 'opera'
595
+ end
596
+
597
+ should "agree that the browser version is '10.00'" do
598
+ assert_equal @detector.browser_version, '10.00'
599
+ end
600
+
601
+ should "agree that the browser major version is '10'" do
602
+ assert_equal @detector.browser_version_major, '10'
603
+ end
604
+
605
+ should "agree that the browser minor version is '0'" do
606
+ assert_equal @detector.browser_version_minor, '0'
607
+ end
608
+
609
+ should "agree that the browser build version is '0'" do
610
+ assert_equal @detector.browser_version_build, '0'
611
+ end
612
+
613
+ should "agree that the browser revision version is '0'" do
614
+ assert_equal @detector.browser_version_revision, '0'
615
+ end
616
+
617
+ should "have a browser id of 'opera1000'" do
618
+ assert_equal @detector.browser_id, 'opera1000'
619
+ end
620
+
621
+ should "have a browser full name of 'Opera 10.00'" do
622
+ assert_equal @detector.browser_full_name, 'Opera 10.00'
623
+ end
624
+
625
+ should "be able to use a png" do
626
+ assert @detector.can_use_png?
627
+ end
628
+
629
+ should "agree that the browser is :browser => 'opera'" do
630
+ assert @detector.browser_is?( :name => 'opera' )
631
+ end
632
+
633
+ should "agree that the browser is :browser => opera" do
634
+ assert @detector.browser_is?( :name => :opera )
635
+ end
636
+
637
+ should "agree that the browser is :version => '10.00'" do
638
+ assert @detector.browser_is?( :version => '10.00' )
639
+ end
640
+
641
+ should "agree that the browser is :name => 'opera' and :version => '10.00'" do
642
+ assert @detector.browser_is?( :name => 'opera', :version => '10.00' )
643
+ end
644
+
645
+ should "agree that the browser is :name => :opera and :version => '10.00'" do
646
+ assert @detector.browser_is?( :name => :opera, :version => '10.00' )
647
+ end
648
+
649
+ should "agree that the browser is :major_version => '10'" do
650
+ assert @detector.browser_is?( :major_version => '10' )
651
+ end
652
+
653
+ should "agree that the browser is :minor_version => '0'" do
654
+ assert @detector.browser_is?( :minor_version => '0' )
655
+ end
656
+
657
+ should "agree that the browser is :build_version => '0'" do
658
+ assert @detector.browser_is?( :build_version => '0' )
659
+ end
660
+
661
+ should "agree that the browser is :revision_version => '0'" do
662
+ assert @detector.browser_is?( :revision_version => '0' )
663
+ end
664
+
665
+ should "agree that the browser is :major_version => 10" do
666
+ assert @detector.browser_is?( :major_version => 10 )
667
+ end
668
+
669
+ should "agree that the browser is :minor_version => 0" do
670
+ assert @detector.browser_is?( :minor_version => 0 )
671
+ end
672
+
673
+ should "agree that the browser is :build_version => 0" do
674
+ assert @detector.browser_is?( :build_version => 0 )
675
+ end
676
+
677
+ should "agree that the browser is :revision_version => 0" do
678
+ assert @detector.browser_is?( :revision_version => 0 )
679
+ end
680
+
681
+ should "agree that the browser is :major_version => '10', :minor_version => '0'" do
682
+ assert @detector.browser_is?( :major_version => '10', :minor_version => '0' )
683
+ end
684
+
685
+ should "agree that the browser is :major_version => '10', :minor_version => '0', :build_version => '0'" do
686
+ assert @detector.browser_is?( :major_version => '10', :minor_version => '0', :build_version => '0' )
687
+ end
688
+
689
+ should "agree that the browser is :major_version => '10', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
690
+ assert @detector.browser_is?( :major_version => '10', :minor_version => '0', :build_version => '0', :revision_version => '0' )
691
+ end
692
+
693
+ should "agree that the browser is :name => 'opera', :major_version => '10'" do
694
+ assert @detector.browser_is?( :name => 'opera', :major_version => '10' )
695
+ end
696
+
697
+ should "agree that the browser is :name => 'opera', :minor_version => '0'" do
698
+ assert @detector.browser_is?( :name => 'opera', :minor_version => '0' )
699
+ end
700
+
701
+ should "agree that the browser is :name => 'opera', :build_version => '0'" do
702
+ assert @detector.browser_is?( :name => 'opera', :build_version => '0' )
703
+ end
704
+
705
+ should "agree that the browser is :name => 'opera', :revision_version => '0'" do
706
+ assert @detector.browser_is?( :name => 'opera', :revision_version => '0' )
707
+ end
708
+
709
+ should "agree that the browser is :name => 'opera', :major_version => '10', :minor_version => '0'" do
710
+ assert @detector.browser_is?( :name => 'opera', :major_version => '10', :minor_version => '0' )
711
+ end
712
+
713
+ should "agree that the browser is :name => 'opera', :major_version => '10', :minor_version => '0', :build_version => '0'" do
714
+ assert @detector.browser_is?( :name => 'opera', :major_version => '10', :minor_version => '0', :build_version => '0' )
715
+ end
716
+
717
+ should "agree that the browser is :name => 'opera', :major_version => '10', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
718
+ assert @detector.browser_is?( :name => 'opera', :major_version => '10', :minor_version => '0', :build_version => '0', :revision_version => '0' )
719
+ end
720
+ end
721
+
722
+ context "when given IE 5.5 user agent" do
723
+ setup do
724
+ @detector = BrowserDetector::Detector.new( @user_agents[:ie55] )
725
+ assert !@detector.ua.nil?
726
+ end
727
+
728
+ should "agree that the browser name is 'ie'" do
729
+ assert_equal @detector.browser_name, 'ie'
730
+ end
731
+
732
+ should "agree that the browser version is '5.5'" do
733
+ assert_equal @detector.browser_version, '5.5'
734
+ end
735
+
736
+ should "agree that the browser major version is '5'" do
737
+ assert_equal @detector.browser_version_major, '5'
738
+ end
739
+
740
+ should "agree that the browser minor version is '5'" do
741
+ assert_equal @detector.browser_version_minor, '5'
742
+ end
743
+
744
+ should "agree that the browser build version is '0'" do
745
+ assert_equal @detector.browser_version_build, '0'
746
+ end
747
+
748
+ should "agree that the browser revision version is '0'" do
749
+ assert_equal @detector.browser_version_revision, '0'
750
+ end
751
+
752
+ should "have a browser id of 'ie55'" do
753
+ assert_equal @detector.browser_id, 'ie55'
754
+ end
755
+
756
+ should "have a browser full name of 'Internet Explorer 5.5'" do
757
+ assert_equal @detector.browser_full_name, 'Internet Explorer 5.5'
758
+ end
759
+
760
+ should "not be able to use a png" do
761
+ assert !@detector.can_use_png?
762
+ end
763
+
764
+ should "agree that the browser is :browser => 'ie'" do
765
+ assert @detector.browser_is?( :name => 'ie' )
766
+ end
767
+
768
+ should "agree that the browser is :browser => :ie" do
769
+ assert @detector.browser_is?( :name => :ie )
770
+ end
771
+
772
+ should "agree that the browser is :version => '5.5'" do
773
+ assert @detector.browser_is?( :version => '5.5' )
774
+ end
775
+
776
+ should "agree that the browser is :name => 'ie' and :version => '5.5'" do
777
+ assert @detector.browser_is?( :name => 'ie', :version => '5.5' )
778
+ end
779
+
780
+ should "agree that the browser is :name => :ie and :version => '5.5'" do
781
+ assert @detector.browser_is?( :name => :ie, :version => '5.5' )
782
+ end
783
+
784
+ should "agree that the browser is :major_version => '5'" do
785
+ assert @detector.browser_is?( :major_version => '5' )
786
+ end
787
+
788
+ should "agree that the browser is :minor_version => '5'" do
789
+ assert @detector.browser_is?( :minor_version => '5' )
790
+ end
791
+
792
+ should "agree that the browser is :build_version => '0'" do
793
+ assert @detector.browser_is?( :build_version => '0' )
794
+ end
795
+
796
+ should "agree that the browser is :revision_version => '0'" do
797
+ assert @detector.browser_is?( :revision_version => '0' )
798
+ end
799
+
800
+ should "agree that the browser is :major_version => 5" do
801
+ assert @detector.browser_is?( :major_version => 5 )
802
+ end
803
+
804
+ should "agree that the browser is :minor_version => 5" do
805
+ assert @detector.browser_is?( :minor_version => 5 )
806
+ end
807
+
808
+ should "agree that the browser is :build_version => 0" do
809
+ assert @detector.browser_is?( :build_version => 0 )
810
+ end
811
+
812
+ should "agree that the browser is :revision_version => 0" do
813
+ assert @detector.browser_is?( :revision_version => 0 )
814
+ end
815
+
816
+ should "agree that the browser is :major_version => '5', :minor_version => '5'" do
817
+ assert @detector.browser_is?( :major_version => '5', :minor_version => '5' )
818
+ end
819
+
820
+ should "agree that the browser is :major_version => '5', :minor_version => '5', :build_version => '0'" do
821
+ assert @detector.browser_is?( :major_version => '5', :minor_version => '5', :build_version => '0' )
822
+ end
823
+
824
+ should "agree that the browser is :major_version => '5', :minor_version => '5', :build_version => '0', :revision_version => '0'" do
825
+ assert @detector.browser_is?( :major_version => '5', :minor_version => '5', :build_version => '0', :revision_version => '0' )
826
+ end
827
+
828
+ should "agree that the browser is :name => 'ie', :major_version => '5'" do
829
+ assert @detector.browser_is?( :name => 'ie', :major_version => '5' )
830
+ end
831
+
832
+ should "agree that the browser is :name => 'ie', :minor_version => '5'" do
833
+ assert @detector.browser_is?( :name => 'ie', :minor_version => '5' )
834
+ end
835
+
836
+ should "agree that the browser is :name => 'ie', :build_version => '0'" do
837
+ assert @detector.browser_is?( :name => 'ie', :build_version => '0' )
838
+ end
839
+
840
+ should "agree that the browser is :name => 'ie', :revision_version => '0'" do
841
+ assert @detector.browser_is?( :name => 'ie', :revision_version => '0' )
842
+ end
843
+
844
+ should "agree that the browser is :name => 'ie', :major_version => '5', :minor_version => '5'" do
845
+ assert @detector.browser_is?( :name => 'ie', :major_version => '5', :minor_version => '5' )
846
+ end
847
+
848
+ should "agree that the browser is :name => 'ie', :major_version => '5', :minor_version => '5', :build_version => '0'" do
849
+ assert @detector.browser_is?( :name => 'ie', :major_version => '5', :minor_version => '5', :build_version => '0' )
850
+ end
851
+
852
+ should "agree that the browser is :name => 'ie', :major_version => '5', :minor_version => '5', :build_version => '0', :revision_version => '0'" do
853
+ assert @detector.browser_is?( :name => 'ie', :major_version => '5', :minor_version => '5', :build_version => '0', :revision_version => '0' )
854
+ end
855
+ end
856
+
857
+ context "when given IE 6.0 user agent" do
858
+ setup do
859
+ @detector = BrowserDetector::Detector.new( @user_agents[:ie60] )
860
+ assert !@detector.ua.nil?
861
+ end
862
+
863
+ should "agree that the browser name is 'ie'" do
864
+ assert_equal @detector.browser_name, 'ie'
865
+ end
866
+
867
+ should "agree that the browser version is '6.0'" do
868
+ assert_equal @detector.browser_version, '6.0'
869
+ end
870
+
871
+ should "agree that the browser major version is '6'" do
872
+ assert_equal @detector.browser_version_major, '6'
873
+ end
874
+
875
+ should "agree that the browser minor version is '0'" do
876
+ assert_equal @detector.browser_version_minor, '0'
877
+ end
878
+
879
+ should "agree that the browser build version is '0'" do
880
+ assert_equal @detector.browser_version_build, '0'
881
+ end
882
+
883
+ should "agree that the browser revision version is '0'" do
884
+ assert_equal @detector.browser_version_revision, '0'
885
+ end
886
+
887
+ should "have a browser id of 'ie60'" do
888
+ assert_equal @detector.browser_id, 'ie60'
889
+ end
890
+
891
+ should "have a browser full name of 'Internet Explorer 6.0'" do
892
+ assert_equal @detector.browser_full_name, 'Internet Explorer 6.0'
893
+ end
894
+
895
+ should "not be able to use a png" do
896
+ assert !@detector.can_use_png?
897
+ end
898
+
899
+ should "agree that the browser is :browser => 'ie'" do
900
+ assert @detector.browser_is?( :name => 'ie' )
901
+ end
902
+
903
+ should "agree that the browser is :browser => :ie" do
904
+ assert @detector.browser_is?( :name => :ie )
905
+ end
906
+
907
+ should "agree that the browser is :version => '6.0'" do
908
+ assert @detector.browser_is?( :version => '6.0' )
909
+ end
910
+
911
+ should "agree that the browser is :name => 'ie' and :version => '6.0'" do
912
+ assert @detector.browser_is?( :name => 'ie', :version => '6.0' )
913
+ end
914
+
915
+ should "agree that the browser is :name => :ie and :version => '6.0'" do
916
+ assert @detector.browser_is?( :name => :ie, :version => '6.0' )
917
+ end
918
+
919
+ should "agree that the browser is :major_version => '6'" do
920
+ assert @detector.browser_is?( :major_version => '6' )
921
+ end
922
+
923
+ should "agree that the browser is :minor_version => '0'" do
924
+ assert @detector.browser_is?( :minor_version => '0' )
925
+ end
926
+
927
+ should "agree that the browser is :build_version => '0'" do
928
+ assert @detector.browser_is?( :build_version => '0' )
929
+ end
930
+
931
+ should "agree that the browser is :revision_version => '0'" do
932
+ assert @detector.browser_is?( :revision_version => '0' )
933
+ end
934
+
935
+ should "agree that the browser is :major_version => 6" do
936
+ assert @detector.browser_is?( :major_version => 6 )
937
+ end
938
+
939
+ should "agree that the browser is :minor_version => 0" do
940
+ assert @detector.browser_is?( :minor_version => 0 )
941
+ end
942
+
943
+ should "agree that the browser is :build_version => 0" do
944
+ assert @detector.browser_is?( :build_version => 0 )
945
+ end
946
+
947
+ should "agree that the browser is :revision_version => 0" do
948
+ assert @detector.browser_is?( :revision_version => 0 )
949
+ end
950
+
951
+ should "agree that the browser is :major_version => '6', :minor_version => '0'" do
952
+ assert @detector.browser_is?( :major_version => '6', :minor_version => '0' )
953
+ end
954
+
955
+ should "agree that the browser is :major_version => '6', :minor_version => '0', :build_version => '0'" do
956
+ assert @detector.browser_is?( :major_version => '6', :minor_version => '0', :build_version => '0' )
957
+ end
958
+
959
+ should "agree that the browser is :major_version => '6', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
960
+ assert @detector.browser_is?( :major_version => '6', :minor_version => '0', :build_version => '0', :revision_version => '0' )
961
+ end
962
+
963
+ should "agree that the browser is :name => 'ie', :major_version => '6'" do
964
+ assert @detector.browser_is?( :name => 'ie', :major_version => '6' )
965
+ end
966
+
967
+ should "agree that the browser is :name => 'ie', :minor_version => '0'" do
968
+ assert @detector.browser_is?( :name => 'ie', :minor_version => '0' )
969
+ end
970
+
971
+ should "agree that the browser is :name => 'ie', :build_version => '0'" do
972
+ assert @detector.browser_is?( :name => 'ie', :build_version => '0' )
973
+ end
974
+
975
+ should "agree that the browser is :name => 'ie', :revision_version => '0'" do
976
+ assert @detector.browser_is?( :name => 'ie', :revision_version => '0' )
977
+ end
978
+
979
+ should "agree that the browser is :name => 'ie', :major_version => '6', :minor_version => '0'" do
980
+ assert @detector.browser_is?( :name => 'ie', :major_version => '6', :minor_version => '0' )
981
+ end
982
+
983
+ should "agree that the browser is :name => 'ie', :major_version => '6', :minor_version => '0', :build_version => '0'" do
984
+ assert @detector.browser_is?( :name => 'ie',:major_version => '6', :minor_version => '0', :build_version => '0' )
985
+ end
986
+
987
+ should "agree that the browser is :name => 'ie', :major_version => '6', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
988
+ assert @detector.browser_is?( :name => 'ie', :major_version => '6', :minor_version => '0', :build_version => '0', :revision_version => '0' )
989
+ end
990
+ end
991
+
992
+ context "when given IE 7.0 user agent" do
993
+ setup do
994
+ @detector = BrowserDetector::Detector.new( @user_agents[:ie70] )
995
+ assert !@detector.ua.nil?
996
+ end
997
+
998
+ should "agree that the browser name is 'ie'" do
999
+ assert_equal @detector.browser_name, 'ie'
1000
+ end
1001
+
1002
+ should "agree that the browser version is '7.0'" do
1003
+ assert_equal @detector.browser_version, '7.0'
1004
+ end
1005
+
1006
+ should "agree that the browser major version is '7'" do
1007
+ assert_equal @detector.browser_version_major, '7'
1008
+ end
1009
+
1010
+ should "agree that the browser minor version is '0'" do
1011
+ assert_equal @detector.browser_version_minor, '0'
1012
+ end
1013
+
1014
+ should "agree that the browser build version is '0'" do
1015
+ assert_equal @detector.browser_version_build, '0'
1016
+ end
1017
+
1018
+ should "agree that the browser revision version is '0'" do
1019
+ assert_equal @detector.browser_version_revision, '0'
1020
+ end
1021
+
1022
+ should "have a browser id of 'ie70'" do
1023
+ assert_equal @detector.browser_id, 'ie70'
1024
+ end
1025
+
1026
+ should "have a browser full name of 'Internet Explorer 7.0'" do
1027
+ assert_equal @detector.browser_full_name, 'Internet Explorer 7.0'
1028
+ end
1029
+
1030
+ should "be able to use a png" do
1031
+ assert @detector.can_use_png?
1032
+ end
1033
+
1034
+ should "agree that the browser is :browser => 'ie'" do
1035
+ assert @detector.browser_is?( :name => 'ie' )
1036
+ end
1037
+
1038
+ should "agree that the browser is :browser => :ie" do
1039
+ assert @detector.browser_is?( :name => :ie )
1040
+ end
1041
+
1042
+ should "agree that the browser is :version => '7.0'" do
1043
+ assert @detector.browser_is?( :version => '7.0' )
1044
+ end
1045
+
1046
+ should "agree that the browser is :name => 'ie' and :version => '7.0'" do
1047
+ assert @detector.browser_is?( :name => 'ie', :version => '7.0' )
1048
+ end
1049
+
1050
+ should "agree that the browser is :name => :ie and :version => '7.0'" do
1051
+ assert @detector.browser_is?( :name => :ie, :version => '7.0' )
1052
+ end
1053
+
1054
+ should "agree that the browser is :major_version => '7'" do
1055
+ assert @detector.browser_is?( :major_version => '7' )
1056
+ end
1057
+
1058
+ should "agree that the browser is :minor_version => '0'" do
1059
+ assert @detector.browser_is?( :minor_version => '0' )
1060
+ end
1061
+
1062
+ should "agree that the browser is :build_version => '0'" do
1063
+ assert @detector.browser_is?( :build_version => '0' )
1064
+ end
1065
+
1066
+ should "agree that the browser is :revision_version => '0'" do
1067
+ assert @detector.browser_is?( :revision_version => '0' )
1068
+ end
1069
+
1070
+ should "agree that the browser is :major_version => 7" do
1071
+ assert @detector.browser_is?( :major_version => 7 )
1072
+ end
1073
+
1074
+ should "agree that the browser is :minor_version => 0" do
1075
+ assert @detector.browser_is?( :minor_version => 0 )
1076
+ end
1077
+
1078
+ should "agree that the browser is :build_version => 0" do
1079
+ assert @detector.browser_is?( :build_version => 0 )
1080
+ end
1081
+
1082
+ should "agree that the browser is :revision_version => 0" do
1083
+ assert @detector.browser_is?( :revision_version => 0 )
1084
+ end
1085
+
1086
+ should "agree that the browser is :major_version => '7', :minor_version => '0'" do
1087
+ assert @detector.browser_is?( :major_version => '7', :minor_version => '0' )
1088
+ end
1089
+
1090
+ should "agree that the browser is :major_version => '7', :minor_version => '0', :build_version => '0'" do
1091
+ assert @detector.browser_is?( :major_version => '7', :minor_version => '0', :build_version => '0' )
1092
+ end
1093
+
1094
+ should "agree that the browser is :major_version => '7', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
1095
+ assert @detector.browser_is?( :major_version => '7', :minor_version => '0', :build_version => '0', :revision_version => '0' )
1096
+ end
1097
+
1098
+ should "agree that the browser is :name => 'ie', :major_version => '7'" do
1099
+ assert @detector.browser_is?( :name => 'ie', :major_version => '7' )
1100
+ end
1101
+
1102
+ should "agree that the browser is :name => 'ie', :minor_version => '0'" do
1103
+ assert @detector.browser_is?( :name => 'ie', :minor_version => '0' )
1104
+ end
1105
+
1106
+ should "agree that the browser is :name => 'ie', :build_version => '0'" do
1107
+ assert @detector.browser_is?( :name => 'ie', :build_version => '0' )
1108
+ end
1109
+
1110
+ should "agree that the browser is :name => 'ie', :revision_version => '0'" do
1111
+ assert @detector.browser_is?( :name => 'ie', :revision_version => '0' )
1112
+ end
1113
+
1114
+ should "agree that the browser is :name => 'ie', :major_version => '7', :minor_version => '0'" do
1115
+ assert @detector.browser_is?( :name => 'ie', :major_version => '7', :minor_version => '0' )
1116
+ end
1117
+
1118
+ should "agree that the browser is :name => 'ie', :major_version => '7', :minor_version => '0', :build_version => '0'" do
1119
+ assert @detector.browser_is?( :name => 'ie',:major_version => '7', :minor_version => '0', :build_version => '0' )
1120
+ end
1121
+
1122
+ should "agree that the browser is :name => 'ie', :major_version => '7', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
1123
+ assert @detector.browser_is?( :name => 'ie', :major_version => '7', :minor_version => '0', :build_version => '0', :revision_version => '0' )
1124
+ end
1125
+ end
1126
+
1127
+ context "when given IE 8.0 user agent" do
1128
+ setup do
1129
+ @detector = BrowserDetector::Detector.new( @user_agents[:ie80] )
1130
+ assert !@detector.ua.nil?
1131
+ end
1132
+
1133
+ should "agree that the browser name is 'ie'" do
1134
+ assert_equal @detector.browser_name, 'ie'
1135
+ end
1136
+
1137
+ should "agree that the browser version is '8.0'" do
1138
+ assert_equal @detector.browser_version, '8.0'
1139
+ end
1140
+
1141
+ should "agree that the browser major version is '8'" do
1142
+ assert_equal @detector.browser_version_major, '8'
1143
+ end
1144
+
1145
+ should "agree that the browser minor version is '0'" do
1146
+ assert_equal @detector.browser_version_minor, '0'
1147
+ end
1148
+
1149
+ should "agree that the browser build version is '0'" do
1150
+ assert_equal @detector.browser_version_build, '0'
1151
+ end
1152
+
1153
+ should "agree that the browser revision version is '0'" do
1154
+ assert_equal @detector.browser_version_revision, '0'
1155
+ end
1156
+
1157
+ should "have a browser id of 'ie80'" do
1158
+ assert_equal @detector.browser_id, 'ie80'
1159
+ end
1160
+
1161
+ should "have a browser full name of 'Internet Explorer 8.0'" do
1162
+ assert_equal @detector.browser_full_name, 'Internet Explorer 8.0'
1163
+ end
1164
+
1165
+ should "be able to use a png" do
1166
+ assert @detector.can_use_png?
1167
+ end
1168
+
1169
+ should "agree that the browser is :browser => 'ie'" do
1170
+ assert @detector.browser_is?( :name => 'ie' )
1171
+ end
1172
+
1173
+ should "agree that the browser is :browser => :ie" do
1174
+ assert @detector.browser_is?( :name => :ie )
1175
+ end
1176
+
1177
+ should "agree that the browser is :version => '8.0'" do
1178
+ assert @detector.browser_is?( :version => '8.0' )
1179
+ end
1180
+
1181
+ should "agree that the browser is :name => 'ie' and :version => '8.0'" do
1182
+ assert @detector.browser_is?( :name => 'ie', :version => '8.0' )
1183
+ end
1184
+
1185
+ should "agree that the browser is :name => :ie and :version => '8.0'" do
1186
+ assert @detector.browser_is?( :name => :ie, :version => '8.0' )
1187
+ end
1188
+
1189
+ #
1190
+ should "agree that the browser is :major_version => '8'" do
1191
+ assert @detector.browser_is?( :major_version => '8' )
1192
+ end
1193
+
1194
+ should "agree that the browser is :minor_version => '0'" do
1195
+ assert @detector.browser_is?( :minor_version => '0' )
1196
+ end
1197
+
1198
+ should "agree that the browser is :build_version => '0'" do
1199
+ assert @detector.browser_is?( :build_version => '0' )
1200
+ end
1201
+
1202
+ should "agree that the browser is :revision_version => '0'" do
1203
+ assert @detector.browser_is?( :revision_version => '0' )
1204
+ end
1205
+
1206
+ should "agree that the browser is :major_version => 8" do
1207
+ assert @detector.browser_is?( :major_version => 8 )
1208
+ end
1209
+
1210
+ should "agree that the browser is :minor_version => 0" do
1211
+ assert @detector.browser_is?( :minor_version => 0 )
1212
+ end
1213
+
1214
+ should "agree that the browser is :build_version => 0" do
1215
+ assert @detector.browser_is?( :build_version => 0 )
1216
+ end
1217
+
1218
+ should "agree that the browser is :revision_version => 0" do
1219
+ assert @detector.browser_is?( :revision_version => 0 )
1220
+ end
1221
+
1222
+ should "agree that the browser is :major_version => '8', :minor_version => '0'" do
1223
+ assert @detector.browser_is?( :major_version => '8', :minor_version => '0' )
1224
+ end
1225
+
1226
+ should "agree that the browser is :major_version => '8', :minor_version => '0', :build_version => '0'" do
1227
+ assert @detector.browser_is?( :major_version => '8', :minor_version => '0', :build_version => '0' )
1228
+ end
1229
+
1230
+ should "agree that the browser is :major_version => '8', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
1231
+ assert @detector.browser_is?( :major_version => '8', :minor_version => '0', :build_version => '0', :revision_version => '0' )
1232
+ end
1233
+
1234
+ should "agree that the browser is :name => 'ie', :major_version => '8'" do
1235
+ assert @detector.browser_is?( :name => 'ie', :major_version => '8' )
1236
+ end
1237
+
1238
+ should "agree that the browser is :name => 'ie', :minor_version => '0'" do
1239
+ assert @detector.browser_is?( :name => 'ie', :minor_version => '0' )
1240
+ end
1241
+
1242
+ should "agree that the browser is :name => 'ie', :build_version => '0'" do
1243
+ assert @detector.browser_is?( :name => 'ie', :build_version => '0' )
1244
+ end
1245
+
1246
+ should "agree that the browser is :name => 'ie', :revision_version => '0'" do
1247
+ assert @detector.browser_is?( :name => 'ie', :revision_version => '0' )
1248
+ end
1249
+
1250
+ should "agree that the browser is :name => 'ie', :major_version => '8', :minor_version => '0'" do
1251
+ assert @detector.browser_is?( :name => 'ie', :major_version => '8', :minor_version => '0' )
1252
+ end
1253
+
1254
+ should "agree that the browser is :name => 'ie', :major_version => '8', :minor_version => '0', :build_version => '0'" do
1255
+ assert @detector.browser_is?( :name => 'ie',:major_version => '8', :minor_version => '0', :build_version => '0' )
1256
+ end
1257
+
1258
+ should "agree that the browser is :name => 'ie', :major_version => '8', :minor_version => '0', :build_version => '0', :revision_version => '0'" do
1259
+ assert @detector.browser_is?( :name => 'ie', :major_version => '8', :minor_version => '0', :build_version => '0', :revision_version => '0' )
1260
+ end
1261
+ end
1262
+
1263
+ context "when given Safari 4.0.3 user agent" do
1264
+ setup do
1265
+ @detector = BrowserDetector::Detector.new( @user_agents[:safari403] )
1266
+ assert !@detector.ua.nil?
1267
+ end
1268
+
1269
+ should "agree that the browser name is 'safari'" do
1270
+ assert_equal 'safari', @detector.browser_name
1271
+ end
1272
+
1273
+ should "agree that the browser version is '4.0.3'" do
1274
+ assert_equal '4.0.3', @detector.browser_version
1275
+ end
1276
+
1277
+ should "agree that the browser major version is '4'" do
1278
+ assert_equal @detector.browser_version_major, '4'
1279
+ end
1280
+
1281
+ should "agree that the browser minor version is '0'" do
1282
+ assert_equal @detector.browser_version_minor, '0'
1283
+ end
1284
+
1285
+ should "agree that the browser build version is '3'" do
1286
+ assert_equal @detector.browser_version_build, '3'
1287
+ end
1288
+
1289
+ should "agree that the browser revision version is '0'" do
1290
+ assert_equal @detector.browser_version_revision, '0'
1291
+ end
1292
+
1293
+ should "have a browser id of 'safari403'" do
1294
+ assert_equal @detector.browser_id, 'safari403'
1295
+ end
1296
+
1297
+ should "have a browser full name of 'Safari 4.0.3'" do
1298
+ assert_equal @detector.browser_full_name, 'Safari 4.0.3'
1299
+ end
1300
+
1301
+ should "be able to use a png" do
1302
+ assert @detector.can_use_png?
1303
+ end
1304
+
1305
+ should "agree that the browser is :name => 'safari'" do
1306
+ assert @detector.browser_is?( :name => 'safari' )
1307
+ end
1308
+
1309
+ should "agree that the browser is :name => :safari" do
1310
+ assert @detector.browser_is?( :name => :safari )
1311
+ end
1312
+
1313
+ should "agree that the browser is :version => '4.0.3'" do
1314
+ assert @detector.browser_is?( :version => '4.0.3' )
1315
+ end
1316
+
1317
+ should "agree that the browser is :name => 'safari' and :version => '4.0.3'" do
1318
+ assert @detector.browser_is?( :name => 'safari', :version => '4.0.3' )
1319
+ end
1320
+
1321
+ should "agree that the browser is :name => :safari and :version => '4.0.3'" do
1322
+ assert @detector.browser_is?( :name => :safari, :version => '4.0.3' )
1323
+ end
1324
+
1325
+ should "agree that the browser is :major_version => '4'" do
1326
+ assert @detector.browser_is?( :major_version => '4' )
1327
+ end
1328
+
1329
+ should "agree that the browser is :minor_version => '0'" do
1330
+ assert @detector.browser_is?( :minor_version => '0' )
1331
+ end
1332
+
1333
+ should "agree that the browser is :build_version => '3'" do
1334
+ assert @detector.browser_is?( :build_version => '3' )
1335
+ end
1336
+
1337
+ should "agree that the browser is :revision_version => '0'" do
1338
+ assert @detector.browser_is?( :revision_version => '0' )
1339
+ end
1340
+
1341
+ should "agree that the browser is :major_version => 4" do
1342
+ assert @detector.browser_is?( :major_version => 4 )
1343
+ end
1344
+
1345
+ should "agree that the browser is :minor_version => 0" do
1346
+ assert @detector.browser_is?( :minor_version => 0 )
1347
+ end
1348
+
1349
+ should "agree that the browser is :build_version => 3" do
1350
+ assert @detector.browser_is?( :build_version => 3 )
1351
+ end
1352
+
1353
+ should "agree that the browser is :revision_version => 0" do
1354
+ assert @detector.browser_is?( :revision_version => 0 )
1355
+ end
1356
+
1357
+ should "agree that the browser is :major_version => '4', :minor_version => '0'" do
1358
+ assert @detector.browser_is?( :major_version => '4', :minor_version => '0' )
1359
+ end
1360
+
1361
+ should "agree that the browser is :major_version => '4', :minor_version => '0', :build_version => '3'" do
1362
+ assert @detector.browser_is?( :major_version => '4', :minor_version => '0', :build_version => '3' )
1363
+ end
1364
+
1365
+ should "agree that the browser is :major_version => '4', :minor_version => '0', :build_version => '3', :revision_version => '0'" do
1366
+ assert @detector.browser_is?( :major_version => '4', :minor_version => '0', :build_version => '3', :revision_version => '0' )
1367
+ end
1368
+
1369
+ should "agree that the browser is :name => 'safari', :major_version => '4'" do
1370
+ assert @detector.browser_is?( :name => 'safari', :major_version => '4' )
1371
+ end
1372
+
1373
+ should "agree that the browser is :name => 'safari', :minor_version => '0'" do
1374
+ assert @detector.browser_is?( :name => 'safari', :minor_version => '0' )
1375
+ end
1376
+
1377
+ should "agree that the browser is :name => 'safari', :build_version => '3'" do
1378
+ assert @detector.browser_is?( :name => 'safari', :build_version => '3' )
1379
+ end
1380
+
1381
+ should "agree that the browser is :name => 'safari', :revision_version => '0'" do
1382
+ assert @detector.browser_is?( :name => 'safari', :revision_version => '0' )
1383
+ end
1384
+
1385
+ should "agree that the browser is :name => 'safari', :major_version => '4', :minor_version => '0'" do
1386
+ assert @detector.browser_is?( :name => 'safari', :major_version => '4', :minor_version => '0' )
1387
+ end
1388
+
1389
+ should "agree that the browser is :name => 'safari', :major_version => '4', :minor_version => '0', :build_version => '3'" do
1390
+ assert @detector.browser_is?( :name => 'safari', :major_version => '4', :minor_version => '0', :build_version => '3' )
1391
+ end
1392
+
1393
+ should "agree that the browser is :name => 'firefox', :major_version => '4', :minor_version => '0', :build_version => '3', :revision_version => '0'" do
1394
+ assert @detector.browser_is?( :name => 'safari', :major_version => '4', :minor_version => '0', :build_version => '3', :revision_version => '0' )
1395
+ end
1396
+ end
1397
+
1398
+ context "when given a bad Safari 4.0.3 user agent where version cannot be determined" do
1399
+ setup do
1400
+ @detector = BrowserDetector::Detector.new( 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.8 Safari/999.2' )
1401
+ assert !@detector.ua.nil?
1402
+ end
1403
+
1404
+ should "agree that the browser verison is 0.0.0.0" do
1405
+ assert_equal '0.0.0.0', @detector.browser_version
1406
+ end
1407
+
1408
+ should "agree that the browser verison major is 0" do
1409
+ assert_equal '0', @detector.browser_version_major
1410
+ end
1411
+
1412
+ should "agree that the browser verison minor is 0" do
1413
+ assert_equal '0', @detector.browser_version_minor
1414
+ end
1415
+
1416
+ should "agree that the browser verison build is 0" do
1417
+ assert_equal '0', @detector.browser_version_build
1418
+ end
1419
+
1420
+ should "agree that the browser verison revision is 0" do
1421
+ assert_equal '0', @detector.browser_version_revision
1422
+ end
1423
+ end
1424
+ end
1425
+ end