Sha256: 568b8f93a23fd0813a4f5b54090fa5b2294578b15de08f5950e3197c1a5ca458

Contents?: true

Size: 972 Bytes

Versions: 9

Compression:

Stored size: 972 Bytes

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
    expect( klass.new.per_page ).to eq 25
  end

  it "includes paging values in to_param" do
    expect( klass.new.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

9 entries across 9 versions & 1 rubygems

Version Path
shamu-0.0.13 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.11 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.9 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.8 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.7 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.5 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.4 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.3 spec/lib/shamu/entities/list_scope/paging_spec.rb
shamu-0.0.2 spec/lib/shamu/entities/list_scope/paging_spec.rb