spell_number 0.0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,301 +1,300 @@
1
- require 'spell_number'
1
+ require 'spec_helper'
2
2
 
3
- describe "spell numbers in english" do
4
-
3
+ describe "spell numbers in english" do
5
4
  def test_number(number, result)
6
- SpellNumber.number_to_words(number, :locale => 'en').should == result
5
+ expect(SpellNumber.number_to_words(number, locale: 'en')).to eq result
7
6
  end
8
-
7
+
9
8
  describe "Single digits" do
10
9
  it "should transform 1" do
11
10
  test_number(1, 'one')
12
11
  end
13
-
12
+
14
13
  it "should transform 2" do
15
14
  test_number(2, 'two')
16
15
  end
17
-
16
+
18
17
  it "should transform 3" do
19
18
  test_number(3, 'three')
20
19
  end
21
-
20
+
22
21
  it "should transform 4" do
23
22
  test_number(4, 'four')
24
23
  end
25
-
24
+
26
25
  it "should transform 5" do
27
26
  test_number(5, 'five')
28
27
  end
29
-
28
+
30
29
  it "should transform 6" do
31
30
  test_number(6, 'six')
32
31
  end
33
-
32
+
34
33
  it "should transform 7" do
35
34
  test_number(7, 'seven')
36
35
  end
37
-
36
+
38
37
  it "should transform 8" do
39
38
  test_number(8, 'eight')
40
39
  end
41
-
40
+
42
41
  it "should transform 9" do
43
42
  test_number(9, 'nine')
44
43
  end
45
-
44
+
46
45
  it "should transform 10" do
47
46
  test_number(0, 'zero')
48
47
  end
49
48
  end
50
-
51
- describe "Teens" do
52
-
49
+
50
+ describe "Teens" do
51
+
53
52
  it "should spell 10 as ten" do
54
53
  test_number(10, 'ten')
55
54
  end
56
-
55
+
57
56
  it "should spell 11 as eleven" do
58
57
  test_number(11, 'eleven')
59
58
  end
60
-
59
+
61
60
  it "should spell 12 as twelve" do
62
61
  test_number(12, 'twelve')
63
62
  end
64
-
63
+
65
64
  it "should spell 13 as thirteen" do
66
65
  test_number(13, 'thirteen')
67
66
  end
68
-
67
+
69
68
  it "should spell 14 as fourteen" do
70
69
  test_number(14, 'fourteen')
71
70
  end
72
-
71
+
73
72
  it "should spell 15 as fifteen" do
74
73
  test_number(15, 'fifteen')
75
74
  end
76
-
75
+
77
76
  it "should spell 16 as sixteen" do
78
77
  test_number(16, 'sixteen')
79
78
  end
80
-
79
+
81
80
  it "should spell 17 as seventeen" do
82
81
  test_number(17, 'seventeen')
83
82
  end
84
-
83
+
85
84
  it "should spell 18 as eighteen" do
86
85
  test_number(18, 'eighteen')
87
86
  end
88
-
87
+
89
88
  it "should spell 19 as nineteen" do
90
89
  test_number(19, 'nineteen')
91
90
  end
92
91
  end
93
-
92
+
94
93
  describe "Twenties" do
95
-
94
+
96
95
  it "should spell 20 as twenty" do
97
96
  test_number(20, 'twenty')
98
97
  end
99
-
98
+
100
99
  it "should spell 21 as twenty-one" do
101
100
  test_number(21, 'twenty-one')
102
101
  end
103
-
102
+
104
103
  it "should spell 22 as twenty-two" do
105
104
  test_number(22, 'twenty-two')
106
105
  end
107
-
106
+
108
107
  it "should spell 23 as twenty-three" do
109
108
  test_number(23, 'twenty-three')
110
109
  end
111
-
110
+
112
111
  it "should spell 24 as twenty-four" do
113
112
  test_number(24, 'twenty-four')
114
113
  end
115
-
114
+
116
115
  it "should spell 25 as twenty-five" do
117
116
  test_number(25, 'twenty-five')
118
117
  end
119
-
118
+
120
119
  it "should spell 26 as twenty-six" do
121
120
  test_number(26, 'twenty-six')
122
121
  end
123
-
122
+
124
123
  it "should spell 27 as twenty-seven" do
125
124
  test_number(27, 'twenty-seven')
126
125
  end
127
-
126
+
128
127
  it "should spell 28 as twenty-eight" do
129
128
  test_number(28, 'twenty-eight')
130
129
  end
