browser 1.1.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.hound.yml +26 -6
- data/.rubocop.yml +26 -6
- data/CHANGELOG.md +10 -0
- data/README.md +177 -41
- data/Rakefile +1 -1
- data/bin/rake +16 -0
- data/bot_exceptions.yml +1 -0
- data/bots.yml +188 -192
- data/browser.gemspec +14 -28
- data/languages.yml +54 -54
- data/lib/browser.rb +82 -202
- data/lib/browser/accept_language.rb +47 -0
- data/lib/browser/action_controller.rb +1 -1
- data/lib/browser/base.rb +159 -0
- data/lib/browser/blackberry.rb +21 -0
- data/lib/browser/bot.rb +63 -0
- data/lib/browser/chrome.rb +23 -0
- data/lib/browser/detect_version.rb +19 -0
- data/lib/browser/device.rb +175 -0
- data/lib/browser/device/base.rb +11 -0
- data/lib/browser/device/blackberry_playbook.rb +17 -0
- data/lib/browser/device/ipad.rb +17 -0
- data/lib/browser/device/iphone.rb +17 -0
- data/lib/browser/device/ipod_touch.rb +17 -0
- data/lib/browser/device/kindle.rb +17 -0
- data/lib/browser/device/kindle_fire.rb +17 -0
- data/lib/browser/device/playstation3.rb +17 -0
- data/lib/browser/device/playstation4.rb +17 -0
- data/lib/browser/device/psp.rb +17 -0
- data/lib/browser/device/psvita.rb +17 -0
- data/lib/browser/device/surface.rb +23 -0
- data/lib/browser/device/tv.rb +17 -0
- data/lib/browser/device/unknown.rb +17 -0
- data/lib/browser/device/wii.rb +17 -0
- data/lib/browser/device/wiiu.rb +17 -0
- data/lib/browser/device/xbox_360.rb +17 -0
- data/lib/browser/device/xbox_one.rb +17 -0
- data/lib/browser/edge.rb +19 -0
- data/lib/browser/firefox.rb +19 -0
- data/lib/browser/generic.rb +32 -0
- data/lib/browser/internet_explorer.rb +61 -0
- data/lib/browser/meta/base.rb +1 -1
- data/lib/browser/meta/device.rb +9 -0
- data/lib/browser/meta/generic_browser.rb +1 -1
- data/lib/browser/meta/id.rb +1 -1
- data/lib/browser/meta/ie.rb +1 -1
- data/lib/browser/meta/ios.rb +2 -2
- data/lib/browser/meta/mobile.rb +2 -2
- data/lib/browser/meta/modern.rb +1 -1
- data/lib/browser/meta/platform.rb +2 -2
- data/lib/browser/meta/proxy.rb +1 -1
- data/lib/browser/meta/safari.rb +1 -1
- data/lib/browser/meta/tablet.rb +9 -0
- data/lib/browser/meta/webkit.rb +1 -1
- data/lib/browser/middleware.rb +1 -1
- data/lib/browser/middleware/context.rb +2 -2
- data/lib/browser/middleware/context/additions.rb +1 -1
- data/lib/browser/middleware/context/url_methods.rb +3 -3
- data/lib/browser/nokia.rb +19 -0
- data/lib/browser/opera.rb +19 -0
- data/lib/browser/phantom_js.rb +19 -0
- data/lib/browser/platform.rb +152 -0
- data/lib/browser/platform/adobe_air.rb +21 -0
- data/lib/browser/platform/android.rb +21 -0
- data/lib/browser/platform/base.rb +15 -0
- data/lib/browser/platform/blackberry.rb +21 -0
- data/lib/browser/platform/chrome_os.rb +21 -0
- data/lib/browser/platform/firefox_os.rb +21 -0
- data/lib/browser/platform/ios.rb +28 -0
- data/lib/browser/platform/linux.rb +21 -0
- data/lib/browser/platform/mac.rb +21 -0
- data/lib/browser/platform/other.rb +21 -0
- data/lib/browser/platform/windows.rb +21 -0
- data/lib/browser/platform/windows_mobile.rb +21 -0
- data/lib/browser/platform/windows_phone.rb +21 -0
- data/lib/browser/rails.rb +3 -2
- data/lib/browser/safari.rb +22 -0
- data/lib/browser/testing.rb +23 -0
- data/lib/browser/uc_browser.rb +19 -0
- data/lib/browser/version.rb +2 -7
- data/search_engines.yml +5 -5
- data/test/browser_test.rb +71 -172
- data/test/middleware_test.rb +7 -7
- data/test/sample_app.rb +3 -3
- data/test/test_helper.rb +11 -10
- data/test/ua.yml +15 -26
- data/test/ua_bots.yml +27 -0
- data/test/ua_search_engines.yml +6 -0
- data/test/unit/accept_language_test.rb +92 -0
- data/test/unit/adobe_air_test.rb +5 -10
- data/test/unit/android_test.rb +44 -49
- data/test/unit/blackberry_test.rb +55 -77
- data/test/unit/bots_test.rb +52 -84
- data/test/unit/chrome_test.rb +48 -42
- data/test/unit/console_test.rb +4 -62
- data/test/unit/device_test.rb +193 -0
- data/test/unit/firefox_test.rb +32 -27
- data/test/unit/ie_test.rb +223 -238
- data/test/unit/ios_app_test.rb +3 -3
- data/test/unit/ios_test.rb +87 -94
- data/test/unit/kindle_test.rb +10 -24
- data/test/unit/nokia_test.rb +3 -7
- data/test/unit/opera_test.rb +20 -30
- data/test/unit/platform_test.rb +161 -0
- data/test/unit/proxy_test.rb +3 -3
- data/test/unit/safari_test.rb +66 -0
- data/test/unit/uc_browser_test.rb +3 -7
- data/test/unit/windows_phone_test.rb +19 -40
- data/test/unit/windows_test.rb +32 -34
- metadata +73 -28
- data/lib/browser/methods/blackberry.rb +0 -51
- data/lib/browser/methods/bots.rb +0 -35
- data/lib/browser/methods/consoles.rb +0 -43
- data/lib/browser/methods/devices.rb +0 -41
- data/lib/browser/methods/ie.rb +0 -99
- data/lib/browser/methods/language.rb +0 -16
- data/lib/browser/methods/mobile.rb +0 -35
- data/lib/browser/methods/platform.rb +0 -152
- data/lib/browser/methods/proxy.rb +0 -8
- data/lib/browser/methods/tv.rb +0 -8
@@ -0,0 +1,21 @@
|
|
1
|
+
module Browser
|
2
|
+
class Platform
|
3
|
+
class ChromeOS < Base
|
4
|
+
def match?
|
5
|
+
ua =~ /CrOS/
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"Chrome OS"
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
:chrome_os
|
14
|
+
end
|
15
|
+
|
16
|
+
def version
|
17
|
+
ua[/CrOS(?: x86_64)? ([\d.]+)/, 1]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Browser
|
2
|
+
class Platform
|
3
|
+
class FirefoxOS < Base
|
4
|
+
def version
|
5
|
+
"0"
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"Firefox OS"
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
:firefox_os
|
14
|
+
end
|
15
|
+
|
16
|
+
def match?
|
17
|
+
ua !~ /(Android|Linux|BlackBerry|Windows|Mac)/ && ua =~ /Firefox/
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Browser
|
2
|
+
class Platform
|
3
|
+
class IOS < Base
|
4
|
+
MATCHER = /(iPhone|iPad|iPod)/
|
5
|
+
VERSION_MATCHER = /OS ([\d.]+)/
|
6
|
+
|
7
|
+
def version
|
8
|
+
ua[VERSION_MATCHER, 1] || "0"
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
"iOS (#{device})"
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
:ios
|
17
|
+
end
|
18
|
+
|
19
|
+
def match?
|
20
|
+
ua =~ MATCHER
|
21
|
+
end
|
22
|
+
|
23
|
+
def device
|
24
|
+
ua[MATCHER, 1]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Browser
|
2
|
+
class Platform
|
3
|
+
class WindowsPhone < Base
|
4
|
+
def version
|
5
|
+
ua[/Windows Phone ([\d.]+)/, 1]
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"Windows Phone"
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
:windows_phone
|
14
|
+
end
|
15
|
+
|
16
|
+
def match?
|
17
|
+
ua =~ /Windows Phone/
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/browser/rails.rb
CHANGED
@@ -2,13 +2,14 @@ require "rails/railtie"
|
|
2
2
|
require "browser/action_controller"
|
3
3
|
require "browser/middleware/context/additions"
|
4
4
|
|
5
|
-
|
5
|
+
module Browser
|
6
6
|
class Railtie < Rails::Railtie
|
7
7
|
config.browser = ActiveSupport::OrderedOptions.new
|
8
8
|
|
9
9
|
initializer "browser" do
|
10
10
|
::ActionController::Base.send :include, Browser::ActionController
|
11
|
-
Browser::Middleware::Context.send :include,
|
11
|
+
Browser::Middleware::Context.send :include,
|
12
|
+
Browser::Middleware::Context::Additions
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Browser
|
2
|
+
class Safari < Base
|
3
|
+
def id
|
4
|
+
:safari
|
5
|
+
end
|
6
|
+
|
7
|
+
def name
|
8
|
+
"Safari"
|
9
|
+
end
|
10
|
+
|
11
|
+
def full_version
|
12
|
+
ua[%r[Version/([\d.]+)], 1] ||
|
13
|
+
ua[%r[Safari/([\d.]+)], 1] ||
|
14
|
+
ua[%r[AppleWebKit/([\d.]+)], 1] ||
|
15
|
+
"0.0"
|
16
|
+
end
|
17
|
+
|
18
|
+
def match?
|
19
|
+
!!(ua =~ /Safari/ && ua !~ /Chrome|CriOS|PhantomJS|FxiOS/)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Browser
|
2
|
+
def self.user_agents
|
3
|
+
@user_agents ||= browser_user_agents
|
4
|
+
.merge(bot_user_agents)
|
5
|
+
.merge(search_engine_user_agents)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.browser_user_agents
|
9
|
+
@browser_user_agents ||= YAML.load_file(Browser.root.join("test/ua.yml"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.bot_user_agents
|
13
|
+
@bot_user_agents ||= YAML.load_file(Browser.root.join("test/ua_bots.yml"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.search_engine_user_agents
|
17
|
+
@search_engine_user_agents ||= YAML.load_file(Browser.root.join("test/ua_search_engines.yml"))
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.[](key)
|
21
|
+
user_agents.fetch(key)
|
22
|
+
end
|
23
|
+
end
|
data/lib/browser/version.rb
CHANGED
data/search_engines.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
baidu: "Chinese search engine"
|
2
2
|
bingbot: "Microsoft bing bot"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
googlebot: "Google spider"
|
4
|
+
slurp: "Yahoo spider"
|
5
|
+
duckduckbot: "Duck Duck Go"
|
6
|
+
ask jeeves: "Ask Jeeves"
|
data/test/browser_test.rb
CHANGED
@@ -1,147 +1,88 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
class BrowserTest < Minitest::Test
|
4
|
-
setup do
|
5
|
-
@browser = Browser.new
|
6
|
-
end
|
7
|
-
|
8
|
-
test "yields self when block is given" do
|
9
|
-
browser = nil
|
10
|
-
Browser.new {|b| browser = b }
|
11
|
-
assert_kind_of Browser, browser
|
12
|
-
end
|
13
|
-
|
14
|
-
test "responds to ua methods" do
|
15
|
-
assert @browser.respond_to?(:ua)
|
16
|
-
assert @browser.respond_to?(:ua=)
|
17
|
-
end
|
18
|
-
|
19
|
-
test "delegates ua methods" do
|
20
|
-
@browser.user_agent = "Safari"
|
21
|
-
assert_equal "Safari", @browser.ua
|
22
|
-
|
23
|
-
@browser.ua = "Mozilla"
|
24
|
-
assert_equal "Mozilla", @browser.user_agent
|
25
|
-
end
|
26
|
-
|
27
|
-
test "sets accept language while instantiating object" do
|
28
|
-
@browser = Browser.new(:accept_language => "pt-br")
|
29
|
-
assert_equal ["pt-br"], @browser.accept_language
|
30
|
-
end
|
31
|
-
|
32
4
|
test "sets user agent while instantianting object" do
|
33
|
-
|
34
|
-
assert_equal "Safari",
|
35
|
-
|
36
|
-
@browser = Browser.new(:user_agent => "Chrome")
|
37
|
-
assert_equal "Chrome", @browser.ua
|
5
|
+
browser = Browser.new("Safari")
|
6
|
+
assert_equal "Safari", browser.ua
|
38
7
|
end
|
39
8
|
|
40
9
|
test "detects android" do
|
41
|
-
|
10
|
+
browser = Browser.new(Browser["ANDROID"])
|
42
11
|
|
43
|
-
assert_equal "
|
44
|
-
assert
|
45
|
-
|
46
|
-
assert
|
47
|
-
assert
|
48
|
-
|
49
|
-
|
50
|
-
assert_equal "3.1.2", @browser.full_version
|
51
|
-
assert_equal "3", @browser.version
|
12
|
+
assert_equal "Safari", browser.name
|
13
|
+
assert browser.platform.android?
|
14
|
+
assert browser.safari?
|
15
|
+
assert browser.webkit?
|
16
|
+
assert browser.modern?
|
17
|
+
assert_equal "3.1.2", browser.full_version
|
18
|
+
assert_equal "3", browser.version
|
52
19
|
end
|
53
20
|
|
54
21
|
test "detects android tablet" do
|
55
|
-
|
22
|
+
browser = Browser.new(Browser["TABLOID"])
|
56
23
|
|
57
|
-
assert_equal "
|
58
|
-
assert
|
59
|
-
|
60
|
-
assert
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
assert_equal "4.0", @browser.full_version
|
65
|
-
assert_equal "4", @browser.version
|
24
|
+
assert_equal "Safari", browser.name
|
25
|
+
assert browser.platform.android?
|
26
|
+
assert browser.safari?
|
27
|
+
assert browser.webkit?
|
28
|
+
assert browser.modern?
|
29
|
+
assert_equal "4.0", browser.full_version
|
30
|
+
assert_equal "4", browser.version
|
66
31
|
end
|
67
32
|
|
68
33
|
test "detects surface tablet" do
|
69
|
-
|
34
|
+
browser = Browser.new(Browser["SURFACE"])
|
70
35
|
|
71
|
-
assert_equal "Internet Explorer",
|
72
|
-
assert
|
73
|
-
assert
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
assert_equal "10.0", @browser.full_version
|
78
|
-
assert_equal "10", @browser.version
|
36
|
+
assert_equal "Internet Explorer", browser.name
|
37
|
+
assert browser.device.surface?
|
38
|
+
assert browser.ie?
|
39
|
+
assert browser.modern?
|
40
|
+
assert_equal "10.0", browser.full_version
|
41
|
+
assert_equal "10", browser.version
|
79
42
|
end
|
80
43
|
|
81
44
|
test "detects quicktime" do
|
82
|
-
|
45
|
+
browser = Browser.new(Browser["QUICKTIME"])
|
83
46
|
|
84
|
-
assert_equal "QuickTime",
|
85
|
-
assert
|
86
|
-
assert_equal "7.6.8",
|
87
|
-
assert_equal "7",
|
47
|
+
assert_equal "QuickTime", browser.name
|
48
|
+
assert browser.quicktime?
|
49
|
+
assert_equal "7.6.8", browser.full_version
|
50
|
+
assert_equal "7", browser.version
|
88
51
|
end
|
89
52
|
|
90
53
|
test "detects core media" do
|
91
|
-
|
54
|
+
browser = Browser.new(Browser["COREMEDIA"])
|
92
55
|
|
93
|
-
assert_equal "Apple CoreMedia",
|
94
|
-
assert
|
95
|
-
assert_equal "1.0.0.
|
96
|
-
assert_equal "1",
|
56
|
+
assert_equal "Apple CoreMedia", browser.name
|
57
|
+
assert browser.core_media?
|
58
|
+
assert_equal "1.0.0.10", browser.full_version
|
59
|
+
assert_equal "1", browser.version
|
97
60
|
end
|
98
61
|
|
99
62
|
test "detects phantom.js" do
|
100
|
-
|
63
|
+
browser = Browser.new(Browser["PHANTOM_JS"])
|
101
64
|
|
102
|
-
assert_equal "PhantomJS",
|
103
|
-
assert
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
assert_equal "1.9.0", @browser.full_version
|
108
|
-
assert_equal "1", @browser.version
|
109
|
-
end
|
110
|
-
|
111
|
-
test "detects other mobiles" do
|
112
|
-
@browser.ua = "Symbian OS"
|
113
|
-
assert @browser.mobile?
|
114
|
-
refute @browser.tablet?
|
115
|
-
|
116
|
-
@browser.ua = "MIDP-2.0"
|
117
|
-
assert @browser.mobile?
|
118
|
-
refute @browser.tablet?
|
119
|
-
end
|
120
|
-
|
121
|
-
test "detects windows mobile" do
|
122
|
-
@browser.ua = $ua["WINDOWS_MOBILE"]
|
123
|
-
|
124
|
-
assert @browser.mobile?
|
125
|
-
assert @browser.windows?
|
126
|
-
assert @browser.windows_mobile?
|
127
|
-
refute @browser.windows_phone?
|
128
|
-
refute @browser.tablet?
|
65
|
+
assert_equal "PhantomJS", browser.name
|
66
|
+
assert browser.phantom_js?
|
67
|
+
assert browser.modern?
|
68
|
+
assert_equal "1.9.0", browser.full_version
|
69
|
+
assert_equal "1", browser.version
|
129
70
|
end
|
130
71
|
|
131
72
|
test "returns a zero version" do
|
132
|
-
|
133
|
-
assert_equal "0.0",
|
134
|
-
assert_equal "0",
|
73
|
+
browser = Browser.new("Bot")
|
74
|
+
assert_equal "0.0", browser.full_version
|
75
|
+
assert_equal "0", browser.version
|
135
76
|
end
|
136
77
|
|
137
78
|
test "sets meta" do
|
138
|
-
|
139
|
-
assert_kind_of Array,
|
79
|
+
browser = Browser.new(Browser["CHROME"])
|
80
|
+
assert_kind_of Array, browser.meta
|
140
81
|
end
|
141
82
|
|
142
83
|
test "returns string representation" do
|
143
|
-
|
144
|
-
meta =
|
84
|
+
browser = Browser.new(Browser["CHROME"])
|
85
|
+
meta = browser.to_s
|
145
86
|
|
146
87
|
assert meta.include?("chrome")
|
147
88
|
assert meta.include?("webkit")
|
@@ -150,99 +91,57 @@ class BrowserTest < Minitest::Test
|
|
150
91
|
end
|
151
92
|
|
152
93
|
test "returns string representation for mobile" do
|
153
|
-
|
154
|
-
meta =
|
94
|
+
browser = Browser.new(Browser["BLACKBERRY"])
|
95
|
+
meta = browser.to_s
|
155
96
|
|
156
97
|
assert meta.include?("blackberry")
|
157
|
-
assert meta.include?("blackberry4")
|
158
|
-
assert meta.include?("other")
|
159
98
|
assert meta.include?("mobile")
|
160
99
|
end
|
161
100
|
|
162
101
|
test "detects unknown id" do
|
163
|
-
|
164
|
-
assert_equal :
|
102
|
+
browser = Browser.new("Unknown")
|
103
|
+
assert_equal :generic, browser.id
|
165
104
|
end
|
166
105
|
|
167
106
|
test "detects unknown name" do
|
168
|
-
|
169
|
-
assert_equal "
|
107
|
+
browser = Browser.new("Unknown")
|
108
|
+
assert_equal "Generic Browser", browser.name
|
170
109
|
end
|
171
110
|
|
172
|
-
test "
|
173
|
-
|
174
|
-
assert_equal
|
175
|
-
assert @browser.mac?
|
111
|
+
test "returns empty language set for missing accept language" do
|
112
|
+
browser = Browser.new("")
|
113
|
+
assert_equal [], browser.accept_language
|
176
114
|
end
|
177
115
|
|
178
|
-
test "
|
179
|
-
|
180
|
-
assert_equal :linux, @browser.platform
|
181
|
-
assert @browser.linux?
|
182
|
-
end
|
116
|
+
test "sets accept language while instantiating object" do
|
117
|
+
browser = Browser.new("", accept_language: "pt-br")
|
183
118
|
|
184
|
-
|
185
|
-
|
186
|
-
assert_equal :other, @browser.platform
|
119
|
+
assert_kind_of Array, browser.accept_language
|
120
|
+
assert_equal ["pt-BR"], browser.accept_language.map(&:full)
|
187
121
|
end
|
188
122
|
|
189
123
|
test "returns all known languages" do
|
190
|
-
|
191
|
-
assert_equal ["en-
|
192
|
-
end
|
193
|
-
|
194
|
-
test "detects xoom" do
|
195
|
-
@browser.ua = $ua["XOOM"]
|
196
|
-
|
197
|
-
assert @browser.android?
|
198
|
-
assert @browser.tablet?
|
199
|
-
refute @browser.mobile?
|
200
|
-
end
|
201
|
-
|
202
|
-
test "detects nexus tablet" do
|
203
|
-
@browser.ua = $ua["NEXUS_TABLET"]
|
204
|
-
|
205
|
-
assert @browser.android?
|
206
|
-
assert @browser.tablet?
|
207
|
-
refute @browser.mobile?
|
208
|
-
end
|
209
|
-
|
210
|
-
test "detects nook" do
|
211
|
-
@browser.ua = $ua["NOOK"]
|
212
|
-
|
213
|
-
assert @browser.tablet?
|
214
|
-
refute @browser.mobile?
|
215
|
-
end
|
216
|
-
|
217
|
-
test "detects samsung" do
|
218
|
-
@browser.ua = $ua["SAMSUNG"]
|
219
|
-
|
220
|
-
assert @browser.tablet?
|
221
|
-
refute @browser.mobile?
|
124
|
+
browser = Browser.new("", accept_language: "en-us,en;q=0.8,pt-br;q=0.5,pt;q=0.3")
|
125
|
+
assert_equal ["en-US", "en", "pt-BR", "pt"], browser.accept_language.map(&:full)
|
222
126
|
end
|
223
127
|
|
224
128
|
test "removes duplicate items" do
|
225
|
-
|
226
|
-
assert_equal ["safari"],
|
129
|
+
browser = Browser.new(Browser["SAFARI"])
|
130
|
+
assert_equal ["safari"], browser.meta.select {|item| item == "safari" }
|
227
131
|
end
|
228
132
|
|
229
133
|
test "detects meta aliased as to_a" do
|
230
|
-
|
231
|
-
assert_equal
|
232
|
-
end
|
233
|
-
|
234
|
-
test "detects tv" do
|
235
|
-
@browser.ua = $ua["SMART_TV"]
|
236
|
-
assert @browser.tv?
|
134
|
+
browser = Browser.new(Browser["SAFARI"])
|
135
|
+
assert_equal browser.meta, browser.to_a
|
237
136
|
end
|
238
137
|
|
239
138
|
test "knows a supported browser" do
|
240
|
-
|
241
|
-
assert
|
139
|
+
browser = Browser.new("Chrome")
|
140
|
+
assert browser.known?
|
242
141
|
end
|
243
142
|
|
244
143
|
test "does not know an unsupported browser" do
|
245
|
-
|
246
|
-
refute
|
144
|
+
browser = Browser.new("Fancy new browser")
|
145
|
+
refute browser.known?
|
247
146
|
end
|
248
147
|
end
|