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