Permalink
Browse files

normalize arg for ActionView::TestCase tests method

  • Loading branch information...
1 parent 0defbc6 commit 8df7fe3f630e13da1585c151f6f2f986ea7dcdfd @avakhov avakhov committed Oct 3, 2011
Showing with 22 additions and 1 deletion.
  1. +6 −1 actionpack/lib/action_view/test_case.rb
  2. +16 −0 actionpack/test/template/test_test.rb
@@ -50,7 +50,12 @@ module Behavior
module ClassMethods
def tests(helper_class)
- self.helper_class = 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
def determine_default_helper_class(name)
@@ -62,3 +62,19 @@ def test_helper_class_can_be_set_manually_not_just_inferred
assert_equal PeopleHelper, self.class.helper_class
end
end
+
+class CrazySymbolHelperTest < ActionView::TestCase
+ tests :people
+
+ def test_set_helper_class_using_symbol
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+end
+
+class CrazyStringHelperTest < ActionView::TestCase
+ tests 'people'
+
+ def test_set_helper_class_using_string
+ assert_equal PeopleHelper, self.class.helper_class
+ end
+end

0 comments on commit 8df7fe3

Please sign in to comment.