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,106 +1,84 @@
1
1
  require "test_helper"
2
2
 
3
3
  class BlackberryTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
4
  test "detects blackberry" do
9
- @browser.ua = $ua["BLACKBERRY"]
10
-
11
- assert_equal "BlackBerry", @browser.name
12
- assert @browser.blackberry?
13
- refute @browser.tablet?
14
- assert @browser.mobile?
15
- refute @browser.modern?
16
- assert_equal "4.1.0", @browser.full_version
17
- assert_equal "4", @browser.version
5
+ browser = Browser.new(Browser["BLACKBERRY"])
6
+
7
+ assert_equal "BlackBerry", browser.name
8
+ refute browser.device.tablet?
9
+ assert browser.device.mobile?
10
+ refute browser.modern?
11
+ assert_equal "4.1.0", browser.full_version
12
+ assert_equal "4", browser.version
18
13
  end
19
14
 
20
15
  test "detects blackberry4" do
21
- @browser.ua = $ua["BLACKBERRY4"]
22
-
23
- assert_equal "BlackBerry", @browser.name
24
- assert_equal "4", @browser.blackberry_version
25
- assert @browser.blackberry?(4)
26
- refute @browser.tablet?
27
- assert @browser.mobile?
28
- refute @browser.modern?
29
- assert_equal "4.2.1", @browser.full_version
30
- assert_equal "4", @browser.version
16
+ browser = Browser.new(Browser["BLACKBERRY4"])
17
+
18
+ assert_equal "BlackBerry", browser.name
19
+ refute browser.modern?
20
+ assert_equal "4.2.1", browser.full_version
21
+ assert_equal "4", browser.version
31
22
  end
32
23
 
33
24
  test "detects blackberry5" do
34
- @browser.ua = $ua["BLACKBERRY5"]
35
-
36
- assert_equal "BlackBerry", @browser.name
37
- assert @browser.blackberry?(5)
38
- assert_equal "5", @browser.blackberry_version
39
- refute @browser.tablet?
40
- assert @browser.mobile?
41
- refute @browser.modern?
42
- assert_equal "5.0.0.93", @browser.full_version
43
- assert_equal "5", @browser.version
25
+ browser = Browser.new(Browser["BLACKBERRY5"])
26
+
27
+ assert_equal "BlackBerry", browser.name
28
+ refute browser.device.tablet?
29
+ assert browser.device.mobile?
30
+ refute browser.modern?
31
+ assert_equal "5.0.0.93", browser.full_version
32
+ assert_equal "5", browser.version
44
33
  end
45
34
 
46
35
  test "detects blackberry6" do
47
- @browser.ua = $ua["BLACKBERRY6"]
48
-
49
- assert_equal "Safari", @browser.name
50
- assert @browser.blackberry?(6)
51
- assert_equal "6", @browser.blackberry_version
52
- refute @browser.tablet?
53
- assert @browser.mobile?
54
- assert @browser.modern?
55
- assert_equal "534.11", @browser.full_version
56
- assert_equal "534", @browser.version
36
+ browser = Browser.new(Browser["BLACKBERRY6"])
37
+
38
+ assert_equal "BlackBerry", browser.name
39
+ refute browser.device.tablet?
40
+ assert browser.device.mobile?
41
+ assert browser.modern?
42
+ assert_equal "6.0.0.141", browser.full_version
43
+ assert_equal "6", browser.version
57
44
  end
58
45
 
59
46
  test "detects blackberry7" do
60
- @browser.ua = $ua["BLACKBERRY7"]
61
-
62
- assert_equal "Safari", @browser.name
63
- assert @browser.blackberry?(7)
64
- assert_equal "7", @browser.blackberry_version
65
- refute @browser.tablet?
66
- assert @browser.mobile?
67
- assert @browser.modern?
68
- assert_equal "534.11", @browser.full_version
69
- assert_equal "534", @browser.version
47
+ browser = Browser.new(Browser["BLACKBERRY7"])
48
+
49
+ assert_equal "BlackBerry", browser.name
50
+ refute browser.device.tablet?
51
+ assert browser.device.mobile?
52
+ assert browser.modern?
53
+ assert_equal "7.0.0.1", browser.full_version
54
+ assert_equal "7", browser.version
70
55
  end
