Sha256: 2d9278732a006994ecf7414dccc8bb72dc34b06805a0deeae1b8578f4fe273f4

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"
require "shamu/entities"

describe Shamu::Entities::ListScope::Paging do
  let( :klass ) do
    Class.new( Shamu::Entities::ListScope ) do
      include Shamu::Entities::ListScope::Paging
    end
  end

  it "has a :page attribute" do
    expect( klass.attributes ).to have_key :page
  end

  it "has a :per_page attribute" do
    expect( klass.attributes ).to have_key :per_page
  end

  it "has a :default_per_page" do
    expect( klass.attributes ).to have_key :default_per_page
  end

  it "uses default_per_page if not per_page set" do
    scope = klass.new
    scope.default_per_page = 25
    expect( scope.per_page ).to eq 25
  end

  it "includes paging values in to_param" do
    scope = klass.new
    scope.default_per_page = 25
    expect( scope.params ).to eq page: nil, per_page: 25
  end

  it "should not be paged if using defaults" do
    scope = klass.new
    expect( scope.paged? ).to be_falsy
  end

  it "should be paged when attribute specified" do
    scope = klass.new page: 1
    expect( scope.paged? ).to be_truthy
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.21 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.20 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.19 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.18 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.17 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.15 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.14 spec/lib/shamu/entities/list_scope/paging_spec.rb