Sha256: 1efcd13c0d1716a2180f6e086b3fa39a5f0c6289a17be94bf76635c00e32e13b

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

require 'rails_helper'

describe LHC do

  context 'get' do

    before(:each) do
      stub_request(:get, 'http://datastore.lb-service/v2/feedbacks?has_reviews=true')
        .to_return(status: 200, body: { total: 99 }.to_json, headers: {'Content-Encoding' => 'UTF-8'})
    end

    let(:parameters) do
      { has_reviews: true }
    end

    it 'does a get request when providing a complete url' do
      LHC.get('http://datastore.lb-service/v2/feedbacks', params: parameters)
    end

    it 'does a get request when providing the name of a configured endpoint' do
      url = 'http://:datastore/v2/feedbacks'
      options = { params: { datastore: 'datastore.lb-service' } }
      LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
      LHC.get(:feedbacks, params: parameters)
    end

    it 'it makes response data available in a rails way' do
      response = LHC.get('http://datastore.lb-service/v2/feedbacks', params: parameters)
      expect(response.data.total).to eq 99
    end

    it 'provides response headers' do
      response = LHC.get('http://datastore.lb-service/v2/feedbacks', params: parameters)
      expect(response.headers).to be
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lhc-3.1.1 spec/basic_methods/get_spec.rb
lhc-3.1.0 spec/basic_methods/get_spec.rb
lhc-3.0.0 spec/basic_methods/get_spec.rb
lhc-2.0.0 spec/basic_methods/get_spec.rb
lhc-1.2.0 spec/basic_methods/get_spec.rb
lhc-1.1.0 spec/basic_methods/get_spec.rb
lhc-0.2.1 spec/basic_methods/get_spec.rb