Sha256: 2b3e445d3968206f9d50ef254ef668dab9c51b21729ec2b18c69478294885fe1

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

require 'test_helper'

module PaginatedTable
  describe DataPage do
    describe "#data" do
      let(:page) {
        Page.new(
          :number => 2,
          :rows => 5,
          :sort_column => 'name',
          :sort_direction => 'asc'
        )
      }
      let(:collection) {
        collection = (1..10).map { |i| "Name #{i}" }
        def collection.order(clause)
          raise unless clause == "name asc"
          sort
        end
        collection
      }

      it "sorts the collection and pages to the given page number" do
        DataPage.new(collection, page).data.must_equal(
          ["Name 5", "Name 6", "Name 7", "Name 8", "Name 9"]
        )
      end

      describe "#page" do
        it "provides a reference to the given page" do
          DataPage.new(collection, page).page.must_equal page
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paginated_table-0.0.9 test/units/data_page_test.rb
paginated_table-0.0.8 test/units/data_page_test.rb
paginated_table-0.0.7 test/units/data_page_test.rb