Sha256: abf435477fc7c8cafaa4f94a7f1c33dca88eefcda33f5477950d538ec74a5f0f

Contents?: true

Size: 1.71 KB

Versions: 85

Compression:

Stored size: 1.71 KB

Contents

module MuckPaginationMacros
  # Example:
  #  context "a GET to index logged in as admin" do
  #    setup do
  #      login_as_admin 
  #      get :index
  #    end
  #    should_paginate_collection :users
  #    should_display_pagination
  #  end
  def should_paginate_collection(collection_name)
    should "paginate #{collection_name}" do
      assert collection = assigns(collection_name), 
        "Controller isn't assigning to @#{collection_name.to_s}."
      assert_kind_of WillPaginate::Collection, collection, 
        "@#{collection_name.to_s} isn't a WillPaginate collection."
    end
  end
  
  def should_display_pagination
    should "display pagination" do
      assert_select "div.pagination", { :minimum => 1 }, 
        "View isn't displaying pagination. Add <%= will_paginate @collection %>."
    end
  end
  
  # Example:
  #  context "a GET to index not logged in as admin" do
  #    setup { get :index }
  #    should_not_paginate_collection :users
  #    should_not_display_pagination
  #  end
  def should_not_paginate_collection(collection_name)
    should "not paginate #{collection_name}" do
      assert collection = assigns(collection_name), 
        "Controller isn't assigning to @#{collection_name.to_s}."
      assert_not_equal WillPaginate::Collection, collection.class, 
        "@#{collection_name.to_s} is a WillPaginate collection."
    end
  end
  
  def should_not_display_pagination
    should "not display pagination" do
      assert_select "div.pagination", { :count => 0 }, 
        "View is displaying pagination. Check your logic."
    end
  end
end

ActiveSupport::TestCase.extend(MuckPaginationMacros)
Test::Unit::TestCase.extend(MuckPaginationMacros)
ActionController::TestCase.extend(MuckPaginationMacros)

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
muck-engine-3.5.0 lib/test/shoulda_macros/pagination.rb
muck-engine-3.4.0 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.18 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.17 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.16 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.15 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.14 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.13 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.12 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.11 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.10 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.9 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.8 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.7 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.6 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.5 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.4 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.3 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.2 lib/test/shoulda_macros/pagination.rb
muck-engine-3.3.1 lib/test/shoulda_macros/pagination.rb