I am running two tests where one fails and one passes. The only difference is the use of :should
vs :expect
. Why does one test work and the other doesn't?
Passing Test:
it "returns no comma, when the integer is smaller than 1000" do
separate_comma(random_num(0, 999)).should match /^\d{1,3}$/
end
Failing Test:
it "explanation" do
expect(separate_comma(random_num(0, 999))).to match /^\d{1,3}$/
end
Here's the boring stuff:
def random_num(min, max)
rand(max - min + 1) + min
end
def separate_comma(number, delimiter = ',')
new = number.to_s.reverse.scan(/.../).join(delimiter)
end