Sha256: 0e3768fd129746208bad1ccbc45be44dbcdde6475b6821346c68b1989e957b41

Contents?: true

Size: 1.22 KB

Versions: 39

Compression:

Stored size: 1.22 KB

Contents

require 'rails_helper'

describe LHC do
  context 'post' do
    let(:feedback) do
      {
        recommended: true,
        source_id: 'aaa',
        content_ad_id: '1z-5r1fkaj'
      }
    end

    before(:each) do
      stub_request(:post, "http://datastore/v2/feedbacks")
        .with(body: feedback.to_json)
        .to_return(status: 200, body: feedback.to_json, headers: { 'Content-Encoding' => 'UTF-8' })
    end

    it 'does a post request when providing a complete url' do
      LHC.post('http://datastore/v2/feedbacks', body: feedback.to_json)
    end

    it 'does a post request when providing the name of a configured endpoint' do
      url = 'http://:datastore/v2/feedbacks'
      options = { params: { datastore: 'datastore' } }
      LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
      LHC.post(:feedbacks, body: feedback.to_json)
    end

    it 'it makes response data available in a rails way' do
      response = LHC.post('http://datastore/v2/feedbacks', body: feedback.to_json)
      expect(response.data.source_id).to eq 'aaa'
    end

    it 'provides response headers' do
      response = LHC.post('http://datastore/v2/feedbacks', body: feedback.to_json)
      expect(response.headers).to be
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
lhc-6.7.2 spec/basic_methods/post_spec.rb
lhc-6.7.1 spec/basic_methods/post_spec.rb
lhc-6.7.0 spec/basic_methods/post_spec.rb
lhc-6.6.0.zipkin.pre.03 spec/basic_methods/post_spec.rb
lhc-6.6.0.zipkin.pre.02 spec/basic_methods/post_spec.rb
lhc-6.6.0.zipkin.pre.01 spec/basic_methods/post_spec.rb
lhc-6.6.0.zipkin.pre spec/basic_methods/post_spec.rb
lhc-6.6.0 spec/basic_methods/post_spec.rb
lhc-6.5.0 spec/basic_methods/post_spec.rb
lhc-6.4.0 spec/basic_methods/post_spec.rb
lhc-6.3.1 spec/basic_methods/post_spec.rb
lhc-6.3.0 spec/basic_methods/post_spec.rb
lhc-6.2.0 spec/basic_methods/post_spec.rb
lhc-6.1.3 spec/basic_methods/post_spec.rb
lhc-6.1.2 spec/basic_methods/post_spec.rb
lhc-6.1.1 spec/basic_methods/post_spec.rb
lhc-6.1.0 spec/basic_methods/post_spec.rb
lhc-6.0.1 spec/basic_methods/post_spec.rb
lhc-6.0.0 spec/basic_methods/post_spec.rb
lhc-5.1.1 spec/basic_methods/post_spec.rb