deprecate describe without a block.

minitest/spec provides `describe`, so deprecate the rails version and
have people use the superclass version
This commit is contained in:
Aaron Patterson 2012-07-09 13:11:05 -07:00
parent d1c4acc669
commit d481170251
6 changed files with 17 additions and 38 deletions

@ -358,7 +358,7 @@ class TestCase < ActiveSupport::TestCase
# Use AS::TestCase for the base class when describing a model
register_spec_type(self) do |desc|
desc < ActionController::Base
Class === desc && desc < ActionController::Base
end
module Behavior

@ -86,8 +86,6 @@ class RenderLayoutTest < Rack::TestCase
def setup
end
describe "Both <controller_path>.html.erb and application.html.erb are missing"
test "rendering with layout => true" do
assert_raise(ArgumentError) do
get "/render_action/basic/hello_world_with_layout", {}, "action_dispatch.show_exceptions" => false
@ -154,8 +152,6 @@ def with_builder_and_layout
end
class LayoutTest < Rack::TestCase
describe "Only application.html.erb is present and <controller_path>.html.erb is missing"
test "rendering implicit application.html.erb as layout" do
get "/render_action_with_application_layout/basic/hello_world"
@ -232,8 +228,6 @@ def hello_world_with_custom_layout
end
class ControllerLayoutTest < Rack::TestCase
describe "Only <controller_path>.html.erb is present and application.html.erb is missing"
test "render hello_world and implicitly use <controller_path>.html.erb as a layout." do
get "/render_action_with_controller_layout/basic/hello_world"
@ -290,8 +284,6 @@ def hello_world_with_layout_nil
end
class ControllerLayoutTest < Rack::TestCase
describe "Both <controller_path>.html.erb and application.html.erb are present"
test "rendering implicitly use <controller_path>.html.erb over application.html.erb as a layout" do
get "/render_action_with_both_layouts/basic/hello_world"

@ -160,8 +160,6 @@ def with_custom_layout
end
class TestWithLayout < Rack::TestCase
describe "Rendering with :template using implicit or explicit layout"
test "rendering with implicit layout" do
with_routing do |set|
set.draw { get ':controller', :action => :index }

@ -63,8 +63,6 @@ def with_ivar_in_layout
end
class RenderTextTest < Rack::TestCase
describe "Rendering text using render :text"
test "rendering text from an action with default options renders the text with the layout" do
with_routing do |set|
set.draw { get ':controller', :action => 'index' }

@ -3,10 +3,10 @@
require 'active_support/testing/setup_and_teardown'
require 'active_support/testing/assertions'
require 'active_support/testing/deprecation'
require 'active_support/testing/declarative'
require 'active_support/testing/isolation'
require 'active_support/testing/mocha_module'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/deprecation'
module ActiveSupport
class TestCase < ::MiniTest::Spec
@ -15,7 +15,7 @@ class TestCase < ::MiniTest::Spec
# Use AS::TestCase for the base class when describing a model
register_spec_type(self) do |desc|
desc < ActiveRecord::Model
Class === desc && desc < ActiveRecord::Model
end
Assertion = MiniTest::Assertion
@ -35,7 +35,20 @@ def self.test_order # :nodoc:
include ActiveSupport::Testing::SetupAndTeardown
include ActiveSupport::Testing::Assertions
include ActiveSupport::Testing::Deprecation
extend ActiveSupport::Testing::Declarative
def self.describe(text)
if block_given?
super
else
ActiveSupport::Deprecation.warn("`describe` without a block is deprecated, please switch to: `def self.name; #{text.inspect}; end`\n")
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def self.name
"#{text}"
end
RUBY_EVAL
end
end
class << self
alias :test :it

@ -1,22 +0,0 @@
module ActiveSupport
module Testing
module Declarative
def self.extended(klass) #:nodoc:
klass.class_eval do
unless method_defined?(:describe)
def self.describe(text)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def self.name
"#{text}"
end
RUBY_EVAL
end
end
end
end
end
end
end