131
-
130
+
132
131
  it "should spell 29 as twenty-nine" do
133
132
  test_number(29, 'twenty-nine')
134
133
  end
135
134
  end
136
-
137
- describe "Thirties" do
135
+
136
+ describe "Thirties" do
138
137
  it "should spell 30 as thirty" do
139
138
  test_number(30, 'thirty')
140
139
  end
141
-
140
+
142
141
  it "should spell 33 as thirty-three" do
143
142
  test_number(33, 'thirty-three')
144
- end
143
+ end
145
144
  end
146
-
147
- describe "Fourties" do
145
+
146
+ describe "Fourties" do
148
147
  it "should spell 40 as fourty" do
149
148
  test_number(40, 'fourty')
150
149
  end
151
-
150
+
152
151
  it "should spell 44 as fourty-four" do
153
152
  test_number(44, 'fourty-four')
154
- end
153
+ end
155
154
  end
156
-
157
- describe "Fifties" do
155
+
156
+ describe "Fifties" do
158
157
  it "should spell 50 as fifty" do
159
158
  test_number(50, 'fifty')
160
159
  end
161
-
160
+
162
161
  it "should spell 55 as fifty-five" do
163
162
  test_number(55, 'fifty-five')
164
- end
163
+ end
165
164
  end
166
-
167
- describe "Sixties" do
165
+
166
+ describe "Sixties" do
168
167
  it "should spell 60 as sixty" do
169
168
  test_number(60, 'sixty')
170
169
  end
171
-
170
+
172
171
  it "should spell 66 as sixty-six" do
173
172
  test_number(66, 'sixty-six')
174
- end
173
+ end
175
174
  end
176
-
177
- describe "Seventies" do
175
+
176
+ describe "Seventies" do
178
177
  it "should spell 70 as seventy" do
179
178
  test_number(70, 'seventy')
180
179
  end
181
-
180
+
182
181
  it "should spell 77 as seventy-seven" do
183
182
  test_number(77, 'seventy-seven')
184
- end
183
+ end
185
184
  end
186
-
187
- describe "Eighties" do
185
+
186
+ describe "Eighties" do
188
187
  it "should spell 80 as eighty" do
189
188
  test_number(80, 'eighty')
190
189
  end
191
-
190
+
192
191
  it "should spell 88 as eighty-eight" do
193
192
  test_number(88, 'eighty-eight')
194
- end
193
+ end
195
194
  end
196
-
197
- describe "Nineties" do
195
+
196
+ describe "Nineties" do
198
197
  it "should spell 90 as ninety" do
199
198
  test_number(90, 'ninety')
200
199
  end
201
-
200
+
202
201
  it "should spell 99 as ninety-nine" do
203
202
  test_number(99, 'ninety-nine')
204
- end
203
+ end
205
204
  end
206
-
205
+
207
206
  describe "Hundreds" do
208
207
  it "should spell 100 as one hundred" do
209
208
  test_number(100, 'one hundred')
210
209
  end
211
-
210
+
212
211
  it "should spell 101 as one hundred and one" do
213
212
  test_number(101, 'one hundred and one')
214
213
  end
215
-
214
+
216
215
  it "should spell 111 as one hundred and eleven" do
217
216
  test_number(111, 'one hundred and eleven')
218
217
  end
219
-
218
+
220
219
  it "should spell 155 as one hundred and fifty-five" do
221
220
  test_number(155, 'one hundred and fifty-five')
222
221
  end
223
-
222
+
224
223
  it "should spell 190 as one hundred and ninety" do
225
224
  test_number(190, 'one hundred and ninety')
226
225
  end
227
-
226
+
228
227
  it "should spell 200 as two hundred" do
229
228
  test_number(200, 'two hundred')
230
229
  end
231
-
230
+
232
231
  it "should spell 222 as two hundred and twenty-two" do
233
232
  test_number(222, 'two hundred and twenty-two')
234
233
  end
235
-
234
+
236
235
  it "should spell 999 as nine hundred and ninety-nine" do
237
236
  test_number(999, 'nine hundred and ninety-nine')
238
237
  end
239
238
  end
240
-
239
+
241
240
  describe "Thousands" do
242
-
241
+
243
242
  it "should spell 1000 as one thousand" do
244
243
  test_number(1000, 'one thousand')
245
244
  end
246
-
245
+
247
246
  it "should spell 1001 as one thousand and one" do
248
247
  test_number(1001, 'one thousand and one')
249
248
  end
250
-
249
+
251
250
  it "should spell 1011 as one thousand and eleven" do
