Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # require the helper module
- require "savon/mock/spec_helper"
- module Agillitas
- Models = Moneto::Core::Models
- Agillitas = Models::Agillitas::AgillitasIntegration
- RSpec.describe Agillitas do
- # include the helper module
- include Savon::SpecHelper
- # set Savon in and out of mock mode
- before(:all) { savon.mock! }
- after(:all) { savon.unmock! }
- describe "AgillitasIntegration" do
- describe 'check_has_balance' do
- it 'simple test' do
- agillitas_mocked_response =
- '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body>
- <IntegrarResponse xmlns="http://tempuri.org/">
- <IntegrarResult
- xmlns:a="http://schemas.datacontract.org/2004/07/Agillitas.Servico.ContratosDeServico"
- xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <a:Cabecalho>
- <a:Metodo>54</a:Metodo>
- <a:Status>Sucesso</a:Status>
- </a:Cabecalho>
- <a:Corpo>
- <![CDATA[
- <SaldoCartaoVirtual>
- <Saldo>500</Saldo>
- <ValorPendente>0</ValorPendente>
- </SaldoCartaoVirtual>
- ]]>
- </a:Corpo>
- </IntegrarResult>
- </IntegrarResponse>
- </s:Body>
- </s:Envelope>'
- body_of_xml = {
- ConsultarSaldoCartaoVirtual:{
- Empresa: '3596',
- Moeda: '790'
- }
- }
- xml = Agillitas.new.to_xml(body_of_xml)
- message = {
- request: {
- 'agil:Cabecalho':
- {
- 'agil:Metodo': 54,
- 'agil:PublicKey': 'integr@moneto',
- 'agil:Senha': '27958950',
- 'agil:Usuario': 'ws.integramoneto'
- #'agil:Metodo': method_id,
- #'agil:PublicKey': config[:public_key],
- #'agil:Senha': config[:senha],
- #'agil:Usuario': config[:usuario]
- },
- 'agil:Corpo!': "<![CDATA[#{xml}]]>"
- }
- }
- savon.expects(:integrar).with(message: message).returns (agillitas_mocked_response)
- result = Agillitas.new.check_has_balance()
- expect(result[:balance].to_f).to eq 500
- expect(result[:pendent_balance].to_f).to eq 0
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement