spob_browser_detector 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,97 @@
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
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BrowserDetectorTest < Test::Unit::TestCase
4
+ should "be true" do
5
+ assert true
6
+ end
7
+ end
@@ -0,0 +1,27 @@
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
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spob_browser_detector
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - C. Jason Harrelson (midas)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-03 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.10.2
24
+ version:
25
+ description: Determines the name and version of the browser currently making a request. I forked this because gemcutter did not appear to have the latest version of the gem.
26
+ email: jason@lookforwardenterprises.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - LICENSE
36
+ - README.rdoc
37
+ has_rdoc: true
38
+ homepage: http://github.com/midas/browser_detector
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.3.5
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Determines the name and version of the browser currently making a request.
65
+ test_files:
66
+ - test/test_helper.rb
67
+ - test/browser_detector_test.rb
68
+ - test/browser_detector/rails/view_helpers_test.rb
69
+ - test/browser_detector/detector_test.rb