aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/test_case.rb42
-rw-r--r--activesupport/lib/active_support/testing/autorun.rb5
-rw-r--r--activesupport/lib/active_support/testing/declarative.rb40
-rw-r--r--activesupport/test/abstract_unit.rb2
-rw-r--r--activesupport/test/core_ext/thread_test.rb4
-rw-r--r--activesupport/test/spec_type_test.rb22
-rw-r--r--activesupport/test/string_inquirer_test.rb2
-rw-r--r--activesupport/test/ts_isolated.rb2
8 files changed, 64 insertions, 55 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index e4f182a3aa..8b392c36d0 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -1,10 +1,11 @@
gem 'minitest' # make sure we get the gem, not stdlib
-require 'minitest/spec'
+require 'minitest/unit'
require 'active_support/testing/tagged_logging'
require 'active_support/testing/setup_and_teardown'
require 'active_support/testing/assertions'
require 'active_support/testing/deprecation'
require 'active_support/testing/pending'
+require 'active_support/testing/declarative'
require 'active_support/testing/isolation'
require 'active_support/testing/constant_lookup'
require 'active_support/core_ext/kernel/reporting'
@@ -16,13 +17,7 @@ rescue LoadError
end
module ActiveSupport
- class TestCase < ::MiniTest::Spec
-
- # Use AS::TestCase for the base class when describing a model
- register_spec_type(self) do |desc|
- Class === desc && desc < ActiveRecord::Base
- end
-
+ class TestCase < ::MiniTest::Unit::TestCase
Assertion = MiniTest::Assertion
alias_method :method_name, :__name__
@@ -42,31 +37,22 @@ module ActiveSupport
include ActiveSupport::Testing::Assertions
include ActiveSupport::Testing::Deprecation
include ActiveSupport::Testing::Pending
-
- def self.describe(text)
- if block_given?
- super
- else
- message = "`describe` without a block is deprecated, please switch to: `def self.name; #{text.inspect}; end`\n"
- ActiveSupport::Deprecation.warn message
-
- class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
- def self.name
- "#{text}"
- end
- RUBY_EVAL
- end
- end
-
- class << self
- alias :test :it
- end
+ extend ActiveSupport::Testing::Declarative
# test/unit backwards compatibility methods
alias :assert_raise :assert_raises
- alias :assert_not_nil :refute_nil
+ alias :assert_not_empty :refute_empty
alias :assert_not_equal :refute_equal
+ alias :assert_not_in_delta :refute_in_delta
+ alias :assert_not_in_epsilon :refute_in_epsilon
+ alias :assert_not_includes :refute_includes
+ alias :assert_not_instance_of :refute_instance_of
+ alias :assert_not_kind_of :refute_kind_of
alias :assert_no_match :refute_match
+ alias :assert_not_nil :refute_nil
+ alias :assert_not_operator :refute_operator
+ alias :assert_not_predicate :refute_predicate
+ alias :assert_not_respond_to :refute_respond_to
alias :assert_not_same :refute_same
# Fails if the block raises an exception.
diff --git a/activesupport/lib/active_support/testing/autorun.rb b/activesupport/lib/active_support/testing/autorun.rb
new file mode 100644
index 0000000000..c446adc16d
--- /dev/null
+++ b/activesupport/lib/active_support/testing/autorun.rb
@@ -0,0 +1,5 @@
+gem 'minitest'
+
+require 'minitest/unit'
+
+MiniTest::Unit.autorun
diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb
new file mode 100644
index 0000000000..508e37254a
--- /dev/null
+++ b/activesupport/lib/active_support/testing/declarative.rb
@@ -0,0 +1,40 @@
+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
+
+ unless defined?(Spec)
+ # test "verify something" do
+ # ...
+ # end
+ def test(name, &block)
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
+ defined = instance_method(test_name) rescue false
+ raise "#{test_name} is already defined in #{self}" if defined
+ if block_given?
+ define_method(test_name, &block)
+ else
+ define_method(test_name) do
+ flunk "No implementation provided for #{name}"
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb
index 8a67b148c3..90e50f235b 100644
--- a/activesupport/test/abstract_unit.rb
+++ b/activesupport/test/abstract_unit.rb
@@ -15,7 +15,7 @@ silence_warnings do
Encoding.default_external = "UTF-8"
end
-require 'minitest/autorun'
+require 'active_support/testing/autorun'
require 'empty_bool'
ENV['NO_RELOAD'] = '1'
diff --git a/activesupport/test/core_ext/thread_test.rb b/activesupport/test/core_ext/thread_test.rb
index b58f59a8d4..230c1203ad 100644
--- a/activesupport/test/core_ext/thread_test.rb
+++ b/activesupport/test/core_ext/thread_test.rb
@@ -39,14 +39,14 @@ class ThreadExt < ActiveSupport::TestCase
end
def test_thread_variable?
- refute Thread.new { Thread.current.thread_variable?("foo") }.join.value
+ assert_not Thread.new { Thread.current.thread_variable?("foo") }.join.value
t = Thread.new {
Thread.current.thread_variable_set("foo", "bar")
}.join
assert t.thread_variable?("foo")
assert t.thread_variable?(:foo)
- refute t.thread_variable?(:bar)
+ assert_not t.thread_variable?(:bar)
end
def test_thread_variable_strings_and_symbols_are_the_same_key
diff --git a/activesupport/test/spec_type_test.rb b/activesupport/test/spec_type_test.rb
deleted file mode 100644
index 9a6cb4ded2..0000000000
--- a/activesupport/test/spec_type_test.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require "abstract_unit"
-require "active_record"
-
-class SomeRandomModel < ActiveRecord::Base; end
-
-class SpecTypeTest < ActiveSupport::TestCase
- def assert_support actual
- assert_equal ActiveSupport::TestCase, actual
- end
-
- def assert_spec actual
- assert_equal MiniTest::Spec, actual
- end
-
- def test_spec_type_resolves_for_active_record_constants
- assert_support MiniTest::Spec.spec_type(SomeRandomModel)
- end
-
- def test_spec_type_doesnt_resolve_random_strings
- assert_spec MiniTest::Spec.spec_type("Unmatched String")
- end
-end
diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb
index 94d5fe197d..a2ed577eb0 100644
--- a/activesupport/test/string_inquirer_test.rb
+++ b/activesupport/test/string_inquirer_test.rb
@@ -10,7 +10,7 @@ class StringInquirerTest < ActiveSupport::TestCase
end
def test_miss
- refute @string_inquirer.development?
+ assert_not @string_inquirer.development?
end
def test_missing_question_mark
diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb
index 2c217157d3..294d6595f7 100644
--- a/activesupport/test/ts_isolated.rb
+++ b/activesupport/test/ts_isolated.rb
@@ -1,4 +1,4 @@
-require 'minitest/autorun'
+require 'active_support/testing/autorun'
require 'active_support/test_case'
require 'rbconfig'
require 'active_support/core_ext/kernel/reporting'