aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/spec_type_test.rb
diff options
context:
space:
mode:
authorMike Moore <mike@blowmage.com>2012-09-24 14:18:58 -0600
committerMike Moore <mike@blowmage.com>2012-09-24 14:21:47 -0600
commitb2e5db9c719bcbddc4777c31df6220e8d0a8c307 (patch)
tree4be1c2d91bf333642038610d5d6c8ec306c5f64d /actionpack/test/controller/spec_type_test.rb
parentfdc11fd01a4cc4f5580bf9e5a782f2a97c8442f7 (diff)
downloadrails-b2e5db9c719bcbddc4777c31df6220e8d0a8c307.tar.gz
rails-b2e5db9c719bcbddc4777c31df6220e8d0a8c307.tar.bz2
rails-b2e5db9c719bcbddc4777c31df6220e8d0a8c307.zip
Allow strings in the controller test describe blocks
Allow controller tests using the spec DSL to match strings. Add test coverage for the register_spec_type calls.
Diffstat (limited to 'actionpack/test/controller/spec_type_test.rb')
-rw-r--r--actionpack/test/controller/spec_type_test.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/actionpack/test/controller/spec_type_test.rb b/actionpack/test/controller/spec_type_test.rb
new file mode 100644
index 0000000000..caeb0fd4dd
--- /dev/null
+++ b/actionpack/test/controller/spec_type_test.rb
@@ -0,0 +1,37 @@
+require "abstract_unit"
+
+class ApplicationController < ActionController::Base; end
+class ModelsController < ApplicationController; end
+
+class SpecTypeTest < ActiveSupport::TestCase
+ def assert_controller actual
+ assert_equal ActionController::TestCase, actual
+ end
+
+ def refute_controller actual
+ refute_equal ActionController::TestCase, actual
+ end
+
+ def test_spec_type_resolves_for_class_constants
+ assert_controller MiniTest::Spec.spec_type(ApplicationController)
+ assert_controller MiniTest::Spec.spec_type(ModelsController)
+ end
+
+ def test_spec_type_resolves_for_matching_strings
+ assert_controller MiniTest::Spec.spec_type("WidgetController")
+ assert_controller MiniTest::Spec.spec_type("WidgetControllerTest")
+ assert_controller MiniTest::Spec.spec_type("Widget Controller Test")
+ # And is not case sensitive
+ assert_controller MiniTest::Spec.spec_type("widgetcontroller")
+ assert_controller MiniTest::Spec.spec_type("widgetcontrollertest")
+ assert_controller MiniTest::Spec.spec_type("widget controller test")
+ end
+
+ def test_spec_type_wont_match_non_space_characters
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\tTest")
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\rTest")
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\nTest")
+ refute_controller MiniTest::Spec.spec_type("Widget Controller\fTest")
+ refute_controller MiniTest::Spec.spec_type("Widget ControllerXTest")
+ end
+end