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.7 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.6 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.5 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.4 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.3 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.2 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.1 lib/test/shoulda_macros/pagination.rb
muck-engine-0.4.0 lib/test/shoulda_macros/pagination.rb
muck-engine-0.3.3 lib/test/shoulda_macros/pagination.rb
muck-engine-0.3.2 lib/test/shoulda_macros/pagination.rb
muck-engine-0.3.1 lib/test/shoulda_macros/pagination.rb
muck-engine-0.3.0 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.27 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.26 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.25 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.24 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.23 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.22 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.21 lib/test/shoulda_macros/pagination.rb
muck-engine-0.2.20 lib/test/shoulda_macros/pagination.rb