Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created March 9, 2013 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/5125688 to your computer and use it in GitHub Desktop.
Save metaskills/5125688 to your computer and use it in GitHub Desktop.
diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb
index 8d8df55..6e005e0 100644
--- a/lib/minitest/spec.rb
+++ b/lib/minitest/spec.rb
@@ -243,13 +243,16 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
end
def to_s # :nodoc:
- defined?(@name) ? @name : (super rescue "dunno") # rescue is a 1.8 oddity
+ defined?(@name) ? @name : super
+ end
+
+ def name # :nodoc:
+ defined?(@name) ? @name : super
end
# :stopdoc:
attr_reader :desc
alias :specify :it
- alias :name :to_s
# :startdoc:
end
diff --git a/test/minitest/test_minitest_spec.rb b/test/minitest/test_minitest_spec.rb
index 3b18359..57718c8 100755
--- a/test/minitest/test_minitest_spec.rb
+++ b/test/minitest/test_minitest_spec.rb
@@ -6,6 +6,8 @@ class MiniSpecA < MiniTest::Spec; end
class MiniSpecB < MiniTest::Spec; end
class ExampleA; end
class ExampleB < ExampleA; end
+class DslExampleA; extend MiniTest::Spec::DSL; end
+class DslExampleB < DslExampleA; end
describe MiniTest::Spec do
# do not parallelize this suite... it just can"t handle it.
@@ -658,6 +660,11 @@ class TestMeta < MiniTest::Unit::TestCase
assert_equal "ExampleB::random_method", spec_b.name
end
+ def test_dsl_name
+ assert_equal "DslExampleA", DslExampleA.name
+ assert_equal "DslExampleB", DslExampleB.name
+ end
+
def test_structure
x, y, z, * = util_structure
@blowmage
Copy link

blowmage commented Mar 9, 2013

Why not have name call to_s? Or to_s call name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment