Sha256: 86384414e5863cf1a9eb8e5bc61838106df7c5de3bcb8cf1d1137222d28730de

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe MWS::API::Base do
  let(:connection) {MWS::Connection.new({
    aws_access_key_id: "access key",
    aws_secret_access_key: "secret key",
    seller_id: "seller id"
  })}

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

  it "hould receive a connection object" do
    base.connection.should eq(connection)
  end

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

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

  it "should set :verb to :get as default" do
    base.verb.should 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) {HTTParty.stub(:get).and_return({})}

    it "should not raise exception if Actions contain the action name" do
      expect {test_api.test_action}.to_not raise_error
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mws-rb-0.0.1 spec/mws-rb/api/base_spec.rb