-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluhn_algorithm_spec.rb
56 lines (55 loc) · 980 Bytes
/
luhn_algorithm_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
RSpec.describe LuhnAlgorithm do
it "has a version number" do
expect(LuhnAlgorithm::VERSION).not_to be nil
end
[
{
value: '6011111111111117',
result: true
},
{
value: '6011111111111118',
result: false
},
{
value: 4222222222222,
result: true
},
{
value: '4222221222222',
result: false
},
{
value: '4522222222222',
result: false
},
{
value: '4522222222222',
result: false
},
{
value: '45222222222220',
result: false
},
{
value: '45222222222220',
result: false
},
{
value: '4111111111111111',
result: true
},
{
value: 'A122333333333',
result: false
},
{
value: 6011000990139424,
result: true
}
].each do |hs|
it "return #{hs[:result]} for value #{hs[:value]}" do
expect(LuhnAlgorithm.valid?(hs[:value])).to eq(hs[:result])
end
end
end