spec/spec_helper.rb in grape-pagy-0.2.0 vs spec/spec_helper.rb in grape-pagy-0.3.0
- old
+ new
@@ -5,17 +5,34 @@
require 'rack/test'
Pagy::VARS[:items] = 10
Pagy::VARS[:max_items] = 20
+class TestArray < Array
+ def limit(num)
+ slice!(0, num)
+ end
+
+ def offset(num)
+ slice!(num..-1)
+ end
+end
+
class TestAPI < Grape::API
helpers Grape::Pagy::Helpers
params do
use :pagy, items: 5, max_items: 6
end
get '' do
pagy (1..12).to_a
+ end
+
+ params do
+ use :pagy, items: 3
+ end
+ get '/countless' do
+ pagy TestArray.new((1..12).to_a), using: :countless
end
resource :sub do
params do
use :pagy, items_param: :per_page