browser 1.1.0 → 2.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +2 -0
  3. data/.hound.yml +26 -6
  4. data/.rubocop.yml +26 -6
  5. data/CHANGELOG.md +10 -0
  6. data/README.md +177 -41
  7. data/Rakefile +1 -1
  8. data/bin/rake +16 -0
  9. data/bot_exceptions.yml +1 -0
  10. data/bots.yml +188 -192
  11. data/browser.gemspec +14 -28
  12. data/languages.yml +54 -54
  13. data/lib/browser.rb +82 -202
  14. data/lib/browser/accept_language.rb +47 -0
  15. data/lib/browser/action_controller.rb +1 -1
  16. data/lib/browser/base.rb +159 -0
  17. data/lib/browser/blackberry.rb +21 -0
  18. data/lib/browser/bot.rb +63 -0
  19. data/lib/browser/chrome.rb +23 -0
  20. data/lib/browser/detect_version.rb +19 -0
  21. data/lib/browser/device.rb +175 -0
  22. data/lib/browser/device/base.rb +11 -0
  23. data/lib/browser/device/blackberry_playbook.rb +17 -0
  24. data/lib/browser/device/ipad.rb +17 -0
  25. data/lib/browser/device/iphone.rb +17 -0
  26. data/lib/browser/device/ipod_touch.rb +17 -0
  27. data/lib/browser/device/kindle.rb +17 -0
  28. data/lib/browser/device/kindle_fire.rb +17 -0
  29. data/lib/browser/device/playstation3.rb +17 -0
  30. data/lib/browser/device/playstation4.rb +17 -0
  31. data/lib/browser/device/psp.rb +17 -0
  32. data/lib/browser/device/psvita.rb +17 -0
  33. data/lib/browser/device/surface.rb +23 -0
  34. data/lib/browser/device/tv.rb +17 -0
  35. data/lib/browser/device/unknown.rb +17 -0
  36. data/lib/browser/device/wii.rb +17 -0
  37. data/lib/browser/device/wiiu.rb +17 -0
  38. data/lib/browser/device/xbox_360.rb +17 -0
  39. data/lib/browser/device/xbox_one.rb +17 -0
  40. data/lib/browser/edge.rb +19 -0
  41. data/lib/browser/firefox.rb +19 -0
  42. data/lib/browser/generic.rb +32 -0
  43. data/lib/browser/internet_explorer.rb +61 -0
  44. data/lib/browser/meta/base.rb +1 -1
  45. data/lib/browser/meta/device.rb +9 -0
  46. data/lib/browser/meta/generic_browser.rb +1 -1
  47. data/lib/browser/meta/id.rb +1 -1
  48. data/lib/browser/meta/ie.rb +1 -1
  49. data/lib/browser/meta/ios.rb +2 -2
  50. data/lib/browser/meta/mobile.rb +2 -2
  51. data/lib/browser/meta/modern.rb +1 -1
  52. data/lib/browser/meta/platform.rb +2 -2
  53. data/lib/browser/meta/proxy.rb +1 -1
  54. data/lib/browser/meta/safari.rb +1 -1
  55. data/lib/browser/meta/tablet.rb +9 -0
  56. data/lib/browser/meta/webkit.rb +1 -1
  57. data/lib/browser/middleware.rb +1 -1
  58. data/lib/browser/middleware/context.rb +2 -2
  59. data/lib/browser/middleware/context/additions.rb +1 -1
  60. data/lib/browser/middleware/context/url_methods.rb +3 -3
  61. data/lib/browser/nokia.rb +19 -0
  62. data/lib/browser/opera.rb +19 -0
  63. data/lib/browser/phantom_js.rb +19 -0
  64. data/lib/browser/platform.rb +152 -0
  65. data/lib/browser/platform/adobe_air.rb +21 -0
  66. data/lib/browser/platform/android.rb +21 -0
  67. data/lib/browser/platform/base.rb +15 -0
  68. data/lib/browser/platform/blackberry.rb +21 -0
  69. data/lib/browser/platform/chrome_os.rb +21 -0
  70. data/lib/browser/platform/firefox_os.rb +21 -0
  71. data/lib/browser/platform/ios.rb +28 -0
  72. data/lib/browser/platform/linux.rb +21 -0
  73. data/lib/browser/platform/mac.rb +21 -0
  74. data/lib/browser/platform/other.rb +21 -0
  75. data/lib/browser/platform/windows.rb +21 -0
  76. data/lib/browser/platform/windows_mobile.rb +21 -0
  77. data/lib/browser/platform/windows_phone.rb +21 -0
  78. data/lib/browser/rails.rb +3 -2
  79. data/lib/browser/safari.rb +22 -0
  80. data/lib/browser/testing.rb +23 -0
  81. data/lib/browser/uc_browser.rb +19 -0
  82. data/lib/browser/version.rb +2 -7
  83. data/search_engines.yml +5 -5
  84. data/test/browser_test.rb +71 -172
  85. data/test/middleware_test.rb +7 -7
  86. data/test/sample_app.rb +3 -3
  87. data/test/test_helper.rb +11 -10
  88. data/test/ua.yml +15 -26
  89. data/test/ua_bots.yml +27 -0
  90. data/test/ua_search_engines.yml +6 -0
  91. data/test/unit/accept_language_test.rb +92 -0
  92. data/test/unit/adobe_air_test.rb +5 -10
  93. data/test/unit/android_test.rb +44 -49
  94. data/test/unit/blackberry_test.rb +55 -77
  95. data/test/unit/bots_test.rb +52 -84
  96. data/test/unit/chrome_test.rb +48 -42
  97. data/test/unit/console_test.rb +4 -62
  98. data/test/unit/device_test.rb +193 -0
  99. data/test/unit/firefox_test.rb +32 -27
  100. data/test/unit/ie_test.rb +223 -238
  101. data/test/unit/ios_app_test.rb +3 -3
  102. data/test/unit/ios_test.rb +87 -94
  103. data/test/unit/kindle_test.rb +10 -24
  104. data/test/unit/nokia_test.rb +3 -7
  105. data/test/unit/opera_test.rb +20 -30
  106. data/test/unit/platform_test.rb +161 -0
  107. data/test/unit/proxy_test.rb +3 -3
  108. data/test/unit/safari_test.rb +66 -0
  109. data/test/unit/uc_browser_test.rb +3 -7
  110. data/test/unit/windows_phone_test.rb +19 -40
  111. data/test/unit/windows_test.rb +32 -34
  112. metadata +73 -28
  113. data/lib/browser/methods/blackberry.rb +0 -51
  114. data/lib/browser/methods/bots.rb +0 -35
  115. data/lib/browser/methods/consoles.rb +0 -43
  116. data/lib/browser/methods/devices.rb +0 -41
  117. data/lib/browser/methods/ie.rb +0 -99
  118. data/lib/browser/methods/language.rb +0 -16
  119. data/lib/browser/methods/mobile.rb +0 -35
  120. data/lib/browser/methods/platform.rb +0 -152
  121. data/lib/browser/methods/proxy.rb +0 -8
  122. data/lib/browser/methods/tv.rb +0 -8