71
56
 
72
57
  test "detects blackberry10" do
73
- @browser.ua = $ua["BLACKBERRY10"]
74
-
75
- assert_equal "Safari", @browser.name
76
- assert_equal "10", @browser.blackberry_version
77
- assert @browser.blackberry?(10)
78
- refute @browser.tablet?
79
- assert @browser.mobile?
80
- assert @browser.modern?
81
- assert_equal "10.0.9.1675", @browser.full_version
82
- assert_equal "10", @browser.version
58
+ browser = Browser.new(Browser["BLACKBERRY10"])
59
+
60
+ assert_equal "BlackBerry", browser.name
61
+ refute browser.device.tablet?
62
+ assert browser.device.mobile?
63
+ assert browser.modern?
64
+ assert_equal "10.0.9.1675", browser.full_version
65
+ assert_equal "10", browser.version
83
66
  end
84
67
 
85
68
  test "detects blackberry playbook tablet" do
86
- @browser.ua = $ua["PLAYBOOK"]
69
+ browser = Browser.new(Browser["PLAYBOOK"])
87
70
 
88
- refute @browser.android?
89
- assert @browser.tablet?
90
- refute @browser.mobile?
91
-
92
- assert_equal "7.2.1.0", @browser.full_version
93
- assert_equal "7", @browser.version
94
- end
71
+ refute browser.platform.android?
72
+ assert browser.device.tablet?
73
+ refute browser.device.mobile?
95
74
 
96
- test "warn about deprecated numbered version" do
97
- message = "Browser#blackberry10? is deprecated; use Browser#blackberry?(version) instead"
98
- assert_deprecated(message, __FILE__, __LINE__) { @browser.blackberry10? }
75
+ assert_equal "7.2.1.0", browser.full_version
76
+ assert_equal "7", browser.version
99
77
  end
100
78
 
101
79
  test "don't detect as two different versions" do
102
- @browser.ua = $ua["BLACKBERRY10"]
103
- assert @browser.blackberry?(10)
104
- refute @browser.blackberry?(7)
80
+ browser = Browser.new(Browser["BLACKBERRY10"])
81
+ assert browser.platform.blackberry?("~> 10.0")
82
+ refute browser.platform.blackberry?("~> 7.0")
105
83
  end
106
84
  end
@@ -1,121 +1,89 @@
1
1
  require "test_helper"
2
2
 
3
3
  class BotsTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
- test "detects bots" do
9
- %w[
10
- APPLE_BOT
11
- DOMAINAREANIMATOR
12
- DOT_BOT
13
- FACEBOOK_BOT
14
- GOOGLE_BOT
15
- GRAPESHOT
16
- LINKDEXBOT
17
- LOAD_TIME_BOT
18
- MAIL_RU
19
- MEGAINDEX_RU
20
- MSN_BOT
21
- QUERYSEEKER
22
- SCRAPY
23
- SEOKICKS
24
- TINEYE
25
- SISTRIX
26
- YANDEX_DIRECT
27
- YANDEX_METRIKA
28
- ].each do |key|
29
- @browser.ua = $ua[key]
30
- assert @browser.bot?, "#{$ua[key]} should be a bot"
4
+ Browser.bot_user_agents.each do |key, ua|
5
+ test "detect #{key} as bot" do
6
+ browser = Browser.new(ua)
7
+ assert browser.bot?
31
8
  end
32
-
33
- @browser.ua = $ua["CHROME"]
34
- refute @browser.bot?
35
9
  end
36
10
 
