browser 5.3.1 → 6.1.0
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.
- checksums.yaml +4 -4
- data/{FUNDING.yml → .github/FUNDING.yml} +2 -1
- data/.github/workflows/{tests.yml → ruby-tests.yml} +17 -17
- data/.rubocop.yml +3 -23
- data/CHANGELOG.md +18 -7
- data/LICENSE.md +20 -0
- data/README.md +11 -4
- data/bots.yml +23 -0
- data/browser.gemspec +4 -5
- data/gemfiles/{rails6_0.gemfile → 7_0.gemfile} +1 -1
- data/gemfiles/{rails6_1.gemfile → 7_1.gemfile} +1 -1
- data/lib/browser/accept_language.rb +1 -1
- data/lib/browser/base.rb +34 -29
- data/lib/browser/browser.rb +4 -3
- data/lib/browser/chrome.rb +4 -0
- data/lib/browser/device.rb +10 -10
- data/lib/browser/edge.rb +1 -1
- data/lib/browser/meta/base.rb +1 -1
- data/lib/browser/platform/ios.rb +1 -1
- data/lib/browser/platform.rb +1 -1
- data/lib/browser/testing.rb +3 -3
- data/lib/browser/version.rb +1 -1
- data/lib/browser.rb +1 -1
- data/search_engines.yml +1 -0
- data/test/browser_test.rb +3 -3
- data/test/rails_test.rb +1 -1
- data/test/sample_app.rb +2 -2
- data/test/test_helper.rb +4 -2
- data/test/ua.yml +10 -4
- data/test/ua_bots.yml +18 -0
- data/test/unit/accept_language_test.rb +1 -1
- data/test/unit/android_app_test.rb +3 -3
- data/test/unit/android_test.rb +17 -17
- data/test/unit/blackberry_test.rb +1 -1
- data/test/unit/bots_test.rb +15 -4
- data/test/unit/chrome_test.rb +7 -0
- data/test/unit/device_test.rb +25 -25
- data/test/unit/edge_test.rb +6 -0
- data/test/unit/electron_test.rb +1 -1
- data/test/unit/facebook_test.rb +3 -3
- data/test/unit/generic_test.rb +3 -3
- data/test/unit/instagram_test.rb +2 -2
- data/test/unit/internet_explorer_test.rb +18 -18
- data/test/unit/ios_app_test.rb +3 -3
- data/test/unit/ios_test.rb +18 -12
- data/test/unit/kindle_test.rb +15 -0
- data/test/unit/meta_test.rb +13 -13
- data/test/unit/platform_test.rb +33 -25
- data/test/unit/proxy_test.rb +2 -2
- data/test/unit/safari_test.rb +14 -9
- data/test/unit/snapchat_test.rb +3 -3
- data/test/unit/uc_browser_test.rb +1 -1
- data/test/unit/windows_test.rb +11 -11
- metadata +12 -77
data/test/unit/device_test.rb
CHANGED
@@ -13,7 +13,7 @@ class DeviceTest < Minitest::Test
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
test "
|
16
|
+
test "extends matchers" do
|
17
17
|
Browser::Device.matchers.unshift(CustomDevice)
|
18
18
|
device = Browser::Device.new("Custom")
|
19
19
|
assert_equal :custom, device.id
|
@@ -23,28 +23,28 @@ class DeviceTest < Minitest::Test
|
|
23
23
|
assert_equal :unknown_device, device.id
|
24
24
|
end
|
25
25
|
|
26
|
-
test "
|
26
|
+
test "detects generic device" do
|
27
27
|
device = Browser::Device.new("")
|
28
28
|
|
29
29
|
assert device.unknown?
|
30
30
|
assert_equal :unknown_device, device.id
|
31
31
|
end
|
32
32
|
|
33
|
-
test "
|
33
|
+
test "detects ipad" do
|
34
34
|
device = Browser::Device.new(Browser["IOS9"])
|
35
35
|
assert device.ipad?
|
36
36
|
assert_equal :ipad, device.id
|
37
37
|
assert_equal "iPad", device.name
|
38
38
|
end
|
39
39
|
|
40
|
-
test "
|
40
|
+
test "detects old ipad" do
|
41
41
|
device = Browser::Device.new(Browser["IOS3"])
|
42
42
|
assert device.ipad?
|
43
43
|
assert_equal :ipad, device.id
|
44
44
|
assert_equal "iPad", device.name
|
45
45
|
end
|
46
46
|
|
47
|
-
test "
|
47
|
+
test "detects ipod" do
|
48
48
|
device = Browser::Device.new(Browser["IPOD"])
|
49
49
|
assert device.ipod_touch?
|
50
50
|
assert device.ipod?
|
@@ -52,14 +52,14 @@ class DeviceTest < Minitest::Test
|
|
52
52
|
assert_equal "iPod Touch", device.name
|
53
53
|
end
|
54
54
|
|
55
|
-
test "
|
55
|
+
test "detects iphone" do
|
56
56
|
device = Browser::Device.new(Browser["IOS8"])
|
57
57
|
assert device.iphone?
|
58
58
|
assert_equal :iphone, device.id
|
59
59
|
assert_equal "iPhone", device.name
|
60
60
|
end
|
61
61
|
|
62
|
-
test "
|
62
|
+
test "detects ps3" do
|
63
63
|
device = Browser::Device.new(Browser["PLAYSTATION3"])
|
64
64
|
assert device.ps3?
|
65
65
|
assert device.playstation3?
|
@@ -68,7 +68,7 @@ class DeviceTest < Minitest::Test
|
|
68
68
|
assert_equal "PlayStation 3", device.name
|
69
69
|
end
|
70
70
|
|
71
|
-
test "
|
71
|
+
test "detects ps4" do
|
72
72
|
device = Browser::Device.new(Browser["PLAYSTATION4"])
|
73
73
|
assert device.ps4?
|
74
74
|
assert device.playstation4?
|
@@ -99,14 +99,14 @@ class DeviceTest < Minitest::Test
|
|
99
99
|
assert_equal "Xbox One", device.name
|
100
100
|
end
|
101
101
|
|
102
|
-
test "
|
102
|
+
test "detects psp" do
|
103
103
|
device = Browser::Device.new(Browser["PSP"])
|
104
104
|
assert device.psp?
|
105
105
|
assert_equal :psp, device.id
|
106
106
|
assert_equal "PlayStation Portable", device.name
|
107
107
|
end
|
108
108
|
|
109
|
-
test "
|
109
|
+
test "detects psvita" do
|
110
110
|
device = Browser::Device.new(Browser["PSP_VITA"])
|
111
111
|
assert device.playstation_vita?
|
112
112
|
assert device.vita?
|
@@ -114,7 +114,7 @@ class DeviceTest < Minitest::Test
|
|
114
114
|
assert_equal "PlayStation Vita", device.name
|
115
115
|
end
|
116
116
|
|
117
|
-
test "
|
117
|
+
test "detects kindle" do
|
118
118
|
device = Browser::Device.new(Browser["KINDLE"])
|
119
119
|
assert device.kindle?
|
120
120
|
assert_equal :kindle, device.id
|
@@ -127,7 +127,7 @@ class DeviceTest < Minitest::Test
|
|
127
127
|
KINDLE_FIRE_HD
|
128
128
|
KINDLE_FIRE_HD_MOBILE
|
129
129
|
].each do |key|
|
130
|
-
test "
|
130
|
+
test "detects #{key} as kindle fire" do
|
131
131
|
device = Browser::Device.new(Browser[key])
|
132
132
|
|
133
133
|
assert device.kindle?
|
@@ -137,7 +137,7 @@ class DeviceTest < Minitest::Test
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
test "
|
140
|
+
test "detects wii" do
|
141
141
|
device = Browser::Device.new(Browser["NINTENDO_WII"])
|
142
142
|
assert device.nintendo_wii?
|
143
143
|
assert device.console?
|
@@ -147,7 +147,7 @@ class DeviceTest < Minitest::Test
|
|
147
147
|
assert_equal "Nintendo Wii", device.name
|
148
148
|
end
|
149
149
|
|
150
|
-
test "
|
150
|
+
test "detects wiiu" do
|
151
151
|
device = Browser::Device.new(Browser["NINTENDO_WIIU"])
|
152
152
|
assert device.nintendo_wiiu?
|
153
153
|
assert device.wiiu?
|
@@ -157,7 +157,7 @@ class DeviceTest < Minitest::Test
|
|
157
157
|
assert_equal "Nintendo WiiU", device.name
|
158
158
|
end
|
159
159
|
|
160
|
-
test "
|
160
|
+
test "detects switch" do
|
161
161
|
device = Browser::Device.new(Browser["NINTENDO_SWITCH"])
|
162
162
|
assert device.nintendo_switch?
|
163
163
|
assert device.switch?
|
@@ -167,7 +167,7 @@ class DeviceTest < Minitest::Test
|
|
167
167
|
assert_equal "Nintendo Switch", device.name
|
168
168
|
end
|
169
169
|
|
170
|
-
test "
|
170
|
+
test "detects blackberry playbook" do
|
171
171
|
device = Browser::Device.new(Browser["PLAYBOOK"])
|
172
172
|
assert device.playbook?
|
173
173
|
assert device.blackberry_playbook?
|
@@ -175,21 +175,21 @@ class DeviceTest < Minitest::Test
|
|
175
175
|
assert_equal "BlackBerry Playbook", device.name
|
176
176
|
end
|
177
177
|
|
178
|
-
test "
|
178
|
+
test "detects surface" do
|
179
179
|
device = Browser::Device.new(Browser["SURFACE"])
|
180
180
|
assert device.surface?
|
181
181
|
assert_equal :surface, device.id
|
182
182
|
assert_equal "Microsoft Surface", device.name
|
183
183
|
end
|
184
184
|
|
185
|
-
test "
|
185
|
+
test "detects tv" do
|
186
186
|
device = Browser::Device.new(Browser["SMART_TV"])
|
187
187
|
assert device.tv?
|
188
188
|
assert_equal :tv, device.id
|
189
189
|
assert_equal "TV", device.name
|
190
190
|
end
|
191
191
|
|
192
|
-
test "
|
192
|
+
test "detects unknown device" do
|
193
193
|
device = Browser::Device.new("")
|
194
194
|
|
195
195
|
assert device.unknown?
|
@@ -214,7 +214,7 @@ class DeviceTest < Minitest::Test
|
|
214
214
|
OPERA_MOBI
|
215
215
|
KINDLE_FIRE_HD_MOBILE
|
216
216
|
].each do |key|
|
217
|
-
test "
|
217
|
+
test "detects #{key} as mobile" do
|
218
218
|
device = Browser::Device.new(Browser[key])
|
219
219
|
assert device.mobile?
|
220
220
|
refute device.tablet?
|
@@ -232,7 +232,7 @@ class DeviceTest < Minitest::Test
|
|
232
232
|
FIREFOX_TABLET
|
233
233
|
NEXUS7
|
234
234
|
].each do |key|
|
235
|
-
test "
|
235
|
+
test "detects #{key} as tablet" do
|
236
236
|
device = Browser::Device.new(Browser[key])
|
237
237
|
assert device.tablet?
|
238
238
|
refute device.mobile?
|
@@ -253,13 +253,13 @@ class DeviceTest < Minitest::Test
|
|
253
253
|
"CUSTOM_APP" => "HTC Ruby",
|
254
254
|
"NOOK" => "NOOK BNTV250A"
|
255
255
|
}.each do |key, name|
|
256
|
-
test "
|
256
|
+
test "detects device name of #{key} as #{name}" do
|
257
257
|
device = Browser::Device.new(Browser[key])
|
258
258
|
assert_equal name, device.name
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
-
test "
|
262
|
+
test "detects samsung devices" do
|
263
263
|
device = Browser::Device.new(Browser["SAMSUNG_SM-G975F"])
|
264
264
|
|
265
265
|
assert device.samsung?
|
@@ -267,7 +267,7 @@ class DeviceTest < Minitest::Test
|
|
267
267
|
assert_equal "Samsung Galaxy S10+", device.name
|
268
268
|
end
|
269
269
|
|
270
|
-
test "
|
270
|
+
test "detects generic samsung devices" do
|
271
271
|
device = Browser::Device.new(Browser["SAMSUNG_SM-FAKE"])
|
272
272
|
|
273
273
|
assert device.samsung?
|
@@ -280,7 +280,7 @@ class DeviceTest < Minitest::Test
|
|
280
280
|
"SAMSUNG_SM-G960F" => "Samsung Galaxy S9",
|
281
281
|
"SAMSUNG_SM-F700F" => "Samsung Galaxy Z Flip"
|
282
282
|
}.each do |key, name|
|
283
|
-
test "
|
283
|
+
test "detects device name of #{key} as #{name}" do
|
284
284
|
device = Browser::Device.new(Browser[key])
|
285
285
|
assert_equal name, device.name
|
286
286
|
end
|
data/test/unit/edge_test.rb
CHANGED
@@ -16,6 +16,7 @@ class EdgeTest < ActionController::TestCase
|
|
16
16
|
refute browser.chrome?
|
17
17
|
refute browser.safari?
|
18
18
|
refute browser.device.mobile?
|
19
|
+
refute browser.chromium_based?
|
19
20
|
end
|
20
21
|
|
21
22
|
test "detects Microsoft Edge in compatibility view" do
|
@@ -33,6 +34,7 @@ class EdgeTest < ActionController::TestCase
|
|
33
34
|
refute browser.chrome?
|
34
35
|
refute browser.safari?
|
35
36
|
refute browser.device.mobile?
|
37
|
+
refute browser.chromium_based?
|
36
38
|
end
|
37
39
|
|
38
40
|
test "detects Microsoft Edge Mobile" do
|
@@ -48,6 +50,7 @@ class EdgeTest < ActionController::TestCase
|
|
48
50
|
refute browser.webkit?
|
49
51
|
refute browser.chrome?
|
50
52
|
refute browser.safari?
|
53
|
+
refute browser.chromium_based?
|
51
54
|
end
|
52
55
|
|
53
56
|
test "detects Microsoft Edge based on Chrome" do
|
@@ -58,6 +61,7 @@ class EdgeTest < ActionController::TestCase
|
|
58
61
|
assert_equal "79.0.309.18", browser.full_version
|
59
62
|
assert_equal "79", browser.version
|
60
63
|
assert browser.platform.mac?
|
64
|
+
assert browser.chromium_based?
|
61
65
|
refute browser.platform.windows?
|
62
66
|
assert browser.edge?
|
63
67
|
assert browser.webkit?
|
@@ -79,6 +83,7 @@ class EdgeTest < ActionController::TestCase
|
|
79
83
|
refute browser.webkit?
|
80
84
|
refute browser.chrome?
|
81
85
|
refute browser.safari?
|
86
|
+
refute browser.chromium_based?
|
82
87
|
end
|
83
88
|
|
84
89
|
test "detects Microsoft Edge Mobile on Android" do
|
@@ -95,6 +100,7 @@ class EdgeTest < ActionController::TestCase
|
|
95
100
|
refute browser.webkit?
|
96
101
|
refute browser.chrome?
|
97
102
|
refute browser.safari?
|
103
|
+
refute browser.chromium_based?
|
98
104
|
end
|
99
105
|
|
100
106
|
test "detects version by range" do
|
data/test/unit/electron_test.rb
CHANGED
data/test/unit/facebook_test.rb
CHANGED
@@ -8,7 +8,7 @@ class FacebookTest < Minitest::Test
|
|
8
8
|
|
9
9
|
assert_equal "Facebook", browser.name
|
10
10
|
assert browser.facebook?
|
11
|
-
|
11
|
+
assert_equal :facebook, browser.id
|
12
12
|
assert_equal "135.0.0.45.90", browser.full_version
|
13
13
|
assert_equal "135", browser.version
|
14
14
|
end
|
@@ -18,7 +18,7 @@ class FacebookTest < Minitest::Test
|
|
18
18
|
|
19
19
|
assert_equal "Facebook", browser.name
|
20
20
|
assert browser.facebook?
|
21
|
-
|
21
|
+
assert_equal :facebook, browser.id
|
22
22
|
assert_equal "AppleWebKit/605.1.15", browser.full_version
|
23
23
|
assert_equal "AppleWebKit/605", browser.version
|
24
24
|
end
|
@@ -28,7 +28,7 @@ class FacebookTest < Minitest::Test
|
|
28
28
|
|
29
29
|
assert_equal "Facebook", browser.name
|
30
30
|
assert browser.facebook?
|
31
|
-
|
31
|
+
assert_equal :facebook, browser.id
|
32
32
|
assert_equal "214.0.0.43.83", browser.full_version
|
33
33
|
assert_equal "214", browser.version
|
34
34
|
end
|
data/test/unit/generic_test.rb
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
require "test_helper"
|
4
4
|
|
5
5
|
class GenericTest < Minitest::Test
|
6
|
-
test "
|
6
|
+
test "returns default msie version" do
|
7
7
|
browser = Browser.new("")
|
8
8
|
|
9
9
|
assert_equal "0.0", browser.msie_full_version
|
10
10
|
assert_equal "0", browser.msie_version
|
11
11
|
end
|
12
12
|
|
13
|
-
test "
|
13
|
+
test "returns default compatibility view" do
|
14
14
|
browser = Browser.new("")
|
15
15
|
|
16
16
|
refute browser.compatibility_view?
|
17
17
|
end
|
18
18
|
|
19
|
-
test "
|
19
|
+
test "returns default safari web app mode" do
|
20
20
|
browser = Browser.new("")
|
21
21
|
|
22
22
|
refute browser.safari_webapp_mode?
|
data/test/unit/instagram_test.rb
CHANGED
@@ -8,7 +8,7 @@ class InstagramTest < Minitest::Test
|
|
8
8
|
|
9
9
|
assert_equal "Instagram", browser.name
|
10
10
|
assert browser.instagram?
|
11
|
-
|
11
|
+
assert_equal :instagram, browser.id
|
12
12
|
assert_equal "41.0.0.14.90", browser.full_version
|
13
13
|
assert_equal "41", browser.version
|
14
14
|
end
|
@@ -18,7 +18,7 @@ class InstagramTest < Minitest::Test
|
|
18
18
|
|
19
19
|
assert_equal "Instagram", browser.name
|
20
20
|
assert browser.instagram?
|
21
|
-
|
21
|
+
assert_equal :instagram, browser.id
|
22
22
|
assert_equal "182257141", browser.full_version
|
23
23
|
assert_equal "182257141", browser.version
|
24
24
|
end
|
@@ -261,43 +261,43 @@ class IeTest < Minitest::Test
|
|
261
261
|
browser = Browser.new(Browser["IE6"])
|
262
262
|
meta = browser.meta
|
263
263
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
264
|
+
assert_includes meta, "ie"
|
265
|
+
assert_includes meta, "ie6"
|
266
|
+
assert_includes meta, "oldie"
|
267
|
+
assert_includes meta, "lt-ie8"
|
268
|
+
assert_includes meta, "lt-ie9"
|
269
|
+
assert_includes meta, "windows"
|
270
270
|
end
|
271
271
|
|
272
272
|
test "returns string representation for ie7" do
|
273
273
|
browser = Browser.new(Browser["IE7"])
|
274
274
|
meta = browser.meta
|
275
275
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
276
|
+
assert_includes meta, "ie"
|
277
|
+
assert_includes meta, "ie7"
|
278
|
+
assert_includes meta, "oldie"
|
279
|
+
assert_includes meta, "lt-ie8"
|
280
|
+
assert_includes meta, "lt-ie9"
|
281
|
+
assert_includes meta, "windows"
|
282
282
|
end
|
283
283
|
|
284
284
|
test "returns string representation for ie8" do
|
285
285
|
browser = Browser.new(Browser["IE8"])
|
286
286
|
meta = browser.meta
|
287
287
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
288
|
+
assert_includes meta, "ie"
|
289
|
+
assert_includes meta, "ie8"
|
290
|
+
assert_includes meta, "lt-ie9"
|
291
|
+
assert_includes meta, "windows"
|
292
292
|
end
|
293
293
|
|
294
|
-
test "
|
294
|
+
test "does not detect as two different versions" do
|
295
295
|
browser = Browser.new(Browser["IE8"])
|
296
296
|
assert browser.ie?(8)
|
297
297
|
refute browser.ie?(7)
|
298
298
|
end
|
299
299
|
|
300
|
-
test "more complex versioning check" do
|
300
|
+
test "handles more complex versioning check" do
|
301
301
|
browser = Browser.new(Browser["IE8"])
|
302
302
|
assert browser.ie?(["> 7", "< 9"])
|
303
303
|
end
|
data/test/unit/ios_app_test.rb
CHANGED
@@ -5,15 +5,15 @@ require "test_helper"
|
|
5
5
|
class IosAppTest < Minitest::Test
|
6
6
|
let(:browser) { Browser.new(Browser["IOS_WEBVIEW"]) }
|
7
7
|
|
8
|
-
test "
|
8
|
+
test "detects as ios" do
|
9
9
|
assert browser.platform.ios?
|
10
10
|
end
|
11
11
|
|
12
|
-
test "
|
12
|
+
test "does not detect as safari" do
|
13
13
|
refute browser.safari?
|
14
14
|
end
|
15
15
|
|
16
|
-
test "
|
16
|
+
test "detects as webview" do
|
17
17
|
assert browser.platform.ios_webview?
|
18
18
|
end
|
19
19
|
end
|
data/test/unit/ios_test.rb
CHANGED
@@ -25,6 +25,12 @@ class IosTest < Minitest::Test
|
|
25
25
|
assert_equal "5", browser.version
|
26
26
|
end
|
27
27
|
|
28
|
+
test "detects chrome in desktop mode" do
|
29
|
+
browser = Browser.new(Browser["CHROME_REQUEST_DESKTOP_SITE"])
|
30
|
+
assert browser.platform.ios?
|
31
|
+
assert browser.device.mobile?
|
32
|
+
end
|
33
|
+
|
28
34
|
test "detects safari in webapp mode" do
|
29
35
|
browser = Browser.new(Browser["SAFARI_IPAD_WEBAPP_MODE"])
|
30
36
|
refute browser.safari?
|
@@ -109,7 +115,7 @@ class IosTest < Minitest::Test
|
|
109
115
|
refute browser.platform.mac?
|
110
116
|
end
|
111
117
|
|
112
|
-
test "
|
118
|
+
test "does not detect as two different versions" do
|
113
119
|
browser = Browser.new(Browser["IOS8"])
|
114
120
|
assert browser.platform.ios?(8)
|
115
121
|
refute browser.platform.ios?(7)
|
@@ -119,22 +125,22 @@ class IosTest < Minitest::Test
|
|
119
125
|
browser = Browser.new(Browser["IPHONE"])
|
120
126
|
meta = browser.to_s
|
121
127
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
+
assert_includes meta, "webkit"
|
129
|
+
assert_includes meta, "ios"
|
130
|
+
assert_includes meta, "safari"
|
131
|
+
assert_includes meta, "safari3"
|
132
|
+
assert_includes meta, "mobile"
|
133
|
+
refute_includes meta, "tablet"
|
128
134
|
end
|
129
135
|
|
130
136
|
test "returns string representation for ipad" do
|
131
137
|
browser = Browser.new(Browser["IPAD"])
|
132
138
|
meta = browser.to_s
|
133
139
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
140
|
+
assert_includes meta, "webkit"
|
141
|
+
assert_includes meta, "ios"
|
142
|
+
assert_includes meta, "safari"
|
143
|
+
assert_includes meta, "tablet"
|
144
|
+
refute_includes meta, "mobile"
|
139
145
|
end
|
140
146
|
end
|
data/test/unit/kindle_test.rb
CHANGED
@@ -11,6 +11,21 @@ class KindleTest < Minitest::Test
|
|
11
11
|
test "detects kindle fire" do
|
12
12
|
browser = Browser.new(Browser["KINDLE_FIRE"])
|
13
13
|
assert browser.webkit?
|
14
|
+
|
15
|
+
browser = Browser.new(Browser["KINDLE_SILK_TABLET"])
|
16
|
+
assert browser.webkit?
|
17
|
+
|
18
|
+
browser = Browser.new(Browser["KINDLE_SILK_DESKTOP"])
|
19
|
+
assert browser.webkit?
|
20
|
+
|
21
|
+
browser = Browser.new(Browser["KINDLE_SILK_MOBILE"])
|
22
|
+
assert browser.webkit?
|
23
|
+
|
24
|
+
browser = Browser.new(Browser["KINDLE_SILK_TABLET_1ST_GEN"])
|
25
|
+
assert browser.webkit?
|
26
|
+
|
27
|
+
browser = Browser.new(Browser["KINDLE_SILK_MOBILE_1ST_GEN"])
|
28
|
+
assert browser.webkit?
|
14
29
|
end
|
15
30
|
|
16
31
|
test "detects kindle fire hd" do
|
data/test/unit/meta_test.rb
CHANGED
@@ -5,23 +5,23 @@ require "test_helper"
|
|
5
5
|
class MetaTest < Minitest::Test
|
6
6
|
class CustomRule < Browser::Meta::Base
|
7
7
|
def meta
|
8
|
-
"custom" if
|
8
|
+
"custom" if browser.ua.include?("Custom")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
test "
|
12
|
+
test "extends rules" do
|
13
13
|
Browser::Meta.rules.unshift(CustomRule)
|
14
14
|
|
15
15
|
browser = Browser.new("Custom")
|
16
|
-
|
16
|
+
assert_includes browser.meta, "custom"
|
17
17
|
|
18
18
|
browser = Browser.new("Safari")
|
19
|
-
|
19
|
+
refute_includes browser.meta, "custom"
|
20
20
|
|
21
21
|
Browser::Meta.rules.shift
|
22
22
|
|
23
23
|
browser = Browser.new("Custom")
|
24
|
-
|
24
|
+
refute_includes browser.meta, "custom"
|
25
25
|
end
|
26
26
|
|
27
27
|
test "sets meta" do
|
@@ -33,25 +33,25 @@ class MetaTest < Minitest::Test
|
|
33
33
|
browser = Browser.new(Browser["CHROME"])
|
34
34
|
meta = browser.to_s
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
assert_includes meta, "chrome"
|
37
|
+
assert_includes meta, "webkit"
|
38
|
+
assert_includes meta, "mac"
|
39
39
|
end
|
40
40
|
|
41
41
|
test "returns string representation for mobile" do
|
42
42
|
browser = Browser.new(Browser["BLACKBERRY"])
|
43
43
|
meta = browser.to_s
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
assert_includes meta, "blackberry"
|
46
|
+
assert_includes meta, "mobile"
|
47
47
|
end
|
48
48
|
|
49
49
|
test "returns string representation for unknown platform/device/browser" do
|
50
50
|
browser = Browser.new("Unknown")
|
51
51
|
meta = browser.to_s
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
assert_includes meta, "unknown_platform"
|
54
|
+
assert_includes meta, "unknown_device"
|
55
|
+
assert_includes meta, "unknown_browser"
|
56
56
|
end
|
57
57
|
end
|