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

Defined in:
lib/action_view/test_case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#helper_classObject



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

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

Instance Method Details

#determine_default_helper_class(name) ⇒ Object



53
54
55
56
57
58
# File 'lib/action_view/test_case.rb', line 53

def determine_default_helper_class(name)
  mod = name.sub(/Test$/, '').constantize
  mod.is_a?(Class) ? nil : mod
rescue NameError
  nil
end

#helper_method(*methods) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/action_view/test_case.rb', line 60

def helper_method(*methods)
  # Almost a duplicate from ActionController::Helpers
  methods.flatten.each do |method|
    _helpers.module_eval <<-end_eval
      def #{method}(*args, &block)                    # def current_user(*args, &block)
        _test_case.send(%(#{method}), *args, &block)  #   test_case.send(%(current_user), *args, &block)
      end                                             # end
    end_eval
  end
end

#newObject



77
78
79
80
# File 'lib/action_view/test_case.rb', line 77

def new(*)
  include_helper_modules!
  super
end

#tests(helper_class) ⇒ Object



49
50
51
# File 'lib/action_view/test_case.rb', line 49

def tests(helper_class)
  self.helper_class = helper_class
end