Sha256: 3cb5e90c64338524fcfc4f417fbc240d576fb4a5e3c6d693f9661ef7bfdf9ac1
Contents?: true
Size: 1.84 KB
Versions: 10
Compression:
Stored size: 1.84 KB
Contents
require 'spec_helper' describe ActiveZuora::Connection do context "custom header" do before do @connection = ActiveZuora::Connection.new @stub_was_called = false end it "passes the regular header if not set" do allow(Savon::SOAP::Request).to receive(:new) do |config, http, soap| @stub_was_called = true expect(soap.header).to eq( { "SessionHeader" => {"session" => nil} } ) double('response').as_null_object end @connection.request(:amend) {} expect(@stub_was_called).to be_truthy end it "merges in a custom header if set" do @connection.custom_header = {'CallOptions' => {'useSingleTransaction' => true}} allow(Savon::SOAP::Request).to receive(:new) do |config, http, soap| @stub_was_called = true expect(soap.header).to eq( { "SessionHeader" => {"session" => nil}, 'CallOptions' => {'useSingleTransaction' => true} } ) double('response').as_null_object end @connection.request(:amend) {} expect(@stub_was_called).to be_truthy end end describe 'login' do before do @connection = described_class.new end context 'when a custom header is set' do it 'uses the custom header' do @connection.custom_header = { 'TestHeader' => 'Foo' } allow(Savon::SOAP::Request).to receive(:new) do |config, http, soap| expect(soap.header).to eq({ 'TestHeader' => 'Foo' }) double('response').as_null_object end @connection.login end end context 'when a custom header is not set' do it 'does not use the custom header' do allow(Savon::SOAP::Request).to receive(:new) do |config, http, soap| expect(soap.header).to eq({}) double('response').as_null_object end @connection.login end end end end
Version data entries
10 entries across 10 versions & 1 rubygems