252
251
  test_number(1011, 'one thousand and eleven')
253
252
  end
254
-
253
+
255
254
  it "should spell 1100 as one thousand, one hundred" do
256
255
  test_number(1100, 'one thousand, one hundred')
257
256
  end
258
-
257
+
259
258
  it "should spell 1111 as one thousand, one hundred and one" do
260
259
  test_number(1111, 'one thousand, one hundred and eleven')
261
260
  end
262
-
261
+
263
262
  it "should spell 999,999 as nine hundred ninety-nine thousand, nine hundred and ninety-nine" do
264
263
  test_number(999999, 'nine hundred and ninety-nine thousand, nine hundred and ninety-nine')
265
264
  end
266
-
265
+
267
266
  end
268
-
267
+
269
268
  describe "Millions" do
270
-
269
+
271
270
  it "should spell 1.000.000 as one million" do
272
271
  test_number(1000000, 'one million')
273
272
  end
274
-
273
+
275
274
  it "should spell 1.000.001 as one million and one" do
276
275
  test_number(1000001, 'one million and one')
277
276
  end
278
-
277
+
279
278
  it "should spell 1.000.011 as one million and eleven" do
280
279
  test_number(1000011, 'one million and eleven')
281
280
  end
282
-
281
+
283
282
  it "should spell 1.000.100 as one million, one hundred" do
284
283
  test_number(1000100, 'one million, one hundred')
285
284
  end
286
-
285
+
287
286
  it "should spell 1.000.111 as one million, one hundred and eleven" do
288
287
  test_number(1000000, 'one million')
289
288
  end
290
-
289
+
291
290
  it "should spell 1.001.111 as one million, one thousand, one hundred and eleven" do
292
291
  test_number(1001111, 'one million, one thousand, one hundred and eleven')
293
292
  end
294
-
293
+
295
294
  it "should spell 999.999.999.999 as nine hundred ninety-nine thousand million, nine hundred ninenty-nine thousand, nine hundred and ninety-nine" do
296
295
  test_number(999999999999, 'nine hundred and ninety-nine thousand, nine hundred and ninety-nine million, nine hundred and ninety-nine thousand, nine hundred and ninety-nine')
297
296
  end
298
-
297
+
299
298
  end
300
-
301
- end
299
+
300
+ end
@@ -0,0 +1 @@
1
+ require 'spell_number'
data/spell_number.gemspec CHANGED
@@ -1,69 +1,21 @@
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 -*-
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = "spell_number"
8
- s.version = "0.0.2"
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "spell_number"
6
+ spec.version = "0.2.1"
7
+ spec.authors = ["Daniel Hahn"]
8
+ spec.description = "Simple Gem to spell numbers as words"
9
+ spec.email = ["developers@betterplace.org"]
10
+ spec.summary = "Spell numbers as words"
11
+ spec.homepage = "https://github.com/betterplace/spell_number"
9
12
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Daniel Hahn"]
12
- s.date = "2012-04-19"
13
- s.description = "Simple Gem to spell numbers as words"
14
- s.email = "developers@betterplace.org"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/spell_number.rb",
28
- "lib/spell_number/speller.rb",
29
- "locales/de.yml",
30
- "locales/en.yml",
31
- "spec/number_to_spell_de_spec.rb",
32
- "spec/number_to_spell_spec.rb",
33
- "spell_number.gemspec"
34
- ]
35
- s.homepage = "http://github.com/betterplace/spell_number"
36
- s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "1.8.17"
39
- s.summary = "Spell numbers as words"
40
- s.test_files = [
41
- "spec/number_to_spell_de_spec.rb",
42
- "spec/number_to_spell_spec.rb"
43
- ]
13
+ spec.files = `git ls-files`.split("\n")
14
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ spec.require_paths = ["lib"]
44
16
 
45
- if s.respond_to? :specification_version then
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<i18n>, [">= 0.3.7"])
50
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
51
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
- s.add_development_dependency(%q<rcov>, [">= 0"])
54
- else
55
- s.add_dependency(%q<i18n>, [">= 0.3.7"])
56
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
59
- s.add_dependency(%q<rcov>, [">= 0"])
60
- end
61
- else
62
- s.add_dependency(%q<i18n>, [">= 0.3.7"])
63
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
66
- s.add_dependency(%q<rcov>, [">= 0"])
67
- end
17
+ spec.add_dependency "i18n", "~> 1.0.0"
18
+ spec.add_development_dependency "bundler"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "rspec"
68
21
  end
69
-