|
10 | 10 |
|
11 | 11 | it 'raises an exception for an invalid issuer_id_number' do |
12 | 12 | expect do |
13 | | - Minfraud::Components::CreditCard.new( |
| 13 | + described_class.new( |
14 | 14 | issuer_id_number: '5', |
15 | 15 | ) |
16 | 16 | end.to raise_exception(Minfraud::InvalidInputError) |
17 | 17 | end |
18 | 18 |
|
19 | 19 | it 'raises an exception for an invalid last_digits' do |
20 | 20 | expect do |
21 | | - Minfraud::Components::CreditCard.new( |
| 21 | + described_class.new( |
22 | 22 | last_digits: '6', |
23 | 23 | ) |
24 | 24 | end.to raise_exception(Minfraud::InvalidInputError) |
25 | 25 | end |
26 | 26 |
|
27 | 27 | it 'raises an exception for an invalid last_4_digits' do |
28 | 28 | expect do |
29 | | - Minfraud::Components::CreditCard.new( |
| 29 | + described_class.new( |
30 | 30 | last_4_digits: '6', |
31 | 31 | ) |
32 | 32 | end.to raise_exception(Minfraud::InvalidInputError) |
33 | 33 | end |
34 | 34 |
|
35 | 35 | it 'raises an exception for an invalid token' do |
36 | 36 | expect do |
37 | | - Minfraud::Components::CreditCard.new( |
| 37 | + described_class.new( |
38 | 38 | token: '☃️', |
39 | 39 | ) |
40 | 40 | end.to raise_exception(Minfraud::InvalidInputError) |
41 | 41 | end |
42 | 42 |
|
43 | 43 | it 'raises an exception for an invalid token (all digits)' do |
44 | 44 | expect do |
45 | | - Minfraud::Components::CreditCard.new( |
| 45 | + described_class.new( |
46 | 46 | token: '123', |
47 | 47 | ) |
48 | 48 | end.to raise_exception(Minfraud::InvalidInputError) |
49 | 49 | end |
50 | 50 |
|
51 | 51 | it 'does not raise an exception for valid values (deprecated last_4_digits)' do |
52 | | - @cc = Minfraud::Components::CreditCard.new( |
| 52 | + cc = described_class.new( |
53 | 53 | issuer_id_number: '123456', |
54 | 54 | last_4_digits: '1234', |
55 | 55 | token: 'abcd', |
56 | 56 | was_3d_secure_successful: true, |
57 | 57 | ) |
58 | | - expect(@cc.last_digits).to be(@cc.last_4_digits) |
59 | | - expect(@cc.last_digits).to be('1234') |
| 58 | + expect(cc.last_digits).to be(cc.last_4_digits) |
| 59 | + expect(cc.last_digits).to be('1234') |
60 | 60 | end |
61 | 61 |
|
62 | 62 | it 'does not raise an exception for valid values (eight digit issuer_id_number)' do |
63 | | - Minfraud::Components::CreditCard.new( |
| 63 | + described_class.new( |
64 | 64 | issuer_id_number: '12345678', |
65 | 65 | last_4_digits: '1234', |
66 | 66 | token: 'abcd', |
|
69 | 69 | end |
70 | 70 |
|
71 | 71 | it 'does not raise an exception for valid values (two digit last_digits)' do |
72 | | - @cc = Minfraud::Components::CreditCard.new( |
| 72 | + cc = described_class.new( |
73 | 73 | issuer_id_number: '12345678', |
74 | 74 | last_digits: '34', |
75 | 75 | token: 'abcd', |
76 | 76 | was_3d_secure_successful: true, |
77 | 77 | ) |
78 | | - expect(@cc.last_digits).to be(@cc.last_4_digits) |
79 | | - expect(@cc.last_digits).to be('34') |
| 78 | + expect(cc.last_digits).to be(cc.last_4_digits) |
| 79 | + expect(cc.last_digits).to be('34') |
80 | 80 | end |
81 | 81 |
|
82 | 82 | it 'does not raise an exception for valid values (token is all digits)' do |
83 | | - Minfraud::Components::CreditCard.new( |
| 83 | + described_class.new( |
84 | 84 | issuer_id_number: '123456', |
85 | 85 | last_digits: '1234', |
86 | 86 | token: '1' * 20, |
|
89 | 89 | end |
90 | 90 |
|
91 | 91 | it 'does not raise an exception when country is given and issuer_id_number is not provided' do |
92 | | - Minfraud::Components::CreditCard.new( |
| 92 | + described_class.new( |
93 | 93 | country: 'CA', |
94 | 94 | ) |
95 | 95 | end |
|
0 commit comments