Sha256: 8ad51e0327c2f3d52027ba8c443821edad702af53ca71913201f7ae82abe2636

Contents?: true

Size: 965 Bytes

Versions: 49

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHC::Request do
  context 'encode body' do
    let(:encoded_data) { data.to_json }

    before do
      stub_request(:post, "http://datastore/q")
        .with(body: encoded_data)
        .to_return(status: 200)
    end

    context 'hash' do
      let(:data) { { name: 'Steve' } }

      it 'encodes the request body to the given format' do
        LHC.post('http://datastore/q', body: data)
      end

      it 'does not encode the request body if it is already a string' do
        LHC.post('http://datastore/q', body: encoded_data)
      end
    end

    context 'array' do
      let(:data) { [{ name: 'Steve' }] }

      it 'encodes the request body to the given format' do
        LHC.post('http://datastore/q', body: data)
      end

      it 'does not encode the request body if it is already a string' do
        LHC.post('http://datastore/q', body: encoded_data)
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
lhc-15.2.1 spec/request/body_spec.rb
lhc-15.2.0 spec/request/body_spec.rb
lhc-15.1.3 spec/request/body_spec.rb
lhc-15.1.2 spec/request/body_spec.rb
lhc-15.1.1 spec/request/body_spec.rb
lhc-15.1.0 spec/request/body_spec.rb
lhc-16.0.0.pre.pro2162.2 spec/request/body_spec.rb
lhc-16.0.0.pre.pro2162 spec/request/body_spec.rb
lhc-15.0.1 spec/request/body_spec.rb
lhc-15.0.0 spec/request/body_spec.rb
lhc-14.0.0 spec/request/body_spec.rb
lhc-13.4.0.pre.pro1766.1 spec/request/body_spec.rb
lhc-13.2.0 spec/request/body_spec.rb
lhc-13.1.0 spec/request/body_spec.rb
lhc-13.0.0 spec/request/body_spec.rb
lhc-12.3.0 spec/request/body_spec.rb
lhc-12.2.1 spec/request/body_spec.rb
lhc-12.2.0 spec/request/body_spec.rb
lhc-12.1.3 spec/request/body_spec.rb
lhc-12.1.2 spec/request/body_spec.rb