Sha256: cf4b22b537e92b8a6e5e07e494843eb5023137204b48a378e5af3a9c35b726e5

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

require 'spec_helper'

describe Bling::API::Client do
  before(:each) { allow(Net::HTTP).to receive(:get_response) }
  let(:client) { Bling::API::Client.new('path', {}, :product) }

  it 'always return a Response object' do
    expect(client.get).to be_kind_of(Bling::API::Response)
  end

  it 'always set api key' do
    expect(Bling.config).to receive(:api_key)
    client.get
  end

  it 'get default response format' do
    expect(Bling.config).to receive(:response_format)
    client.get
  end

  it 'get default api endpoint' do
    expect(Bling.config).to receive(:api_url).and_return('https://foo.bar')
    client.get
  end

  describe '#get' do
    it 'set parameter to uri' do
      expect( URI ).to receive(:encode_www_form)
      client.get
    end

    it 'makes a get request' do
      expect(Net::HTTP).to receive(:get_response)
      client.get
    end
  end

  describe '#post' do
    it 'makes a post request' do
      expect(Net::HTTP).to receive(:post_form)
      client.post
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bling-ruby-api-0.0.1 spec/lib/bling/api/client_spec.rb