Skip to content

Commit

Permalink
deprecate describe without a block.
Browse files Browse the repository at this point in the history
minitest/spec provides `describe`, so deprecate the rails version and
have people use the superclass version
  • Loading branch information
tenderlove committed Jul 9, 2012
1 parent d1c4acc commit d481170
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 38 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/test_case.rb
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions actionpack/test/controller/new_base/render_action_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions actionpack/test/controller/new_base/render_template_test.rb
Expand Up @@ -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 }
Expand Down
2 changes: 0 additions & 2 deletions actionpack/test/controller/new_base/render_text_test.rb
Expand Up @@ -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' }
Expand Down
19 changes: 16 additions & 3 deletions activesupport/lib/active_support/test_case.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
22 changes: 0 additions & 22 deletions activesupport/lib/active_support/testing/declarative.rb

This file was deleted.

0 comments on commit d481170

Please sign in to comment.