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-0.4.32 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.31 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.30 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.29 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.27 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.26 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.25 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.24 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.23 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.21 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.17 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.16 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.15 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.14 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.13 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.12 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.11 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.10 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.9 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.8 lib/test/shoulda_macros/pagination.rb