Sha256: f4780685f6b86916aabaa5ce09893a0a7ac5238622cc94d531197f7bd4a4dcb9
Contents?: true
Size: 803 Bytes
Versions: 19
Compression:
Stored size: 803 Bytes
Contents
require 'rails_helper' describe LHS::Item do before do class Record < LHS::Record endpoint '{+datastore}/records' end end let(:json) do { key: 'value' } end let(:item) do LHS::Data.new(json, nil, Record) end it 'is possible to map' do mapped_data = item.map do |key, value| { value => key } end expect(mapped_data).to eq([{ 'value' => :key }]) end context 'nested' do let(:json) do { languages: { de: { key: 'german value' }, en: { key: 'english value' } } } end it 'also maps nested data' do mapped_data = item.languages.map do |_language, value| value[:key] end expect(mapped_data).to eq(['german value', 'english value']) end end end
Version data entries
19 entries across 19 versions & 1 rubygems