Sha256: dddbb1f0684399bcc2e51809e20782e135f13bf7d7132ce886e769f6ee401890

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 Bytes

Contents

require 'spec_helper'

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

    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

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 spec/unit/pagination/collection_spec.rb
mark_mapper-0.0.5 spec/unit/pagination/collection_spec.rb
mark_mapper-0.0.4 spec/unit/pagination/collection_spec.rb
mark_mapper-0.0.3 spec/unit/pagination/collection_spec.rb
mark_mapper-0.0.2 spec/unit/pagination/collection_spec.rb
mark_mapper-0.0.1 spec/unit/pagination/collection_spec.rb