Sha256: 94135c601f3adfc7853aa8fa8b8be811597c87f73ca21ea09c765270e11e29d0

Contents?: true

Size: 1.01 KB

Versions: 82

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

82 entries across 82 versions & 1 rubygems

Version Path
lhs-14.6.5 spec/item/internal_data_structure_spec.rb
lhs-14.6.4 spec/item/internal_data_structure_spec.rb
lhs-14.6.3 spec/item/internal_data_structure_spec.rb
lhs-14.6.2 spec/item/internal_data_structure_spec.rb
lhs-14.6.1 spec/item/internal_data_structure_spec.rb
lhs-14.6.0 spec/item/internal_data_structure_spec.rb
lhs-14.5.0 spec/item/internal_data_structure_spec.rb
lhs-14.4.0 spec/item/internal_data_structure_spec.rb
lhs-14.3.4 spec/item/internal_data_structure_spec.rb
lhs-14.3.3 spec/item/internal_data_structure_spec.rb
lhs-14.3.2 spec/item/internal_data_structure_spec.rb
lhs-14.3.1 spec/item/internal_data_structure_spec.rb
lhs-14.3.0 spec/item/internal_data_structure_spec.rb
lhs-14.2.0 spec/item/internal_data_structure_spec.rb
lhs-14.1.1 spec/item/internal_data_structure_spec.rb
lhs-14.1.0 spec/item/internal_data_structure_spec.rb
lhs-14.0.3 spec/item/internal_data_structure_spec.rb
lhs-14.0.2 spec/item/internal_data_structure_spec.rb
lhs-14.0.1 spec/item/internal_data_structure_spec.rb
lhs-14.0.0 spec/item/internal_data_structure_spec.rb