Sha256: 6e10106bb96dbb8a522dab8594a4b4d45cf18dd6ff378329681518f69a70cd9e

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 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; charset=utf-8', 'Content-Type' => 'application/json; 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

3 entries across 3 versions & 1 rubygems

Version Path
lhc-10.1.6 spec/response/data_accessor_spec.rb
lhc-10.1.5 spec/response/data_accessor_spec.rb
lhc-10.1.3 spec/response/data_accessor_spec.rb