-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenglish_numbers_spec.rb
61 lines (47 loc) · 1.7 KB
/
english_numbers_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require_relative "english_numbers"
RSpec.describe EnglishNumber do
describe "#in_english" do
it "translate singles" do
expect(EnglishNumber.new(2).in_english).to eq("two")
end
it "translate negative singles" do
expect(EnglishNumber.new(-2).in_english).to eq("minus two")
end
it "translate tens" do
expect(EnglishNumber.new(20).in_english).to eq("twenty")
end
it "translate negative tens" do
expect(EnglishNumber.new(-20).in_english).to eq("minus twenty")
end
it "translate teens" do
expect(EnglishNumber.new(16).in_english).to eq("sixteen")
end
it "translate teens" do
expect(EnglishNumber.new(-16).in_english).to eq("minus sixteen")
end
it "returns nil if the number is bigger than 99" do
expect(EnglishNumber.new(100).in_english).to eq(nil)
end
it "returns nil if the number is smaller than 99" do
expect(EnglishNumber.new(-100).in_english).to eq(nil)
end
it "combines tens and singles" do
expect(EnglishNumber.new(81).in_english).to eq("eighty-one")
end
it "combines negative tens and singles" do
expect(EnglishNumber.new(-81).in_english).to eq("minus eighty-one")
end
it "combines tens and singles and ignores the decimal point" do
expect(EnglishNumber.new(81.5).in_english).to eq("eighty-one")
end
it "combines negative tens and singles and ignores the decimal point" do
expect(EnglishNumber.new(-81.5).in_english).to eq("minus eighty-one")
end
it "translate zero" do
expect(EnglishNumber.new(0).in_english).to eq("zero")
end
it "translate 27.1" do
expect(EnglishNumber.new(27.1).in_english).to eq("twenty-seven")
end
end
end