Sha256: db0101ebf63fc8326dc6a9b8a59a604ead28ef3b329aa2fcff4a44256cd3c097

Contents?: true

Size: 1008 Bytes

Versions: 4

Compression:

Stored size: 1008 Bytes

Contents

require 'helper'

describe Plucky::Pagination::Decorator do
  context "Object decorated with Decorator with paginator set" do
    before do
      @object    = [1, 2, 3, 4]
      @object_id = @object.object_id
      @paginator = Plucky::Pagination::Paginator.new(20, 2, 10)
      @object.extend(described_class)
      @object.paginator(@paginator)
    end
    subject { @object }

    it "knows paginator" do
      subject.paginator.should == @paginator
    end

    [:total_entries, :current_page, :per_page, :total_pages, :out_of_bounds?,
     :previous_page, :next_page, :skip, :limit, :offset].each do |method|
      it "delegates #{method} to paginator" do
        subject.send(method).should == @paginator.send(method)
      end
    end

    it "does not interfere with other methods on the object" do
      @object.object_id.should  == @object_id
      @object.should            == [1, 2, 3, 4]
      @object.size.should       == 4
      @object.select { |o| o > 2 }.should == [3, 4]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plucky-0.6.3 spec/plucky/pagination/decorator_spec.rb
plucky-0.6.2 spec/plucky/pagination/decorator_spec.rb
plucky-0.6.1 spec/plucky/pagination/decorator_spec.rb
plucky-0.6.0 spec/plucky/pagination/decorator_spec.rb