@@ -1,10 +1,10 @@
1
1
  require "test_helper"
2
2
 
3
3
  class IosAppTest < Minitest::Test
4
- let(:browser) { Browser.new(ua: $ua["IOS_WEBVIEW"]) }
4
+ let(:browser) { Browser.new(Browser["IOS_WEBVIEW"]) }
5
5
 
6
6
  test "detect as ios" do
7
- assert browser.ios?
7
+ assert browser.platform.ios?
8
8
  end
9
9
 
10
10
  test "don't detect as safari" do
@@ -12,6 +12,6 @@ class IosAppTest < Minitest::Test
12
12
  end
13
13
 
14
14
  test "detect as webview" do
15
- assert browser.ios_webview?
15
+ assert browser.platform.ios_webview?
16
16
  end
17
17
  end
@@ -1,143 +1,136 @@
1
1
  require "test_helper"
2
2
 
3
3
  class IosTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
4
  test "detects iphone" do
9
- @browser.ua = $ua["IPHONE"]
10
-
11
- assert_equal "iPhone", @browser.name
12
- assert @browser.iphone?
13
- assert @browser.safari?
14
- assert @browser.webkit?
15
- assert @browser.mobile?
16
- assert @browser.modern?
17
- assert @browser.ios?
18
- refute @browser.tablet?
19
- refute @browser.mac?
20
- assert_equal "3.0", @browser.full_version
21
- assert_equal "3", @browser.version
5
+ browser = Browser.new(Browser["IPHONE"])
6
+
7
+ assert_equal "Safari", browser.name
8
+ assert browser.safari?
9
+ assert browser.webkit?
10
+ assert browser.modern?
11
+ assert browser.platform.ios?
12
+ refute browser.platform.mac?
13
+ assert_equal "3.0", browser.full_version
14
+ assert_equal "3", browser.version
22
15
  end