37
- test "detects Google Page Speed as a bot" do
38
- @browser.ua = $ua["GOOGLE_PAGE_SPEED_INSIGHTS"]
39
- assert @browser.bot?
11
+ test "don't detect as bot" do
12
+ browser = Browser.new(Browser["CHROME"])
13
+ refute browser.bot?
40
14
  end
41
15
 
42
16
  test "doesn't consider empty UA as bot" do
43
- @browser.ua = ""
44
- refute @browser.bot?
17
+ browser = Browser.new("")
18
+ refute browser.bot?
45
19
  end
46
20
 
47
21
  test "allows setting empty string as bots" do
48
- Browser::Bots.detect_empty_ua!
49
- @browser.ua = ""
22
+ Browser::Bot.detect_empty_ua!
23
+ browser = Browser.new("")
50
24
 
51
- assert @browser.bot?
25
+ assert browser.bot?
52
26
  end
53
27
 
54
28
  test "doesn't detect mozilla as a bot when considering empty UA" do
55
- Browser::Bots.detect_empty_ua!
56
- @browser.ua = "Mozilla"
29
+ Browser::Bot.detect_empty_ua!
30
+ browser = Browser.new("Mozilla")
57
31
 
58
- refute @browser.bot?
32
+ refute browser.bot?
59
33
  end
60
34
 
61
35
  test "returns bot name" do
62
- @browser.ua = $ua["GOOGLE_BOT"]
63
- assert_equal @browser.bot_name, "Googlebot"
36
+ browser = Browser.new(Browser["GOOGLE_BOT"])
37
+ assert_equal "Google Bot", browser.bot.name
64
38
 
65
- @browser.ua = $ua["FACEBOOK_BOT"]
66
- assert_equal @browser.bot_name, "facebookexternalhit"
39
+ browser = Browser.new(Browser["FACEBOOK_BOT"])
40
+ assert_equal "Facebook Bot", browser.bot.name
67
41
  end
68
42
 
69
43
  test "returns bot name (empty string ua detection enabled)" do
70
- Browser::Bots.detect_empty_ua!
71
- @browser.ua = ""
44
+ Browser::Bot.detect_empty_ua!
45
+ browser = Browser.new("")
72
46
 
73
- assert_equal @browser.bot_name, "Generic Bot"
47
+ assert_equal browser.bot.name, "Generic Bot"
74
48
  end
75
49
 
76
50
  test "returns nil for non-bots" do
77
- @browser.ua = $ua["CHROME"]
78
- assert_equal @browser.bot_name, nil
51
+ browser = Browser.new(Browser["CHROME"])
52
+ assert_nil browser.bot.name
79
53
  end
80
54
 
81
- test "detects as search engines" do
82
- %w[
83
- ASK
84
- BAIDU
85
- BINGBOT
86
- DUCKDUCKGO
87
- GOOGLE_BOT
88
- YAHOO_SLURP
89
- ].each do |key|
90
- @browser.ua = $ua[key]
91
- assert @browser.search_engine?, "#{$ua[key]} should be a search engine"
55
+ Browser.search_engine_user_agents.each do |key, ua|
56
+ test "detects #{key} as search engine" do
57
+ browser = Browser.new(ua)
58
+ assert browser.bot.search_engine?
92
59
  end
93
60
  end
94
61
 
95
- test "detects Google Structured Data Testing Tool as a bot" do
96
- @browser.ua = $ua["GOOGLE_STRUCTURED_DATA_TESTING_TOOL"]
97
-
98
- assert @browser.bot?, "Google Structured Data Testing Tool should be a bot"
62
+ test "detects Daumoa" do
63
+ browser = Browser.new(Browser["DAUMOA"])
64
+
65
+ assert_equal :ie, browser.id
66
+ assert_equal "Internet Explorer", browser.name
67
+ assert_equal "0.0", browser.msie_full_version
68
+ assert_equal "0", browser.msie_version
69
+ assert_equal "0.0", browser.full_version
70
+ assert_equal "0", browser.version
71
+ assert browser.ie?
72
+ assert browser.bot?
73
+ refute browser.platform.windows10?
74
+ refute browser.platform.windows_phone?
75
+ refute browser.edge?
76
+ refute browser.modern?
77
+ refute browser.device.mobile?
78
+ refute browser.webkit?
79
+ refute browser.chrome?
80
+ refute browser.safari?
99
81
  end
