Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Register helper and view tests for minitest's spec DSL

  • Loading branch information...
commit 1949d1f6b29bd374e7e1cb015ec85ee78e52361a 1 parent 58434e0
@blowmage blowmage authored
View
3  actionpack/lib/action_view/test_case.rb
@@ -30,6 +30,9 @@ def initialize
end
end
+ # Use AV::TestCase for the base class for helpers and views
+ register_spec_type(/(Helper|View)( ?Test)?\z/i, self)
+
module Behavior
extend ActiveSupport::Concern
View
39 actionpack/test/template/spec_type_test.rb
@@ -0,0 +1,39 @@
+require 'abstract_unit'
+
+class SpecTypeTest < ActiveSupport::TestCase
+ def assert_view actual
+ assert_equal ActionView::TestCase, actual
+ end
+
+ def refute_view actual
+ refute_equal ActionView::TestCase, actual
+ end
+
+ def test_spec_type_resolves_for_matching_helper_strings
+ assert_view MiniTest::Spec.spec_type("WidgetHelper")
+ assert_view MiniTest::Spec.spec_type("WidgetHelperTest")
+ assert_view MiniTest::Spec.spec_type("Widget Helper Test")
+ # And is not case sensitive
+ assert_view MiniTest::Spec.spec_type("widgethelper")
+ assert_view MiniTest::Spec.spec_type("widgethelpertest")
+ assert_view MiniTest::Spec.spec_type("widget helper test")
+ end
+
+ def test_spec_type_resolves_for_matching_view_strings
+ assert_view MiniTest::Spec.spec_type("WidgetView")
+ assert_view MiniTest::Spec.spec_type("WidgetViewTest")
+ assert_view MiniTest::Spec.spec_type("Widget View Test")
+ # And is not case sensitive
+ assert_view MiniTest::Spec.spec_type("widgetview")
+ assert_view MiniTest::Spec.spec_type("widgetviewtest")
+ assert_view MiniTest::Spec.spec_type("widget view test")
+ end
+
+ def test_spec_type_wont_match_non_space_characters
+ refute_view MiniTest::Spec.spec_type("Widget Helper\tTest")
+ refute_view MiniTest::Spec.spec_type("Widget Helper\rTest")
+ refute_view MiniTest::Spec.spec_type("Widget Helper\nTest")
+ refute_view MiniTest::Spec.spec_type("Widget Helper\fTest")
+ refute_view MiniTest::Spec.spec_type("Widget HelperXTest")
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.