Sha256: cfb1fe9c2fc55815b8c1dd95ca4bbb5dc2bcc16ec9cebb593320d603a4cef660
Contents?: true
Size: 1.57 KB
Versions: 12
Compression:
Stored size: 1.57 KB
Contents
require 'rails_helper' describe LHS::Record do context 'inherit endpoints' do before do class Base < LHS::Record endpoint 'records/{id}' end class Example < Base end end it 'inherits endpoints based on ruby class_attribute behaviour' do request = stub_request(:get, 'http://records/1').to_return(body: [].to_json) Example.find(1) Base.find(1) assert_requested(request, times: 2) end end context 'define endpoints in subclass' do before do class Base < LHS::Record endpoint 'records/{id}' end class Example < Base endpoint 'records' end end it 'inherits endpoints based on ruby class_attribute behaviour' do stub_request(:get, 'http://records?color=blue').to_return(body: [].to_json) Example.where(color: 'blue') expect( -> { Base.all.first } ).to raise_error(RuntimeError, 'Compilation incomplete. Unable to find value for id.') end end context 'ambiguous endpoints between super and subclass' do before do class Base < LHS::Record endpoint 'records' end class Example < Base endpoint 'examples/{id}' end end it 'inherits endpoints based on ruby class_attribute behaviour' do request = stub_request(:get, 'http://records?limit=100').to_return(body: [].to_json) Base.all.first assert_requested(request) request = stub_request(:get, 'http://examples/1').to_return(body: {}.to_json) Example.find(1) assert_requested(request) end end end
Version data entries
12 entries across 12 versions & 1 rubygems