100
82
 
101
- test "detects Daumoa" do
102
- @browser.ua = $ua["DAUMOA"]
103
-
104
- assert_equal :ie, @browser.id
105
- assert_equal "Internet Explorer", @browser.name
106
- assert_equal "0.0", @browser.msie_full_version
107
- assert_equal "0", @browser.msie_version
108
- assert_equal "0.0", @browser.full_version
109
- assert_equal "0", @browser.version
110
- assert @browser.ie?
111
- assert @browser.bot?
112
- refute @browser.windows10?
113
- refute @browser.windows_phone?
114
- refute @browser.edge?
115
- refute @browser.modern?
116
- refute @browser.mobile?
117
- refute @browser.webkit?
118
- refute @browser.chrome?
119
- refute @browser.safari?
83
+ test "custom android user agent (#144)" do
84
+ browser = Browser.new(Browser["CUSTOM_APP"])
85
+
86
+ assert browser.platform.android?
87
+ refute browser.bot?
120
88
  end
121
89
  end
@@ -1,60 +1,66 @@
1
1
  require "test_helper"
2
2
 
3
3
  class ChromeTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
4
  test "detects chrome" do
9
- @browser.ua = $ua["CHROME"]
10
-
11
- assert_equal "Chrome", @browser.name
12
- assert @browser.chrome?
13
- refute @browser.safari?
14
- assert @browser.webkit?
15
- assert @browser.modern?
16
- assert_equal "5.0.375.99", @browser.full_version
17
- assert_equal "5", @browser.version
5
+ browser = Browser.new(Browser["CHROME"])
6
+
7
+ assert_equal "Chrome", browser.name
8
+ assert browser.chrome?
9
+ refute browser.safari?
10
+ assert browser.webkit?
11
+ assert browser.modern?
12
+ assert_equal "5.0.375.99", browser.full_version
13
+ assert_equal "5", browser.version
18
14
  end
19
15
 
20
16
  test "detects mobile chrome" do
21
- @browser.ua = $ua["MOBILE_CHROME"]
22
-
23
- assert_equal "Chrome", @browser.name
24
- assert @browser.chrome?
25
- refute @browser.safari?
26
- assert @browser.webkit?
27
- assert @browser.modern?
28
- assert_equal "19.0.1084.60", @browser.full_version
29
- assert_equal "19", @browser.version
17
+ browser = Browser.new(Browser["MOBILE_CHROME"])
18
+
19
+ assert_equal "Chrome", browser.name
20
+ assert browser.chrome?
21
+ refute browser.safari?
22
+ assert browser.webkit?
23
+ assert browser.modern?
24
+ assert_equal "19.0.1084.60", browser.full_version
25
+ assert_equal "19", browser.version
30
26
  end
31
27
 
32
28
  test "detects samsung chrome" do
33
- @browser.ua = $ua["SAMSUNG_CHROME"]
34
-
35
- assert_equal "Chrome", @browser.name
36
- assert @browser.chrome?
37
- assert @browser.android?
38
- refute @browser.safari?
39
- assert @browser.webkit?
40
- assert @browser.modern?
41
- assert_equal "28.0.1500.94", @browser.full_version
42
- assert_equal "28", @browser.version
29
+ browser = Browser.new(Browser["SAMSUNG_CHROME"])
30
+
31
+ assert_equal "Chrome", browser.name
32
+ assert browser.chrome?
33
+ assert browser.platform.android?
34
+ refute browser.safari?
35
+ assert browser.webkit?
36
+ assert browser.modern?
37
+ assert_equal "28.0.1500.94", browser.full_version
38
+ assert_equal "28", browser.version
43
39
  end
