Sha256: 2bed0fd3fa62d39169daed0c807807ee6cbbe04a8962921b86dc6705f99d67e7

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

require 'rails_helper'

describe LHS::Data do
  before(:each) do
    class Record < LHS::Record
      endpoint ':datastore/v2/:campaign_id/feedbacks'
      endpoint ':datastore/v2/feedbacks'
    end
  end

  let(:json) do
    load_json(:feedbacks)
  end

  let(:data) do
    LHS::Data.new(json, nil, Record)
  end

  let(:item) do
    data[0]
  end

  context 'item' do
    it 'makes data accessible' do
      expect(item.href).to be_kind_of String
      expect(item.recommended).to be_kind_of TrueClass
      expect(item.average_rating).to be_kind_of Float
    end

    it 'returns nil if no data is present' do
      expect(item.something).to eq nil
    end

    it 'returns TimeWithZone if string can be parsed as date_time' do
      expect(item.created_date).to be_kind_of ActiveSupport::TimeWithZone
    end

    it 'returns date if string can be parsed as date' do
      expect(item.valid_from).to be_kind_of Date
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lhs-3.0.4 spec/data/item_spec.rb