test/spec/transfers_spec.rb in openpay-1.0.10 vs test/spec/transfers_spec.rb in openpay-2.0.0b

- old
+ new

@@ -1,10 +1,9 @@ require_relative '../spec_helper' describe Transfers do - before(:all) do @merchant_id='mywvupjjs9xdnryxtplq' @private_key='sk_92b25d3baec149e6b428d81abfe37006' @@ -29,30 +28,30 @@ describe '.create' do it 'transfers money from customer to customer' do #create new customer - customer_hash= FactoryGirl.build(:customer) + customer_hash= FactoryBot.build(:customer) customer=@customers.create(customer_hash) - #create new customer card - card_hash=FactoryGirl.build(:valid_card) + card_hash=FactoryBot.build(:valid_card) card=@cards.create(card_hash, customer['id']) #create charge - charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id']) + charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id']) charge=@charges.create(charge_hash,customer['id']) #create customer 2 - customer_hash= FactoryGirl.build(:customer,name: 'Alejandro') + customer_hash= FactoryBot.build(:customer,name: 'Alejandro') customer2=@customers.create(customer_hash) + sleep(50) #create new transfer - customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id']) - + customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id']) transfer=@transfers.create(customer_hash,customer['id']) t=@transfers.get(transfer['id'],customer['id']) + expect(t['amount']).to be_within(0.1).of 12.5 expect(t['method']).to match 'customer' #clanup @cards.delete_all(customer['id']) @@ -64,27 +63,28 @@ describe 'get' do it 'gets a customer transfer' do #create new customer - customer_hash= FactoryGirl.build(:customer) + customer_hash= FactoryBot.build(:customer) customer=@customers.create(customer_hash) #create new customer card - card_hash=FactoryGirl.build(:valid_card) + card_hash=FactoryBot.build(:valid_card) card=@cards.create(card_hash, customer['id']) #create charge - charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id']) + charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id']) charge=@charges.create(charge_hash,customer['id']) #create customer 2 - customer_hash= FactoryGirl.build(:customer,name: 'Alejandro') + customer_hash= FactoryBot.build(:customer,name: 'Alejandro') customer2=@customers.create(customer_hash) - + + sleep(50) #create new transfer - customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id']) + customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id']) transfer=@transfers.create(customer_hash,customer['id']) t=@transfers.get(transfer['id'],customer['id']) expect(t).to be_a Hash expect(t['amount']).to be_within(0.1).of 12.5 @@ -98,33 +98,33 @@ it 'fails to get a non existing transfer' do expect { @transfers.get(11111,11111) }.to raise_exception OpenpayTransactionException end end - describe '.each' do it 'iterates over a given customer transfers' do #create new customer - customer_hash= FactoryGirl.build(:customer) + customer_hash= FactoryBot.build(:customer) customer=@customers.create(customer_hash) #create new customer card - card_hash=FactoryGirl.build(:valid_card) + card_hash=FactoryBot.build(:valid_card) card=@cards.create(card_hash, customer['id']) #create charge - charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id']) + charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id']) charge=@charges.create(charge_hash,customer['id']) #create customer 2 - customer_hash= FactoryGirl.build(:customer,name: 'Alejandro') + customer_hash= FactoryBot.build(:customer,name: 'Alejandro') customer2=@customers.create(customer_hash) + sleep(50) #create new transfer - customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id']) + customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id']) transfer=@transfers.create(customer_hash,customer['id']) #iterates over transfers @transfers.each(customer2['id']) do |tran| expect(tran['amount']).to be_within(0.1).of 12.5 @@ -141,27 +141,28 @@ it 'list all transfers under the given filter' do #create new customer - customer_hash= FactoryGirl.build(:customer) + customer_hash= FactoryBot.build(:customer) customer=@customers.create(customer_hash) #create new customer card - card_hash=FactoryGirl.build(:valid_card) + card_hash=FactoryBot.build(:valid_card) card=@cards.create(card_hash, customer['id']) #create charge - charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id']) + charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id']) charge=@charges.create(charge_hash,customer['id']) #create customer 2 - customer_hash= FactoryGirl.build(:customer,name: 'Alejandro') + customer_hash= FactoryBot.build(:customer,name: 'Alejandro') customer2=@customers.create(customer_hash) - + + sleep(50) #create new transfer - customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id']) + customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id']) transfer=@transfers.create(customer_hash,customer['id']) transfer=@transfers.create(customer_hash,customer['id']) #returns all transfers @transfers.all(customer2['id']) @@ -183,28 +184,30 @@ describe '.all' do it 'returns all customer transfers' do #create new customer - customer_hash= FactoryGirl.build(:customer) + customer_hash= FactoryBot.build(:customer) customer=@customers.create(customer_hash) #create new customer card - card_hash=FactoryGirl.build(:valid_card) + card_hash=FactoryBot.build(:valid_card) card=@cards.create(card_hash, customer['id']) #create charge - charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id']) + charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id']) charge=@charges.create(charge_hash,customer['id']) #create customer 2 - customer_hash= FactoryGirl.build(:customer,name: 'Alejandro') + customer_hash= FactoryBot.build(:customer,name: 'Alejandro') customer2=@customers.create(customer_hash) + + sleep(50) #create new transfer - customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id']) + customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id']) transfer=@transfers.create(customer_hash,customer['id']) #returns all transfers @transfers.all(customer2['id']) @@ -214,6 +217,7 @@ @cards.delete_all(customer['id']) end end + end