Sha256: 16e7fdbc49a9e5ea518bcfb2437a029beea80c0f3bcfe2e2dce923b530e98d1f

Contents?: true

Size: 640 Bytes

Versions: 76

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

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

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

  let(:item) do
    LHS::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

76 entries across 76 versions & 1 rubygems

Version Path
lhs-26.2.0 spec/item/fetch_spec.rb
lhs-26.1.0 spec/item/fetch_spec.rb
lhs-26.0.1 spec/item/fetch_spec.rb
lhs-26.0.0 spec/item/fetch_spec.rb
lhs-25.2.0 spec/item/fetch_spec.rb
lhs-25.1.0 spec/item/fetch_spec.rb
lhs-25.0.4 spec/item/fetch_spec.rb
lhs-25.0.3 spec/item/fetch_spec.rb
lhs-25.0.2 spec/item/fetch_spec.rb
lhs-25.0.1 spec/item/fetch_spec.rb
lhs-25.0.0 spec/item/fetch_spec.rb
lhs-24.1.2 spec/item/fetch_spec.rb
lhs-24.1.1 spec/item/fetch_spec.rb
lhs-24.1.0 spec/item/fetch_spec.rb
lhs-24.1.0.pre.2 spec/item/fetch_spec.rb
lhs-24.1.0.pre.1 spec/item/fetch_spec.rb
lhs-24.0.0 spec/item/fetch_spec.rb
lhs-23.0.2 spec/item/fetch_spec.rb
lhs-23.0.1 spec/item/fetch_spec.rb
lhs-23.0.0 spec/item/fetch_spec.rb