Permalink
Browse files

+ Holy crap! 100% doco! `rdoc -C` ftw

[git-p4: depot-paths = "//src/minitest/dev/": change = 6786]
  • Loading branch information...
1 parent b4f5b5d commit 1b844218d7eaa82314178bfab2e287f84b2d5221 @zenspider zenspider committed Dec 7, 2011
Showing with 84 additions and 17 deletions.
  1. +5 −0 lib/hoe/minitest.rb
  2. +10 −3 lib/minitest/benchmark.rb
  3. +2 −1 lib/minitest/mock.rb
  4. +25 −6 lib/minitest/pride.rb
  5. +13 −1 lib/minitest/spec.rb
  6. +29 −6 lib/minitest/unit.rb
View
@@ -1,3 +1,8 @@
+# :stopdoc:
+
+class Hoe
+end
+
module Hoe::Minitest
def initialize_minitest
gem "minitest"
View
@@ -1,9 +1,7 @@
require 'minitest/unit'
require 'minitest/spec'
-class MiniTest::Unit
- attr_accessor :runner
-
+class MiniTest::Unit # :nodoc:
def run_benchmarks # :nodoc:
_run_anything :benchmark
end
@@ -312,6 +310,15 @@ def self.bench name, &block
define_method "bench_#{name.gsub(/\W+/, '_')}", &block
end
+ ##
+ # Specifies the ranges used for benchmarking for that class.
+ #
+ # bench_range do
+ # bench_exp(2, 16, 2)
+ # end
+ #
+ # See Unit::TestCase.bench_range for more details.
+
def self.bench_range &block
return super unless block
View
@@ -1,4 +1,5 @@
-class MockExpectationError < StandardError; end
+class MockExpectationError < StandardError # :nodoc:
+end # omg... worst bug ever. rdoc doesn't allow 1-liners
##
# A simple and clean mock object framework.
View
@@ -4,12 +4,17 @@
# Show your testing pride!
class PrideIO
+
+ # Start an escape sequence
ESC = "\e["
+
+ # End the escape sequence
NND = "#{ESC}0m"
+ # The IO we're going to pipe through.
attr_reader :io
- def initialize io
+ def initialize io # :nodoc:
@io = io
# stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
# also reference http://en.wikipedia.org/wiki/ANSI_escape_code
@@ -19,6 +24,9 @@ def initialize io
# io.sync = true
end
+ ##
+ # Wrap print to colorize the output.
+
def print o
case o
when "." then
@@ -30,7 +38,7 @@ def print o
end
end
- def puts(*o)
+ def puts(*o) # :nodoc:
o.map! { |s|
s.sub(/Finished tests/) {
@index = 0
@@ -43,22 +51,30 @@ def puts(*o)
super
end
+ ##
+ # Color a string.
+
def pride string
string = "*" if string == "."
c = @colors[@index % @size]
@index += 1
"#{ESC}#{c}m#{string}#{NND}"
end
- def method_missing msg, *args
+ def method_missing msg, *args # :nodoc:
io.send(msg, *args)
end
end
-class PrideLOL < PrideIO # inspired by lolcat, but massively cleaned up
- PI_3 = Math::PI / 3
+##
+# If you thought the PrideIO was colorful...
+#
+# (Inspired by lolcat, but with clean math)
+
+class PrideLOL < PrideIO
+ PI_3 = Math::PI / 3 # :nodoc:
- def initialize io
+ def initialize io # :nodoc:
# walk red, green, and blue around a circle separated by equal thirds.
#
# To visualize, type this into wolfram-alpha:
@@ -82,6 +98,9 @@ def initialize io
super
end
+ ##
+ # Make the string even more colorful. Damnit.
+
def pride string
c = @colors[@index % @size]
@index += 1
View
@@ -197,13 +197,22 @@ def self.it desc = "anonymous", &block
end
end
+ ##
+ # Essentially, define an accessor for +name+ with +block+.
+ #
+ # Why use let instead of def? I honestly don't know.
+
def self.let name, &block
define_method name do
@_memoized ||= {}
@_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
end
end
+ ##
+ # Another lazy man's accessor generator. Made even more lazy by
+ # setting the name for you to +subject+.
+
def self.subject &block
let :subject, &block
end
@@ -234,6 +243,9 @@ class << self
# :startdoc:
end
+##
+# It's where you hide your "assertions".
+
module MiniTest::Expectations
##
# See MiniTest::Assertions#assert_empty.
@@ -511,6 +523,6 @@ module MiniTest::Expectations
infect_an_assertion :refute_same, :wont_be_same_as
end
-class Object
+class Object # :nodoc:
include MiniTest::Expectations
end
View
@@ -55,8 +55,13 @@ def self.filter_backtrace bt # :nodoc:
# printed if the assertion fails.
module Assertions
+ UNDEFINED = Object.new # :nodoc:
- WINDOZE = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
+ def UNDEFINED.inspect # :nodoc:
+ "UNDEFINED" # again with the rdoc bugs... :(
+ end
+
+ WINDOZE = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ # :nodoc:
##
# Returns the diff command to use in #diff. Tries to intelligently
@@ -281,9 +286,6 @@ def assert_nil obj, msg = nil
assert obj.nil?, msg
end
- UNDEFINED = Object.new
- def UNDEFINED.inspect; "UNDEFINED"; end
-
##
# For testing with binary operators.
#
@@ -640,7 +642,7 @@ def skip msg = nil, bt = caller
end
end
- class Unit
+ class Unit # :nodoc:
VERSION = "2.8.1" # :nodoc:
attr_accessor :report, :failures, :errors, :skips # :nodoc:
@@ -650,6 +652,9 @@ class Unit
attr_accessor :verbose # :nodoc:
attr_writer :options # :nodoc:
+ ##
+ # Lazy accessor for options.
+
def options
@options ||= {}
end
@@ -738,6 +743,9 @@ def self.plugins
grep(/^run_/).map { |s| s.to_s }).uniq
end
+ ##
+ # Return the IO for output.
+
def output
self.class.output
end
@@ -750,6 +758,9 @@ def print *a # :nodoc:
output.print(*a)
end
+ ##
+ # Runner for a given +type+ (eg, test vs bench).
+
def _run_anything type
suites = TestCase.send "#{type}_suites"
return if suites.empty?
@@ -787,10 +798,16 @@ def _run_anything type
status
end
+ ##
+ # Runs all the +suites+ for a given +type+.
+
def _run_suites suites, type
suites.map { |suite| _run_suite suite, type }
end
+ ##
+ # Run a single +suite+ for a given +type+.
+
def _run_suite suite, type
header = "#{type}_suite_header"
puts send(header, suite) if respond_to? header
@@ -855,7 +872,7 @@ def initialize # :nodoc:
@verbose = false
end
- def process_args args = []
+ def process_args args = [] # :nodoc:
options = {}
orig_args = args.dup
@@ -1051,11 +1068,17 @@ def self.current # :nodoc:
@@current
end
+ ##
+ # Return the output IO object
+
def io
@__io__ = true
MiniTest::Unit.output
end
+ ##
+ # Have we hooked up the IO yet?
+
def io?
@__io__
end

0 comments on commit 1b84421

Please sign in to comment.