Sha256: 7fc7a02e74ff69c5f9d4b3474228b0bc6cd23e18cec78f4c70d804e5167ac834

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

require 'rails_helper'

describe LHS::Item do
  before(:each) do
    class Feedback < LHS::Record
      endpoint '{+datastore}/v2/feedbacks'
      endpoint '{+datastore}/v2/feedbacks/{id}'
    end
  end

  let(:hash) do
    { 'addresses' => [{ 'businesses' => { 'identities' => [{ 'name' => 'Löwenzorn' }] } }] }
  end

  let(:data) do
    LHS::Data.new(hash, nil, Feedback)
  end

  it 'deep symbolizes keys internaly when new data is initalized' do
    expect(data._raw[:addresses].first[:businesses][:identities].first[:name]).to eq 'Löwenzorn'
    data.id = 'YZ12'
    expect(data._raw.keys).to include(:id)
  end

  it 'deep symbolizes internal data' do
    feedback = Feedback.build(hash)
    expect(feedback._raw.keys).to include(:addresses)
    expect(feedback._raw[:addresses].first[:businesses][:identities].first[:name]).to eq 'Löwenzorn'
  end

  it 'deep symbolizes internal data when building new objects' do
    feedback = Feedback.build('name' => 'BB8')
    expect(feedback._data._raw.keys).to include(:name)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lhs-15.3.1 spec/item/internal_data_structure_spec.rb
lhs-15.3.1.pre.fixlhc.1 spec/item/internal_data_structure_spec.rb
lhs-15.3.0 spec/item/internal_data_structure_spec.rb
lhs-15.2.5 spec/item/internal_data_structure_spec.rb
lhs-15.2.4 spec/item/internal_data_structure_spec.rb
lhs-15.2.3 spec/item/internal_data_structure_spec.rb
lhs-15.2.3.pre.favorites.1 spec/item/internal_data_structure_spec.rb
lhs-15.2.2.pre.favorites.1 spec/item/internal_data_structure_spec.rb
lhs-15.2.2 spec/item/internal_data_structure_spec.rb
lhs-15.2.1 spec/item/internal_data_structure_spec.rb
lhs-15.2.0 spec/item/internal_data_structure_spec.rb
lhs-15.1.1 spec/item/internal_data_structure_spec.rb
lhs-15.1.0 spec/item/internal_data_structure_spec.rb
lhs-15.0.2 spec/item/internal_data_structure_spec.rb
lhs-15.0.1 spec/item/internal_data_structure_spec.rb
lhs-15.0.0 spec/item/internal_data_structure_spec.rb