spec/models/array_spec.rb in kaminari-0.12.4 vs spec/models/array_spec.rb in kaminari-0.13.0
- old
+ new
@@ -1,12 +1,20 @@
-require File.expand_path('../spec_helper', File.dirname(__FILE__))
+require 'spec_helper'
describe Kaminari::PaginatableArray do
+ it { should have(0).items }
+
+ context 'specifying limit and offset when initializing' do
+ subject { Kaminari::PaginatableArray.new((1..100).to_a, :limit => 10, :offset => 20) }
+ its(:current_page) { should == 3 }
+ end
+
let(:array) { Kaminari::PaginatableArray.new((1..100).to_a) }
describe '#page' do
shared_examples_for 'the first page of array' do
it { should have(25).users }
+ its(:current_page) { should == 1 }
its(:first) { should == 1 }
end
shared_examples_for 'blank array page' do
it { should have(0).items }
@@ -18,10 +26,11 @@
end
context 'page 2' do
subject { array.page 2 }
it { should have(25).users }
+ its(:current_page) { should == 2 }
its(:first) { should == 26 }
end
context 'page without an argument' do
subject { array.page }
@@ -99,7 +108,14 @@
context 'page 2' do
subject { array.page 2 }
its(:count) { should == 25 }
end
+ end
+
+ context 'when setting total count explicitly' do
+ subject { Kaminari::PaginatableArray.new((1..10).to_a, :total_count => 9999).page(5).per(10) }
+ it { should have(10).items }
+ its(:first) { should == 1 }
+ its(:total_count) { should == 9999 }
end
end