Sha256: bc5378157c165d7822c731d94517325573a496388228dae181cbcdb645322879

Contents?: true

Size: 1.32 KB

Versions: 19

Compression:

Stored size: 1.32 KB

Contents

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

19 entries across 19 versions & 1 rubygems

Version Path
lhs-16.1.5 spec/data/raw_spec.rb
lhs-16.1.4 spec/data/raw_spec.rb
lhs-16.1.3 spec/data/raw_spec.rb
lhs-16.1.2 spec/data/raw_spec.rb
lhs-16.1.1 spec/data/raw_spec.rb
lhs-16.1.0 spec/data/raw_spec.rb
lhs-16.0.1 spec/data/raw_spec.rb
lhs-16.0.0 spec/data/raw_spec.rb
lhs-15.7.0 spec/data/raw_spec.rb
lhs-15.6.1 spec/data/raw_spec.rb
lhs-15.6.0 spec/data/raw_spec.rb
lhs-15.5.1 spec/data/raw_spec.rb
lhs-15.5.0 spec/data/raw_spec.rb
lhs-15.4.1 spec/data/raw_spec.rb
lhs-15.4.0 spec/data/raw_spec.rb
lhs-15.4.0.pre.hasone.1 spec/data/raw_spec.rb
lhs-15.3.3 spec/data/raw_spec.rb
lhs-15.3.3.pre.fixoptions.1 spec/data/raw_spec.rb
lhs-15.3.2 spec/data/raw_spec.rb