folio-pagination-legacy 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +17 -0
  2. data/.travis.yml +3 -0
  3. data/Gemfile +16 -0
  4. data/Guardfile +5 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +235 -0
  7. data/Rakefile +11 -0
  8. data/folio-pagination-legacy.gemspec +30 -0
  9. data/lib/folio-pagination-legacy.rb +3 -0
  10. data/lib/folio.rb +84 -0
  11. data/lib/folio/core_ext/enumerable.rb +51 -0
  12. data/lib/folio/invalid_page.rb +5 -0
  13. data/lib/folio/ordinal.rb +33 -0
  14. data/lib/folio/ordinal/page.rb +107 -0
  15. data/lib/folio/page.rb +86 -0
  16. data/lib/folio/per_page.rb +15 -0
  17. data/lib/folio/rails.rb +21 -0
  18. data/lib/folio/version.rb +3 -0
  19. data/lib/folio/will_paginate/active_record.rb +71 -0
  20. data/lib/folio/will_paginate/array.rb +10 -0
  21. data/lib/folio/will_paginate/collection.rb +19 -0
  22. data/lib/folio/will_paginate/view_helpers.rb +59 -0
  23. data/lib/folio/will_paginate/view_helpers/action_view.rb +10 -0
  24. data/lib/folio/will_paginate/view_helpers/link_renderer.rb +53 -0
  25. data/test/folio/core_ext/enumerable_test.rb +55 -0
  26. data/test/folio/ordinal/page_test.rb +173 -0
  27. data/test/folio/ordinal_test.rb +57 -0
  28. data/test/folio/page_test.rb +198 -0
  29. data/test/folio/per_page_test.rb +49 -0
  30. data/test/folio/rails_test.rb +11 -0
  31. data/test/folio/version_test.rb +8 -0
  32. data/test/folio/will_paginate/active_record_test.rb +113 -0
  33. data/test/folio/will_paginate/collection_test.rb +43 -0
  34. data/test/folio/will_paginate/view_helpers/link_renderer_test.rb +160 -0
  35. data/test/folio/will_paginate/view_helpers_test.rb +49 -0
  36. data/test/folio_test.rb +192 -0
  37. data/test/setup/active_record.rb +13 -0
  38. metadata +133 -0