44
40
 
45
41
  test "detects chrome os" do
46
- @browser.ua = $ua["CHROME_OS"]
47
- assert @browser.chrome_os?
42
+ browser = Browser.new(Browser["CHROME_OS"])
43
+ assert browser.platform.chrome_os?
48
44
  end
49
45
 
50
46
  test "detects yandex browser" do
51
- @browser.ua = $ua["YANDEX_BROWSER"]
52
-
53
- assert @browser.yandex?
54
- assert @browser.chrome?
55
- refute @browser.safari?
56
- assert @browser.webkit?
57
- assert_equal "41.0.2272.118", @browser.full_version
58
- assert_equal "41", @browser.version
47
+ browser = Browser.new(Browser["YANDEX_BROWSER"])
48
+
49
+ assert browser.yandex?
50
+ assert browser.chrome?
51
+ refute browser.safari?
52
+ assert browser.webkit?
53
+ assert_equal "41.0.2272.118", browser.full_version
54
+ assert_equal "41", browser.version
55
+ end
56
+
57
+ test "detects chrome frame" do
58
+ browser = Browser.new(Browser["IE9_CHROME_FRAME"])
59
+
60
+ assert browser.chrome?
61
+ refute browser.safari?
62
+ assert browser.webkit?
63
+ assert_equal "26.0.1410.43", browser.full_version
64
+ assert_equal "26", browser.version
59
65
  end
60
66
  end
@@ -1,71 +1,13 @@
1
1
  require "test_helper"
2
2
 
3
3
  class ConsoleTest < Minitest::Test
4
- setup do
5
- @browser = Browser.new
6
- end
7
-
8
- test "detects nintendo wii" do
9
- @browser.ua = $ua["NINTENDO_WII"]
10
-
11
- assert @browser.console?
12
- assert @browser.nintendo?
13
- end
14
-
15
- test "detects nintendo wii u" do
16
- @browser.ua = $ua["NINTENDO_WIIU"]
17
-
18
- assert @browser.console?
19
- assert @browser.nintendo?
20
- end
21
-
22
- test "detects playstation 3" do
23
- @browser.ua = $ua["PLAYSTATION3"]
24
-
25
- assert @browser.console?
26
- assert @browser.playstation?
27
- refute @browser.playstation4?
28
- end
29
-
30
- test "detects playstation 4" do
31
- @browser.ua = $ua["PLAYSTATION4"]
32
-
33
- assert @browser.console?
34
- assert @browser.playstation?
35
- assert @browser.playstation4?
36
- end
37
-
38
- test "detects xbox 360" do
39
- @browser.ua = $ua["XBOX360"]
40
-
41
- assert @browser.console?
42
- assert @browser.xbox?
43
- refute @browser.xbox_one?
44
- end
45
-
46
- test "detects xbox one" do
47
- @browser.ua = $ua["XBOXONE"]
48
-
49
- assert @browser.console?
50
- assert @browser.xbox?
51
- assert @browser.xbox_one?
52
- end
53
-
54
4
  test "detects psp" do
55
- @browser.ua = $ua["PSP"]
56
-
57
- assert_equal "PlayStation Portable", @browser.name
58
- assert @browser.psp?
59
- refute @browser.psp_vita?
60
- assert @browser.mobile?
5
+ browser = Browser.new(Browser["PSP"])
6
+ assert_equal "Generic Browser", browser.name
61
7
  end
62
8
 
63
9
  test "detects psp vita" do
64
- @browser.ua = $ua["PSP_VITA"]
65
-
66
- assert_equal "PlayStation Portable", @browser.name
67
- assert @browser.psp?
68
- assert @browser.psp_vita?
69
- assert @browser.mobile?
10
+ browser = Browser.new(Browser["PSP_VITA"])
11
+ assert_equal "Generic Browser", browser.name
70
12
  end
71
13
  end