Sha256: f5510c515d99a74914b2915cd63b6a8e4255a6de06c5c646293b21813ba4fbea

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"

module ShipCompliant
  describe AddUpdateProduct do

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

    let(:message) do
      {
        'Request' => {
          'Security' => {
            'PartnerKey' => 'abc-123',
            'Username' => 'bob@example.com',
            'Password' => 'secret'
          },
          'Product' => {
            'BottleSizeML' => 123,
            'DefaultWholesaleCasePrice' => 150
          },
          'UpdateMode' => 'DoWackaDo'
        }
      }
    end
    let(:response) { File.read('spec/fixtures/add_update_product.xml') }

    context "product" do
      it "queries the client with product an update mode" do
        allow(AddUpdateProduct).to receive(:add_update_product) { {} }
        
        result = AddUpdateProduct.product({
          bottle_size_ml: 123,
          default_wholesale_case_price: 150
        }, update_mode: 'DoWackaDo')

        expect(result).to be_kind_of(AddUpdateProductResult)
      end

      it "update mode defaults to ErrorOnExisting" do
        message['Request']['UpdateMode'] = 'ErrorOnExisting'
        savon.expects(:add_update_product)
          .with(message: message).returns(response)
        
        AddUpdateProduct.product({
          bottle_size_ml: 123,
          default_wholesale_case_price: 150
        })
      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_product_spec.rb