country_with_currency 1.0.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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +3 -0
- data/country_with_currency.gemspec +27 -0
- data/lib/country_with_currency.rb +3 -0
- data/lib/country_with_currency/country.rb +95 -0
- data/lib/country_with_currency/version.rb +3 -0
- data/lib/data/countries.yaml +1136 -0
- data/spec/country_with_currency_spec.rb +46 -0
- data/spec/spec_helper.rb +6 -0
- metadata +132 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Country do
|
4
|
+
describe "all" do
|
5
|
+
it "should return an array list of all countries" do
|
6
|
+
countries = Country.all
|
7
|
+
countries.should be_an(Array)
|
8
|
+
countries.first.should be_an(Country)
|
9
|
+
countries.should have(227).countries
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "dynamic finder methods" do
|
14
|
+
context "when search name found" do
|
15
|
+
let(:country) { Country.find_by_name("United States") }
|
16
|
+
|
17
|
+
it "should return an array with United States country object" do
|
18
|
+
country.should be_a(Array)
|
19
|
+
country.first.should be_an(Country)
|
20
|
+
country.first.iso.should == "USA"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when search lowercase name found" do
|
25
|
+
let(:country) { Country.find_by_name("united states") }
|
26
|
+
|
27
|
+
it "should return an array with United States country object" do
|
28
|
+
country.should be_a(Array)
|
29
|
+
country.first.should be_an(Country)
|
30
|
+
country.first.iso.should == "USA"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when search name not found" do
|
35
|
+
it "should raise Country::UnknownCountry error" do
|
36
|
+
lambda { Country.find_by_name("Invalid Country") }.should raise_error(Country::UnknownCountry, "Country not found.")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when search by invalid attribute" do
|
41
|
+
it "should raise Country::UnknownAttribute error" do
|
42
|
+
lambda { Country.find_by_invalid("Invalid Country") }.should raise_error(Country::UnknownAttribute, "Invalid attribute 'invalid'.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: country_with_currency
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diganta Mandal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: kramdown
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
description: Provides a helper to get a country list along with ISO code, currency
|
84
|
+
code and currency symbol by following ISO 3166 country list.
|
85
|
+
email:
|
86
|
+
- urs.diganta@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- country_with_currency.gemspec
|
98
|
+
- lib/country_with_currency.rb
|
99
|
+
- lib/country_with_currency/country.rb
|
100
|
+
- lib/country_with_currency/version.rb
|
101
|
+
- lib/data/countries.yaml
|
102
|
+
- spec/country_with_currency_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/dark-prince/country_with_currency
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.9.3
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 1.8.11
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.0
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Provides a helper to get a country list along with ISO code, currency code
|
128
|
+
and currency symbol by following ISO 3166 country list.
|
129
|
+
test_files:
|
130
|
+
- spec/country_with_currency_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
has_rdoc:
|