@@ -0,0 +1,49 @@
1
+ require 'minitest/autorun'
2
+ require 'folio/per_page'
3
+ require 'folio'
4
+
5
+ describe Folio::PerPage do
6
+ before do
7
+ @klass = Class.new{ include Folio::PerPage }
8
+ @object = @klass.new
9
+ end
10
+
11
+ describe "default_per_page" do
12
+ it "should be Folio.per_page" do
13
+ was = Folio.per_page
14
+ Folio.per_page = 100
15
+ @object.default_per_page.must_equal 100
16
+ Folio.per_page = was
17
+ end
18
+ end
19
+
20
+ describe "per_page" do
21
+ it "should return default_per_page if nil" do
22
+ @klass.send(:define_method, :default_per_page) { 100 }
23
+ @object.per_page = nil
24
+ @object.per_page.must_equal 100
25
+ end
26
+
27
+ it "should return set value if non-nil" do
28
+ @object.per_page = 100
29
+ @object.per_page.must_equal 100
30
+ end
31
+
32
+ it "should allow setting through argument" do
33
+ @object.per_page(100)
34
+ @object.per_page.must_equal 100
35
+ end
36
+
37
+ it "should cast to integer when setting non-nil through argument" do
38
+ @object.per_page("100")
39
+ @object.per_page.must_equal 100
40
+ end
41
+
42
+ it "should allow setting to nil through argument" do
43
+ @klass.send(:define_method, :default_per_page) { 100 }
44
+ @object.per_page(30)
45
+ @object.per_page(nil)
46
+ @object.per_page.must_equal 100
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,11 @@
1
+ require 'folio/rails'
2
+ require 'folio/invalid_page'
3
+ require 'action_controller/base'
4
+
5
+ describe ActionController::Base do
6
+ it "should translate Folio::InvalidPage to a 404" do
7
+ controller = ActionController::Base.new
8
+ code = controller.send :response_code_for_rescue, Folio::InvalidPage.new
9
+ code.must_equal :not_found
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ require 'minitest/autorun'
2
+ require 'folio/version'
3
+
4
+ describe Folio::VERSION do
5
+ it "should have a version" do
6
+ Folio::VERSION.wont_be_nil
7
+ end
8
+ end
@@ -0,0 +1,113 @@
1
+ require 'minitest/autorun'
2
+ require 'folio/will_paginate/active_record'
3
+ require_relative '../../setup/active_record'
4
+
5
+ describe ActiveRecord do
6
+ TestSetup::ActiveRecord.migrate do |m|
7
+ m.create_table(:items) do |t|
8
+ t.boolean :filter
9
+ end
10
+
11
+ m.create_table(:related_things) do |t|
12
+ t.integer :item_id
13
+ end
14
+ end
15
+
16
+ class Item < ::ActiveRecord::Base
17
+ has_many :related_things
18
+ end
19
+
20
+ class RelatedThing < ::ActiveRecord::Base; end
21
+
22
+ before do
23
+ RelatedThing.delete_all
24
+ Item.delete_all
25
+ 24.times{ |i| Item.create(filter: (i % 2).zero?) }
26
+ end
27
+
28
+ describe "per_page" do
29
+ it "should default to Folio.per_page" do
30
+ was = Folio.per_page
31
+ Folio.per_page = 10
32
+ ActiveRecord::Base.per_page.must_equal 10
33
+ Folio.per_page = was
34
+ end
35
+ end
36
+
37
+ describe "paginate" do
38
+ it "should return an ordinal folio page" do
39
+ page = Item.paginate
40
+ page.is_a?(Folio::Ordinal::Page).must_equal true
41
+ end
42
+
43
+ it "should set per_page from parameter" do
44
+ page = Item.paginate(per_page: 10)
45
+ page.per_page.must_equal 10
46
+ end
47
+
48
+ it "should default per_page to model's per_page" do
49
+ was = Item.per_page
50
+ Item.per_page = 10
51
+ page = Item.paginate
52
+ page.per_page.must_equal 10
53
+ Item.per_page = was
54
+ end
55
+
56
+ it "should set offset from page and per_page" do
57
+ page = Item.paginate(page: 3, per_page: 10)
58
+ page.offset.must_equal 20
59
+ end
60
+
61
+ it "should set current_page" do
62
+ page = Item.paginate(page: 3, per_page: 10)
63
+ page.current_page.must_equal 3
64
+ end
65
+
66
+ it "should have the right size on the page" do
67
+ page = Item.paginate(page: 3, per_page: 10)
68
+ page.size.must_equal 4
69
+ end
70
+
71
+ it "should return the expected items" do
72
+ page = Item.paginate(page: 3, per_page: 10)
73
+ page.to_a.must_equal Item.find(:all, offset: 20, limit: 10)
74
+ end
75
+
76
+ it "should auto-count total_entries unless specified as nil" do
77
+ page = Item.paginate
78
+ page.total_entries.must_equal 24
79
+ end
80
+
81
+ it "should not auto-count total_entries when specified as nil and not last page" do
82
+ page = Item.paginate(per_page: 10, total_entries: nil)
83
+ page.total_entries.must_be_nil
84
+ end
85
+
86
+ it "should calculate total_entries when specified as nil but last page" do
87
+ page = Item.paginate(page: 3, per_page: 10, total_entries: nil)
88
+ page.total_entries.must_equal 24
89
+ end
90
+
91
+ it "should still work with total_entries nil" do
92
+ page = Item.paginate(page: 3, total_entries: nil)
93
+ page.current_page.must_equal 3
94
+ end
95
+
96
+ it "should validate page number against auto-counted total_entries" do
97
+ lambda{ Item.paginate(page: 4, per_page: 10) }.must_raise Folio::InvalidPage
98
+ end
99
+
100
+ it "should work on associations" do
101
+ item = Item.first
102
+ 12.times{ |i| item.related_things.create! }
103
+ page = item.related_things.paginate(page: 2, per_page: 10)
104
+ page.count.must_equal 2
105
+ end
106
+
107
+ it "should work when autocounting with string page/per_page" do
108
+ page = Item.paginate(page: "3", per_page: "10")
109
+ page.size.must_equal 4
110
+ page.total_entries.must_equal 24
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,43 @@
1
+ require 'minitest/autorun'
2
+ require 'folio/will_paginate/collection'
3
+
4
+ describe WillPaginate::Collection do
5
+ describe "create" do
6
+ it "should create an ordinal page" do
7
+ page = WillPaginate::Collection.create(1)
8
+ page.is_a?(Folio::Ordinal::Page).must_equal true
9
+ end
10
+
11
+ it "should set current_page on the created page" do
12
+ page = WillPaginate::Collection.create(4)
13
+ page.current_page.must_equal 4
14
+ end
15
+
16
+ it "should set per_page on the created page if given" do
17
+ page = WillPaginate::Collection.create(4, 10)
18
+ page.per_page.must_equal 10
19
+ end
20
+
21
+ it "should set total_entries on the created page if given" do
22
+ page = WillPaginate::Collection.create(4, 10, 50)
23
+ page.total_entries.must_equal 50
24
+ end
25
+
26
+ it "should yield the page to block if given" do
27
+ page = WillPaginate::Collection.create(1) { |p| p.replace [1, 2, 3] }
28
+ page.must_equal [1, 2, 3]
29
+ end
30
+
31
+ it "created page should have offset method like WillPaginate::Collection" do
32
+ page = WillPaginate::Collection.create(4, 10)
33
+ page.offset.must_equal 30
34
+ end
35
+
36
+ it "created should set total_entries on replace like WillPaginate::Collection" do
37
+ page = WillPaginate::Collection.create(4, 10)
38
+ page.total_entries.must_be_nil
39
+ page.replace [1, 2, 3]
40
+ page.total_entries.must_equal 33
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,160 @@
1
+ require 'minitest/autorun'
2
+ require 'folio/will_paginate/view_helpers/link_renderer'
3
+ require 'folio/page'
4
+
5
+ describe WillPaginate::LinkRenderer do
6
+ before do
7
+ @template = Class.new do
8
+ def link_to(*args)
9
+ "link_to(#{args.map(&:inspect).join(', ')})"
10
+ end
11
+
12
+ def content_tag(*args)
13
+ "content_tag(#{args.map(&:inspect).join(', ')})"
14
+ end
15
+
16
+ def will_paginate_translate(*args)
17
+ yield
18
+ end
19
+ end.new
20
+
21
+ @renderer = Class.new(WillPaginate::LinkRenderer) do
22
+ def url_for(page)
23
+ "url://#{page}"
24
+ end
25
+ end.new
26
+
27
+ # looks just like a standard WillPaginate collection would
28
+ @collection = Folio::Page.create
29
+ @collection.ordinal_pages = true
30
+ @collection.first_page = 1
31
+ @collection.total_entries = 200
32
+ @collection.per_page = 10
33
+ @collection.last_page = 20
34
+ @collection.current_page = 10
35
+ @collection.next_page = 11
36
+ @collection.previous_page = 9
37
+ end
38
+
39
+ it "should ignore page_links parameter with non-ordinal pages" do
40
+ @collection.ordinal_pages = false
41
+ @renderer.prepare(@collection, {page_links: true, previous_label: "Previous", next_label: "Next"}, @template)
42
+ @renderer.to_html.must_equal [
43
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
44
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
45
+ ].join
46
+ end
47
+
48
+ it "should still honor page_links parameter with ordinal pages" do
49
+ @renderer.prepare(@collection, {page_links: false, previous_label: "Previous", next_label: "Next"}, @template)
50
+ @renderer.to_html.must_equal [
51
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
52
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
53
+ ].join
54
+
55
+ @renderer.prepare(@collection, {page_links: true, previous_label: "Previous", next_label: "Next"}, @template)
56
+ @renderer.to_html.must_equal [
57
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
58
+ @template.link_to("1", "url://1", {:rel=>"start", :class=>nil}),
59
+ @renderer.gap_marker,
60
+ @template.content_tag(:span, "10", {:class=>"current"}),
61
+ @renderer.gap_marker,
62
+ @template.link_to("20", "url://20", {:rel=>nil, :class=>nil}),
63
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
64
+ ].join
65
+ end
66
+
67
+ it "should treat last_page as total_pages when known" do
68
+ @collection.last_page = 15
69
+ @renderer.prepare(@collection, {}, @template)
70
+ @renderer.total_pages.must_equal @collection.last_page
71
+ end
72
+
73
+ it "should treat next_page as total_pages when last_page unknown" do
74
+ @collection.last_page = nil
75
+ @renderer.prepare(@collection, {}, @template)
76
+ @renderer.total_pages.must_equal @collection.next_page
77
+ end
78
+
79
+ it "should add :gap after page links when last_page unknown" do
80
+ @collection.last_page = nil
81
+ @renderer.prepare(@collection, {page_links: true, previous_label: "Previous", next_label: "Next", inner_window: 1}, @template)
82
+ @renderer.to_html.must_equal [
83
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
84
+ @template.link_to("1", "url://1", {:rel=>"start", :class=>nil}),
85
+ @renderer.gap_marker,
86
+ @template.link_to("9", "url://9", {:rel=>"prev", :class=>nil}),
87
+ @template.content_tag(:span, "10", {:class=>"current"}),
88
+ @template.link_to("11", "url://11", {:rel=>"next", :class=>nil}),
89
+ @renderer.gap_marker,
90
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
91
+ ].join
92
+ end
93
+
94
+ it "should end inner window at next_page when last_page unknown" do
95
+ @collection.last_page = nil
96
+ @renderer.prepare(@collection, {page_links: true, previous_label: "Previous", next_label: "Next", inner_window: 2}, @template)
97
+ @renderer.to_html.must_equal [
98
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
99
+ @template.link_to("1", "url://1", {:rel=>"start", :class=>nil}),
100
+ @renderer.gap_marker,
101
+ @template.link_to("7", "url://7", {:rel=>nil, :class=>nil}),
102
+ @template.link_to("8", "url://8", {:rel=>nil, :class=>nil}),
103
+ @template.link_to("9", "url://9", {:rel=>"prev", :class=>nil}),
104
+ @template.content_tag(:span, "10", {:class=>"current"}),
105
+ @template.link_to("11", "url://11", {:rel=>"next", :class=>nil}),
106
+ @renderer.gap_marker,
107
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
108
+ ].join
109
+ end
110
+
111
+ describe "previous_page" do
112
+ it "should respect collection.previous_page" do
113
+ @collection.previous_page = 5
114
+ @renderer.prepare(@collection, {page_links: false, previous_label: "Previous", next_label: "Next"}, @template)
115
+ @renderer.to_html.must_equal [
116
+ @template.link_to("Previous", "url://5", {:rel=>"prev", :class=>"prev_page"}),
117
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
118
+ ].join
119
+ end
120
+
121
+ it "should produce link with rel=prev for non-numeric" do
122
+ @collection.previous_page = "abcdef"
123
+ @renderer.prepare(@collection, {page_links: false, previous_label: "Previous", next_label: "Next"}, @template)
124
+ @renderer.to_html.must_equal [
125
+ @template.link_to("Previous", "url://abcdef", {:rel=>"prev", :class=>"prev_page"}),
126
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
127
+ ].join
128
+ end
129
+
130
+ it "should have rel=start in the html for non-numeric value matching first_page" do
131
+ @collection.first_page = "abcdef"
132
+ @collection.previous_page = "abcdef"
133
+ @renderer.prepare(@collection, {page_links: false, previous_label: "Previous", next_label: "Next"}, @template)
134
+ @renderer.to_html.must_equal [
135
+ @template.link_to("Previous", "url://abcdef", {:rel=>"prev start", :class=>"prev_page"}),
136
+ @template.link_to("Next", "url://11", {:rel=>"next", :class=>"next_page"})
137
+ ].join
138
+ end
139
+ end
140
+
141
+ describe "next_page" do
142
+ it "should respect collection.next_page" do
143
+ @collection.next_page = 15
144
+ @renderer.prepare(@collection, {page_links: false, previous_label: "Previous", next_label: "Next"}, @template)
145
+ @renderer.to_html.must_equal [
146
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
147
+ @template.link_to("Next", "url://15", {:rel=>"next", :class=>"next_page"})
148
+ ].join
149
+ end
150
+
151
+ it "should produce link with rel=next for non-numeric value" do
152
+ @collection.next_page = "abcdef"
153
+ @renderer.prepare(@collection, {page_links: false, previous_label: "Previous", next_label: "Next"}, @template)
154
+ @renderer.to_html.must_equal [
155
+ @template.link_to("Previous", "url://9", {:rel=>"prev", :class=>"prev_page"}),
156
+ @template.link_to("Next", "url://abcdef", {:rel=>"next", :class=>"next_page"})
157
+ ].join
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,49 @@
1
+ require 'minitest/autorun'
2
+ require 'folio/will_paginate/view_helpers'
3
+
4
+ # for I18n in page_entries_info
5
+ require 'active_support/core_ext/string/inflections'
6
+
7
+ describe WillPaginate::ViewHelpers do
8
+ include WillPaginate::ViewHelpers
9
+
10
+ before do
11
+ @collection = Folio::Ordinal::Page.create
12
+ end
13
+
14
+ describe "will_paginate" do
15
+ before do
16
+ @renderer = Minitest::Mock.new
17
+ @renderer.expect(:prepare, nil, [@collection, Hash, self])
18
+ @renderer.expect(:to_html, '<PAGES>')
19
+ end
20
+
21
+ it "should return nil if total_pages is 1" do
22
+ @collection.total_entries = @collection.per_page
23
+ will_paginate(@collection, :renderer => @renderer).must_be_nil
24
+ end
25
+
26
+ it "should not error if total_entries is unknown" do
27
+ @collection.total_entries = nil
28
+ will_paginate(@collection, :renderer => @renderer).must_equal '<PAGES>'
29
+ end
30
+ end
31
+
32
+ describe "page_entries_info" do
33
+ it "should return nominally if collection is ordinal with total_entries known" do
34
+ @collection.total_entries = 20
35
+ page_entries_info(@collection).wont_be_nil
36
+ end
37
+
38
+ it "should return nil if total_entries is unknown" do
39
+ @collection.total_entries = nil
40
+ page_entries_info(@collection).must_be_nil
41
+ end
42
+
43
+ it "should return nil if collection is non-ordinal" do
44
+ @collection = Folio::Page.create
45
+ @collection.total_entries = 20
46
+ page_entries_info(@collection).must_be_nil
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,192 @@
1
+ require 'minitest/autorun'
2
+ require 'folio'
3
+
4
+ describe Folio do
5
+ describe "class per_page" do
6
+ it "should have a per_page attribute" do
7
+ Folio.must_respond_to :per_page
8
+ Folio.must_respond_to :per_page=
9
+ end
10
+
11
+ it "should allow setting by per_page=" do
12
+ was = Folio.per_page
13
+ Folio.per_page = 100
14
+ Folio.per_page.must_equal 100
15
+ Folio.per_page = was
16
+ end
17
+
18
+ it "should allow setting by argument to per_page" do
19
+ was = Folio.per_page
20
+ Folio.per_page(100)
21
+ Folio.per_page.must_equal 100
22
+ Folio.per_page = was
23
+ end
24
+
25
+ it "should default to 30" do
26
+ Folio.per_page.must_equal 30
27
+ end
28
+ end
29
+
30
+ before do
31
+ page_klass = Class.new do
32
+ include Folio::Page
33
+ end
34
+
35
+ @klass = Class.new do
36
+ define_method :build_page do
37
+ page = page_klass.new
38
+ page.ordinal_pages = false
39
+ page.first_page = :first
40
+ page.last_page = :last
41
+ page
42
+ end
43
+
44
+ def fill_page(page)
45
+ page.next_page = :next
46
+ page.previous_page = :previous
47
+ page
48
+ end
49
+
50
+ include Folio
51
+ end
52
+
53
+ @folio = @klass.new
54
+ end
55
+
56
+ describe "paginate" do
57
+ it "should get the page from the folio's build_page method" do
58
+ page = @folio.paginate
59
+ page.ordinal_pages.must_equal false
60
+ page.first_page.must_equal :first
61
+ page.last_page.must_equal :last
62
+ end
63
+
64
+ it "should pass the page through the folio's fill_page method" do
65
+ page = @folio.paginate
66
+ page.next_page.must_equal :next
67
+ page.previous_page.must_equal :previous
68
+ end
69
+
70
+ it "should populate current_page and per_page before passing it to fill_page" do
71
+ @klass.send(:define_method, :fill_page) do |page|
72
+ page.current_page.wont_be_nil
73
+ page.per_page.wont_be_nil
74
+ end
75
+ @folio.paginate
76
+ end
77
+
78
+ describe "page parameter" do
79
+ it "should populate onto the page" do
80
+ page = @folio.paginate(page: :current)
81
+ page.current_page.must_equal :current
82
+ end
83
+
84
+ it "should default to the page's first_page" do
85
+ page = @folio.paginate
86
+ page.current_page.must_equal page.first_page
87
+ end
88
+
89
+ it "should set to the page's first_page if explicitly nil" do
90
+ page = @folio.paginate(page: nil)
91
+ page.current_page.must_equal page.first_page
92
+ end
93
+
94
+ it "should not set to the page's first_page if explicitly false" do
95
+ page = @folio.paginate(page: false)
96
+ page.current_page.must_equal false
97
+ end
98
+ end
99
+
100
+ describe "per_page parameter" do
101
+ it "should populate onto the page" do
102
+ page = @folio.paginate(per_page: 100)
103
+ page.per_page.must_equal 100
104
+ end
105
+
106
+ it "should default to the folio's per_page" do
107
+ @folio.per_page = 100
108
+ page = @folio.paginate
109
+ page.per_page.must_equal 100
110
+ end
111
+ end
112
+
113
+ describe "total_entries parameter" do
114
+ it "should populate onto the page" do
115
+ page = @folio.paginate(total_entries: 100)
116
+ page.total_entries.must_equal 100
117
+ end
118
+
119
+ it "should default to the nil if the folio does not implement count" do
120
+ page = @folio.paginate
121
+ page.total_entries.must_be_nil
122
+ end
123
+
124
+ it "should default to the result of count if the folio implements count" do
125
+ @klass.send(:define_method, :count) { 100 }
126
+ page = @folio.paginate
127
+ page.total_entries.must_equal 100
128
+ end
129
+
130
+ it "should not-execute the count if total_entries provided" do
131
+ called = false
132
+ @klass.send(:define_method, :count) { called = true }
133
+ @folio.paginate(total_entries: 100)
134
+ called.must_equal false
135
+ end
136
+
137
+ it "should not-execute the count if total_entries provided as nil" do
138
+ called = false
139
+ @klass.send(:define_method, :count) { called = true }
140
+ page = @folio.paginate(total_entries: nil)
141
+ called.must_equal false
142
+ page.total_entries.must_be_nil
143
+ end
144
+ end
145
+ end
146
+
147
+ describe "per_page class attribute" do
148
+ it "should exist" do
149
+ @klass.must_respond_to :per_page
150
+ @klass.must_respond_to :per_page=
151
+ end
152
+
153
+ it "should be settable from per_page=" do
154
+ @klass.per_page = 100
155
+ @klass.per_page.must_equal 100
156
+ end
157
+
158
+ it "should be settable from per_page with argument" do
159
+ @klass.per_page(100)
160
+ @klass.per_page.must_equal 100
161
+ end
162
+
163
+ it "should default to Folio.per_page" do
164
+ was = Folio.per_page
165
+ Folio.per_page = 50
166
+ @klass.per_page.must_equal 50
167
+ Folio.per_page = was
168
+ end
169
+ end
170
+
171
+ describe "per_page instance attribute" do
172
+ it "should exist" do
173
+ @folio.must_respond_to :per_page
174
+ @folio.must_respond_to :per_page=
175
+ end
176
+
177
+ it "should be settable from per_page=" do
178
+ @folio.per_page = 100
179
+ @folio.per_page.must_equal 100
180
+ end
181
+
182
+ it "should be settable from per_page with argument" do
183
+ @folio.per_page(100)
184
+ @folio.per_page.must_equal 100
185
+ end
186
+
187
+ it "should default to class' per_page" do
188
+ @klass.per_page = 50
189
+ @folio.per_page.must_equal 50
190
+ end
191
+ end
192
+ end