23
16
 
24
17
  test "detects safari" do
25
- @browser.ua = $ua["SAFARI"]
26
-
27
- assert_equal "Safari", @browser.name
28
- assert @browser.safari?
29
- assert @browser.webkit?
30
- assert @browser.modern?
31
- assert_equal "5.0.1", @browser.full_version
32
- assert_equal "5", @browser.version
18
+ browser = Browser.new(Browser["SAFARI"])
19
+
20
+ assert_equal "Safari", browser.name
21
+ assert browser.safari?
22
+ assert browser.webkit?
23
+ assert browser.modern?
24
+ assert_equal "5.0.1", browser.full_version
25
+ assert_equal "5", browser.version
33
26
  end
34
27
 
35
28
  test "detects safari in webapp mode" do
36
- @browser.ua = $ua["SAFARI_IPAD_WEBAPP_MODE"]
37
- refute @browser.safari?
38
- assert @browser.ios_webview?
29
+ browser = Browser.new(Browser["SAFARI_IPAD_WEBAPP_MODE"])
30
+ refute browser.safari?
31
+ assert browser.platform.ios_webview?
39
32
 
40
- @browser.ua = $ua["SAFARI_IPHONE_WEBAPP_MODE"]
41
- refute @browser.safari?
42
- assert @browser.ios_webview?
33
+ browser = Browser.new(Browser["SAFARI_IPHONE_WEBAPP_MODE"])
34
+ refute browser.safari?
35
+ assert browser.platform.ios_webview?
43
36
  end
44
37
 
45
38
  test "detects ipod" do
46
- @browser.ua = $ua["IPOD"]
47
-
48
- assert_equal "iPod Touch", @browser.name
49
- assert @browser.ipod?
50
- assert @browser.safari?
51
- assert @browser.webkit?
52
- assert @browser.mobile?
53
- assert @browser.modern?
54
- assert @browser.ios?
55
- refute @browser.tablet?
56
- refute @browser.mac?
57
- assert_equal "3.0", @browser.full_version
58
- assert_equal "3", @browser.version
39
+ browser = Browser.new(Browser["IPOD"])
40
+
41
+ assert_equal "Safari", browser.name
42
+ assert browser.safari?
43
+ assert browser.webkit?
44
+ assert browser.platform.ios?
45
+ refute browser.device.tablet?
46
+ refute browser.platform.mac?
47
+ assert_equal "3.0", browser.full_version
48
+ assert_equal "3", browser.version
59
49
  end
60
50
 
61
51
  test "detects ipad" do
