Sha256: 3c047aa5114b1b4d6b37bba3b01ca1363e2e6f9b06b4a6785851cd4614911013

Contents?: true

Size: 1.35 KB

Versions: 76

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Data do
  before do
    class Record < LHS::Record
      endpoint '{+datastore}/v2/entries/{entry_id}/content-ads/{campaign_id}/feedbacks'
      endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
      endpoint '{+datastore}/v2/feedbacks'
    end
  end

  let(:data_from_raw) do
    LHS::Data.new({ href: 'http://www.local.ch/v2/stuff', id: '123123123' }, nil, Record)
  end

  let(:data_from_item) do
    raw = { href: 'http://www.local.ch/v2/stuff' }
    item = LHS::Item.new(LHS::Data.new(raw, nil, Record))
    LHS::Data.new(item)
  end

  let(:data_from_array) do
    LHS::Data.new([
      { href: 'http://www.local.ch/v2/stuff/3', id: '123123123' },
      { href: 'http://www.local.ch/v2/stuff/4', id: '123123124' }
    ].to_json)
  end

  context 'raw' do
    it 'you can access raw data that is underlying' do
      expect(data_from_raw._raw).to be_kind_of Hash
    end

    it 'forwards raw when you feed data with some LHS object' do
      expect(data_from_item._raw).to be_kind_of Hash
      expect(data_from_item._raw).to eq(
        href: 'http://www.local.ch/v2/stuff'
      )
    end

    it 'returns a Hash with symbols when the input is an array' do
      expect(data_from_array._raw).to be_kind_of Array
      expect(data_from_array._raw.first.keys.first).to be_kind_of Symbol
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

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