Sha256: 057918b2877545c57b940d6b2ddedffd4dacdb8b4a5e1b2fc5cacea2dbd881f8

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe MWS::API::Feeds::Envelope do
  it 'should validate the envelope' do
    expect do
      MWS::API::Feeds::Envelope.new(message_type: 'InvalidMessageType', message: { 'InvalidItem' => 'Invalid' })
    end.to raise_error RuntimeError
  end

  it 'accepts text based envelope' do
    expect(MWS::API::Feeds::Envelope.new(type: :text, message: 'test').to_s).to eq('test')
  end

  it 'should skip validation when param skip_schema_validation is true' do
    MWS::API::Feeds::Envelope.new(message_type: 'InvalidMessageType', message: { 'InvalidItem' => 'Invalid' }, skip_schema_validation: true)
  end

  it 'should remove array items' do
    envelope = MWS::API::Feeds::Envelope.new(
      message_type: 'InvalidMessageType',
      message: {
        'Items' => [{ item_1: '1' }, { item_2: '2' }],
        'Inventories' => [{ inventory_1: '1' }]
      },
      skip_schema_validation: true)

    expect(envelope.to_s.include?('Items')).to eq(false)
    expect(envelope.to_s.include?('Inventories')).to eq(false)
    expect(envelope.to_s.include?('array')).to eq(false)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mws_rb-0.0.6 spec/mws-rb/api/feeds/envelope/general_spec.rb