62
- @browser.ua = $ua["IPAD"]
63
-
64
- assert_equal "iPad", @browser.name
65
- assert @browser.ipad?
66
- assert @browser.safari?
67
- assert @browser.webkit?
68
- assert @browser.modern?
69
- assert @browser.ios?
70
- assert @browser.tablet?
71
- refute @browser.mobile?
72
- refute @browser.mac?
73
- assert_equal "4.0.4", @browser.full_version
74
- assert_equal "4", @browser.version
52
+ browser = Browser.new(Browser["IPAD"])
53
+
54
+ assert_equal "Safari", browser.name
55
+ assert browser.safari?
56
+ assert browser.webkit?
57
+ assert browser.modern?
58
+ assert browser.platform.ios?
59
+ refute browser.platform.mac?
60
+ assert_equal "4.0.4", browser.full_version
61
+ assert_equal "4", browser.version
75
62
  end
76
63
 
77
64
  test "detects ios4" do
78
- @browser.ua = $ua["IOS4"]
79
- assert @browser.ios?
80
- assert @browser.ios?(4)
81
- refute @browser.mac?
65
+ browser = Browser.new(Browser["IOS4"])
66
+ assert browser.platform.ios?
67
+ assert browser.platform.ios?(4)
68
+ refute browser.platform.mac?
82
69
  end
83
70
 
84
-
85
71
  test "detects ios5" do
86
- @browser.ua = $ua["IOS5"]
87
- assert @browser.ios?
88
- assert @browser.ios?(5)
89
- refute @browser.mac?
72
+ browser = Browser.new(Browser["IOS5"])
73
+ assert browser.platform.ios?
74
+ assert browser.platform.ios?(5)
75
+ refute browser.platform.mac?
90
76
  end
91
77
 
92
78
  test "detects ios6" do
93
- @browser.ua = $ua["IOS6"]
94
- assert @browser.ios?
95
- assert @browser.ios?(6)
96
- refute @browser.mac?
79
+ browser = Browser.new(Browser["IOS6"])
80
+ assert browser.platform.ios?
81
+ assert browser.platform.ios?(6)
82
+ refute browser.platform.mac?
97
83
  end
98
84
 
99
85
  test "detects ios7" do
100
- @browser.ua = $ua["IOS7"]
101
- assert @browser.ios?
102
- assert @browser.ios?(7)
103
- refute @browser.mac?
86
+ browser = Browser.new(Browser["IOS7"])
87
+ assert browser.platform.ios?
88
+ assert browser.platform.ios?(7)
89
+ refute browser.platform.mac?
104
90
  end
105
91
 
106
92
  test "detects ios8" do
107
- @browser.ua = $ua["IOS8"]
108
- assert @browser.ios?
109
- assert @browser.ios?(8)
110
- refute @browser.mac?
93
+ browser = Browser.new(Browser["IOS8"])
94
+ assert browser.platform.ios?
95
+ assert browser.platform.ios?(8)
96
+ refute browser.platform.mac?
111
97
  end
112
98
 
113
99
  test "detects ios9" do
114
- @browser.ua = $ua["IOS9"]
115
- assert @browser.ios?
116
- assert @browser.ios?(9)
117
- refute @browser.mac?
100
+ browser = Browser.new(Browser["IOS9"])
101
+ assert browser.platform.ios?
102
+ assert browser.platform.ios?(9)
103
+ refute browser.platform.mac?
118
104
  end
119
105
 
120
106
  test "don't detect as two different versions" do
121
- @browser.ua = $ua["IOS8"]
122
- assert @browser.ios?(8)
123
- refute @browser.ios?(7)
107
+ browser = Browser.new(Browser["IOS8"])
108
+ assert browser.platform.ios?(8)
109
+ refute browser.platform.ios?(7)
124
110
  end
125
111
 
126
- test "warn about deprecated numbered version" do
127
- message = "Browser#ios8? is deprecated; use Browser#ios?(version) instead"
128
- assert_deprecated(message, __FILE__, __LINE__) { @browser.ios8? }
129
- end
130
-
131
- test "returns string representation for ios" do
132
- @browser.ua = $ua["IPHONE"]
133
- meta = @browser.to_s
112
+ test "returns string representation for iphone" do
113
+ browser = Browser.new(Browser["IPHONE"])
114
+ meta = browser.to_s
134
115
 
