Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from kamui/gemspec

Fix nested describe blocks and incorrect controller_name in Controller specs
  • Loading branch information...
commit b8997a7044b41d4c372b7a071927f376864b8104 2 parents 6396a48 + ca2fa10
@rawongithub authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/minitest/rails/controller.rb
View
12 lib/minitest/rails/controller.rb
@@ -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.