test/pagarme/resources/transaction_test.rb in pagarme-2.1.2 vs test/pagarme/resources/transaction_test.rb in pagarme-2.1.3

- old
+ new

@@ -1,9 +1,9 @@ require_relative '../../test_helper' module PagarMe - class TransactionTest < Test::Unit::TestCase + class TransactionTest < PagarMeTestCase def setup super ensure_positive_balance end @@ -214,8 +214,19 @@ assert_equal result['installments'].size, 12 (1..12).each do |i| installment = (amount.to_f/i).round assert_equal result['installments'][i.to_s]['installment_amount'], installment end + end + + should 'be able to get public key' do + transaction = PagarMe::Transaction.generate_card_hash + assert_match(/BEGIN\ PUBLIC\ KEY/, transaction.public_key) + end + + should 'validate encryption_key' do + PagarMe.encryption_key = nil + exception = assert_raises(PagarMe::RequestError){ PagarMe::Transaction.generate_card_hash } + assert_equal exception.message, "Invalid Encryption Key" end end end