Permalink
Browse files

+ Runnable#run needs to return self. Allows for swapping of results a…

…s needed.

[git-p4: depot-paths = "//src/minitest/dev/": change = 8495]
  • Loading branch information...
1 parent efd8c1e commit 6ba22983c931aba65cae410386384e74d37b38c6 @zenspider zenspider committed May 4, 2013
Showing with 14 additions and 3 deletions.
  1. +10 −3 lib/minitest.rb
  2. +2 −0 lib/minitest/test.rb
  3. +2 −0 test/minitest/test_minitest_unit.rb
View
@@ -255,9 +255,9 @@ def self.run reporter, options = {}
}
filtered_methods.each do |method_name|
- runnable = self.new(method_name)
- runnable.run
- reporter.record runnable
+ result = self.new(method_name).run
+ raise "#{self}#run _must_ return self" unless self === result
+ reporter.record result
end
end
@@ -296,6 +296,13 @@ def initialize name # :nodoc:
self.assertions = 0
end
+ ##
+ # Runs a single method. Needs to return self.
+
+ def run
+ raise NotImplementedError, "subclass responsibility"
+ end
+
##
# Did this run pass?
#
View
@@ -112,6 +112,8 @@ def run
end
end
end
+
+ self # per contract
end
##
@@ -162,6 +162,8 @@ def run
@foo = "hi mom!"
super
@foo = "okay"
+
+ self # per contract
end
def test_something

0 comments on commit 6ba2298

Please sign in to comment.