Sha256: 204a0a05e88aa30d425b2178c7c48564dbd65fa4917aaa8865b600396bf41a63
Contents?: true
Size: 1.06 KB
Versions: 76
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHS::Record do let(:datastore) do 'http://datastore/v2' end let(:response) do { body: [{ name: 'Steve' }] } end before do LHC.config.placeholder('datastore', datastore) class Record < LHS::Record endpoint '{+datastore}/records/' scope :blue, -> { where(color: 'blue') } scope :available, -> { where(availalbe: 'true') } scope :limited_to, ->(limit) { where(limit: limit) } end end context 'scope chains' do it 'allows chaining multiple scopes' do stub_request(:get, "http://datastore/v2/records/?availalbe=true&color=blue&limit=20").to_return(response) expect( Record.blue.available.limited_to(20).first.name ).to eq 'Steve' end it 'allows to chain multiple scopes when first one has arguments' do stub_request(:get, "http://datastore/v2/records/?availalbe=true&color=blue&limit=20").to_return(response) expect( Record.limited_to(20).blue.available.first.name ).to eq 'Steve' end end end
Version data entries
76 entries across 76 versions & 1 rubygems