Sha256: aa0a392d1f450b50049f5c964767bc04cf49ffa3f74a662abe18aefcf78e189d

Contents?: true

Size: 1.65 KB

Versions: 154

Compression:

Stored size: 1.65 KB

Contents

module ShouldaPaginationMacros
  # 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 self.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 self.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 self.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 self.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


class ActiveSupport::TestCase
  extend ShouldaPaginationMacros
end

Version data entries

154 entries across 154 versions & 6 rubygems

Version Path
overlord-3.0.2 test/rails_test/test/shoulda_macros/pagination.rb
overlord-3.0.1 test/rails_test/test/shoulda_macros/pagination.rb
overlord-3.0.0 test/rails_test/test/shoulda_macros/pagination.rb
overlord-0.1.22 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.21 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.20 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.19 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.18 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.17 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.16 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.15 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.14 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.13 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.12 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.11 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.10 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.9 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.8 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.7 test/rails_root/test/shoulda_macros/pagination.rb
overlord-0.1.6 test/rails_root/test/shoulda_macros/pagination.rb