Sha256: eb8849c83f1ba46d28ce9851fb63f760b38ce805e4d2fb13d180c416649a7d6a

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

require 'rails_helper'

describe LHC do

  context 'post' do

    let(:feedback) do
      {
        recommended: false,
        source_id: 'aaa',
        content_ad_id: '1z-5r1fkaj'
      }
    end

    let(:change) do
      {
        recommended: false
      }
    end

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

    it 'does a post request when providing a complete url' do
      LHC.put('http://datastore.lb-service/v2/feedbacks', body: change.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.lb-service' } }
      LHC.configure { |c| c.endpoint(:feedbacks, url, options) }
      LHC.put(:feedbacks, body: change.to_json)
    end

    it 'it makes response data available in a rails way' do
      response = LHC.put('http://datastore.lb-service/v2/feedbacks', body: change.to_json)
      expect(response.data.recommended).to eq false
    end

    it 'provides response headers' do
      response = LHC.put('http://datastore.lb-service/v2/feedbacks', body: change.to_json)
      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/put_spec.rb
lhc-3.1.0 spec/basic_methods/put_spec.rb
lhc-3.0.0 spec/basic_methods/put_spec.rb
lhc-2.0.0 spec/basic_methods/put_spec.rb
lhc-1.2.0 spec/basic_methods/put_spec.rb
lhc-1.1.0 spec/basic_methods/put_spec.rb
lhc-0.2.1 spec/basic_methods/put_spec.rb