File: per_page_spec.rb

package info (click to toggle)
ruby-will-paginate 4.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 440 kB
  • sloc: ruby: 2,734; sh: 33; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'spec_helper'
require 'will_paginate/per_page'

RSpec.describe WillPaginate::PerPage do

  class MyModel
    extend WillPaginate::PerPage
  end

  it "has the default value" do
    expect(MyModel.per_page).to eq(30)

    WillPaginate.per_page = 10
    begin
      expect(MyModel.per_page).to eq(10)
    ensure
      WillPaginate.per_page = 30
    end
  end

  it "casts values to int" do
    WillPaginate.per_page = '10'
    begin
      expect(MyModel.per_page).to eq(10)
    ensure
      WillPaginate.per_page = 30
    end
  end

  it "has an explicit value" do
    MyModel.per_page = 12
    begin
      expect(MyModel.per_page).to eq(12)
      subclass = Class.new(MyModel)
      expect(subclass.per_page).to eq(12)
    ensure
      MyModel.send(:remove_instance_variable, '@per_page')
    end
  end

end