spec/paginate_helper_spec.rb in grape-kaminari-0.2.1 vs spec/paginate_helper_spec.rb in grape-kaminari-0.3.0
- old
+ new
@@ -11,17 +11,22 @@
paginate offset: false
get 'no-offset' do
paginate(Kaminari.paginate_array((1..10).to_a))
end
+
+ resource :sub do
+ paginate per_page: 2
+ get '/' do
+ paginate(Kaminari.paginate_array((1..10).to_a))
+ end
+ end
end
describe Grape::Kaminari do
subject { PaginatedAPI.new }
- def app
- subject
- end
+ let(:app) { subject }
let(:json) { JSON.parse(last_response.body) }
let(:header) { last_response.header }
describe 'paginated helper' do
it 'returns the first page' do
@@ -48,8 +53,13 @@
expect(header['X-Per-Page']).to eq '2'
expect(header['X-Page']).to eq '3'
expect(header['X-Next-Page']).to eq '4'
expect(header['X-Prev-Page']).to eq '2'
expect(header['X-Offset']).to eq '1'
+ end
+
+ it 'can be inherited' do
+ get '/sub', page: 1
+ expect(json).to eq [1, 2]
end
end
end