Sha256: 9b34092bc37bb8addc9df36f52a84faaffdfa4c97d3838eb0950158a64b9745c

Contents?: true

Size: 928 Bytes

Versions: 22

Compression:

Stored size: 928 Bytes

Contents

require 'rails_helper'

describe LHS::Data do

  before(:each) do
    class SomeService < LHS::Service
      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, SomeService)
  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 datetime if string can be parsed as date_time' do
      expect(item.created_date).to be_kind_of DateTime
    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

22 entries across 22 versions & 1 rubygems

Version Path
lhs-2.2.0 spec/data/item_spec.rb
lhs-1.6.0 spec/data/item_spec.rb
lhs-2.1.1 spec/data/item_spec.rb
lhs-2.1.0 spec/data/item_spec.rb
lhs-2.0.5 spec/data/item_spec.rb
lhs-2.0.4 spec/data/item_spec.rb
lhs-2.0.3 spec/data/item_spec.rb
lhs-2.0.2 spec/data/item_spec.rb
lhs-2.0.1 spec/data/item_spec.rb
lhs-2.0.0 spec/data/item_spec.rb
lhs-1.5.0 spec/data/item_spec.rb
lhs-1.4.0 spec/data/item_spec.rb
lhs-1.3.1 spec/data/item_spec.rb
lhs-1.3.0 spec/data/item_spec.rb
lhs-1.2.3 spec/data/item_spec.rb
lhs-1.2.2 spec/data/item_spec.rb
lhs-1.2.1 spec/data/item_spec.rb
lhs-1.2.0 spec/data/item_spec.rb
lhs-1.1.0 spec/data/item_spec.rb
lhs-1.0.0 spec/data/item_spec.rb