Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Override #determine_default_controller_class in MiniTest::Rails::Cont…

…roller to allow controller class arguments and nested describe blocks
  • Loading branch information...
commit 79386bb3863f8476680eb34ab6be03801f42ea42 1 parent 1e71b9f
Jack Chu kamui authored committed
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/minitest/rails/controller.rb
12 lib/minitest/rails/controller.rb
View
@@ -8,6 +8,17 @@ class Controller < Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActionController::TestCase::Behavior
+ # Rails 3.2 determines the controller class by matching class names that end in Test
+ # This overides the #determine_default_controller_class method to allow you use Controller
+ # class names in your describe argument
+ def self.determine_default_controller_class(name)
+ if name.match(/.*(?:^|::)(\w+Controller)/)
+ $1.safe_constantize
+ else
+ super(name)
+ end
+ end
+
before do
@controller = self.class.name.match(/((.*)Controller)/)[1].constantize.new
@routes = ::Rails.application.routes
@@ -21,4 +32,3 @@ class Controller < Spec
end
MiniTest::Spec.register_spec_type /Controller/, MiniTest::Rails::Controller
-
Please sign in to comment.
Something went wrong with that request. Please try again.