browser_detector 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +19 -31
- data/VERSION +1 -1
- data/browser_detector.gemspec +19 -15
- data/lib/browser_detector.rb +1 -1
- data/lib/browser_detector/detector.rb +111 -98
- data/lib/browser_detector/rails/view_helpers.rb +27 -0
- data/spec/browser_detector/detector_shared_specs.rb +158 -0
- data/spec/browser_detector/detector_spec.rb +475 -0
- data/spec/browser_detector_spec.rb +7 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +9 -0
- metadata +51 -18
- data/test/browser_detector/detector_test.rb +0 -1425
- data/test/browser_detector/rails/view_helpers_test.rb +0 -97
- data/test/browser_detector_test.rb +0 -7
- data/test/test_helper.rb +0 -27
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ViewHelpersTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "The browser detector view helpers" do
|
6
|
-
setup do
|
7
|
-
@view = View.new
|
8
|
-
end
|
9
|
-
|
10
|
-
should "resolve the correct browser name" do
|
11
|
-
assert_equal 'firefox', @view.g_browser_name
|
12
|
-
end
|
13
|
-
|
14
|
-
should "resolve the correct g_browser_version" do
|
15
|
-
assert_equal '3.5.3', @view.g_browser_version
|
16
|
-
end
|
17
|
-
|
18
|
-
should "resolve the correct g_browser_full_name" do
|
19
|
-
assert_equal 'Firefox 3.5.3', @view.g_browser_full_name
|
20
|
-
end
|
21
|
-
|
22
|
-
should "resolve the correct g_browser_id" do
|
23
|
-
assert_equal 'firefox353', @view.g_browser_id
|
24
|
-
end
|
25
|
-
|
26
|
-
should "agree that the browser is :name => :firefox" do
|
27
|
-
assert @view.g_browser_is?( :name => :firefox )
|
28
|
-
end
|
29
|
-
|
30
|
-
should "agree that the browser is :version => '3.5.3'" do
|
31
|
-
assert @view.g_browser_is?( :version => '3.5.3' )
|
32
|
-
end
|
33
|
-
|
34
|
-
should "agree that the browser is :name => :firefox, :version => '3.5.3'" do
|
35
|
-
assert @view.g_browser_is?( :name => :firefox, :version => '3.5.3' )
|
36
|
-
end
|
37
|
-
|
38
|
-
should "agree that the browser is :name => :firefox, :major_version => '3'" do
|
39
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => '3' )
|
40
|
-
end
|
41
|
-
|
42
|
-
should "agree that the browser is :name => :firefox, :minor_version => '5'" do
|
43
|
-
assert @view.g_browser_is?( :name => :firefox, :minor_version => '5' )
|
44
|
-
end
|
45
|
-
|
46
|
-
should "agree that the browser is :name => :firefox, :build_version => '3'" do
|
47
|
-
assert @view.g_browser_is?( :name => :firefox, :build_version => '3' )
|
48
|
-
end
|
49
|
-
|
50
|
-
should "agree that the browser is :name => :firefox, :revision_version => '0'" do
|
51
|
-
assert @view.g_browser_is?( :name => :firefox, :revision_version => '0' )
|
52
|
-
end
|
53
|
-
|
54
|
-
should "agree that the browser is :name => :firefox, :major_version => '3', :minor_version => '5'" do
|
55
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => '3', :minor_version => '5' )
|
56
|
-
end
|
57
|
-
|
58
|
-
should "agree that the browser is :name => :firefox, :major_version => '3', :minor_version => '5', :build_version => '3'" do
|
59
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => '3', :minor_version => '5', :build_version => '3' )
|
60
|
-
end
|
61
|
-
|
62
|
-
should "agree that the browser is :name => :firefox, :major_version => '3', :minor_version => '5', :build_version => '3', :revision_version => '0'" do
|
63
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => '3', :minor_version => '5', :build_version => '3',
|
64
|
-
:revision_version => '0' )
|
65
|
-
end
|
66
|
-
|
67
|
-
should "agree that the browser is :name => :firefox, :major_version => 3" do
|
68
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => 3 )
|
69
|
-
end
|
70
|
-
|
71
|
-
should "agree that the browser is :name => :firefox, :minor_version => 5" do
|
72
|
-
assert @view.g_browser_is?( :name => :firefox, :minor_version => 5 )
|
73
|
-
end
|
74
|
-
|
75
|
-
should "agree that the browser is :name => :firefox, :build_version => 3" do
|
76
|
-
assert @view.g_browser_is?( :name => :firefox, :build_version => 3 )
|
77
|
-
end
|
78
|
-
|
79
|
-
should "agree that the browser is :name => :firefox, :revision_version => 0" do
|
80
|
-
assert @view.g_browser_is?( :name => :firefox, :revision_version => 0 )
|
81
|
-
end
|
82
|
-
|
83
|
-
should "agree that the browser is :name => :firefox, :major_version => 3, :minor_version => 5" do
|
84
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5 )
|
85
|
-
end
|
86
|
-
|
87
|
-
should "agree that the browser is :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3" do
|
88
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3 )
|
89
|
-
end
|
90
|
-
|
91
|
-
should "agree that the browser is :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3, :revision_version => 0" do
|
92
|
-
assert @view.g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3,
|
93
|
-
:revision_version => '0' )
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
require 'browser_detector'
|
8
|
-
|
9
|
-
class Test::Unit::TestCase
|
10
|
-
end
|
11
|
-
|
12
|
-
class View
|
13
|
-
attr_accessor :request
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@request = Request.new
|
17
|
-
end
|
18
|
-
end
|
19
|
-
View.send( :include, BrowserDetector::Rails::ViewHelpers )
|
20
|
-
|
21
|
-
class Request
|
22
|
-
attr_accessor :env
|
23
|
-
|
24
|
-
def initialize
|
25
|
-
@env = { 'HTTP_USER_AGENT' => BrowserDetector::Detector.user_agents[:firefox35] }
|
26
|
-
end
|
27
|
-
end
|