test/test_helper.rb in pagarme-2.2.1 vs test/test_helper.rb in pagarme-2.2.2
- old
+ new
@@ -53,21 +53,31 @@
recipient.anticipatable_volume_percentage = 100
recipient.save
end
end
- def fixed_api_key
- PagarMe.encryption_key = FIXED_ENCRYPTION_KEY
- PagarMe.api_key = FIXED_API_KEY
+ def change_company(api_version: nil, &block)
+ company = temporary_company api_version: api_version
+ change_api_and_encryption_keys api_key: company.api_key.test, encryption_key: company.encryption_key.test, &block
+ end
+
+ def change_api_and_encryption_keys(api_key: FIXED_API_KEY, encryption_key: FIXED_ENCRYPTION_KEY)
+ previous_encryption_key = PagarMe.encryption_key
+ previous_api_key = PagarMe.api_key
+
+ PagarMe.encryption_key = encryption_key
+ PagarMe.api_key = api_key
yield
- PagarMe.encryption_key = temporary_company.encryption_key.test
- PagarMe.api_key = temporary_company.api_key.test
+
+ PagarMe.encryption_key = previous_encryption_key
+ PagarMe.api_key = previous_api_key
end
+ alias :fixed_api_key :change_api_and_encryption_keys
- def temporary_company
- VCR.use_cassette 'TestCase/tmp_company' do
+ def temporary_company(api_version: nil)
+ VCR.use_cassette "TestCase/tmp_company/api_key/#{api_version}" do
PagarMe.api_key = FIXED_API_KEY
- PagarMe::Company.temporary
+ PagarMe::Company.temporary api_version: api_version
end
end
# Monkey Patch that adds VCR everywhere
def self.should(description, &block)