22
22
ua . device . engine . browser . name . should == "Safari"
23
23
ua . device . engine . browser . version . to_s . should == "533.21.1"
24
24
end
25
-
26
- detect "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.5 (KHTML, like Gecko) Chrome/16.0.891.1 Safari/535.5" do |ua |
27
- ua . device . type . should == :computer
28
- ua . device . name . should == "Computer"
29
- ua . device . version . should == nil
30
-
31
- ua . device . operating_system . name . should == "Mac OS X"
32
- ua . device . operating_system . version . to_s . should == "10.7.1"
33
-
34
- ua . device . platform . name . should == "Macintosh"
35
- ua . device . platform . version . should == nil
36
-
37
- ua . device . engine . name . should == "AppleWebKit"
38
- ua . device . engine . version . to_s . should == "535.5"
39
-
40
- ua . device . engine . browser . name . should == "Safari"
41
- ua . device . engine . browser . version . to_s . should == "535.5"
42
- end
43
25
end
44
26
45
27
describe "Firefox" do
78
60
ua . device . engine . name . should == "AppleWebKit"
79
61
ua . device . engine . version . to_s . should == "535.2"
80
62
81
- # TODO should be Chrome.
82
- ua . device . engine . browser . name . should == "Safari"
83
- ua . device . engine . browser . version . to_s . should == "535.2"
63
+ ua . device . engine . browser . name . should == "Chrome"
64
+ ua . device . engine . browser . version . to_s . should == "15.0.872.0"
84
65
end
85
- end
86
66
87
- describe 'checking with real browsers list' do
88
- before do
89
- @lists = [ Iconv . new ( 'UTF-8//IGNORE' , 'UTF-8' ) . iconv ( File . open ( "spec/fixtures/browser_ids.htm" ) . read ) ]
67
+ detect "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.5 (KHTML, like Gecko) Chrome/16.0.891.1 Safari/535.5" do |ua |
68
+ ua . device . type . should == :computer
69
+ ua . device . name . should == "Computer"
70
+ ua . device . version . should == nil
90
71
91
- begin
92
- @lists . push Net ::HTTP . get ( 'www.zytrax.com' , '/tech/web/browser_ids.htm' )
93
- rescue
94
- end
95
- end
72
+ ua . device . operating_system . name . should == "Mac OS X"
73
+ ua . device . operating_system . version . to_s . should == "10.7.1"
96
74
97
- it "should parse browsers from list" do
98
- [
99
- {
100
- :a_name => 'chrome' ,
101
- :browser_names => [ 'Safari' ]
102
- } ,
103
- {
104
- :a_name => 'safari' ,
105
- :browser_names => [ 'Safari' ]
106
- } ,
107
- {
108
- :a_name => 'firefox' ,
109
- :browser_names => [ 'Firefox' ]
110
- } ,
111
- {
112
- :a_name => 'msie' ,
113
- :browser_names => [ 'MSIE' , 'IEMobile' ]
114
- } ,
115
- {
116
- :a_name => 'opera' ,
117
- :browser_names => [ 'Opera' ]
118
- }
119
- ] . each do |params |
120
- part = ''
121
-
122
- @lists . each do |list |
123
- part += list . scan ( /<a name="#{ params [ :a_name ] } ">.+?<a name="/m ) . first . to_s
124
- end
125
-
126
- part . scan ( /<p class="g-c-s">([^<]+)<\/ p>/ ) . each do |q |
127
- ua = AgentOrange ::UserAgent . new ( q . first )
128
- br_name = ua . device . engine . browser . name
129
-
130
- params [ :browser_names ] . should include ( br_name )
131
- end
132
- end
133
- end
75
+ ua . device . platform . name . should == "Macintosh"
76
+ ua . device . platform . version . should == nil
134
77
135
- end
78
+ ua . device . engine . name . should == "AppleWebKit"
79
+ ua . device . engine . version . to_s . should == "535.5"
80
+
81
+ ua . device . engine . browser . name . should == "Chrome"
82
+ ua . device . engine . browser . version . to_s . should == "16.0.891.1"
83
+ end
136
84
85
+ detect "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/13.0.782.218; chromeframe; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" do |ua |
86
+ ua . device . type . should == :computer
87
+ ua . device . name . should == "Computer"
88
+ ua . device . version . should == nil
137
89
90
+ ua . device . engine . browser . name . should == "Chrome"
91
+ ua . device . engine . browser . version . to_s . should == "13.0.782.218"
92
+ end
93
+ end
138
94
end
0 commit comments