diff options
author | Mike Moore <mike@blowmage.com> | 2012-09-24 14:18:58 -0600 |
---|---|---|
committer | Mike Moore <mike@blowmage.com> | 2012-09-24 14:21:47 -0600 |
commit | b2e5db9c719bcbddc4777c31df6220e8d0a8c307 (patch) | |
tree | 4be1c2d91bf333642038610d5d6c8ec306c5f64d /actionpack/test | |
parent | fdc11fd01a4cc4f5580bf9e5a782f2a97c8442f7 (diff) | |
download | rails-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')
-rw-r--r-- | actionpack/test/controller/spec_style_test.rb | 92 | ||||
-rw-r--r-- | actionpack/test/controller/spec_type_test.rb | 37 |
2 files changed, 129 insertions, 0 deletions
diff --git a/actionpack/test/controller/spec_style_test.rb b/actionpack/test/controller/spec_style_test.rb index 96c08ac3b1..e118c584ca 100644 --- a/actionpack/test/controller/spec_style_test.rb +++ b/actionpack/test/controller/spec_style_test.rb @@ -37,6 +37,36 @@ describe ApplicationController, "unauthenticated user" do end end +describe "ApplicationControllerTest" do + describe "nested" do + describe "even deeper" do + it "exists" do + assert_kind_of ApplicationController, @controller + end + end + end +end + +describe "ApplicationControllerTest", :index do + describe "nested" do + describe "even deeper" do + it "exists" do + assert_kind_of ApplicationController, @controller + end + end + end +end + +describe "ApplicationControllerTest", "unauthenticated user" do + describe "nested" do + describe "even deeper" do + it "exists" do + assert_kind_of ApplicationController, @controller + end + end + end +end + # ModelsController describe ModelsController do describe "nested" do @@ -68,6 +98,36 @@ describe ModelsController, "unauthenticated user" do end end +describe "ModelsControllerTest" do + describe "nested" do + describe "even deeper" do + it "exists" do + assert_kind_of ModelsController, @controller + end + end + end +end + +describe "ModelsControllerTest", :index do + describe "nested" do + describe "even deeper" do + it "exists" do + assert_kind_of ModelsController, @controller + end + end + end +end + +describe "ModelsControllerTest", "unauthenticated user" do + describe "nested" do + describe "even deeper" do + it "exists" do + assert_kind_of ModelsController, @controller + end + end + end +end + # Nested Admin::WidgetsControllerTest module Admin class WidgetsControllerTest < ActionController::TestCase @@ -114,3 +174,35 @@ describe Admin::WidgetsController, "unauthenticated users" do end end end + +describe "Admin::WidgetsController" do + describe "index" do + it "respond successful" do + assert_kind_of Admin::WidgetsController, @controller + end + end +end + +describe "Admin::WidgetsControllerTest" do + describe "index" do + it "respond successful" do + assert_kind_of Admin::WidgetsController, @controller + end + end +end + +describe "Admin::WidgetsController", "unauthenticated users" do + describe "index" do + it "respond successful" do + assert_kind_of Admin::WidgetsController, @controller + end + end +end + +describe "Admin::WidgetsControllerTest", "unauthenticated users" do + describe "index" do + it "respond successful" do + assert_kind_of Admin::WidgetsController, @controller + end + end +end 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 |