diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-09-25 09:26:42 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-09-25 09:26:42 -0700 |
commit | c96b20f8d985c6fa87a8efda7a4884e3c35e5739 (patch) | |
tree | 4fd35e201d0636a50c398525d81e62b8adba536a /actionpack/test/template | |
parent | a05a079c109ebbafd8112be0044c9d82b4a28d97 (diff) | |
parent | 64f254ccf74242453421d0c495388293dbc06c71 (diff) | |
download | rails-c96b20f8d985c6fa87a8efda7a4884e3c35e5739.tar.gz rails-c96b20f8d985c6fa87a8efda7a4884e3c35e5739.tar.bz2 rails-c96b20f8d985c6fa87a8efda7a4884e3c35e5739.zip |
Merge pull request #7749 from blowmage/minitest
Improve support for minitest's spec DSL
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/spec_type_test.rb | 39 | ||||
-rw-r--r-- | actionpack/test/template/test_case_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/test_test.rb | 56 |
3 files changed, 96 insertions, 1 deletions
diff --git a/actionpack/test/template/spec_type_test.rb b/actionpack/test/template/spec_type_test.rb new file mode 100644 index 0000000000..b35985d5f9 --- /dev/null +++ b/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 diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index 387aafebd4..5265ae6b3a 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -64,7 +64,7 @@ module ActionView assert_equal 'Howdy!', from_another_helper end - test "determine_default_helper_class returns nil if name.sub(/Test$/, '').constantize resolves to a class" do + test "determine_default_helper_class returns nil if the test name constant resolves to a class" do assert_nil self.class.determine_default_helper_class("String") end diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index 108a674d95..e843a1deb4 100644 --- a/actionpack/test/template/test_test.rb +++ b/actionpack/test/template/test_test.rb @@ -78,3 +78,59 @@ class CrazyStringHelperTest < ActionView::TestCase assert_equal PeopleHelper, self.class.helper_class end end + +describe PeopleHelper do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end +end + +describe PeopleHelper, :helper_class do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end +end + +describe PeopleHelper do + describe "even while nested" do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end + end +end + +describe PeopleHelper, :helper_class do + describe "even while nested" do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end + end +end + +describe "PeopleHelper" do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end +end + +describe "PeopleHelperTest" do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end +end + +describe "PeopleHelper" do + describe "even while nested" do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end + end +end + +describe "PeopleHelperTest" do + describe "even while nested" do + it "resolves the right helper_class" do + assert_equal PeopleHelper, self.class.helper_class + end + end +end |