lib/lhs/test/stub.rb in lhs-20.1.3.pre.paginationfix.3 vs lib/lhs/test/stub.rb in lhs-20.1.4

- old
+ new

@@ -11,18 +11,18 @@ def self.all(url, items, options = {}) items.each_slice(DEFAULT_LIMIT).with_index do |(*batch), index| uri = LocalUri::URI.new(url) uri.query.merge!(limit: DEFAULT_LIMIT) uri.query.merge!(offset: DEFAULT_LIMIT * index) unless index.zero? - stub_request(:get, uri.to_s) - .with(options) - .to_return( - body: { - items: batch, - offset: index * DEFAULT_LIMIT, - total: items.length - }.to_json - ) + request_stub = stub_request(:get, uri.to_s) + request_stub.with(options) if options.present? + request_stub.to_return( + body: { + items: batch, + offset: index * DEFAULT_LIMIT, + total: items.length + }.to_json + ) end end end end end