Methods
public instance
protected instance
Included modules
- ActionController::TestCase::Assertions
- ActiveSupport::Testing::Deprecation
Public instance methods
setup
()
[show source]
# File test/lib/view_test_process.rb, line 28 def setup super @controller = DummyController.new @request = @controller.request @html_result = nil @template = '<%= will_paginate collection, options %>' @view = ActionView::Base.new @view.assigns['controller'] = @controller @view.assigns['_request'] = @request @view.assigns['_params'] = @request.params end
test_no_complain
()
[show source]
# File test/lib/view_test_process.rb, line 41 def test_no_complain; end
Protected instance methods
assert_links_match
(pattern, links = nil, numbers = nil)
[show source]
# File test/lib/view_test_process.rb, line 89 def assert_links_match pattern, links = nil, numbers = nil links ||= assert_select 'div.pagination a[href]' do |elements| elements end pages = [] if numbers links.each do |el| assert_match pattern, el['href'] if numbers el['href'] =~ pattern pages << ($1.nil?? nil : $1.to_i) end end assert_equal numbers, pages, "page numbers don't match" if numbers end
assert_no_links_match
(pattern)
[show source]
# File test/lib/view_test_process.rb, line 107 def assert_no_links_match pattern assert_select 'div.pagination a[href]' do |elements| elements.each do |el| assert_no_match pattern, el['href'] end end end
paginate
(collection = {}, options = {}, &block)
[show source]
# File test/lib/view_test_process.rb, line 45 def paginate(collection = {}, options = {}, &block) if collection.instance_of? Hash page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection) collection = [1].paginate(page_options) end locals = { :collection => collection, :options => options } unless @view.respond_to? :render_template # Rails 2.2 @html_result = ActionView::InlineTemplate.new(@template).render(@view, locals) else if defined? ActionView::InlineTemplate # Rails 2.1 args = [ ActionView::InlineTemplate.new(@view, @template, locals) ] else # older Rails versions args = [nil, @template, nil, locals] end @html_result = @view.render_template(*args) end @html_document = HTML::Document.new(@html_result, true, false) if block_given? classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class] assert_select("div.#{classname}", 1, 'no main DIV', &block) end end
response_from_page_or_rjs
()
[show source]
# File test/lib/view_test_process.rb, line 76 def response_from_page_or_rjs @html_document.root end
validate_page_numbers
(expected, links, param_name = :page)
[show source]
# File test/lib/view_test_process.rb, line 80 def validate_page_numbers expected, links, param_name = :page param_pattern = /\W#{CGI.escape(param_name.to_s)}=([^&]*)/ assert_equal(expected, links.map { |e| e['href'] =~ param_pattern $1 ? $1.to_i : $1 }) end