edools_mymoip 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +15 -0
  4. data/.travis.yml +4 -0
  5. data/CHANGELOG.md +128 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +3 -0
  9. data/Rakefile +10 -0
  10. data/lib/mymoip.rb +57 -0
  11. data/lib/mymoip/bank_debit.rb +22 -0
  12. data/lib/mymoip/commission.rb +54 -0
  13. data/lib/mymoip/credit_card.rb +73 -0
  14. data/lib/mymoip/exceptions.rb +15 -0
  15. data/lib/mymoip/formatter.rb +23 -0
  16. data/lib/mymoip/instruction.rb +134 -0
  17. data/lib/mymoip/json_parser.rb +11 -0
  18. data/lib/mymoip/payer.rb +75 -0
  19. data/lib/mymoip/payment.rb +10 -0
  20. data/lib/mymoip/payment_methods.rb +46 -0
  21. data/lib/mymoip/payment_slip.rb +74 -0
  22. data/lib/mymoip/payments/bank_debit_payment.rb +27 -0
  23. data/lib/mymoip/payments/credit_card_payment.rb +53 -0
  24. data/lib/mymoip/payments/payment_slip_payment.rb +12 -0
  25. data/lib/mymoip/purchase.rb +40 -0
  26. data/lib/mymoip/request.rb +34 -0
  27. data/lib/mymoip/requests/payment_request.rb +53 -0
  28. data/lib/mymoip/requests/transparent_request.rb +36 -0
  29. data/lib/mymoip/validators.rb +12 -0
  30. data/lib/mymoip/version.rb +3 -0
  31. data/mymoip.gemspec +30 -0
  32. data/test/fixtures/fixture.rb +73 -0
  33. data/test/fixtures/vcr_cassettes/payment_request.yml +37 -0
  34. data/test/fixtures/vcr_cassettes/payment_request_with_payment_slip.yml +32 -0
  35. data/test/fixtures/vcr_cassettes/transparent_request.yml +34 -0
  36. data/test/fixtures/vcr_cassettes/transparent_request_with_commissions.yml +35 -0
  37. data/test/lib/test_bank_debit.rb +36 -0
  38. data/test/lib/test_bank_debit_payment.rb +32 -0
  39. data/test/lib/test_commission.rb +121 -0
  40. data/test/lib/test_credit_card_payment.rb +107 -0
  41. data/test/lib/test_creditcard.rb +206 -0
  42. data/test/lib/test_formatter.rb +49 -0
  43. data/test/lib/test_instruction.rb +243 -0
  44. data/test/lib/test_mymoip.rb +79 -0
  45. data/test/lib/test_payer.rb +249 -0
  46. data/test/lib/test_payment.rb +15 -0
  47. data/test/lib/test_payment_methods.rb +54 -0
  48. data/test/lib/test_payment_request.rb +120 -0
  49. data/test/lib/test_payment_slip.rb +78 -0
  50. data/test/lib/test_payment_slip_payment.rb +8 -0
  51. data/test/lib/test_purchase.rb +109 -0
  52. data/test/lib/test_request.rb +88 -0
  53. data/test/lib/test_transparent_request.rb +71 -0
  54. data/test/lib/test_validators.rb +13 -0
  55. data/test/live_test.rb +4 -0
  56. data/test/test_helper.rb +17 -0
  57. metadata +251 -0
