Sha256: f572c3ba90a22d6d18e7dba333115d09a30a17b7e42a71b6ea2dd3ac3073d48f

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

require 'rails_helper'

describe LHS::Record do
  before(:each) do
    class Location < LHS::Record
      endpoint 'http://uberall/locations'
      endpoint 'http://uberall/locations/:id'
      has_many :listings
    end

    class Listing < LHS::Record

      def supported?
        true
      end
    end
  end

  context 'has_many' do
    let(:location) { Location.find(1) }
    let(:listing) { location.listings.first }

    it 'casts the relation into the correct type' do
      stub_request(:get, 'http://uberall/locations/1')
        .to_return(body: {
          listings: [{
            directory: { name: 'Instagram' }
          }]
        }.to_json)
      expect(listing).to be_kind_of(Listing)
      expect(listing.supported?).to eq true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lhs-14.6.0 spec/record/has_many_spec.rb