aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2011-03-31 12:25:04 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2011-03-31 12:25:04 -0700
commit6eff04499e28865890e1ae3915fe80e4903a997b (patch)
treecd4f7cd98519a3bdc7ec5665f0aec7133e0dba10
parentedf7c9a6a3331bfc0beabc9dc9c8beac22677e53 (diff)
downloadrails-6eff04499e28865890e1ae3915fe80e4903a997b.tar.gz
rails-6eff04499e28865890e1ae3915fe80e4903a997b.tar.bz2
rails-6eff04499e28865890e1ae3915fe80e4903a997b.zip
Add using Turn with natural language test case names if the library is available (which it will be in Rails 3.1) [DHH]
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/test_case.rb19
-rw-r--r--activesupport/lib/active_support/testing/mochaing.rb7
-rw-r--r--activesupport/lib/active_support/testing/turn_formatting.rb33
4 files changed, 44 insertions, 17 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 373236ce9a..1be5f39ac4 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.1.0 (unreleased)*
+* Add using Turn with natural language test case names if the library is available (which it will be in Rails 3.1) [DHH]
+
* LocalCache strategy is now a real middleware class, not an anonymous class
posing for pictures.
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index d25b092fb4..7ac9ad46e9 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -5,25 +5,10 @@ require 'active_support/testing/deprecation'
require 'active_support/testing/declarative'
require 'active_support/testing/pending'
require 'active_support/testing/isolation'
+require 'active_support/testing/turn_formatting'
+require 'active_support/testing/mochaing'
require 'active_support/core_ext/kernel/reporting'
-begin
- silence_warnings { require 'mocha' }
-rescue LoadError
- # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh.
- Object.const_set :Mocha, Module.new
- Mocha.const_set :ExpectationError, Class.new(StandardError)
-end
-
-# Added by Turn to support natural case names in the output formatting
-if defined?(MiniTest)
- require 'turn'
-
- if MiniTest::Unit.respond_to?(:use_natural_language_case_names=)
- MiniTest::Unit.use_natural_language_case_names = true
- end
-end
-
module ActiveSupport
class TestCase < ::Test::Unit::TestCase
if defined? MiniTest
diff --git a/activesupport/lib/active_support/testing/mochaing.rb b/activesupport/lib/active_support/testing/mochaing.rb
new file mode 100644
index 0000000000..4ad75a6681
--- /dev/null
+++ b/activesupport/lib/active_support/testing/mochaing.rb
@@ -0,0 +1,7 @@
+begin
+ silence_warnings { require 'mocha' }
+rescue LoadError
+ # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh.
+ Object.const_set :Mocha, Module.new
+ Mocha.const_set :ExpectationError, Class.new(StandardError)
+end \ No newline at end of file
diff --git a/activesupport/lib/active_support/testing/turn_formatting.rb b/activesupport/lib/active_support/testing/turn_formatting.rb
new file mode 100644
index 0000000000..ed9381e298
--- /dev/null
+++ b/activesupport/lib/active_support/testing/turn_formatting.rb
@@ -0,0 +1,33 @@
+# Turn gives you prettier formatting for MiniTest and inline failure reporting.
+# It also allows us to report test cases in natural language rather than with underscores. Example:
+#
+# CommentsControllerTest:
+# PASS the truth (0.03s)
+#
+# APITest
+# test_api_without_subdomain PASS
+# test_create_milestone_using_typed_xml FAIL
+# /test/integration/api_test.rb:50:in `test_create_milestone_using_typed_xml'
+# <2006-05-01> expected but was
+# <Mon May 01 07:00:00 UTC 2006>.
+# test_create_milestone_using_untyped_xml FAIL
+# /test/integration/api_test.rb:38:in `test_create_milestone_using_untyped_xml'
+# <2006-05-01> expected but was
+# <Mon May 01 07:00:00 UTC 2006>.
+
+#
+# vs:
+#
+# .FF
+
+if defined?(MiniTest)
+ begin
+ silence_warnings { require 'turn' }
+
+ if MiniTest::Unit.respond_to?(:use_natural_language_case_names=)
+ MiniTest::Unit.use_natural_language_case_names = true
+ end
+ rescue LoadError
+ # If there's no turn, that's fine, it's just formatting
+ end
+end \ No newline at end of file