mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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:
parent
d1c4acc669
commit
d481170251
6 changed files with 17 additions and 38 deletions
|
@ -358,7 +358,7 @@ module ActionController
|
||||||
|
|
||||||
# Use AS::TestCase for the base class when describing a model
|
# Use AS::TestCase for the base class when describing a model
|
||||||
register_spec_type(self) do |desc|
|
register_spec_type(self) do |desc|
|
||||||
desc < ActionController::Base
|
Class === desc && desc < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
module Behavior
|
module Behavior
|
||||||
|
|
|
@ -86,8 +86,6 @@ module RenderAction
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Both <controller_path>.html.erb and application.html.erb are missing"
|
|
||||||
|
|
||||||
test "rendering with layout => true" do
|
test "rendering with layout => true" do
|
||||||
assert_raise(ArgumentError) do
|
assert_raise(ArgumentError) do
|
||||||
get "/render_action/basic/hello_world_with_layout", {}, "action_dispatch.show_exceptions" => false
|
get "/render_action/basic/hello_world_with_layout", {}, "action_dispatch.show_exceptions" => false
|
||||||
|
@ -154,8 +152,6 @@ module RenderActionWithApplicationLayout
|
||||||
end
|
end
|
||||||
|
|
||||||
class LayoutTest < Rack::TestCase
|
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
|
test "rendering implicit application.html.erb as layout" do
|
||||||
get "/render_action_with_application_layout/basic/hello_world"
|
get "/render_action_with_application_layout/basic/hello_world"
|
||||||
|
|
||||||
|
@ -232,8 +228,6 @@ module RenderActionWithControllerLayout
|
||||||
end
|
end
|
||||||
|
|
||||||
class ControllerLayoutTest < Rack::TestCase
|
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
|
test "render hello_world and implicitly use <controller_path>.html.erb as a layout." do
|
||||||
get "/render_action_with_controller_layout/basic/hello_world"
|
get "/render_action_with_controller_layout/basic/hello_world"
|
||||||
|
|
||||||
|
@ -290,8 +284,6 @@ module RenderActionWithBothLayouts
|
||||||
end
|
end
|
||||||
|
|
||||||
class ControllerLayoutTest < Rack::TestCase
|
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
|
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"
|
get "/render_action_with_both_layouts/basic/hello_world"
|
||||||
|
|
||||||
|
|
|
@ -160,8 +160,6 @@ module RenderTemplate
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestWithLayout < Rack::TestCase
|
class TestWithLayout < Rack::TestCase
|
||||||
describe "Rendering with :template using implicit or explicit layout"
|
|
||||||
|
|
||||||
test "rendering with implicit layout" do
|
test "rendering with implicit layout" do
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
set.draw { get ':controller', :action => :index }
|
set.draw { get ':controller', :action => :index }
|
||||||
|
|
|
@ -63,8 +63,6 @@ module RenderText
|
||||||
end
|
end
|
||||||
|
|
||||||
class RenderTextTest < Rack::TestCase
|
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
|
test "rendering text from an action with default options renders the text with the layout" do
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
set.draw { get ':controller', :action => 'index' }
|
set.draw { get ':controller', :action => 'index' }
|
||||||
|
|
|
@ -3,10 +3,10 @@ require 'minitest/spec'
|
||||||
require 'active_support/testing/setup_and_teardown'
|
require 'active_support/testing/setup_and_teardown'
|
||||||
require 'active_support/testing/assertions'
|
require 'active_support/testing/assertions'
|
||||||
require 'active_support/testing/deprecation'
|
require 'active_support/testing/deprecation'
|
||||||
require 'active_support/testing/declarative'
|
|
||||||
require 'active_support/testing/isolation'
|
require 'active_support/testing/isolation'
|
||||||
require 'active_support/testing/mocha_module'
|
require 'active_support/testing/mocha_module'
|
||||||
require 'active_support/core_ext/kernel/reporting'
|
require 'active_support/core_ext/kernel/reporting'
|
||||||
|
require 'active_support/deprecation'
|
||||||
|
|
||||||
module ActiveSupport
|
module ActiveSupport
|
||||||
class TestCase < ::MiniTest::Spec
|
class TestCase < ::MiniTest::Spec
|
||||||
|
@ -15,7 +15,7 @@ module ActiveSupport
|
||||||
|
|
||||||
# Use AS::TestCase for the base class when describing a model
|
# Use AS::TestCase for the base class when describing a model
|
||||||
register_spec_type(self) do |desc|
|
register_spec_type(self) do |desc|
|
||||||
desc < ActiveRecord::Model
|
Class === desc && desc < ActiveRecord::Model
|
||||||
end
|
end
|
||||||
|
|
||||||
Assertion = MiniTest::Assertion
|
Assertion = MiniTest::Assertion
|
||||||
|
@ -35,7 +35,20 @@ module ActiveSupport
|
||||||
include ActiveSupport::Testing::SetupAndTeardown
|
include ActiveSupport::Testing::SetupAndTeardown
|
||||||
include ActiveSupport::Testing::Assertions
|
include ActiveSupport::Testing::Assertions
|
||||||
include ActiveSupport::Testing::Deprecation
|
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
|
class << self
|
||||||
alias :test :it
|
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
|
|
Loading…
Reference in a new issue