Sha256: 5e31b93f1e01828848b10960d2db069d0bf4b1e70b1649ef3c4ad18265b8d55f
Contents?: true
Size: 990 Bytes
Versions: 13
Compression:
Stored size: 990 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 } before(:each) do stub_request(:get, 'http://uberall/locations/1') .to_return(body: { listings: [{ directory: { name: 'Instagram' } }] }.to_json) end it 'casts the relation into the correct type' do expect(listing).to be_kind_of(Listing) expect(listing.supported?).to eq true end it 'keeps hirachy when casting it to another class on access' do expect(listing._root._raw).to eq location._raw expect(listing.parent.parent._raw).to eq location._raw end end end
Version data entries
13 entries across 13 versions & 1 rubygems