carmen 0.2.9 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/lib/carmen.rb +2 -0
- data/lib/carmen/version.rb +3 -0
- metadata +81 -70
- data/Gemfile +0 -8
- data/Rakefile +0 -52
- data/VERSION +0 -1
- data/carmen.gemspec +0 -90
- data/test/carmen_test.rb +0 -157
- data/test/carmen_view_helper_test.rb +0 -46
- data/test/test_helper.rb +0 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 0.2.12
|
2
|
+
* Republish the gem with Ruby 1.8.7.
|
3
|
+
### 0.2.11
|
4
|
+
* Remove Jeweler and release new version.
|
5
|
+
### 0.2.10
|
6
|
+
* Generate the gem with Ruby 1.8.7 to try to fix YAML library
|
7
|
+
incompatibilities.
|
1
8
|
### 0.2.9
|
2
9
|
* Preserve order of priority_countries in country_select (castiglione)
|
3
10
|
* Add Finnish localization (marjakapyaho)
|
data/lib/carmen.rb
CHANGED
metadata
CHANGED
@@ -1,75 +1,77 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: carmen
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 12
|
10
|
+
version: 0.2.12
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Jim Benton
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
requirement: &70251385220620 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - =
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.6.2
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *70251385220620
|
25
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
|
18
|
+
date: 2012-01-06 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
26
21
|
name: mocha
|
27
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
28
24
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
33
32
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
37
35
|
name: rails
|
38
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
44
46
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
48
49
|
name: hanna
|
49
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
52
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
55
60
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
description: A collection of geographic country and state names for Ruby. Also includes
|
59
|
-
replacements for Rails' country_select and state_select plugins
|
61
|
+
version_requirements: *id003
|
62
|
+
description: A collection of geographic country and state names for Ruby. Also includes replacements for Rails' country_select and state_select plugins
|
60
63
|
email: jim@autonomousmachine.com
|
61
64
|
executables: []
|
65
|
+
|
62
66
|
extensions: []
|
63
|
-
|
67
|
+
|
68
|
+
extra_rdoc_files:
|
64
69
|
- README.rdoc
|
65
|
-
files:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
- Rakefile
|
71
|
-
- VERSION
|
72
|
-
- carmen.gemspec
|
70
|
+
files:
|
71
|
+
- lib/carmen/action_view_helpers.rb
|
72
|
+
- lib/carmen/railtie.rb
|
73
|
+
- lib/carmen/version.rb
|
74
|
+
- lib/carmen.rb
|
73
75
|
- data/countries/cn.yml
|
74
76
|
- data/countries/cs.yml
|
75
77
|
- data/countries/de.yml
|
@@ -101,34 +103,43 @@ files:
|
|
101
103
|
- data/states/nz.yml
|
102
104
|
- data/states/ua.yml
|
103
105
|
- data/states/us.yml
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
- test/carmen_test.rb
|
108
|
-
- test/carmen_view_helper_test.rb
|
109
|
-
- test/test_helper.rb
|
106
|
+
- MIT-LICENSE
|
107
|
+
- README.rdoc
|
108
|
+
- CHANGELOG.md
|
110
109
|
homepage: http://github.com/jim/carmen
|
111
110
|
licenses: []
|
111
|
+
|
112
112
|
post_install_message:
|
113
113
|
rdoc_options: []
|
114
|
-
|
114
|
+
|
115
|
+
require_paths:
|
115
116
|
- lib
|
116
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
118
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
|
122
|
-
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
127
|
none: false
|
124
|
-
requirements:
|
125
|
-
- -
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 23
|
132
|
+
segments:
|
133
|
+
- 1
|
134
|
+
- 3
|
135
|
+
- 6
|
136
|
+
version: 1.3.6
|
128
137
|
requirements: []
|
138
|
+
|
129
139
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.8.
|
140
|
+
rubygems_version: 1.8.14
|
131
141
|
signing_key:
|
132
142
|
specification_version: 3
|
133
143
|
summary: A collection of geographic country and state names for Ruby
|
134
144
|
test_files: []
|
145
|
+
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'hanna/rdoctask'
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |gem|
|
8
|
-
gem.name = "carmen"
|
9
|
-
gem.summary = %Q{A collection of geographic country and state names for Ruby}
|
10
|
-
gem.description = %Q{A collection of geographic country and state names for Ruby. Also includes replacements for Rails' country_select and state_select plugins}
|
11
|
-
gem.email = "jim@autonomousmachine.com"
|
12
|
-
gem.homepage = "http://github.com/jim/carmen"
|
13
|
-
gem.authors = ["Jim Benton"]
|
14
|
-
end
|
15
|
-
Jeweler::RubygemsDotOrgTasks.new
|
16
|
-
rescue LoadError
|
17
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'rake/testtask'
|
21
|
-
Rake::TestTask.new(:test) do |test|
|
22
|
-
test.libs << 'lib' << 'test'
|
23
|
-
test.pattern = 'test/**/*_test.rb'
|
24
|
-
test.verbose = true
|
25
|
-
end
|
26
|
-
|
27
|
-
begin
|
28
|
-
require 'rcov/rcovtask'
|
29
|
-
Rcov::RcovTask.new do |test|
|
30
|
-
test.libs << 'test'
|
31
|
-
test.pattern = 'test/**/*_test.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
task :rcov do
|
36
|
-
abort "RCov is not available. In order to run rcov, you must: gem install spicycode-rcov"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
task :default => :test
|
41
|
-
|
42
|
-
desc 'Generate RDoc documentation for the carmen plugin.'
|
43
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
44
|
-
rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE').
|
45
|
-
include('lib/**/*.rb')
|
46
|
-
|
47
|
-
rdoc.main = "README.rdoc" # page to start on
|
48
|
-
rdoc.title = "carmen documentation"
|
49
|
-
|
50
|
-
rdoc.rdoc_dir = 'doc' # rdoc output folder
|
51
|
-
rdoc.options << '--webcvs=http://github.com/jim/carmen/tree/master/'
|
52
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.9
|
data/carmen.gemspec
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "carmen"
|
8
|
-
s.version = "0.2.9"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jim Benton"]
|
12
|
-
s.date = "2011-12-20"
|
13
|
-
s.description = "A collection of geographic country and state names for Ruby. Also includes replacements for Rails' country_select and state_select plugins"
|
14
|
-
s.email = "jim@autonomousmachine.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.rdoc"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
"CHANGELOG.md",
|
20
|
-
"Gemfile",
|
21
|
-
"MIT-LICENSE",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"carmen.gemspec",
|
26
|
-
"data/countries/cn.yml",
|
27
|
-
"data/countries/cs.yml",
|
28
|
-
"data/countries/de.yml",
|
29
|
-
"data/countries/en.yml",
|
30
|
-
"data/countries/es.yml",
|
31
|
-
"data/countries/fi.yml",
|
32
|
-
"data/countries/hi.yml",
|
33
|
-
"data/countries/it.yml",
|
34
|
-
"data/countries/jp.yml",
|
35
|
-
"data/countries/nl.yml",
|
36
|
-
"data/countries/pl.yml",
|
37
|
-
"data/countries/pt.yml",
|
38
|
-
"data/countries/ru.yml",
|
39
|
-
"data/countries/sk.yml",
|
40
|
-
"data/countries/sv.yml",
|
41
|
-
"data/states/au.yml",
|
42
|
-
"data/states/br.yml",
|
43
|
-
"data/states/ca.yml",
|
44
|
-
"data/states/cu.yml",
|
45
|
-
"data/states/de.yml",
|
46
|
-
"data/states/dk.yml",
|
47
|
-
"data/states/es.yml",
|
48
|
-
"data/states/hr.yml",
|
49
|
-
"data/states/in.yml",
|
50
|
-
"data/states/it.yml",
|
51
|
-
"data/states/mx.yml",
|
52
|
-
"data/states/nl.yml",
|
53
|
-
"data/states/no.yml",
|
54
|
-
"data/states/nz.yml",
|
55
|
-
"data/states/ua.yml",
|
56
|
-
"data/states/us.yml",
|
57
|
-
"lib/carmen.rb",
|
58
|
-
"lib/carmen/action_view_helpers.rb",
|
59
|
-
"lib/carmen/railtie.rb",
|
60
|
-
"test/carmen_test.rb",
|
61
|
-
"test/carmen_view_helper_test.rb",
|
62
|
-
"test/test_helper.rb"
|
63
|
-
]
|
64
|
-
s.homepage = "http://github.com/jim/carmen"
|
65
|
-
s.require_paths = ["lib"]
|
66
|
-
s.rubygems_version = "1.8.10"
|
67
|
-
s.summary = "A collection of geographic country and state names for Ruby"
|
68
|
-
|
69
|
-
if s.respond_to? :specification_version then
|
70
|
-
s.specification_version = 3
|
71
|
-
|
72
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
73
|
-
s.add_development_dependency(%q<jeweler>, ["= 1.6.2"])
|
74
|
-
s.add_development_dependency(%q<mocha>, [">= 0"])
|
75
|
-
s.add_development_dependency(%q<rails>, [">= 0"])
|
76
|
-
s.add_development_dependency(%q<hanna>, [">= 0"])
|
77
|
-
else
|
78
|
-
s.add_dependency(%q<jeweler>, ["= 1.6.2"])
|
79
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
80
|
-
s.add_dependency(%q<rails>, [">= 0"])
|
81
|
-
s.add_dependency(%q<hanna>, [">= 0"])
|
82
|
-
end
|
83
|
-
else
|
84
|
-
s.add_dependency(%q<jeweler>, ["= 1.6.2"])
|
85
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
86
|
-
s.add_dependency(%q<rails>, [">= 0"])
|
87
|
-
s.add_dependency(%q<hanna>, [">= 0"])
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
data/test/carmen_test.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class TestCarmen < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def teardown
|
6
|
-
Carmen.default_locale = :en # restore default
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_default_countries
|
10
|
-
assert_equal ['Aland Islands', 'AX'], Carmen.countries[1]
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_localized_countries
|
14
|
-
Carmen.default_locale = :de
|
15
|
-
assert_equal ["Ascension (verwaltet von St. Helena)", 'AC'], Carmen.countries[0]
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_single_localized_countries_call
|
19
|
-
# Check that we are working with the default
|
20
|
-
assert_equal ['Aland Islands', 'AX'], Carmen.countries[1]
|
21
|
-
|
22
|
-
# Switch to a different locale for one call
|
23
|
-
assert_equal ["Ascension (verwaltet von St. Helena)", 'AC'], Carmen.countries(:locale => 'de')[0]
|
24
|
-
|
25
|
-
# Make sure that we are back in the default locale
|
26
|
-
assert_equal ['Aland Islands', 'AX'], Carmen.countries[1]
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_country_name
|
30
|
-
assert_equal 'United States', Carmen.country_name('US')
|
31
|
-
assert_equal 'United States', Carmen.country_name('us')
|
32
|
-
assert_nil Carmen.country_name('')
|
33
|
-
assert_nil Carmen.country_name(nil)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_localized_country_name
|
37
|
-
assert_equal 'Germany', Carmen.country_name('DE')
|
38
|
-
assert_equal 'Deutschland', Carmen.country_name('DE', :locale => :de)
|
39
|
-
Carmen.default_locale = :de
|
40
|
-
assert_equal 'Deutschland', Carmen.country_name('DE')
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_country_code
|
44
|
-
assert_equal 'CA', Carmen.country_code('Canada')
|
45
|
-
assert_equal 'CA', Carmen.country_code('canada')
|
46
|
-
assert_equal 'IR', Carmen.country_code('Iran')
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_localized_country_code
|
50
|
-
assert_equal 'DE', Carmen.country_code('Deutschland', :locale => :de)
|
51
|
-
Carmen.default_locale = :de
|
52
|
-
assert_equal 'DE', Carmen.country_code('Deutschland')
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_country_codes
|
56
|
-
assert_equal 'AF', Carmen.country_codes.first
|
57
|
-
assert_equal 253, Carmen.country_codes.length
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_country_names
|
61
|
-
assert_equal 'Afghanistan', Carmen.country_names.first
|
62
|
-
assert_equal 253, Carmen.country_names.length
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_state_name
|
66
|
-
assert_equal 'IL', Carmen.state_code('Illinois')
|
67
|
-
assert_equal 'MB', Carmen.state_code('Manitoba', 'CA')
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_state_code
|
71
|
-
assert_equal 'Arizona', Carmen.state_name('AZ')
|
72
|
-
assert_equal 'Prince Edward Island', Carmen.state_name('PE', 'CA')
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_states
|
76
|
-
assert_equal 62, Carmen.states.length
|
77
|
-
assert_equal ['Alabama', 'AL'], Carmen.states.first
|
78
|
-
assert_equal 13, Carmen.states('CA').length
|
79
|
-
assert_equal ['Alberta', 'AB'], Carmen.states('CA').first
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_state_names
|
83
|
-
assert_equal 62, Carmen::state_names.length
|
84
|
-
assert_equal 'Alabama', Carmen::state_names.first
|
85
|
-
assert_equal 13, Carmen.state_names('CA').length
|
86
|
-
assert_equal 'Alberta', Carmen.state_names('CA').first
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_state_codes
|
90
|
-
assert_equal 62, Carmen::state_codes.length
|
91
|
-
assert_equal 'AL', Carmen::state_codes.first
|
92
|
-
assert_equal 13, Carmen.state_codes('CA').length
|
93
|
-
assert_equal 'AB', Carmen.state_codes('CA').first
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_supported_states
|
97
|
-
assert Carmen::states?('US')
|
98
|
-
assert_equal Carmen::states?('ZZ'), false
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_excluded_countries
|
102
|
-
Carmen.excluded_countries = [ 'US', 'DE' ]
|
103
|
-
countries = Carmen.countries
|
104
|
-
assert !countries.include?( ["United States", "US"] )
|
105
|
-
assert !countries.include?( ["Germany", "DE"] )
|
106
|
-
assert countries.include?( ["Portugal", "PT"] )
|
107
|
-
Carmen.excluded_countries = [ ]
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_excluded_states
|
111
|
-
Carmen.excluded_states = { 'US' => ['IL', 'OR'], 'DE' => ['BE', 'HH'] }
|
112
|
-
states = Carmen.states
|
113
|
-
assert !states.include?( ["Illinois", "IL"] )
|
114
|
-
assert !states.include?( ["Oregon", "OR"] )
|
115
|
-
assert states.include?( ["Kentucky", "KY"] )
|
116
|
-
|
117
|
-
states = Carmen.states("DE")
|
118
|
-
assert !states.include?( ["Berlin", "BE"] )
|
119
|
-
assert !states.include?( ["Hamburg", "HH"] )
|
120
|
-
assert states.include?( ["Rheinland-Pfalz", "RP"] )
|
121
|
-
|
122
|
-
states = Carmen.states("ES")
|
123
|
-
assert states.include?( ["Cantabria", "CAN"] )
|
124
|
-
|
125
|
-
Carmen.excluded_states = {}
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_prepended_countries
|
129
|
-
us_original_index = Carmen.countries.index(['United States', 'US'])
|
130
|
-
Carmen.priority_countries = %w(US CA AU)
|
131
|
-
countries = Carmen.countries
|
132
|
-
assert_equal 0, countries.index(['United States', 'US'])
|
133
|
-
assert_equal 1, countries.index(['Canada', 'CA'])
|
134
|
-
assert_equal 2, countries.index(['Australia', 'AU'])
|
135
|
-
|
136
|
-
assert_equal 3 + us_original_index, countries.rindex(['United States', 'US'])
|
137
|
-
|
138
|
-
Carmen.priority_countries = []
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_invalid_country_exception
|
142
|
-
assert_raises Carmen::NonexistentCountry do
|
143
|
-
Carmen::state_codes('ZZ')
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_unsupported_states_exception
|
148
|
-
assert_raises Carmen::StatesNotSupported do
|
149
|
-
Carmen::state_codes('ID')
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_special_characters_dont_rails_an_exception
|
154
|
-
assert_equal(nil, Carmen::state_code('alabama\\'))
|
155
|
-
assert_nil(Carmen::country_code('???'))
|
156
|
-
end
|
157
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('test_helper', File.dirname(__FILE__))
|
4
|
-
require 'active_support'
|
5
|
-
require 'action_view'
|
6
|
-
require 'action_controller'
|
7
|
-
require 'action_view/test_case'
|
8
|
-
require 'mocha'
|
9
|
-
|
10
|
-
require File.join('./', File.dirname(__FILE__), '../lib/carmen/action_view_helpers')
|
11
|
-
|
12
|
-
class CarmenViewHelperTest < ActionView::TestCase
|
13
|
-
include ActionView::Helpers::FormOptionsHelper
|
14
|
-
|
15
|
-
def setup
|
16
|
-
@address = stub(:state => 'IL', :country => 'US', :to_s => 'address')
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_state_select_for_us
|
20
|
-
@address.stubs(:state => 'nil')
|
21
|
-
assert_equal US_STATE_SELECT_HTML.chomp, state_select(@address, :state, 'US')
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_state_select_for_canada
|
25
|
-
@address.stubs(:state => 'nil')
|
26
|
-
assert_equal CANADA_STATE_SELECT_HTML.chomp, state_select(@address, :state, 'CA')
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_country_options_for_select_with_priorities
|
30
|
-
assert_equal COUNTRY_SELECT_OPTIONS_HTML.chomp, country_options_for_select('US', 'US')
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_stable_order_of_priority_countries
|
34
|
-
html = country_options_for_select('US', 'US', 'CA')
|
35
|
-
assert html.index('value="US"') < html.index('value="CA"')
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_selected_option
|
39
|
-
@address.stubs(:state => 'ON')
|
40
|
-
assert_match /<option value="ON" selected="selected">Ontario<\/option>/, state_select(@address, :state, 'CA')
|
41
|
-
end
|
42
|
-
|
43
|
-
COUNTRY_SELECT_OPTIONS_HTML = "<option value=\"US\" selected=\"selected\">United States</option>\n<option value=\"\" disabled=\"disabled\">-------------</option>\n<option value=\"AF\">Afghanistan</option>\n<option value=\"AX\">Aland Islands</option>\n<option value=\"AL\">Albania</option>\n<option value=\"DZ\">Algeria</option>\n<option value=\"AS\">American Samoa</option>\n<option value=\"AD\">Andorra</option>\n<option value=\"AO\">Angola</option>\n<option value=\"AI\">Anguilla</option>\n<option value=\"AQ\">Antarctica</option>\n<option value=\"AG\">Antigua and Barbuda</option>\n<option value=\"AR\">Argentina</option>\n<option value=\"AM\">Armenia</option>\n<option value=\"AW\">Aruba</option>\n<option value=\"AC\">Ascension Island</option>\n<option value=\"AU\">Australia</option>\n<option value=\"AT\">Austria</option>\n<option value=\"AZ\">Azerbaijan</option>\n<option value=\"BS\">Bahamas</option>\n<option value=\"BH\">Bahrain</option>\n<option value=\"BD\">Bangladesh</option>\n<option value=\"BB\">Barbados</option>\n<option value=\"BY\">Belarus</option>\n<option value=\"BE\">Belgium</option>\n<option value=\"BZ\">Belize</option>\n<option value=\"BJ\">Benin</option>\n<option value=\"BM\">Bermuda</option>\n<option value=\"BT\">Bhutan</option>\n<option value=\"BO\">Bolivia</option>\n<option value=\"BQ\">Bonaire, Sint Eustatius and Saba</option>\n<option value=\"BA\">Bosnia and Herzegovina</option>\n<option value=\"BW\">Botswana</option>\n<option value=\"BV\">Bouvet Island</option>\n<option value=\"BR\">Brazil</option>\n<option value=\"IO\">British Indian Ocean Territory</option>\n<option value=\"BN\">Brunei Darussalam</option>\n<option value=\"BG\">Bulgaria</option>\n<option value=\"BF\">Burkina Faso</option>\n<option value=\"BI\">Burundi</option>\n<option value=\"KH\">Cambodia</option>\n<option value=\"CM\">Cameroon</option>\n<option value=\"CA\">Canada</option>\n<option value=\"CV\">Cape Verde</option>\n<option value=\"KY\">Cayman Islands</option>\n<option value=\"CF\">Central African Republic</option>\n<option value=\"TD\">Chad</option>\n<option value=\"CL\">Chile</option>\n<option value=\"CN\">China</option>\n<option value=\"CX\">Christmas Island</option>\n<option value=\"CC\">Cocos (Keeling) Islands</option>\n<option value=\"CO\">Colombia</option>\n<option value=\"KM\">Comoros</option>\n<option value=\"CG\">Congo</option>\n<option value=\"CD\">Congo, the Democratic Republic of the</option>\n<option value=\"CK\">Cook Islands</option>\n<option value=\"CR\">Costa Rica</option>\n<option value=\"CI\">Côte d'Ivoire</option>\n<option value=\"HR\">Croatia</option>\n<option value=\"CU\">Cuba</option>\n<option value=\"CW\">Curaçao</option>\n<option value=\"CY\">Cyprus</option>\n<option value=\"CZ\">Czech Republic</option>\n<option value=\"DK\">Denmark</option>\n<option value=\"DJ\">Djibouti</option>\n<option value=\"DM\">Dominica</option>\n<option value=\"DO\">Dominican Republic</option>\n<option value=\"EC\">Ecuador</option>\n<option value=\"EG\">Egypt</option>\n<option value=\"SV\">El Salvador</option>\n<option value=\"GQ\">Equatorial Guinea</option>\n<option value=\"ER\">Eritrea</option>\n<option value=\"EE\">Estonia</option>\n<option value=\"ET\">Ethiopia</option>\n<option value=\"FK\">Falkland Islands (Malvinas)</option>\n<option value=\"FO\">Faroe Islands</option>\n<option value=\"FJ\">Fiji</option>\n<option value=\"FI\">Finland</option>\n<option value=\"FR\">France</option>\n<option value=\"GF\">French Guiana</option>\n<option value=\"PF\">French Polynesia</option>\n<option value=\"TF\">French Southern Territories</option>\n<option value=\"GA\">Gabon</option>\n<option value=\"GM\">Gambia</option>\n<option value=\"GE\">Georgia</option>\n<option value=\"DE\">Germany</option>\n<option value=\"GH\">Ghana</option>\n<option value=\"GI\">Gibraltar</option>\n<option value=\"GR\">Greece</option>\n<option value=\"GL\">Greenland</option>\n<option value=\"GD\">Grenada</option>\n<option value=\"GP\">Guadeloupe</option>\n<option value=\"GU\">Guam</option>\n<option value=\"GT\">Guatemala</option>\n<option value=\"GG\">Guernsey</option>\n<option value=\"GN\">Guinea</option>\n<option value=\"GW\">Guinea-Bissau</option>\n<option value=\"GY\">Guyana</option>\n<option value=\"HT\">Haiti</option>\n<option value=\"HM\">Heard Island and Mcdonald Islands</option>\n<option value=\"VA\">Holy See (Vatican City State)</option>\n<option value=\"HN\">Honduras</option>\n<option value=\"HK\">Hong Kong</option>\n<option value=\"HU\">Hungary</option>\n<option value=\"IS\">Iceland</option>\n<option value=\"IN\">India</option>\n<option value=\"ID\">Indonesia</option>\n<option value=\"IR\">Iran, Islamic Republic of</option>\n<option value=\"IQ\">Iraq</option>\n<option value=\"IE\">Ireland</option>\n<option value=\"IM\">Isle of Man</option>\n<option value=\"IL\">Israel</option>\n<option value=\"IT\">Italy</option>\n<option value=\"JM\">Jamaica</option>\n<option value=\"JP\">Japan</option>\n<option value=\"JE\">Jersey</option>\n<option value=\"JO\">Jordan</option>\n<option value=\"KZ\">Kazakhstan</option>\n<option value=\"KE\">Kenya</option>\n<option value=\"KI\">Kiribati</option>\n<option value=\"KP\">Korea, Democratic People's Republic of</option>\n<option value=\"KR\">Korea, Republic of</option>\n<option value=\"KV\">Kosovo</option>\n<option value=\"KW\">Kuwait</option>\n<option value=\"KG\">Kyrgyzstan</option>\n<option value=\"LA\">Lao People's Democratic Republic</option>\n<option value=\"LV\">Latvia</option>\n<option value=\"LB\">Lebanon</option>\n<option value=\"LS\">Lesotho</option>\n<option value=\"LR\">Liberia</option>\n<option value=\"LY\">Libya</option>\n<option value=\"LI\">Liechtenstein</option>\n<option value=\"LT\">Lithuania</option>\n<option value=\"LU\">Luxembourg</option>\n<option value=\"MO\">Macao</option>\n<option value=\"MK\">Macedonia, Republic of</option>\n<option value=\"MG\">Madagascar</option>\n<option value=\"MW\">Malawi</option>\n<option value=\"MY\">Malaysia</option>\n<option value=\"MV\">Maldives</option>\n<option value=\"ML\">Mali</option>\n<option value=\"MT\">Malta</option>\n<option value=\"MH\">Marshall Islands</option>\n<option value=\"MQ\">Martinique</option>\n<option value=\"MR\">Mauritania</option>\n<option value=\"MU\">Mauritius</option>\n<option value=\"YT\">Mayotte</option>\n<option value=\"MX\">Mexico</option>\n<option value=\"FM\">Micronesia, Federated States of</option>\n<option value=\"MD\">Moldova, Republic of</option>\n<option value=\"MC\">Monaco</option>\n<option value=\"MN\">Mongolia</option>\n<option value=\"ME\">Montenegro</option>\n<option value=\"MS\">Montserrat</option>\n<option value=\"MA\">Morocco</option>\n<option value=\"MZ\">Mozambique</option>\n<option value=\"MM\">Myanmar</option>\n<option value=\"NA\">Namibia</option>\n<option value=\"NR\">Nauru</option>\n<option value=\"NP\">Nepal</option>\n<option value=\"NL\">Netherlands</option>\n<option value=\"AN\">Netherlands Antilles</option>\n<option value=\"NC\">New Caledonia</option>\n<option value=\"NZ\">New Zealand</option>\n<option value=\"NI\">Nicaragua</option>\n<option value=\"NE\">Niger</option>\n<option value=\"NG\">Nigeria</option>\n<option value=\"NU\">Niue</option>\n<option value=\"NF\">Norfolk Island</option>\n<option value=\"MP\">Northern Mariana Islands</option>\n<option value=\"NO\">Norway</option>\n<option value=\"OM\">Oman</option>\n<option value=\"PK\">Pakistan</option>\n<option value=\"PW\">Palau</option>\n<option value=\"PS\">Palestinian Territory, Occupied</option>\n<option value=\"PA\">Panama</option>\n<option value=\"PG\">Papua New Guinea</option>\n<option value=\"PY\">Paraguay</option>\n<option value=\"PE\">Peru</option>\n<option value=\"PH\">Philippines</option>\n<option value=\"PN\">Pitcairn</option>\n<option value=\"PL\">Poland</option>\n<option value=\"PT\">Portugal</option>\n<option value=\"PR\">Puerto Rico</option>\n<option value=\"QA\">Qatar</option>\n<option value=\"RE\">Reunion</option>\n<option value=\"RO\">Romania</option>\n<option value=\"RU\">Russian Federation</option>\n<option value=\"RW\">Rwanda</option>\n<option value=\"BL\">Saint Barthelemy</option>\n<option value=\"SH\">Saint Helena</option>\n<option value=\"KN\">Saint Kitts and Nevis</option>\n<option value=\"LC\">Saint Lucia</option>\n<option value=\"MF\">Saint Martin (French Part)</option>\n<option value=\"PM\">Saint Pierre and Miquelon</option>\n<option value=\"VC\">Saint Vincent and the Grenadines</option>\n<option value=\"WS\">Samoa</option>\n<option value=\"SM\">San Marino</option>\n<option value=\"ST\">Sao Tome and Principe</option>\n<option value=\"SA\">Saudi Arabia</option>\n<option value=\"SN\">Senegal</option>\n<option value=\"RS\">Serbia</option>\n<option value=\"SC\">Seychelles</option>\n<option value=\"SL\">Sierra Leone</option>\n<option value=\"SG\">Singapore</option>\n<option value=\"SX\">Sint Maarten (Dutch part)</option>\n<option value=\"SK\">Slovakia</option>\n<option value=\"SI\">Slovenia</option>\n<option value=\"SB\">Solomon Islands</option>\n<option value=\"SO\">Somalia</option>\n<option value=\"ZA\">South Africa</option>\n<option value=\"GS\">South Georgia and the South Sandwich Islands</option>\n<option value=\"SS\">South Sudan, Republic of</option>\n<option value=\"ES\">Spain</option>\n<option value=\"LK\">Sri Lanka</option>\n<option value=\"SD\">Sudan</option>\n<option value=\"SR\">Suriname</option>\n<option value=\"SJ\">Svalbard and Jan Mayen</option>\n<option value=\"SZ\">Swaziland</option>\n<option value=\"SE\">Sweden</option>\n<option value=\"CH\">Switzerland</option>\n<option value=\"SY\">Syrian Arab Republic</option>\n<option value=\"TW\">Taiwan</option>\n<option value=\"TJ\">Tajikistan</option>\n<option value=\"TZ\">Tanzania, United Republic of</option>\n<option value=\"TH\">Thailand</option>\n<option value=\"TL\">Timor-Leste</option>\n<option value=\"TG\">Togo</option>\n<option value=\"TK\">Tokelau</option>\n<option value=\"TO\">Tonga</option>\n<option value=\"TT\">Trinidad and Tobago</option>\n<option value=\"TA\">Tristan da Cunha</option>\n<option value=\"TN\">Tunisia</option>\n<option value=\"TR\">Turkey</option>\n<option value=\"TM\">Turkmenistan</option>\n<option value=\"TC\">Turks and Caicos Islands</option>\n<option value=\"TV\">Tuvalu</option>\n<option value=\"UG\">Uganda</option>\n<option value=\"UA\">Ukraine</option>\n<option value=\"AE\">United Arab Emirates</option>\n<option value=\"GB\">United Kingdom</option>\n<option value=\"US\">United States</option>\n<option value=\"UM\">United States Minor Outlying Islands</option>\n<option value=\"UY\">Uruguay</option>\n<option value=\"UZ\">Uzbekistan</option>\n<option value=\"VU\">Vanuatu</option>\n<option value=\"VE\">Venezuela</option>\n<option value=\"VN\">Viet Nam</option>\n<option value=\"VG\">Virgin Islands, British</option>\n<option value=\"VI\">Virgin Islands, U.S.</option>\n<option value=\"WF\">Wallis and Futuna</option>\n<option value=\"EH\">Western Sahara</option>\n<option value=\"YE\">Yemen</option>\n<option value=\"ZM\">Zambia</option>\n<option value=\"ZW\">Zimbabwe</option>"
|
44
|
-
US_STATE_SELECT_HTML = "<select id=\"address_state\" name=\"address[state]\"><option value=\"AL\">Alabama</option>\n<option value=\"AK\">Alaska</option>\n<option value=\"AZ\">Arizona</option>\n<option value=\"AR\">Arkansas</option>\n<option value=\"CA\">California</option>\n<option value=\"CO\">Colorado</option>\n<option value=\"CT\">Connecticut</option>\n<option value=\"DE\">Delaware</option>\n<option value=\"DC\">District Of Columbia</option>\n<option value=\"FL\">Florida</option>\n<option value=\"GA\">Georgia</option>\n<option value=\"HI\">Hawaii</option>\n<option value=\"ID\">Idaho</option>\n<option value=\"IL\">Illinois</option>\n<option value=\"IN\">Indiana</option>\n<option value=\"IA\">Iowa</option>\n<option value=\"KS\">Kansas</option>\n<option value=\"KY\">Kentucky</option>\n<option value=\"LA\">Louisiana</option>\n<option value=\"ME\">Maine</option>\n<option value=\"MD\">Maryland</option>\n<option value=\"MA\">Massachusetts</option>\n<option value=\"MI\">Michigan</option>\n<option value=\"MN\">Minnesota</option>\n<option value=\"MS\">Mississippi</option>\n<option value=\"MO\">Missouri</option>\n<option value=\"MT\">Montana</option>\n<option value=\"NE\">Nebraska</option>\n<option value=\"NV\">Nevada</option>\n<option value=\"NH\">New Hampshire</option>\n<option value=\"NJ\">New Jersey</option>\n<option value=\"NM\">New Mexico</option>\n<option value=\"NY\">New York</option>\n<option value=\"NC\">North Carolina</option>\n<option value=\"ND\">North Dakota</option>\n<option value=\"OH\">Ohio</option>\n<option value=\"OK\">Oklahoma</option>\n<option value=\"OR\">Oregon</option>\n<option value=\"PA\">Pennsylvania</option>\n<option value=\"RI\">Rhode Island</option>\n<option value=\"SC\">South Carolina</option>\n<option value=\"SD\">South Dakota</option>\n<option value=\"TN\">Tennessee</option>\n<option value=\"TX\">Texas</option>\n<option value=\"UT\">Utah</option>\n<option value=\"VT\">Vermont</option>\n<option value=\"VA\">Virginia</option>\n<option value=\"WA\">Washington</option>\n<option value=\"WV\">West Virginia</option>\n<option value=\"WI\">Wisconsin</option>\n<option value=\"WY\">Wyoming</option>\n<option value=\"AS\">American Samoa</option>\n<option value=\"FM\">Federated States of Micronesia</option>\n<option value=\"GU\">Guam</option>\n<option value=\"MH\">Marshall Islands</option>\n<option value=\"MP\">Northern Mariana Islands</option>\n<option value=\"PW\">Palau</option>\n<option value=\"PR\">Puerto Rico</option>\n<option value=\"VI\">Virgin Islands</option>\n<option value=\"AA\">Armed Forces Americas (except Canada)</option>\n<option value=\"AE\">Armed Forces Europe, Canada, Africa, or Middle East</option>\n<option value=\"AP\">Armed Forces Pacific</option></select>"
|
45
|
-
CANADA_STATE_SELECT_HTML = "<select id=\"address_state\" name=\"address[state]\"><option value=\"AB\">Alberta</option>\n<option value=\"BC\">British Columbia</option>\n<option value=\"MB\">Manitoba</option>\n<option value=\"NB\">New Brunswick</option>\n<option value=\"NL\">Newfoundland and Labrador</option>\n<option value=\"NT\">Northwest Territories</option>\n<option value=\"NS\">Nova Scotia</option>\n<option value=\"NU\">Nunavut</option>\n<option value=\"ON\">Ontario</option>\n<option value=\"PE\">Prince Edward Island</option>\n<option value=\"QC\">Quebec</option>\n<option value=\"SK\">Saskatchewan</option>\n<option value=\"YT\">Yukon</option></select>"
|
46
|
-
end
|
data/test/test_helper.rb
DELETED