@@ -0,0 +1,32 @@
1
+ require_relative '../test_helper'
2
+
3
+ class TestBankDebitPayment < Test::Unit::TestCase
4
+ def test_initialization_and_setters
5
+ bank_debit = Fixture.bank_debit
6
+ subject = MyMoip::BankDebitPayment.new(bank_debit)
7
+ assert_equal bank_debit, subject.bank_debit
8
+ end
9
+
10
+ def test_json_format
11
+ payment = MyMoip::BankDebitPayment.new(Fixture.bank_debit)
12
+ assert_equal "DebitoBancario", payment.to_json[:Forma]
13
+ end
14
+
15
+ def test_to_json_should_accept_any_bank_from_available_banks_constant
16
+ MyMoip::BankDebit::AVAILABLE_BANKS.each do |bank|
17
+ payment = MyMoip::BankDebitPayment.new(Fixture.bank_debit(bank: bank))
18
+ assert_nothing_raised(KeyError) { payment.to_json }
19
+ end
20
+ end
21
+
22
+ def test_to_json_method_raises_an_exception_when_called_without_a_bank_debit
23
+ subject = MyMoip::BankDebitPayment.new(nil)
24
+ assert_raise(MyMoip::InvalidBankDebit) { subject.to_json }
25
+ end
26
+
27
+ def test_to_json_method_raises_an_exception_when_called_with_a_invalid_bank_debit
28
+ subject = MyMoip::BankDebitPayment.new(Fixture.bank_debit)
29
+ MyMoip::BankDebit.any_instance.stubs(:invalid?).returns(true)
30
+ assert_raise(MyMoip::InvalidBankDebit) { subject.to_json }
31
+ end
32
+ end
@@ -0,0 +1,121 @@
1
+ require_relative '../test_helper'
2
+
3
+ class TestCommission < Test::Unit::TestCase
4
+ def test_initialization_and_setters
5
+ params = {
6
+ reason: 'Because we can',
7
+ receiver_login: 'comissioned_indentifier',
8
+ fixed_value: 23.5,
9
+ percentage_value: 0.15
10
+ }
11
+ subject = MyMoip::Commission.new(params)
12
+ assert_equal params[:reason], subject.reason
13
+ assert_equal params[:receiver_login], subject.receiver_login
14
+ assert_equal params[:fixed_value], subject.fixed_value
15
+ assert_equal params[:percentage_value], subject.percentage_value
16
+ end
17
+
18
+ def test_validate_presence_of_reason
19
+ subject = Fixture.commission(reason: nil)
20
+ assert subject.invalid? && subject.errors[:reason].present?,
21
+ "should be invalid without a reason"
22
+ end
23
+
24
+ def test_validate_presence_of_receiver_login
25
+ subject = Fixture.commission(receiver_login: nil)
26
+ assert subject.invalid? && subject.errors[:receiver_login].present?,
27
+ "should be invalid without a receiver_login"
28
+ end
29
+
30
+ def test_validate_presence_of_fixed_value_or_percentage_value
31
+ subject = Fixture.commission(fixed_value: nil, percentage_value: nil)
32
+
33
+ assert subject.invalid? && subject.errors[:fixed_value].present?,
34
+ "should be invalid without a fixed value"
35
+
36
+ assert subject.invalid? && subject.errors[:percentage_value].present?,
37
+ "should be invalid without a percentage value"
38
+
39
+ subject.fixed_value = 2
40
+ assert subject.valid?, "should be valid with only fixed value set"
41
+
42
+ subject.fixed_value = nil
43
+ subject.percentage_value = 0.15
44
+ assert subject.valid?, "should be valid with only percentage value set"
45
+
46
+ subject.fixed_value = subject.percentage_value
47
+ assert subject.valid?, "should be valid with both values set"
48
+ end
49
+
50
+
51
+ def test_validate_numericality_of_fixed_value
52
+ subject = Fixture.commission(fixed_value: "I'm not a number")
53
+ assert subject.invalid? && subject.errors[:fixed_value].present?,
54
+ "should be invalid with a non number"
55
+ end
56
+
57
+ def test_validate_numericality_of_percentage_value
58
+ subject = Fixture.commission(percentage_value: "I'm not a number", fixed_value: nil)
59
+ assert subject.invalid? && subject.errors[:percentage_value].present?,
60
+ "should be invalid with a non number"
61
+ end
62
+
63
+ def test_validate_positive_number_of_fixed_value
64
+ subject = Fixture.commission(fixed_value: -0.1)
65
+ assert subject.invalid? && subject.errors[:fixed_value].present?,
66
+ "should be invalid with negative number"
67
+ end
68
+
69
+ def test_validate_percentage_number_of_percentage_value
70
+ subject = Fixture.commission(percentage_value: -0.1, fixed_value: nil)
71
+ assert subject.invalid? && subject.errors[:percentage_value].present?,
72
+ "should be invalid if lesser than 0"
73
+ subject.percentage_value = 1.01
74
+ assert subject.invalid? && subject.errors[:percentage_value].present?,
75
+ "should be invalid if greater than 1"
76
+ end
77
+
78
+ def test_gross_amount_is_equal_to_fixed_value_when_this_is_present
79
+ instruction = Fixture.instruction
80
+ subject = Fixture.commission(fixed_value: 5, percentage_value: nil)
81
+ assert_equal 5, subject.gross_amount(instruction)
82
+ end
83
+
84
+ def test_gross_amount_with_percentage_is_equal_to_a_percentage_of_instructions_values
85
+ instruction = stub(gross_amount: 200)
86
+ subject = Fixture.commission(fixed_value: nil, percentage_value: 0.2)
87
+ assert_equal 40, subject.gross_amount(instruction)
88
+ end
89
+
90
+ def test_cannot_give_gross_amount_without_fixed_or_percentage_value_set
91
+ instruction = stub(gross_amount: 200)
92
+ subject = Fixture.commission(fixed_value: nil, percentage_value: nil)
93
+ assert_raise MyMoip::InvalidComission do
94
+ subject.gross_amount(instruction)
95
+ end
96
+ end
97
+
98
+ def test_xml_format_with_fixed_value
99
+ subject = Fixture.commission(fixed_value: 5)
100
+ expected_format = <<XML
101
+ <Comissionamento><Razao>Because we can</Razao><Comissionado><LoginMoIP>commissioned_indentifier</LoginMoIP></Comissionado><ValorFixo>5.00</ValorFixo></Comissionamento>
102
+ XML
103
+ assert_equal expected_format.rstrip, subject.to_xml
104
+ end
105
+
106
+ def test_xml_format_with_percentage_value
107
+ subject = Fixture.commission(percentage_value: 0.15, fixed_value: nil)
108
+ expected_format = <<XML
109
+ <Comissionamento><Razao>Because we can</Razao><Comissionado><LoginMoIP>commissioned_indentifier</LoginMoIP></Comissionado><ValorPercentual>15.00</ValorPercentual></Comissionamento>
110
+ XML
111
+ assert_equal expected_format.rstrip, subject.to_xml
112
+ end
113
+
114
+ def test_xml_method_raises_exception_when_called_with_invalid_params
115
+ subject = Fixture.commission
116
+ subject.stubs(:invalid?).returns(true)
117
+ assert_raise MyMoip::InvalidComission do
118
+ subject.to_xml
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,107 @@
1
+ require_relative '../test_helper'
2
+
3
+ class TestCreditCardPayment < Test::Unit::TestCase
4
+ def test_allow_initialization_with_a_hash_of_options
5
+ credit_card = Fixture.credit_card
6
+ subject = MyMoip::CreditCardPayment.new(credit_card, installments: 2)
7
+ assert_equal credit_card, subject.credit_card
8
+ assert_equal 2, subject.installments
9
+ end
10
+
11
+ def test_cash_method_with_one_tranch
12
+ credit_card = Fixture.credit_card
13
+ subject = MyMoip::CreditCardPayment.new(credit_card, installments: 1)
14
+ assert_equal true, subject.cash?
15
+ end
16
+
17
+ def test_cash_method_with_more_than_one_installments
18
+ credit_card = Fixture.credit_card
19
+ subject = MyMoip::CreditCardPayment.new(credit_card, installments: 3)
20
+ assert_equal false, subject.cash?
21
+ end
22
+
23
+ def test_default_initialization_with_one_tranch
24
+ credit_card = Fixture.credit_card
25
+ subject = MyMoip::CreditCardPayment.new(credit_card)
26
+ assert_equal 1, subject.installments
27
+ end
28
+
29
+ def test_json_format
30
+ payment = MyMoip::CreditCardPayment.new(Fixture.credit_card)
31
+ assert_equal "CartaoCredito", payment.to_json[:Forma]
32
+ assert payment.to_json[:Parcelas].kind_of?(Integer), "'Parcelas' must be a kind of integer."
33
+ end
34
+
35
+ def test_json_credit_card_format
36
+ payment = MyMoip::CreditCardPayment.new(Fixture.credit_card)
37
+ assert_match /\A\d+\z/, payment.to_json[:CartaoCredito][:Numero]
38
+ assert_match /\A((0[1-9])|(1[02]))\/\d{2}\z/, payment.to_json[:CartaoCredito][:Expiracao]
39
+ assert_match /\A\d{3}\z/, payment.to_json[:CartaoCredito][:CodigoSeguranca]
40
+ original_date = Date.new(1980, 11, 3)
41
+ MyMoip::Formatter.stubs(:date).returns('03/11/1980')
42
+ assert_equal '03/11/1980', payment.to_json[:CartaoCredito][:Portador][:DataNascimento]
43
+ assert_match /\A\(\d{2}\)\d{4,5}-\d{4}/, payment.to_json[:CartaoCredito][:Portador][:Telefone]
44
+ assert_match /\A\d{3}\.\d{3}\.\d{3}\-\d{2}\z/, payment.to_json[:CartaoCredito][:Portador][:Identidade]
45
+ end
46
+
47
+ def test_to_json_should_accept_any_creditcard_from_available_logos_constant
48
+ MyMoip::CreditCard::AVAILABLE_LOGOS.each do |logo|
49
+ payment = MyMoip::CreditCardPayment.new(Fixture.credit_card(logo: logo))
50
+ assert_nothing_raised(KeyError) { payment.to_json }
51
+ end
52
+ end
53
+
54
+ def test_to_json_method_uses_the_formatted_version_of_the_credit_cards_owner_birthday
55
+ date = Date.new(2040, 10, 30)
56
+ subject = MyMoip::CreditCardPayment.new(Fixture.credit_card(owner_birthday: date))
57
+ formatter = stub_everything('formatter')
58
+ formatter.expects(:date).with(date)
59
+ subject.to_json(formatter)
60
+ end
61
+
62
+ def test_to_json_method_skip_formatting_when_credit_cards_owner_birthday_is_nil
63
+ subject = MyMoip::CreditCardPayment.new(Fixture.credit_card(owner_birthday: nil))
64
+ formatter = stub_everything('formatter')
65
+ formatter.stubs(:date).with(nil).returns('should not be here')
66
+ json = subject.to_json(formatter)
67
+ assert_nil json[:CartaoCredito][:Portador][:DataNascimento]
68
+ end
69
+
70
+ def test_to_json_method_uses_the_formatted_version_of_the_credit_cards_owner_phone
71
+ subject = MyMoip::CreditCardPayment.new(Fixture.credit_card(owner_phone: '5130405060'))
72
+ formatter = stub_everything('formatter')
73
+ formatter.expects(:phone).with('5130405060')
74
+ subject.to_json(formatter)
75
+ end
76
+
77
+ def test_to_json_method_skip_formatting_when_credit_cards_owner_phone_is_nil
78
+ subject = MyMoip::CreditCardPayment.new(Fixture.credit_card(owner_phone: nil))
79
+ formatter = stub_everything('formatter')
80
+ formatter.stubs(:phone).with(nil).returns('should not be here')
81
+ json = subject.to_json(formatter)
82
+ assert_nil json[:CartaoCredito][:Portador][:Telefone]
83
+ end
84
+
85
+ def test_to_json_method_raises_an_exception_when_called_without_a_credit_card
86
+ subject = MyMoip::CreditCardPayment.new(nil)
87
+ assert_raise MyMoip::InvalidCreditCard do
88
+ subject.to_json
89
+ end
90
+ end
91
+
92
+ def test_to_json_method_skip_formatting_when_credit_cards_owner_cpf_is_nil
93
+ subject = MyMoip::CreditCardPayment.new(Fixture.credit_card(owner_cpf: nil))
94
+ formatter = stub_everything('formatter')
95
+ formatter.stubs(:cpf).with(nil).returns('should not be here')
96
+ json = subject.to_json(formatter)
97
+ assert_nil json[:CartaoCredito][:Portador][:Identidade]
98
+ end
99
+
100
+ def test_to_json_method_raises_an_exception_when_called_with_a_invalid_credit_card
101
+ subject = MyMoip::CreditCardPayment.new(Fixture.credit_card)
102
+ MyMoip::CreditCard.any_instance.stubs(:invalid?).returns(true)
103
+ assert_raise MyMoip::InvalidCreditCard do
104
+ subject.to_json
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,206 @@
1
+ require_relative '../test_helper'
2
+
3
+ class TestCreditCard < Test::Unit::TestCase
4
+ def test_initialization_and_setters
5
+ subject = MyMoip::CreditCard.new(
6
+ logo: :visa,
7
+ card_number: "4916654211627608",
8
+ expiration_date: "06/15",
9
+ security_code: "000",
10
+ owner_name: "Juquinha da Rocha",
11
+ owner_birthday: Date.new(1984, 11, 3),
12
+ owner_phone: "5130405060",
13
+ owner_cpf: "522.116.706-95",
14
+ perform_extra_validation: true
15
+ )
16
+
17
+ assert_equal :visa, subject.logo
18
+ assert_equal "4916654211627608", subject.card_number
19
+ assert_equal "06/15", subject.expiration_date
20
+ assert_equal "000", subject.security_code
21
+ assert_equal "Juquinha da Rocha", subject.owner_name
22
+ assert_equal Date.new(1984, 11, 3), subject.owner_birthday
23
+ assert_equal "5130405060", subject.owner_phone
24
+ assert_equal "52211670695", subject.owner_cpf
25
+ assert_equal true, subject.perform_extra_validation
26
+ end
27
+
28
+ def test_initialization_and_setters_with_string_keys
29
+ subject = MyMoip::CreditCard.new(
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
39
+ )
40
+
41
+ assert_equal :visa, subject.logo
42
+ assert_equal "4916654211627608", subject.card_number
43
+ assert_equal "06/15", subject.expiration_date
44
+ assert_equal "000", subject.security_code
45
+ assert_equal "Juquinha da Rocha", subject.owner_name
46
+ assert_equal Date.new(1984, 11, 3), subject.owner_birthday
47
+ assert_equal "5130405060", subject.owner_phone
48
+ assert_equal "52211670695", subject.owner_cpf
49
+ assert_equal false, subject.perform_extra_validation
50
+ end
51
+
52
+ def test_validate_presence_of_logo_attribute
53
+ subject = Fixture.credit_card
54
+ subject.logo = nil
55
+ assert subject.invalid? && subject.errors[:logo].present?,
56
+ 'should be invalid without a logo'
57
+ end
58
+
59
+ def test_owner_birthday_accepts_string_version_of_dates
60
+ subject = Fixture.credit_card
61
+ subject.owner_birthday = '20/12/1980'
62
+ assert_equal Date.new(1980, 12, 20), subject.owner_birthday
63
+ end
64
+
65
+ def test_owner_birthday_accepts_input_of_invalid_dates
66
+ subject = Fixture.credit_card
67
+ subject.owner_birthday = '50/12/1980'
68
+ assert_equal '50/12/1980', subject.owner_birthday
69
+ end
70
+
71
+ def test_validate_format_of_birthday_date
72
+ subject = Fixture.credit_card
73
+ subject.owner_birthday = '50/12/1980'
74
+ assert subject.invalid? && subject.errors[:owner_birthday].present?,
75
+ 'should be valid'
76
+ end
77
+
78
+ def test_validate_presence_of_security_code_attribute
79
+ subject = Fixture.credit_card
80
+ subject.security_code = nil
81
+ assert subject.invalid? && subject.errors[:security_code].present?,
82
+ 'should be invalid without an security_code'
83
+ end
84
+
85
+ def test_accept_nil_owner_phone
86
+ subject = Fixture.credit_card(owner_phone: nil)
87
+ assert subject.valid?, 'should be valid'
88
+ end
89
+
90
+ def test_validate_length_of_owner_phone_attribute_in_10_or_11_chars
91
+ subject = Fixture.credit_card
92
+ subject.owner_phone = '5130405060'
93
+ assert subject.valid?, 'should accept 10 chars'
94
+ subject.owner_phone = '51930405060'
95
+ assert subject.valid?, 'should accept 11 chars'
96
+ subject.owner_phone = '215130405060'
97
+ assert subject.invalid? && subject.errors[:owner_phone].present?,
98
+ 'should not accept strings with other than 10 or 11 chars'
99
+ end
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
+
118
+ def test_remove_left_zeros_from_owner_phone
119
+ subject = Fixture.credit_card
120
+ subject.owner_phone = '05130405060'
121
+ assert_equal '5130405060', subject.owner_phone
122
+ end
123
+
124
+ def test_remove_dashes_from_owner_phone
125
+ subject = Fixture.credit_card
126
+ subject.owner_phone = '513040-5060'
127
+ assert_equal '5130405060', subject.owner_phone
128
+ subject.owner_phone = '5193040-5060'
129
+ assert_equal '51930405060', subject.owner_phone
130
+ end
131
+
132
+ def test_remove_parenthesis_from_owner_phone
133
+ subject = Fixture.credit_card
134
+ subject.owner_phone = '(51)30405060'
135
+ assert_equal '5130405060', subject.owner_phone
136
+ subject.owner_phone = '(51)930405060'
137
+ assert_equal '51930405060', subject.owner_phone
138
+ end
139
+
140
+ def test_remove_dashes_from_owner_cpf
141
+ subject = Fixture.credit_card
142
+ subject.owner_cpf = '522116706-95'
143
+ assert_equal '52211670695', subject.owner_cpf
144
+ end
145
+
146
+ def test_remove_dots_from_owner_cpf
147
+ subject = Fixture.credit_card
148
+ subject.owner_cpf = '522.116.70695'
149
+ assert_equal '52211670695', subject.owner_cpf
150
+ end
151
+
152
+ def test_accept_nil_owner_cpf
153
+ subject = Fixture.credit_card(owner_cpf: nil)
154
+ assert subject.valid?, 'should be valid'
155
+ end
156
+
157
+ def test_warns_about_owner_rg_attribute_deprecation_on_initialization
158
+ MyMoip::CreditCard.any_instance.expects(:warn).with(regexp_matches(/is deprecated/))
159
+ subject = Fixture.credit_card(owner_rg: '1010202030')
160
+ end
161
+
162
+ def test_warns_about_owner_rg_attribute_deprecation_on_setter
163
+ subject = Fixture.credit_card
164
+ subject.expects(:warn).with(regexp_matches(/is deprecated/))
165
+ subject.owner_rg = '1010202030'
166
+ end
167
+
168
+ def test_accepts_security_codes_of_3_digits
169
+ subject = Fixture.credit_card(security_code: "180")
170
+ assert subject.valid?, 'should be valid'
171
+ end
172
+
173
+ def test_accepts_security_codes_of_4_digits
174
+ subject = Fixture.credit_card(security_code: "1809")
175
+ assert subject.valid?, 'should be valid'
176
+ end
177
+
178
+ def test_dont_accept_security_codes_of_neither_3_or_4_digits
179
+ subject = Fixture.credit_card(security_code: "1")
180
+ assert subject.invalid? && subject.errors[:security_code].present?, 'should not be valid'
181
+ end
182
+
183
+ def test_validate_format_of_expiration_date
184
+ subject = Fixture.credit_card(expiration_date: "12/2018")
185
+ assert subject.invalid? && subject.errors[:expiration_date].present?, 'should not accept other formats'
186
+ subject = Fixture.credit_card(expiration_date: "12/18")
187
+ assert subject.valid? && subject.errors[:expiration_date].empty?, 'should accept "%m/%y" format'
188
+ end
189
+
190
+ def test_converts_creditcard_string_logos_to_symbol
191
+ subject = Fixture.credit_card(logo: "visa")
192
+ assert_equal :visa, subject.logo
193
+ end
194
+
195
+ def test_accepts_any_creditcard_from_available_logos_constant
196
+ MyMoip::CreditCard::AVAILABLE_LOGOS.each do |logo|
197
+ subject = Fixture.credit_card(logo: logo)
198
+ assert subject.valid?, 'should be valid'
199
+ end
200
+ end
201
+
202
+ def test_dont_accept_logos_out_of_available_logos_constant
203
+ subject = Fixture.credit_card(logo: :unavailable_card)
204
+ assert subject.invalid? && subject.errors[:logo].present?, 'should not be valid'
205
+ end
206
+ end