useragent 0.0.5 → 0.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.
- data/{MIT-LICENSE → LICENSE} +1 -1
- data/README +1 -7
- data/lib/user_agent.rb +3 -1
- data/lib/user_agent/browsers.rb +1 -1
- data/lib/user_agent/browsers/gecko.rb +1 -1
- data/lib/user_agent/browsers/internet_explorer.rb +1 -1
- data/lib/user_agent/browsers/webkit.rb +1 -1
- data/lib/user_agent/operating_systems.rb +1 -1
- metadata +12 -18
- data/spec/browsers/gecko_user_agent_spec.rb +0 -209
- data/spec/browsers/internet_explorer_user_agent_spec.rb +0 -99
- data/spec/browsers/opera_user_agent_spec.rb +0 -59
- data/spec/browsers/other_user_agent_spec.rb +0 -19
- data/spec/browsers/webkit_user_agent_spec.rb +0 -373
- data/spec/user_agent_spec.rb +0 -336
data/{MIT-LICENSE → LICENSE}
RENAMED
data/README
CHANGED
@@ -4,12 +4,6 @@ UserAgent
|
|
4
4
|
UserAgent is a Ruby library that parses and compares HTTP User Agents.
|
5
5
|
|
6
6
|
|
7
|
-
Install
|
8
|
-
=======
|
9
|
-
|
10
|
-
sudo gem install useragent --source http://gemcutter.org
|
11
|
-
|
12
|
-
|
13
7
|
Example
|
14
8
|
=======
|
15
9
|
|
@@ -24,4 +18,4 @@ Example
|
|
24
18
|
SupportedBrowsers.detect { |browser| user_agent >= browser }
|
25
19
|
|
26
20
|
|
27
|
-
Copyright (c)
|
21
|
+
Copyright (c) 2009 Joshua Peek, released under the MIT license
|
data/lib/user_agent.rb
CHANGED
@@ -8,7 +8,7 @@ class UserAgent
|
|
8
8
|
^([^/\s]+) # Product
|
9
9
|
/?([^\s]*) # Version
|
10
10
|
(\s\(([^\)]*)\))? # Comment
|
11
|
-
}x.freeze
|
11
|
+
}x.freeze
|
12
12
|
|
13
13
|
def self.parse(string)
|
14
14
|
agents = []
|
@@ -32,6 +32,8 @@ class UserAgent
|
|
32
32
|
|
33
33
|
if version && !version.empty?
|
34
34
|
@version = version
|
35
|
+
else
|
36
|
+
@version = nil
|
35
37
|
end
|
36
38
|
|
37
39
|
if comment.respond_to?(:split)
|
data/lib/user_agent/browsers.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: useragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
8
|
-
- Wout Fierens
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date: 2009-10-01 00:00:00
|
12
|
+
date: 2009-10-01 00:00:00 -05:00
|
14
13
|
default_executable:
|
15
14
|
dependencies: []
|
16
15
|
|
@@ -20,28 +19,28 @@ executables: []
|
|
20
19
|
|
21
20
|
extensions: []
|
22
21
|
|
23
|
-
extra_rdoc_files:
|
24
|
-
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
25
24
|
files:
|
26
|
-
- MIT-LICENSE
|
27
25
|
- README
|
28
|
-
-
|
29
|
-
- lib/user_agent/browsers.rb
|
26
|
+
- LICENSE
|
30
27
|
- lib/user_agent/browsers/all.rb
|
31
28
|
- lib/user_agent/browsers/gecko.rb
|
32
29
|
- lib/user_agent/browsers/internet_explorer.rb
|
33
30
|
- lib/user_agent/browsers/opera.rb
|
34
31
|
- lib/user_agent/browsers/webkit.rb
|
32
|
+
- lib/user_agent/browsers.rb
|
35
33
|
- lib/user_agent/comparable.rb
|
36
34
|
- lib/user_agent/operating_systems.rb
|
35
|
+
- lib/user_agent.rb
|
37
36
|
- lib/useragent.rb
|
38
37
|
has_rdoc: true
|
39
38
|
homepage: http://github.com/josh/useragent
|
40
39
|
licenses: []
|
41
40
|
|
42
41
|
post_install_message:
|
43
|
-
rdoc_options:
|
44
|
-
|
42
|
+
rdoc_options: []
|
43
|
+
|
45
44
|
require_paths:
|
46
45
|
- lib
|
47
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -58,15 +57,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
57
|
version:
|
59
58
|
requirements: []
|
60
59
|
|
61
|
-
rubyforge_project:
|
60
|
+
rubyforge_project: useragent
|
62
61
|
rubygems_version: 1.3.5
|
63
62
|
signing_key:
|
64
63
|
specification_version: 3
|
65
64
|
summary: HTTP User Agent parser
|
66
|
-
test_files:
|
67
|
-
|
68
|
-
- spec/browsers/internet_explorer_user_agent_spec.rb
|
69
|
-
- spec/browsers/opera_user_agent_spec.rb
|
70
|
-
- spec/browsers/other_user_agent_spec.rb
|
71
|
-
- spec/browsers/webkit_user_agent_spec.rb
|
72
|
-
- spec/user_agent_spec.rb
|
65
|
+
test_files: []
|
66
|
+
|
@@ -1,209 +0,0 @@
|
|
1
|
-
require 'user_agent'
|
2
|
-
|
3
|
-
describe "Firefox browser", :shared => true do
|
4
|
-
it "should return 'Firefox' as its browser" do
|
5
|
-
@useragent.browser.should == "Firefox"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should return :strong as its security" do
|
9
|
-
@useragent.security.should == :strong
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "UserAgent: 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1'" do
|
14
|
-
before do
|
15
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1")
|
16
|
-
end
|
17
|
-
|
18
|
-
it_should_behave_like "Firefox browser"
|
19
|
-
|
20
|
-
it "should return '3.0.1' as its version" do
|
21
|
-
@useragent.version.should == "3.0.1"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return '2008070206' as its gecko version" do
|
25
|
-
@useragent.gecko.version.should == "2008070206"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should return 'X11' as its platform" do
|
29
|
-
@useragent.platform.should == "X11"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return 'Linux i686' as its os" do
|
33
|
-
@useragent.os.should == "Linux i686"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return 'en-US' as its localization" do
|
37
|
-
@useragent.localization.should == "en-US"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'" do
|
42
|
-
before do
|
43
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
44
|
-
end
|
45
|
-
|
46
|
-
it_should_behave_like "Firefox browser"
|
47
|
-
|
48
|
-
it "should return '2.0.0.14' as its version" do
|
49
|
-
@useragent.version.should == "2.0.0.14"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should return '20080404' as its gecko version" do
|
53
|
-
@useragent.gecko.version.should == "20080404"
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should return 'Macintosh' as its platform" do
|
57
|
-
@useragent.platform.should == "Macintosh"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should return 'Intel Mac OS X' as its os" do
|
61
|
-
@useragent.os.should == "Intel Mac OS X"
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should return 'en-US' as its localization" do
|
65
|
-
@useragent.localization.should == "en-US"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'" do
|
70
|
-
before do
|
71
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
72
|
-
end
|
73
|
-
|
74
|
-
it_should_behave_like "Firefox browser"
|
75
|
-
|
76
|
-
it "should return '2.0.0.14' as its version" do
|
77
|
-
@useragent.version.should == "2.0.0.14"
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should return '20080404' as its gecko version" do
|
81
|
-
@useragent.gecko.version.should == "20080404"
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should return 'Windows' as its platform" do
|
85
|
-
@useragent.platform.should == "Windows"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return 'Windows XP' as its os" do
|
89
|
-
@useragent.os.should == "Windows XP"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should return 'en-US' as its localization" do
|
93
|
-
@useragent.localization.should == "en-US"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12'" do
|
98
|
-
before do
|
99
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12")
|
100
|
-
end
|
101
|
-
|
102
|
-
it_should_behave_like "Firefox browser"
|
103
|
-
|
104
|
-
it "should return '1.5.0.12' as its version" do
|
105
|
-
@useragent.version.should == "1.5.0.12"
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should return '20070508' as its gecko version" do
|
109
|
-
@useragent.gecko.version.should == "20070508"
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should return 'Macintosh' as its platform" do
|
113
|
-
@useragent.platform.should == "Macintosh"
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should return 'PPC Mac OS X Mach-O' as its os" do
|
117
|
-
@useragent.os.should == "PPC Mac OS X Mach-O"
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should return 'en-US' as its localization" do
|
121
|
-
@useragent.localization.should == "en-US"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12'" do
|
126
|
-
before do
|
127
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12")
|
128
|
-
end
|
129
|
-
|
130
|
-
it_should_behave_like "Firefox browser"
|
131
|
-
|
132
|
-
it "should return '1.5.0.12' as its version" do
|
133
|
-
@useragent.version.should == "1.5.0.12"
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should return '20070508' as its gecko version" do
|
137
|
-
@useragent.gecko.version.should == "20070508"
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should return 'Windows' as its platform" do
|
141
|
-
@useragent.platform.should == "Windows"
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should return 'Windows XP' as its os" do
|
145
|
-
@useragent.os.should == "Windows XP"
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should return 'en-US' as its localization" do
|
149
|
-
@useragent.localization.should == "en-US"
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "UserAgent: 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060612 Firefox/1.5.0.4 Flock/0.7.0.17.1'" do
|
154
|
-
before do
|
155
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060612 Firefox/1.5.0.4 Flock/0.7.0.17.1")
|
156
|
-
end
|
157
|
-
|
158
|
-
it_should_behave_like "Firefox browser"
|
159
|
-
|
160
|
-
it "should return '1.5.0.4' as its version" do
|
161
|
-
@useragent.version.should == "1.5.0.4"
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should return '20060612' as its gecko version" do
|
165
|
-
@useragent.gecko.version.should == "20060612"
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should return 'X11' as its platform" do
|
169
|
-
@useragent.platform.should == "X11"
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should return 'Linux i686' as its os" do
|
173
|
-
@useragent.os.should == "Linux i686"
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should return 'en-US' as its localization" do
|
177
|
-
@useragent.localization.should == "en-US"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.14) Gecko/20080409 Camino/1.6 (like Firefox/2.0.0.14)'" do
|
182
|
-
before do
|
183
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.14) Gecko/20080409 Camino/1.6 (like Firefox/2.0.0.14)")
|
184
|
-
end
|
185
|
-
|
186
|
-
it "should return 'Camino' as its browser" do
|
187
|
-
@useragent.browser.should == "Camino"
|
188
|
-
end
|
189
|
-
|
190
|
-
it "should return '1.6' as its version" do
|
191
|
-
@useragent.version.should == "1.6"
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should return '20080409' as its gecko version" do
|
195
|
-
@useragent.gecko.version.should == "20080409"
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should return 'Macintosh' as its platform" do
|
199
|
-
@useragent.platform.should == "Macintosh"
|
200
|
-
end
|
201
|
-
|
202
|
-
it "should return 'Intel Mac OS X' as its os" do
|
203
|
-
@useragent.os.should == "Intel Mac OS X"
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should return 'en' as its localization" do
|
207
|
-
@useragent.localization.should == "en"
|
208
|
-
end
|
209
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'user_agent'
|
2
|
-
|
3
|
-
describe "Internet Explorer browser", :shared => true do
|
4
|
-
it "should return 'Internet Explorer' as its browser" do
|
5
|
-
@useragent.browser.should == "Internet Explorer"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should return 'Windows' as its platform" do
|
9
|
-
@useragent.platform.should == "Windows"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return 'compatible' as its compatibility" do
|
13
|
-
@useragent.compatibility.should == "compatible"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should be compatible" do
|
17
|
-
@useragent.should be_compatible
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
|
22
|
-
before do
|
23
|
-
@useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
24
|
-
end
|
25
|
-
|
26
|
-
it_should_behave_like "Internet Explorer browser"
|
27
|
-
|
28
|
-
it "should return '7.0' as its version" do
|
29
|
-
@useragent.version.should == "7.0"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return 'Windows Vista' as its os" do
|
33
|
-
@useragent.os.should == "Windows Vista"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'" do
|
38
|
-
before do
|
39
|
-
@useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
|
40
|
-
end
|
41
|
-
|
42
|
-
it_should_behave_like "Internet Explorer browser"
|
43
|
-
|
44
|
-
it "should return '6.0' as its version" do
|
45
|
-
@useragent.version.should == "6.0"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return 'Windows XP' as its os" do
|
49
|
-
@useragent.os.should == "Windows XP"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should be == 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'" do
|
53
|
-
@useragent.should == @useragent
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should not be == 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
|
57
|
-
@useragent.should_not == UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should be > 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
|
61
|
-
@useragent.should > UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should not be < 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
|
65
|
-
@useragent.should_not < UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should be >= 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
|
69
|
-
@useragent.should >= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should not be >= 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
|
73
|
-
@useragent.should_not >= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should be <= 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
|
77
|
-
@useragent.should <= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should not be <= 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
|
81
|
-
@useragent.should_not <= UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)'" do
|
86
|
-
before do
|
87
|
-
@useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
|
88
|
-
end
|
89
|
-
|
90
|
-
it_should_behave_like "Internet Explorer browser"
|
91
|
-
|
92
|
-
it "should return '5.5' as its version" do
|
93
|
-
@useragent.version.should == "5.5"
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should return 'Windows XP' as its os" do
|
97
|
-
@useragent.os.should == "Windows XP"
|
98
|
-
end
|
99
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'user_agent'
|
2
|
-
|
3
|
-
describe "Opera browser", :shared => true do
|
4
|
-
it "should return 'Opera' as its browser" do
|
5
|
-
@useragent.browser.should == "Opera"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should return :strong as its security" do
|
9
|
-
@useragent.security.should == :strong
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "UserAgent: 'Opera/9.27 (Macintosh; Intel Mac OS X; U; en)'" do
|
14
|
-
before do
|
15
|
-
@useragent = UserAgent.parse("Opera/9.27 (Macintosh; Intel Mac OS X; U; en)")
|
16
|
-
end
|
17
|
-
|
18
|
-
it_should_behave_like "Opera browser"
|
19
|
-
|
20
|
-
it "should return '9.27' as its version" do
|
21
|
-
@useragent.version.should == "9.27"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return 'Macintosh' as its platform" do
|
25
|
-
@useragent.platform.should == "Macintosh"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should return 'Intel Mac OS X' as its os" do
|
29
|
-
@useragent.os.should == "Intel Mac OS X"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return 'en' as its localization" do
|
33
|
-
@useragent.localization.should == "en"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "UserAgent: 'Opera/9.27 (Windows NT 5.1; U; en)'" do
|
38
|
-
before do
|
39
|
-
@useragent = UserAgent.parse("Opera/9.27 (Windows NT 5.1; U; en)")
|
40
|
-
end
|
41
|
-
|
42
|
-
it_should_behave_like "Opera browser"
|
43
|
-
|
44
|
-
it "should return '9.27' as its version" do
|
45
|
-
@useragent.version.should == "9.27"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return 'Windows' as its platform" do
|
49
|
-
@useragent.platform.should == "Windows"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should return 'Windows XP' as its os" do
|
53
|
-
@useragent.os.should == "Windows XP"
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should return 'en' as its localization" do
|
57
|
-
@useragent.localization.should == "en"
|
58
|
-
end
|
59
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'user_agent'
|
2
|
-
|
3
|
-
describe "UserAgent: 'amaya/9.51 libwww/5.4.0'" do
|
4
|
-
before do
|
5
|
-
@useragent = UserAgent.parse("amaya/9.51 libwww/5.4.0")
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should return 'amaya' as its browser" do
|
9
|
-
@useragent.browser.should == "amaya"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return '9.51' as its version" do
|
13
|
-
@useragent.version.should == "9.51"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should return '5.4.0' as its libwww version" do
|
17
|
-
@useragent.libwww.version.should == "5.4.0"
|
18
|
-
end
|
19
|
-
end
|
@@ -1,373 +0,0 @@
|
|
1
|
-
require 'user_agent'
|
2
|
-
|
3
|
-
describe "Safari browser", :shared => true do
|
4
|
-
it "should return 'Safari' as its browser" do
|
5
|
-
@useragent.browser.should == "Safari"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should return :strong as its security" do
|
9
|
-
@useragent.security.should == :strong
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'" do
|
14
|
-
before do
|
15
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8")
|
16
|
-
end
|
17
|
-
|
18
|
-
it_should_behave_like "Safari browser"
|
19
|
-
|
20
|
-
it "should return '526.8' as its build" do
|
21
|
-
@useragent.build.should == "526.8"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return '4.0dp1' as its version" do
|
25
|
-
@useragent.version.should == "4.0dp1"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should return '526.9' as its webkit version" do
|
29
|
-
@useragent.webkit.version.should == "526.9"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return 'Macintosh' as its platform" do
|
33
|
-
@useragent.platform.should == "Macintosh"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return 'Intel Mac OS X 10_5_3' as its os" do
|
37
|
-
@useragent.os.should == "Intel Mac OS X 10_5_3"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should return 'en-us' as its localization" do
|
41
|
-
@useragent.localization.should == "en-us"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'" do
|
46
|
-
before do
|
47
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8")
|
48
|
-
end
|
49
|
-
|
50
|
-
it_should_behave_like "Safari browser"
|
51
|
-
|
52
|
-
it "should return '526.8' as its build" do
|
53
|
-
@useragent.build.should == "526.8"
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should return '4.0dp1' as its version" do
|
57
|
-
@useragent.version.should == "4.0dp1"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should return '526.9' as its webkit version" do
|
61
|
-
@useragent.webkit.version.should == "526.9"
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should return 'Windows' as its platform" do
|
65
|
-
@useragent.platform.should == "Windows"
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should return 'Windows XP' as its os" do
|
69
|
-
@useragent.os.should == "Windows XP"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should return 'en' as its localization" do
|
73
|
-
@useragent.localization.should == "en"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18'" do
|
78
|
-
before do
|
79
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18")
|
80
|
-
end
|
81
|
-
|
82
|
-
it_should_behave_like "Safari browser"
|
83
|
-
|
84
|
-
it "should return '525.18' as its build" do
|
85
|
-
@useragent.build.should == "525.18"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return '3.1.1' as its version" do
|
89
|
-
@useragent.version.should == "3.1.1"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should return '525.18' as its webkit version" do
|
93
|
-
@useragent.webkit.version.should == "525.18"
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should return 'Macintosh' as its platform" do
|
97
|
-
@useragent.platform.should == "Macintosh"
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should return 'Intel Mac OS X 10_5_3' as its os" do
|
101
|
-
@useragent.os.should == "Intel Mac OS X 10_5_3"
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should return 'en-us' as its localization" do
|
105
|
-
@useragent.localization.should == "en-us"
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should be == 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18'" do
|
109
|
-
@useragent.should == @useragent
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should not be == 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3'" do
|
113
|
-
@useragent.should_not == UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3")
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should be > 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3'" do
|
117
|
-
@useragent.should > UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3")
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should not be > 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'" do
|
121
|
-
@useragent.should_not > UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8")
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should be < 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'" do
|
125
|
-
@useragent.should < UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8")
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should not be < 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18'" do
|
129
|
-
@useragent.should_not < @useragent
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should be >= 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3'" do
|
133
|
-
@useragent.should >= UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should not be >= 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'" do
|
137
|
-
@useragent.should_not >= UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8")
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should be <= 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18'" do
|
141
|
-
@useragent.should <= @useragent
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should not be <= 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3'" do
|
145
|
-
@useragent.should_not <= UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3")
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18'" do
|
150
|
-
before do
|
151
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18")
|
152
|
-
end
|
153
|
-
|
154
|
-
it_should_behave_like "Safari browser"
|
155
|
-
|
156
|
-
it "should return '525.18' as its build" do
|
157
|
-
@useragent.build.should == "525.18"
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should return '3.1.1' as its version" do
|
161
|
-
@useragent.version.should == "3.1.1"
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should return '525.18' as its webkit version" do
|
165
|
-
@useragent.webkit.version.should == "525.18"
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should return 'Windows' as its platform" do
|
169
|
-
@useragent.platform.should == "Windows"
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should return 'Windows XP' as its os" do
|
173
|
-
@useragent.os.should == "Windows XP"
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should return 'en' as its localization" do
|
177
|
-
@useragent.localization.should == "en"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3'" do
|
182
|
-
before do
|
183
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3")
|
184
|
-
end
|
185
|
-
|
186
|
-
it_should_behave_like "Safari browser"
|
187
|
-
|
188
|
-
it "should return '419.3' as its build" do
|
189
|
-
@useragent.build.should == "419.3"
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should return '2.0.4' as its version" do
|
193
|
-
@useragent.version.should == "2.0.4"
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should return '419' as its webkit version" do
|
197
|
-
@useragent.webkit.version.should == "419"
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should return 'Macintosh' as its platform" do
|
201
|
-
@useragent.platform.should == "Macintosh"
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should return 'Intel Mac OS X' as its os" do
|
205
|
-
@useragent.os.should == "Intel Mac OS X"
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should return 'en' as its localization" do
|
209
|
-
@useragent.localization.should == "en"
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.8 (KHTML, like Gecko) Safari/312.6'" do
|
214
|
-
before do
|
215
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.8 (KHTML, like Gecko) Safari/312.6")
|
216
|
-
end
|
217
|
-
|
218
|
-
it_should_behave_like "Safari browser"
|
219
|
-
|
220
|
-
it "should return '312.6' as its build" do
|
221
|
-
@useragent.build.should == "312.6"
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should return '1.3.2' as its version" do
|
225
|
-
@useragent.version.should == "1.3.2"
|
226
|
-
end
|
227
|
-
|
228
|
-
it "should return '312.8' as its webkit version" do
|
229
|
-
@useragent.webkit.version.should == "312.8"
|
230
|
-
end
|
231
|
-
|
232
|
-
it "should return 'Macintosh' as its platform" do
|
233
|
-
@useragent.platform.should == "Macintosh"
|
234
|
-
end
|
235
|
-
|
236
|
-
it "should return 'PPC Mac OS X' as its os" do
|
237
|
-
@useragent.os.should == "PPC Mac OS X"
|
238
|
-
end
|
239
|
-
|
240
|
-
it "should return 'en' as its localization" do
|
241
|
-
@useragent.localization.should == "en"
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe "UserAgent: 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.7 (KHTML, like Gecko) Safari/125.12'" do
|
246
|
-
before do
|
247
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.7 (KHTML, like Gecko) Safari/125.12")
|
248
|
-
end
|
249
|
-
|
250
|
-
it_should_behave_like "Safari browser"
|
251
|
-
|
252
|
-
it "should return '125.12' as its build" do
|
253
|
-
@useragent.build.should == "125.12"
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should return '1.2.4' as its version" do
|
257
|
-
@useragent.version.should == "1.2.4"
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should return '125.5.7' as its webkit version" do
|
261
|
-
@useragent.webkit.version.should == "125.5.7"
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should return 'Macintosh' as its platform" do
|
265
|
-
@useragent.platform.should == "Macintosh"
|
266
|
-
end
|
267
|
-
|
268
|
-
it "should return 'PPC Mac OS X' as its os" do
|
269
|
-
@useragent.os.should == "PPC Mac OS X"
|
270
|
-
end
|
271
|
-
|
272
|
-
it "should return 'en' as its localization" do
|
273
|
-
@useragent.localization.should == "en"
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
describe "UserAgent: 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419'" do
|
278
|
-
before do
|
279
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419")
|
280
|
-
end
|
281
|
-
|
282
|
-
it_should_behave_like "Safari browser"
|
283
|
-
|
284
|
-
it "should return '419' as its build" do
|
285
|
-
@useragent.build.should == "419"
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should return '3.0' as its version" do
|
289
|
-
@useragent.version.should == "3.0"
|
290
|
-
end
|
291
|
-
|
292
|
-
it "should return '420.1' as its webkit version" do
|
293
|
-
@useragent.webkit.version.should == "420.1"
|
294
|
-
end
|
295
|
-
|
296
|
-
it "should return 'iPhone' as its platform" do
|
297
|
-
@useragent.platform.should == "iPhone"
|
298
|
-
end
|
299
|
-
|
300
|
-
it "should return 'CPU like Mac OS X' as its os" do
|
301
|
-
@useragent.os.should == "CPU like Mac OS X"
|
302
|
-
end
|
303
|
-
|
304
|
-
it "should return 'en' as its localization" do
|
305
|
-
@useragent.localization.should == "en"
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe "UserAgent: 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419'" do
|
310
|
-
before do
|
311
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419")
|
312
|
-
end
|
313
|
-
|
314
|
-
it_should_behave_like "Safari browser"
|
315
|
-
|
316
|
-
it "should return '419' as its build" do
|
317
|
-
@useragent.build.should == "419"
|
318
|
-
end
|
319
|
-
|
320
|
-
it "should return '3.0' as its version" do
|
321
|
-
@useragent.version.should == "3.0"
|
322
|
-
end
|
323
|
-
|
324
|
-
it "should return '420.1' as its webkit version" do
|
325
|
-
@useragent.webkit.version.should == "420.1"
|
326
|
-
end
|
327
|
-
|
328
|
-
it "should return 'iPod' as its platform" do
|
329
|
-
@useragent.platform.should == "iPod"
|
330
|
-
end
|
331
|
-
|
332
|
-
it "should return 'CPU like Mac OS X' as its os" do
|
333
|
-
@useragent.os.should == "CPU like Mac OS X"
|
334
|
-
end
|
335
|
-
|
336
|
-
it "should return 'en' as its localization" do
|
337
|
-
@useragent.localization.should == "en"
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
describe "UserAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.0.2 Safari/525.13'" do
|
342
|
-
before do
|
343
|
-
@useragent = UserAgent.parse("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.0.2 Safari/525.13")
|
344
|
-
end
|
345
|
-
|
346
|
-
it "should return 'Chrome' as its browser" do
|
347
|
-
@useragent.browser.should == "Chrome"
|
348
|
-
end
|
349
|
-
|
350
|
-
it "should return '525.13' as its build" do
|
351
|
-
@useragent.build.should == "525.13"
|
352
|
-
end
|
353
|
-
|
354
|
-
it "should return '0.0.2' as its version" do
|
355
|
-
@useragent.version.should == "0.0.2"
|
356
|
-
end
|
357
|
-
|
358
|
-
it "should return '525.13' as its webkit version" do
|
359
|
-
@useragent.webkit.version.should == "525.13"
|
360
|
-
end
|
361
|
-
|
362
|
-
it "should return 'Windows' as its platform" do
|
363
|
-
@useragent.platform.should == "Windows"
|
364
|
-
end
|
365
|
-
|
366
|
-
it "should return 'Windows XP' as its os" do
|
367
|
-
@useragent.os.should == "Windows XP"
|
368
|
-
end
|
369
|
-
|
370
|
-
it "should return 'en-US' as its localization" do
|
371
|
-
@useragent.localization.should == "en-US"
|
372
|
-
end
|
373
|
-
end
|
data/spec/user_agent_spec.rb
DELETED
@@ -1,336 +0,0 @@
|
|
1
|
-
require 'user_agent'
|
2
|
-
|
3
|
-
describe UserAgent do
|
4
|
-
it "should require a product" do
|
5
|
-
lambda { UserAgent.new(nil) }.should raise_error(ArgumentError, "expected a value for product")
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should split comment to any array if a string is passed in" do
|
9
|
-
useragent = UserAgent.new("Mozilla", "5.0", "Macintosh; U; Intel Mac OS X 10_5_3; en-us")
|
10
|
-
useragent.comment.should == ["Macintosh", "U", "Intel Mac OS X 10_5_3", "en-us"]
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should set version to nil if it is blank" do
|
14
|
-
UserAgent.new("Mozilla", "").version.should be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should only output product when coerced to a string" do
|
18
|
-
UserAgent.new("Mozilla").to_str.should == "Mozilla"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should output product and version when coerced to a string" do
|
22
|
-
UserAgent.new("Mozilla", "5.0").to_str.should == "Mozilla/5.0"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should output product, version and comment when coerced to a string" do
|
26
|
-
useragent = UserAgent.new("Mozilla", "5.0", ["Macintosh", "U", "Intel Mac OS X 10_5_3", "en-us"])
|
27
|
-
useragent.to_str.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us)"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should output product and comment when coerced to a string" do
|
31
|
-
useragent = UserAgent.new("Mozilla", nil, ["Macintosh"])
|
32
|
-
useragent.to_str.should == "Mozilla (Macintosh)"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should be eql if both products are the same" do
|
36
|
-
UserAgent.new("Mozilla").should eql(UserAgent.new("Mozilla"))
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should not be eql if both products are the same" do
|
40
|
-
UserAgent.new("Mozilla").should_not eql(UserAgent.new("Opera"))
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should be eql if both products and versions are the same" do
|
44
|
-
UserAgent.new("Mozilla", "5.0").should eql(UserAgent.new("Mozilla", "5.0"))
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should not be eql if both products and versions are not the same" do
|
48
|
-
UserAgent.new("Mozilla", "5.0").should_not eql(UserAgent.new("Mozilla", "4.0"))
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should be eql if both products, versions and comments are the same" do
|
52
|
-
UserAgent.new("Mozilla", "5.0", ["Macintosh"]).should eql(UserAgent.new("Mozilla", "5.0", ["Macintosh"]))
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should not be eql if both products, versions and comments are not the same" do
|
56
|
-
UserAgent.new("Mozilla", "5.0", ["Macintosh"]).should_not eql(UserAgent.new("Mozilla", "5.0", ["Windows"]))
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should not be eql if both products, versions and comments are not the same" do
|
60
|
-
UserAgent.new("Mozilla", "5.0", ["Macintosh"]).should_not eql(UserAgent.new("Mozilla", "4.0", ["Macintosh"]))
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should not be equal? if both products are the same" do
|
64
|
-
UserAgent.new("Mozilla").should_not equal(UserAgent.new("Mozilla"))
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should be == if products are the same" do
|
68
|
-
UserAgent.new("Mozilla").should == UserAgent.new("Mozilla")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should be == if products and versions are the same" do
|
72
|
-
UserAgent.new("Mozilla", "5.0").should == UserAgent.new("Mozilla", "5.0")
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should not be == if products and versions are the different" do
|
76
|
-
UserAgent.new("Mozilla", "5.0").should_not == UserAgent.new("Mozilla", "4.0")
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should return false if comparing different products" do
|
80
|
-
UserAgent.new("Mozilla").should_not <= UserAgent.new("Opera")
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should not be > if products are the same" do
|
84
|
-
UserAgent.new("Mozilla").should_not > UserAgent.new("Mozilla")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should not be < if products are the same" do
|
88
|
-
UserAgent.new("Mozilla").should_not < UserAgent.new("Mozilla")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should be >= if products are the same" do
|
92
|
-
UserAgent.new("Mozilla").should >= UserAgent.new("Mozilla")
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should be <= if products are the same" do
|
96
|
-
UserAgent.new("Mozilla").should <= UserAgent.new("Mozilla")
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should be > if products are the same and version is greater" do
|
100
|
-
UserAgent.new("Mozilla", "5.0").should > UserAgent.new("Mozilla", "4.0")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should not be > if products are the same and version is less" do
|
104
|
-
UserAgent.new("Mozilla", "4.0").should_not > UserAgent.new("Mozilla", "5.0")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should be < if products are the same and version is less" do
|
108
|
-
UserAgent.new("Mozilla", "4.0").should < UserAgent.new("Mozilla", "5.0")
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should not be < if products are the same and version is greater" do
|
112
|
-
UserAgent.new("Mozilla", "5.0").should_not < UserAgent.new("Mozilla", "4.0")
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should be >= if products are the same and version is greater" do
|
116
|
-
UserAgent.new("Mozilla", "5.0").should >= UserAgent.new("Mozilla", "4.0")
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should not be >= if products are the same and version is less" do
|
120
|
-
UserAgent.new("Mozilla", "4.0").should_not >= UserAgent.new("Mozilla", "5.0")
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should be <= if products are the same and version is less" do
|
124
|
-
UserAgent.new("Mozilla", "4.0").should <= UserAgent.new("Mozilla", "5.0")
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should not be <= if products are the same and version is greater" do
|
128
|
-
UserAgent.new("Mozilla", "5.0").should_not <= UserAgent.new("Mozilla", "4.0")
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should be >= if products are the same and version is the same" do
|
132
|
-
UserAgent.new("Mozilla", "5.0").should >= UserAgent.new("Mozilla", "5.0")
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should be <= if products are the same and version is the same" do
|
136
|
-
UserAgent.new("Mozilla", "5.0").should <= UserAgent.new("Mozilla", "5.0")
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe UserAgent, "::MATCHER" do
|
141
|
-
it "should not match a blank line" do
|
142
|
-
UserAgent::MATCHER.should_not =~ ""
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should match a single product" do
|
146
|
-
UserAgent::MATCHER.should =~ "Mozilla"
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should match a product and version" do
|
150
|
-
UserAgent::MATCHER.should =~ "Mozilla/5.0"
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should match a product, version, and comment" do
|
154
|
-
UserAgent::MATCHER.should =~ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us)"
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should match a product, and comment" do
|
158
|
-
UserAgent::MATCHER.should =~ "Mozilla (Macintosh; U; Intel Mac OS X 10_5_3; en-us)"
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe UserAgent, ".parse" do
|
163
|
-
it "should concatenate user agents when coerced to a string" do
|
164
|
-
string = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18")
|
165
|
-
string.to_str.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18"
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should parse an empty string" do
|
169
|
-
UserAgent.parse("").should be_empty
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should parse a single product" do
|
173
|
-
useragent = UserAgent.new("Mozilla")
|
174
|
-
UserAgent.parse("Mozilla").application.should == useragent
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should parse a single product with version" do
|
178
|
-
useragent = UserAgent.new("Mozilla", "5.0")
|
179
|
-
UserAgent.parse("Mozilla/5.0").application.should == useragent
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should parse a single product, version, and comment" do
|
183
|
-
useragent = UserAgent.new("Mozilla", "5.0", ["Macintosh", "U", "Intel Mac OS X 10_5_3", "en-us"])
|
184
|
-
UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us)").application.should == useragent
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should parse a single product, version, and comment, with space-padded semicolons" do
|
188
|
-
useragent = UserAgent.new("Mozilla", "5.0", ["Macintosh", "U", "Intel Mac OS X 10_5_3", "en-us"])
|
189
|
-
UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3 ; en-us; )").application.should == useragent
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should parse a single product and comment" do
|
193
|
-
useragent = UserAgent.new("Mozilla", nil, ["Macintosh"])
|
194
|
-
UserAgent.parse("Mozilla (Macintosh)").application.should == useragent
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
describe UserAgent::Browsers::All, "#<" do
|
199
|
-
before do
|
200
|
-
@ie_7 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
201
|
-
@ie_6 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
|
202
|
-
@firefox = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should not be < if user agent does not have a browser" do
|
206
|
-
@ie_7.should_not < "Mozilla"
|
207
|
-
end
|
208
|
-
|
209
|
-
it "should not be < if user agent does not have the same browser" do
|
210
|
-
@ie_7.should_not < @firefox
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should be < if version is less than its version" do
|
214
|
-
@ie_6.should < @ie_7
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should not be < if version is the same as its version" do
|
218
|
-
@ie_6.should_not < @ie_6
|
219
|
-
end
|
220
|
-
|
221
|
-
it "should not be < if version is greater than its version" do
|
222
|
-
@ie_7.should_not < @ie_6
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe UserAgent::Browsers::All, "#<=" do
|
227
|
-
before do
|
228
|
-
@ie_7 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
229
|
-
@ie_6 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
|
230
|
-
@firefox = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should not be <= if user agent does not have a browser" do
|
234
|
-
@ie_7.should_not <= "Mozilla"
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should not be <= if user agent does not have the same browser" do
|
238
|
-
@ie_7.should_not <= @firefox
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should be <= if version is less than its version" do
|
242
|
-
@ie_6.should <= @ie_7
|
243
|
-
end
|
244
|
-
|
245
|
-
it "should be <= if version is the same as its version" do
|
246
|
-
@ie_6.should <= @ie_6
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should not be <= if version is greater than its version" do
|
250
|
-
@ie_7.should_not <= @ie_6
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe UserAgent::Browsers::All, "#==" do
|
255
|
-
before do
|
256
|
-
@ie_7 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
257
|
-
@ie_6 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
|
258
|
-
@firefox = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
259
|
-
end
|
260
|
-
|
261
|
-
it "should not be == if user agent does not have a browser" do
|
262
|
-
@ie_7.should_not == "Mozilla"
|
263
|
-
end
|
264
|
-
|
265
|
-
it "should not be == if user agent does not have the same browser" do
|
266
|
-
@ie_7.should_not == @firefox
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should not be == if version is less than its version" do
|
270
|
-
@ie_6.should_not == @ie_7
|
271
|
-
end
|
272
|
-
|
273
|
-
it "should be == if version is the same as its version" do
|
274
|
-
@ie_6.should == @ie_6
|
275
|
-
end
|
276
|
-
|
277
|
-
it "should not be == if version is greater than its version" do
|
278
|
-
@ie_7.should_not == @ie_6
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
describe UserAgent::Browsers::All, "#>" do
|
283
|
-
before do
|
284
|
-
@ie_7 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
285
|
-
@ie_6 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
|
286
|
-
@firefox = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should not be > if user agent does not have a browser" do
|
290
|
-
@ie_7.should_not > "Mozilla"
|
291
|
-
end
|
292
|
-
|
293
|
-
it "should not be > if user agent does not have the same browser" do
|
294
|
-
@ie_7.should_not > @firefox
|
295
|
-
end
|
296
|
-
|
297
|
-
it "should not be > if version is less than its version" do
|
298
|
-
@ie_6.should_not > @ie_7
|
299
|
-
end
|
300
|
-
|
301
|
-
it "should not be > if version is the same as its version" do
|
302
|
-
@ie_6.should_not > @ie_6
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should be > if version is greater than its version" do
|
306
|
-
@ie_7.should > @ie_6
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
describe UserAgent::Browsers::All, "#>=" do
|
311
|
-
before do
|
312
|
-
@ie_7 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
|
313
|
-
@ie_6 = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
|
314
|
-
@firefox = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
|
315
|
-
end
|
316
|
-
|
317
|
-
it "should not be >= if user agent does not have a browser" do
|
318
|
-
@ie_7.should_not >= "Mozilla"
|
319
|
-
end
|
320
|
-
|
321
|
-
it "should not be >= if user agent does not have the same browser" do
|
322
|
-
@ie_7.should_not >= @firefox
|
323
|
-
end
|
324
|
-
|
325
|
-
it "should not be >= if version is less than its version" do
|
326
|
-
@ie_6.should_not >= @ie_7
|
327
|
-
end
|
328
|
-
|
329
|
-
it "should be >= if version is the same as its version" do
|
330
|
-
@ie_6.should >= @ie_6
|
331
|
-
end
|
332
|
-
|
333
|
-
it "should be >= if version is greater than its version" do
|
334
|
-
@ie_7.should >= @ie_6
|
335
|
-
end
|
336
|
-
end
|