135
- assert meta.include?("iphone")
136
116
  assert meta.include?("webkit")
137
117
  assert meta.include?("ios")
138
118
  assert meta.include?("safari")
139
119
  assert meta.include?("safari3")
140
120
  assert meta.include?("modern")
141
121
  assert meta.include?("mobile")
122
+ refute meta.include?("tablet")
123
+ end
124
+
125
+ test "returns string representation for ipad" do
126
+ browser = Browser.new(Browser["IPAD"])
127
+ meta = browser.to_s
128
+
129
+ assert meta.include?("webkit")
130
+ assert meta.include?("ios")
131
+ assert meta.include?("safari")
132
+ assert meta.include?("modern")
133
+ assert meta.include?("tablet")
134
+ refute meta.include?("mobile")
142
135
  end
143
136
  end
@@ -1,41 +1,27 @@
1
1
  require "test_helper"
2
2
 
3
3
  class KindleTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
4
  test "detects kindle monochrome" do
9
- @browser.ua = $ua["KINDLE"]
10
-
11
- assert @browser.kindle?
12
- assert @browser.webkit?
5
+ browser = Browser.new(Browser["KINDLE"])
6
+ assert browser.webkit?
13
7
  end
14
8
 
15
9
  test "detects kindle fire" do
16
- @browser.ua = $ua["KINDLE_FIRE"]
17
-
18
- assert @browser.kindle?
19
- assert @browser.webkit?
10
+ browser = Browser.new(Browser["KINDLE_FIRE"])
11
+ assert browser.webkit?
20
12
  end
21
13
 
22
14
  test "detects kindle fire hd" do
23
- @browser.ua = $ua["KINDLE_FIRE_HD"]
15
+ browser = Browser.new(Browser["KINDLE_FIRE_HD"])
24
16
 
25
- assert @browser.silk?
26
- assert @browser.kindle?
27
- assert @browser.webkit?
28
- assert @browser.modern?
29
- refute @browser.mobile?
17
+ assert browser.webkit?
18
+ assert browser.modern?
30
19
  end
31
20
 
32
21
  test "detects kindle fire hd mobile" do
33
- @browser.ua = $ua["KINDLE_FIRE_HD_MOBILE"]
22
+ browser = Browser.new(Browser["KINDLE_FIRE_HD_MOBILE"])
34
23
 
35
- assert @browser.silk?
36
- assert @browser.kindle?
37
- assert @browser.webkit?
38
- assert @browser.modern?
39
- assert @browser.mobile?
24
+ assert browser.webkit?
25
+ assert browser.modern?
40
26
  end
41
27
  end
@@ -1,13 +1,9 @@
1
1
  require "test_helper"
2
2
 
3
3
  class NokiaTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new(ua: $ua["NOKIA"])
6
- end
7
-
8
4
  test "detects Nokia S40" do
9
- assert @browser.mobile?
10
- assert @browser.nokia?
11
- assert_equal @browser.name, "Nokia S40 Ovi Browser"
5
+ browser = Browser.new(Browser["NOKIA"])
6
+ assert browser.nokia?
7
+ assert_equal "Nokia S40 Ovi Browser", browser.name
12
8
  end
13
9
  end
@@ -1,46 +1,36 @@
1
1
  require "test_helper"
2
2
 
3
3
  class OperaTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
4
  test "detects opera" do
9
- @browser.ua = $ua["OPERA"]
5
+ browser = Browser.new(Browser["OPERA"])
10
6
 
11
- assert_equal "Opera", @browser.name
12
- assert @browser.opera?
13
- refute @browser.modern?
14
- assert_equal "11.64", @browser.full_version
15
- assert_equal "11", @browser.version
7
+ assert_equal "Opera", browser.name
8
+ assert browser.opera?
9
+ refute browser.modern?
10
+ assert_equal "11.64", browser.full_version
11
+ assert_equal "11", browser.version
16
12
  end
