Sha256: eca17b6afab6d0f7ef86c6f8368e0114f04c1f95c58cd6143a63755107676ac0

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 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
        AddUpdateProduct.stub(:add_update_product) { {} }
        
        result = AddUpdateProduct.product({
          bottle_size_ml: 123,
          default_wholesale_case_price: 150
        }, update_mode: 'DoWackaDo')

        result.should 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

4 entries across 4 versions & 1 rubygems

Version Path
ship_compliant-0.2.0 spec/lib/ship_compliant/add_update_product_spec.rb
ship_compliant-0.1.2 spec/lib/ship_compliant/add_update_product_spec.rb
ship_compliant-0.1.1 spec/lib/ship_compliant/add_update_product_spec.rb
ship_compliant-0.1.0 spec/lib/ship_compliant/add_update_product_spec.rb