Module: ActionView::TestCase::Behavior::ClassMethods

Defined in:
actionview/lib/action_view/test_case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#helper_classObject



92
93
94
# File 'actionview/lib/action_view/test_case.rb', line 92

def helper_class
  @helper_class ||= determine_default_helper_class(name)
end

Instance Method Details

#determine_default_helper_class(name) ⇒ Object



72
73
74
75
76
# File 'actionview/lib/action_view/test_case.rb', line 72

def determine_default_helper_class(name)
  determine_constant_from_test_name(name) do |constant|
    Module === constant && !(Class === constant)
  end
end

#helper_method(*methods) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'actionview/lib/action_view/test_case.rb', line 78

def helper_method(*methods)
  # Almost a duplicate from ActionController::Helpers
  methods.flatten.each do |method|
    _helpers_for_modification.module_eval <<~end_eval, __FILE__, __LINE__ + 1
      def #{method}(*args, &block)                    # def current_user(*args, &block)
        _test_case.send(:'#{method}', *args, &block)  #   _test_case.send(:'current_user', *args, &block)
      end                                             # end
      ruby2_keywords(:'#{method}')
    end_eval
  end
end

#newObject



96
97
98
99
# File 'actionview/lib/action_view/test_case.rb', line 96

def new(*)
  include_helper_modules!
  super
end

#tests(helper_class) ⇒ Object



63
64
65
66
67
68
69
70
# File 'actionview/lib/action_view/test_case.rb', line 63

def tests(helper_class)
  case helper_class
  when String, Symbol
    self.helper_class = "#{helper_class.to_s.underscore}_helper".camelize.safe_constantize
  when Module
    self.helper_class = helper_class
  end
end