17
13
 
18
14
  test "detects opera next" do
19
- @browser.ua = $ua["OPERA_NEXT"]
20
-
21
- assert_equal "Opera", @browser.name
22
- assert_equal :opera, @browser.id
23
- assert @browser.opera?
24
- assert @browser.webkit?
25
- assert @browser.modern?
26
- refute @browser.chrome?
27
- assert_equal "15.0.1147.44", @browser.full_version
28
- assert_equal "15", @browser.version
15
+ browser = Browser.new(Browser["OPERA_NEXT"])
16
+
17
+ assert_equal "Opera", browser.name
18
+ assert_equal :opera, browser.id
19
+ assert browser.opera?
20
+ assert browser.webkit?
21
+ assert browser.modern?
22
+ refute browser.chrome?
23
+ assert_equal "15.0.1147.44", browser.full_version
24
+ assert_equal "15", browser.version
29
25
  end
30
26
 
31
27
  test "detects opera mini" do
32
- @browser.ua = $ua["OPERA_MINI"]
33
-
34
- assert @browser.opera_mini?
35
- refute @browser.tablet?
36
- assert @browser.mobile?
28
+ browser = Browser.new(Browser["OPERA_MINI"])
29
+ assert browser.opera_mini?
37
30
  end
38
31
 
39
32
  test "detects opera mobi" do
40
- @browser.ua = $ua["OPERA_MOBI"]
41
-
42
- assert @browser.opera?
43
- refute @browser.tablet?
44
- assert @browser.mobile?
33
+ browser = Browser.new(Browser["OPERA_MOBI"])
34
+ assert browser.opera?
45
35
  end
46
36
  end
