Module: MuckPaginationMacros

Defined in:
lib/test/shoulda_macros/pagination.rb

Instance Method Summary collapse

Instance Method Details

#should_display_paginationObject



20
21
22
23
24
25
# File 'lib/test/shoulda_macros/pagination.rb', line 20

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

#should_not_display_paginationObject



42
43
44
45
46
47
# File 'lib/test/shoulda_macros/pagination.rb', line 42

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

#should_not_paginate_collection(collection_name) ⇒ Object

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


33
34
35
36
37
38
39
40
# File 'lib/test/shoulda_macros/pagination.rb', line 33

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

#should_paginate_collection(collection_name) ⇒ Object

Example:

context "a GET to index logged in as admin" do
  setup do
     
    get :index
  end
  should_paginate_collection :users
  should_display_pagination
end


11
12
13
14
15
16
17
18
# File 'lib/test/shoulda_macros/pagination.rb', line 11

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