Class: Test::Rails::HelperTestCase

Inherits:
FunctionalTestCase show all
Includes:
ActionView::Helpers::ActiveRecordHelper, ActionView::Helpers::AssetTagHelper, ActionView::Helpers::FormHelper, ActionView::Helpers::FormOptionsHelper, ActionView::Helpers::FormTagHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::UrlHelper
Defined in:
lib/test/rails/helper_test_case.rb

Overview

HelperTestCase allows helpers to be easily tested.

Original concept by Ryan Davis, original implementation by Geoff Grosenbach.

Instance Attribute Summary

Attributes inherited from FunctionalTestCase

#flash, #session

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(helper_testcase) ⇒ Object

Automatically includes the helper module into the test sublcass.



41
42
43
44
45
46
47
48
# File 'lib/test/rails/helper_test_case.rb', line 41

def self.inherited(helper_testcase)
  super
  helper_name = helper_testcase.name.sub 'Test', ''
  helper_module = Object.path2class helper_name
  helper_testcase.send :include, helper_module
rescue NameError
  raise "Unable to find helper #{helper_name}"
end

Instance Method Details

#setupObject



50
51
52
53
54
55
56
57
58
# File 'lib/test/rails/helper_test_case.rb', line 50

def setup
  return if self.class.name =~ /TestCase$/
  @controller_class_name = 'HelperTestCaseController'
  super
  @controller.request = @request
  @controller.url = ActionController::UrlRewriter.new @request, {} # url_for
  
  ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
end