Sha256: f5b5e727425d6b63ef68e69846e51aeb95ca6e5ff9687c33de1381c6bd6d71c6

Contents?: true

Size: 1.22 KB

Versions: 21

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe FuelSDK::HTTPRequest do
  let(:client) { Class.new.new.extend FuelSDK::HTTPRequest }
  subject { client }
  it { should respond_to(:get) }
  it { should respond_to(:post) }
  it { should respond_to(:patch) }
  it { should respond_to(:delete) }
  it { should_not respond_to(:request) } # private method

  describe '#get' do
    it 'makes and Net::HTTP::Get request' do
      client.stub(:request).with(Net::HTTP::Get, 'http://some_url', {}).and_return({'success' => 'get'})
      expect(client.get('http://some_url')).to eq 'success' => 'get'
    end
  end

  describe '#post' do
    describe 'makes and Net::HTTP::Post request' do

      it 'with only url' do
        Net::HTTP.any_instance.stub(:request)
        client.stub(:request).with(Net::HTTP::Post, 'http://some_url', {}).and_return({'success' => 'post'})
        expect(client.post('http://some_url')).to eq 'success' => 'post'
      end

      it 'with params' do
        client.stub(:request)
          .with(Net::HTTP::Post, 'http://some_url', {'params' => {'legacy' => 1}})
          .and_return({'success' => 'post'})
        expect(client.post('http://some_url', {'params' => {'legacy' => 1}})).to eq 'success' => 'post'
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
fuelsdk_json_bump-0.0.5 spec/http_request_spec.rb
fuelsdk-0.1.11 spec/http_request_spec.rb
fuelsdk-0.1.9 spec/http_request_spec.rb
fuelsdk-0.1.8 spec/http_request_spec.rb
fuelsdk-0.1.7 spec/http_request_spec.rb
fuelsdk-0.1.6 spec/http_request_spec.rb
fuelsdk-0.1.5 spec/http_request_spec.rb
fuelsdk-0.1.4 spec/http_request_spec.rb
fuelsdk-0.1.3 spec/http_request_spec.rb
fuelsdk-0.1.2 spec/http_request_spec.rb
fuelsdk-0.1.1 spec/http_request_spec.rb
fuelsdk-0.1.0 spec/http_request_spec.rb
fuelsdk-0.0.9 spec/http_request_spec.rb
fuelsdk-0.0.8 spec/http_request_spec.rb
fuelsdk-0.0.7 spec/http_request_spec.rb
fuelsdk-0.0.6 spec/http_request_spec.rb
fuelsdk-0.0.5 spec/http_request_spec.rb
fuelsdk-0.0.4 spec/http_request_spec.rb
fuelsdk-0.0.3 spec/http_request_spec.rb
fuelsdk-0.0.2 spec/http_request_spec.rb