forked from smileyface525/phase_0_unit_2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommas_spec.rb
More file actions
20 lines (17 loc) · 713 Bytes
/
commas_spec.rb
File metadata and controls
20 lines (17 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require_relative "[Your file name here]"
#=> Make sure you change this to the name of your code file! Save that file
# into this directory.
def random_num(min, max)
rand(max - min + 1) + min
end
describe "seperate_comma" do
it "returns no comma, when the integer is smaller than 1000" do
separate_comma(random_num(0, 999)).should match /^\d{1,3}$/
end
it "returns one comma, when the integer is between 1000 and 999999" do
separate_comma(random_num(1000, 999999)).should match /^\d{1,3},\d{3}$/
end
it "returns two commas, when the integer is between 1000000 and 999999999" do
separate_comma(random_num(1000000, 999999999)).should match /^\d{1,3},\d{3},\d{3}$/
end
end