@@ -0,0 +1,161 @@
1
+ require "test_helper"
2
+
3
+ class PlatformTest < Minitest::Test
4
+ test "detect other" do
5
+ platform = Browser::Platform.new("Other")
6
+
7
+ assert_equal "Other", platform.name
8
+ assert_equal :other, platform.id
9
+ assert_equal "0", platform.version
10
+ end
11
+
12
+ test "detect ios (iPhone)" do
13
+ platform = Browser::Platform.new(Browser["IOS4"])
14
+
15
+ assert_equal "iOS (iPhone)", platform.name
16
+ assert_equal :ios, platform.id
17
+ assert platform.ios?
18
+ assert_equal "4", platform.version
19
+ end
20
+
21
+ test "detect ios (iPad)" do
22
+ platform = Browser::Platform.new(Browser["IOS9"])
23
+
24
+ assert_equal "iOS (iPad)", platform.name
25
+ assert_equal :ios, platform.id
26
+ assert platform.ios?
27
+ assert_equal "9", platform.version
28
+ end
29
+
30
+ test "detect ios (iPod Touch)" do
31
+ platform = Browser::Platform.new(Browser["IPOD"])
32
+
33
+ assert_equal "iOS (iPod)", platform.name
34
+ assert_equal :ios, platform.id
35
+ assert platform.ios?
36
+ assert_equal "0", platform.version
37
+ end
38
+
39
+ test "detect linux" do
40
+ platform = Browser::Platform.new(Browser["FIREFOX"])
41
+
42
+ assert_equal "Generic Linux", platform.name
43
+ assert_equal :linux, platform.id
44
+ assert platform.linux?
45
+ assert_equal "0", platform.version
46
+ end
47
+
48
+ test "detect mac" do
49
+ platform = Browser::Platform.new(Browser["SAFARI"])
50
+
51
+ assert_equal "Macintosh", platform.name
52
+ assert_equal :mac, platform.id
53
+ assert platform.mac?
54
+ assert_equal "0", platform.version
55
+ end
56
+
57
+ test "detect firefox os" do
58
+ platform = Browser::Platform.new(Browser["FIREFOX_OS"])
59
+
60
+ assert_equal "Firefox OS", platform.name
61
+ assert_equal :firefox_os, platform.id
62
+ assert platform.firefox_os?
63
+ assert_equal "0", platform.version
64
+ end
65
+
66
+ test "detect windows phone" do
67
+ platform = Browser::Platform.new(Browser["MS_EDGE_MOBILE"])
68
+
69
+ assert_equal "Windows Phone", platform.name
70
+ assert_equal :windows_phone, platform.id
71
+ assert platform.windows_phone?
72
+ assert_equal "10.0", platform.version
73
+ end
74
+
75
+ test "detect windows mobile" do
76
+ platform = Browser::Platform.new(Browser["WINDOWS_MOBILE"])
77
+
78
+ assert_equal "Windows Mobile", platform.name
79
+ assert_equal :windows_mobile, platform.id
80
+ assert platform.windows_mobile?
81
+ assert_equal "0", platform.version
82
+ end
83
+
84
+ test "detect blackberry 10" do
85
+ platform = Browser::Platform.new(Browser["BLACKBERRY10"])
86
+
87
+ assert_equal "BlackBerry", platform.name
88
+ assert_equal :blackberry, platform.id
89
+ assert platform.blackberry?
90
+ assert_equal "10.0.9.1675", platform.version
91
+ end
92
+
93
+ test "detect blackberry 4" do
94
+ platform = Browser::Platform.new(Browser["BLACKBERRY4"])
95
+
96
+ assert_equal "BlackBerry", platform.name
97
+ assert_equal :blackberry, platform.id
98
+ assert platform.blackberry?
99
+ assert_equal "4.2.1", platform.version
100
+ end
101
+
102
+ test "detect blackberry 4 (other)" do
103
+ platform = Browser::Platform.new(Browser["BLACKBERRY"])
104
+
105
+ assert_equal "BlackBerry", platform.name
106
+ assert_equal :blackberry, platform.id
107
+ assert platform.blackberry?
108
+ assert_equal "4.1.0", platform.version
109
+ end
110
+
111
+ test "detect blackberry 5" do
112
+ platform = Browser::Platform.new(Browser["BLACKBERRY5"])
113
+
114
+ assert_equal "BlackBerry", platform.name
115
+ assert_equal :blackberry, platform.id
116
+ assert platform.blackberry?
117
+ assert_equal "5.0.0.93", platform.version
118
+ end
119
+
120
+ test "detect blackberry 6" do
121
+ platform = Browser::Platform.new(Browser["BLACKBERRY6"])
122
+
123
+ assert_equal "BlackBerry", platform.name
124
+ assert_equal :blackberry, platform.id
125
+ assert platform.blackberry?
126
+ assert_equal "6.0.0.141", platform.version
127
+ end
128
+
129
+ test "detect blackberry 7" do
130
+ platform = Browser::Platform.new(Browser["BLACKBERRY7"])
131
+
132
+ assert_equal "BlackBerry", platform.name
133
+ assert_equal :blackberry, platform.id
134
+ assert platform.blackberry?
135
+ assert_equal "7.0.0.1", platform.version
136
+ end
137
+
138
+ test "detect android" do
139
+ platform = Browser::Platform.new(Browser["ANDROID_CUPCAKE"])
140
+
141
+ assert_equal "Android", platform.name
142
+ assert_equal :android, platform.id
143
+ assert platform.android?
144
+ assert_equal "1.5", platform.version
145
+ end
146
+
147
+ test "detect chrome os" do
148
+ platform = Browser::Platform.new(Browser["CHROME_OS"])
149
+
150
+ assert_equal "Chrome OS", platform.name
151
+ assert_equal :chrome_os, platform.id
152
+ assert platform.chrome_os?
153
+ assert_equal "3701.81.0", platform.version
154
+ end
155
+
156
+ test "detect adobe air" do
157
+ platform = Browser::Platform.new(Browser["ADOBE_AIR"])
158
+
159
+ assert platform.adobe_air?
160
+ end
161
+ end