Sha256: 7438e1a761cde80e512e173dee12fbbfeef0dd62886795525247b9f39bc46c73
Contents?: true
Size: 1.77 KB
Versions: 8
Compression:
Stored size: 1.77 KB
Contents
require "spec_helper" require "fastshop_catalog/participant_factory" describe FastshopCatalog::ParticipantService do include Savon::SpecHelper before(:all) { savon.mock! } after(:all) { savon.unmock! } let(:contract_number) do "1234567890" end let(:participant) do ParticipantFactory.build end let(:service) do service = FastshopCatalog::ParticipantService.new end let(:participant_attr) do File.read("spec/fixtures/participant_successful_payload.json") end let(:fixture) do File.read("spec/fixtures/participant_service_successful_response.xml") end let(:fixture_token) do File.read("spec/fixtures/participant_service_successful_token_response.xml") end describe "insert" do it "should insert the participant and return a null token" do participant_attr.gsub!("315543600000-10800", time_helper(participant.birth_date)) encrypted_payload = service.encrypt(participant_attr) savon.expects(:cadastrar_participante).with(:message => {'tns:contrato' => contract_number, 'tns:entrada' => encrypted_payload, 'tns:salt' => ''}).returns(fixture) result = service.insert(participant) expect(result).to be_nil end it "should insert the participant and return a non null token" do participant_attr.gsub!("315543600000-10800", time_helper(participant.birth_date)) encrypted_payload = service.encrypt(participant_attr) savon.expects(:cadastrar_participante).with(:message => {'tns:contrato' => contract_number, 'tns:entrada' => encrypted_payload, 'tns:salt' => ''}).returns(fixture_token) result = service.insert(participant) expect(result).to eq('xpto') end end def time_helper(datetime) "#{(datetime.to_f*1000).to_i}#{datetime.utc_offset}" end end
Version data entries
8 entries across 8 versions & 1 rubygems