Sha256: 8cafc25ea284d6b904d1864f3dc3e147ff865a5b837100274fe08bccd208c347

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

describe MWS::API::Base do
  let(:connection) do
    MWS::Connection.new(aws_access_key_id: 'access key',
                        aws_secret_access_key: 'secret key',
                        seller_id: 'seller id',
                        mws_auth_token: 'auth token')
  end

  let(:base) { MWS::API::Base.new(connection) }

  it 'should receive a connection object' do
    expect(base.connection).to eq(connection)
  end

  it 'should respond to .call' do
    expect(base).to respond_to(:call)
  end

  it 'should respond to :uri and :version and :verb' do
    expect(base).to respond_to(:uri)
    expect(base).to respond_to(:version)
    expect(base).to respond_to(:verb)
  end

  it 'should set :verb to :get as default' do
    expect(base.verb).to eq(:get)
  end

  describe 'method_missing to call actions' do
    class TestApi < MWS::API::Base
      ACTIONS = [:test_action]
      def initialize(connection)
        @uri = '/Products/2011-10-01'
        @version = '2011-10-01'
        super(connection)
      end
    end

    let(:test_api) { TestApi.new(connection) }
    before(:each) { allow(HTTParty).to receive(:get).and_return({}) }

    it 'should raise exception if Actions do not contain the action name' do
      expect { test_api.action_not_found }.to raise_error(NoMethodError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mws_rb-0.0.6 spec/mws-rb/api/base_spec.rb