Sha256: 397b8fd0e0cf4c6e5dec6ab31706c538924cfb034eac527912e3cdb961ad8039

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require "spec_helper"

module ShipCompliant
  describe AddUpdateBrand do

    before { savon.mock! }
    after { savon.unmock! }

    let(:message) do
      {
        'Request' => {
          'Security' => {
            'PartnerKey' => 'abc-123',
            'Username' => 'bob@example.com',
            'Password' => 'secret'
          },
          'Brand' => {
            'Key' => 'WNDFL',
            'Name' => 'Wonderful',
            'Owner' => {
              'Name' => 'Sam'
            }
          },
          'UpdateMode' => 'DoWackaDo'
        }
      }
    end
    let(:response) { File.read('spec/fixtures/add_update_product.xml') }
    context "brand" do

      it "queries the client with an update mode" do
        savon.expects(:add_update_brand)
          .with(message: message).returns(response)

        result = AddUpdateBrand.brand({
          key: 'WNDFL',
          name: 'Wonderful',
          owner: { name: 'Sam' }
        }, update_mode: 'DoWackaDo')

        expect(result).to be_kind_of(AddUpdateBrandResult)
      end

      it "update mode defaults to ErrorOnExisting" do
        message['Request']['UpdateMode'] = 'ErrorOnExisting'
        savon.expects(:add_update_brand)
          .with(message: message).returns(response)

        AddUpdateBrand.brand({
          key: 'WNDFL',
          name: 'Wonderful',
          owner: { name: 'Sam' }
        })
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ship_compliant-0.2.1 spec/lib/ship_compliant/add_update_brand_spec.rb