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-21.0.0 spec/item/fetch_spec.rb
lhs-20.1.4 spec/item/fetch_spec.rb
lhs-20.1.3.pre.paginationfix.3 spec/item/fetch_spec.rb
lhs-20.1.3.pre.paginationfix.2 spec/item/fetch_spec.rb
lhs-20.1.3.pre.paginationfix.1 spec/item/fetch_spec.rb
lhs-20.1.2 spec/item/fetch_spec.rb
lhs-20.1.1 spec/item/fetch_spec.rb
lhs-20.0.0 spec/item/fetch_spec.rb
lhs-19.10.0 spec/item/fetch_spec.rb
lhs-19.9.0 spec/item/fetch_spec.rb
lhs-19.8.2 spec/item/fetch_spec.rb
lhs-19.8.1 spec/item/fetch_spec.rb
lhs-19.8.0 spec/item/fetch_spec.rb
lhs-19.7.0 spec/item/fetch_spec.rb
lhs-19.6.0 spec/item/fetch_spec.rb
lhs-19.5.0 spec/item/fetch_spec.rb
lhs-19.5.0.pre.wherehref.1 spec/item/fetch_spec.rb
lhs-19.4.1 spec/item/fetch_spec.rb
lhs-19.4.0 spec/item/fetch_spec.rb
lhs-19.3.1 spec/item/fetch_spec.rb