Sha256: 590ad08b572c45ed40a4756c2db6e97611aef4d56961eccd3ac0ef857cfc5ae0

Contents?: true

Size: 640 Bytes

Versions: 12

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe DHS::Item do
  before do
    class Record < DHS::Record
      endpoint '{+datastore}/records'
    end
  end

  let(:json) do
    {
      local_entry_id: 'ABC123'
    }
  end

  let(:item) do
    DHS::Data.new(json, nil, Record)
  end

  it 'is possible to fetch data' do
    expect(
      item.fetch(:local_entry_id)
    ).to eq 'ABC123'
  end

  context 'empty data' do
    let(:json) do
      {}
    end

    it 'is possible to get a default when fetched data is nil' do
      expect(
        item.fetch(:local_entry_id, 'DEFAULT')
      ).to eq 'DEFAULT'
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 spec/item/fetch_spec.rb
dhs-1.5.0 spec/item/fetch_spec.rb
dhs-1.4.2 spec/item/fetch_spec.rb
dhs-1.4.1 spec/item/fetch_spec.rb
dhs-1.4.0 spec/item/fetch_spec.rb
dhs-1.3.0 spec/item/fetch_spec.rb
dhs-1.2.0 spec/item/fetch_spec.rb
dhs-1.1.0 spec/item/fetch_spec.rb
dhs-1.0.3 spec/item/fetch_spec.rb
dhs-1.0.2 spec/item/fetch_spec.rb
dhs-1.0.1 spec/item/fetch_spec.rb
dhs-1.0.0 spec/item/fetch_spec.rb