will_paginate 3.3.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/will_paginate/locale/en.yml +2 -0
  4. data/lib/will_paginate/version.rb +3 -3
  5. data/lib/will_paginate/view_helpers/action_view.rb +6 -2
  6. data/lib/will_paginate/view_helpers/link_renderer.rb +7 -5
  7. data/lib/will_paginate.rb +0 -12
  8. metadata +8 -38
  9. data/lib/will_paginate/data_mapper.rb +0 -100
  10. data/lib/will_paginate/view_helpers/merb.rb +0 -26
  11. data/spec/collection_spec.rb +0 -139
  12. data/spec/console +0 -12
  13. data/spec/console_fixtures.rb +0 -28
  14. data/spec/database.yml +0 -29
  15. data/spec/finders/active_record_spec.rb +0 -424
  16. data/spec/finders/activerecord_test_connector.rb +0 -107
  17. data/spec/fixtures/admin.rb +0 -3
  18. data/spec/fixtures/developer.rb +0 -9
  19. data/spec/fixtures/developers_projects.yml +0 -13
  20. data/spec/fixtures/project.rb +0 -13
  21. data/spec/fixtures/projects.yml +0 -6
  22. data/spec/fixtures/replies.yml +0 -29
  23. data/spec/fixtures/reply.rb +0 -8
  24. data/spec/fixtures/schema.rb +0 -38
  25. data/spec/fixtures/topic.rb +0 -8
  26. data/spec/fixtures/topics.yml +0 -30
  27. data/spec/fixtures/user.rb +0 -2
  28. data/spec/fixtures/users.yml +0 -35
  29. data/spec/matchers/deprecation_matcher.rb +0 -27
  30. data/spec/matchers/phrase_matcher.rb +0 -19
  31. data/spec/matchers/query_count_matcher.rb +0 -36
  32. data/spec/page_number_spec.rb +0 -91
  33. data/spec/per_page_spec.rb +0 -41
  34. data/spec/spec_helper.rb +0 -41
  35. data/spec/view_helpers/action_view_spec.rb +0 -481
  36. data/spec/view_helpers/base_spec.rb +0 -143
  37. data/spec/view_helpers/link_renderer_base_spec.rb +0 -87
  38. data/spec/view_helpers/view_example_group.rb +0 -105
@@ -1,105 +0,0 @@
1
- require 'active_support'
2
- require 'stringio'
3
- require 'minitest/assertions'
4
- require 'rails/dom/testing/assertions'
5
- require 'will_paginate/array'
6
-
7
- module ViewExampleGroup
8
-
9
- include Rails::Dom::Testing::Assertions::SelectorAssertions
10
- include Minitest::Assertions
11
-
12
- def assert(value, message)
13
- raise message unless value
14
- end
15
-
16
- def paginate(collection = {}, options = {}, &block)
17
- if collection.instance_of? Hash
18
- page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection)
19
- collection = [1].paginate(page_options)
20
- end
21
-
22
- locals = { :collection => collection, :options => options }
23
-
24
- @render_output = render(locals)
25
- @html_document = nil
26
-
27
- if block_given?
28
- classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class]
29
- assert_select("div.#{classname}", 1, 'no main DIV', &block)
30
- end
31
-
32
- @render_output
33
- end
34
-
35
- def parse_html_document(html)
36
- Nokogiri::HTML::Document.parse(html)
37
- end
38
-
39
- def html_document
40
- @html_document ||= parse_html_document(@render_output)
41
- end
42
-
43
- def document_root_element
44
- html_document.root
45
- end
46
-
47
- def response_from_page_or_rjs
48
- html_document.root
49
- end
50
-
51
- def validate_page_numbers(expected, links, param_name = :page)
52
- param_pattern = /\W#{Regexp.escape(param_name.to_s)}=([^&]*)/
53
-
54
- links.map { |el|
55
- unescape_href(el) =~ param_pattern
56
- $1 ? $1.to_i : $1
57
- }.should == expected
58
- end
59
-
60
- def assert_links_match(pattern, links = nil, numbers = nil)
61
- links ||= assert_select 'div.pagination a[href]' do |elements|
62
- elements
63
- end
64
-
65
- pages = [] if numbers
66
-
67
- links.each do |el|
68
- href = unescape_href(el)
69
- href.should =~ pattern
70
- if numbers
71
- href =~ pattern
72
- pages << ($1.nil?? nil : $1.to_i)
73
- end
74
- end
75
-
76
- pages.should == numbers if numbers
77
- end
78
-
79
- def assert_no_links_match(pattern)
80
- assert_select 'div.pagination a[href]' do |elements|
81
- elements.each do |el|
82
- unescape_href(el).should_not =~ pattern
83
- end
84
- end
85
- end
86
-
87
- def unescape_href(el)
88
- CGI.unescape CGI.unescapeHTML(el['href'])
89
- end
90
-
91
- def build_message(message, pattern, *args)
92
- built_message = pattern.dup
93
- for value in args
94
- built_message.sub! '?', value.inspect
95
- end
96
- built_message
97
- end
98
-
99
- end
100
-
101
- RSpec.configure do |config|
102
- config.include ViewExampleGroup, :type => :view, :example_group => {
103
- :file_path => %r{spec/view_helpers/}
104
- }
105
- end