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-13.2.3 spec/item/internal_data_structure_spec.rb
lhs-13.2.2 spec/item/internal_data_structure_spec.rb
lhs-13.2.1 spec/item/internal_data_structure_spec.rb
lhs-13.2.0 spec/item/internal_data_structure_spec.rb
lhs-13.1.0 spec/item/internal_data_structure_spec.rb
lhs-13.0.1 spec/item/internal_data_structure_spec.rb
lhs-13.0.0 spec/item/internal_data_structure_spec.rb
lhs-12.3.0 spec/item/internal_data_structure_spec.rb
lhs-12.2.1 spec/item/internal_data_structure_spec.rb
lhs-12.2.0 spec/item/internal_data_structure_spec.rb
lhs-12.1.0 spec/item/internal_data_structure_spec.rb
lhs-12.0.3 spec/item/internal_data_structure_spec.rb
lhs-12.0.2 spec/item/internal_data_structure_spec.rb
lhs-12.0.1 spec/item/internal_data_structure_spec.rb
lhs-12.0.0 spec/item/internal_data_structure_spec.rb
lhs-11.3.3 spec/item/internal_data_structure_spec.rb
lhs-11.3.2 spec/item/internal_data_structure_spec.rb
lhs-11.3.1 spec/item/internal_data_structure_spec.rb
lhs-11.3.0 spec/item/internal_data_structure_spec.rb
lhs-11.2.2 spec/item/internal_data_structure_spec.rb