@@ -10,7 +10,8 @@ def test_initialization_and_setters
10
10
owner_name : "Juquinha da Rocha" ,
11
11
owner_birthday : Date . new ( 1984 , 11 , 3 ) ,
12
12
owner_phone : "5130405060" ,
13
- owner_cpf : "522.116.706-95"
13
+ owner_cpf : "522.116.706-95" ,
14
+ perform_extra_validation : true
14
15
)
15
16
16
17
assert_equal :visa , subject . logo
@@ -21,18 +22,20 @@ def test_initialization_and_setters
21
22
assert_equal Date . new ( 1984 , 11 , 3 ) , subject . owner_birthday
22
23
assert_equal "5130405060" , subject . owner_phone
23
24
assert_equal "52211670695" , subject . owner_cpf
25
+ assert_equal true , subject . perform_extra_validation
24
26
end
25
27
26
28
def test_initialization_and_setters_with_string_keys
27
29
subject = MyMoip ::CreditCard . new (
28
- 'logo' => :visa ,
29
- 'card_number' => '4916654211627608' ,
30
- 'expiration_date' => '06/15' ,
31
- 'security_code' => '000' ,
32
- 'owner_name' => 'Juquinha da Rocha' ,
33
- 'owner_birthday' => Date . new ( 1984 , 11 , 3 ) ,
34
- 'owner_phone' => '5130405060' ,
35
- 'owner_cpf' => '522.116.706-95'
30
+ 'logo' => :visa ,
31
+ 'card_number' => '4916654211627608' ,
32
+ 'expiration_date' => '06/15' ,
33
+ 'security_code' => '000' ,
34
+ 'owner_name' => 'Juquinha da Rocha' ,
35
+ 'owner_birthday' => Date . new ( 1984 , 11 , 3 ) ,
36
+ 'owner_phone' => '5130405060' ,
37
+ 'owner_cpf' => '522.116.706-95' ,
38
+ 'perform_extra_validation' => false
36
39
)
37
40
38
41
assert_equal :visa , subject . logo
@@ -43,6 +46,7 @@ def test_initialization_and_setters_with_string_keys
43
46
assert_equal Date . new ( 1984 , 11 , 3 ) , subject . owner_birthday
44
47
assert_equal "5130405060" , subject . owner_phone
45
48
assert_equal "52211670695" , subject . owner_cpf
49
+ assert_equal false , subject . perform_extra_validation
46
50
end
47
51
48
52
def test_validate_presence_of_logo_attribute
@@ -94,6 +98,23 @@ def test_validate_length_of_owner_phone_attribute_in_10_or_11_chars
94
98
'should not accept strings with other than 10 or 11 chars'
95
99
end
96
100
101
+ def test_perform_extra_validation
102
+ subject = Fixture . credit_card ( {
103
+ card_number : nil ,
104
+ expiration_date : nil ,
105
+ owner_name : nil ,
106
+ owner_phone : nil ,
107
+ owner_cpf : nil ,
108
+ perform_extra_validation : true
109
+ } )
110
+ assert subject . invalid?
111
+ assert subject . errors [ :card_number ] , "can't be blank"
112
+ assert subject . errors [ :expiration_date ] , "can't be blank"
113
+ assert subject . errors [ :owner_name ] , "can't be blank"
114
+ assert subject . errors [ :owner_phone ] , "can't be blank"
115
+ assert subject . errors [ :owner_cpf ] , "can't be blank"
116
+ end
117
+
97
118
def test_remove_left_zeros_from_owner_phone
98
119
subject = Fixture . credit_card
99
120
subject . owner_phone = '05130405060'
0 commit comments