Sha256: 4e38e6f8556f1ff6320e399c8025a58f88dc400590a3070abe83ac61a19050e8

Contents?: true

Size: 752 Bytes

Versions: 25

Compression:

Stored size: 752 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(:collection) do
    LHS::Data.new(json, nil, SomeService)
  end

  let(:item) do
    collection[0]
  end

  it 'converts item to json' do
    expect(item.to_json)
    .to eq JSON.parse(load_json(:feedbacks))['items'].first.to_json
  end

  it 'converts collection to json' do
    expect(collection.to_json)
    .to eq JSON.parse(load_json(:feedbacks)).to_json
  end

  it 'converts link to json' do
    expect(item.campaign.to_json)
    .to eq item.campaign._raw.to_json
  end  

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
lhs-1.2.0 spec/data/to_json_spec.rb
lhs-1.1.0 spec/data/to_json_spec.rb
lhs-1.0.0 spec/data/to_json_spec.rb
lhs-0.4.0 spec/data/to_json_spec.rb
lhs-0.3.0 spec/data/to_json_spec.rb