Sha256: 2d79ba709b3234542780c5c240b7f61d1ad3aa9dbe1e10538a980df9098332ea

Contents?: true

Size: 840 Bytes

Versions: 46

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHC do
  context 'data accessor (hash with indifferent access)' do
    before(:each) do
      stub_request(:get, "http://local.ch/")
        .with(headers: {
                'Accept' => 'application/json,application/vnd.api+json',
                'Content-Type' => 'application/json; charset=utf-8',
                'Accept-Charset' => 'utf-8'
              })
        .to_return(body: { 'MyProp' => 'MyValue' }.to_json)
    end

    it 'makes data accessible with square bracket accessor (string)' do
      expect(
        LHC.json.get('http://local.ch')['MyProp']
      ).to eq 'MyValue'
    end

    it 'makes data accessible with square bracket accessor (symbol)' do
      expect(
        LHC.json.get('http://local.ch')[:MyProp]
      ).to eq 'MyValue'
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

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