Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move common setup into RDoc::TestCase

  • Loading branch information...
commit e032a36ce817d8a9d22b9ab9ee49c6657c0ff540 1 parent 734550f
@drbrain drbrain authored
Showing with 101 additions and 50 deletions.
  1. +2 −0  lib/rdoc.rb
  2. +12 −0 lib/rdoc/test_case.rb
  3. +2 −0  test/test_attribute_manager.rb
  4. +2 −0  test/test_rdoc_attr.rb
  5. +0 −6 test/test_rdoc_class_module.rb
  6. +2 −0  test/test_rdoc_context_section.rb
  7. +2 −0  test/test_rdoc_encoding.rb
  8. +4 −2 test/test_rdoc_generator_darkfish.rb
  9. +2 −0  test/test_rdoc_generator_markup.rb
  10. +4 −3 test/test_rdoc_generator_ri.rb
  11. +2 −0  test/test_rdoc_markup_attribute_manager.rb
  12. +2 −1  test/test_rdoc_markup_document.rb
  13. +6 −4 test/test_rdoc_markup_formatter.rb
  14. +2 −0  test/test_rdoc_markup_heading.rb
  15. +2 −1  test/test_rdoc_markup_include.rb
  16. +2 −0  test/test_rdoc_markup_indented_paragraph.rb
  17. +2 −1  test/test_rdoc_markup_parser.rb
  18. +2 −2 test/test_rdoc_markup_pre_process.rb
  19. +2 −1  test/test_rdoc_markup_raw.rb
  20. +2 −0  test/test_rdoc_markup_to_label.rb
  21. +0 −1  test/test_rdoc_method_attr.rb
  22. +4 −0 test/test_rdoc_options.rb
  23. +2 −0  test/test_rdoc_parser.rb
  24. +4 −3 test/test_rdoc_parser_c.rb
  25. +4 −3 test/test_rdoc_parser_rd.rb
  26. +4 −0 test/test_rdoc_parser_ruby.rb
  27. +4 −2 test/test_rdoc_parser_simple.rb
  28. +0 −4 test/test_rdoc_rd.rb
  29. +2 −1  test/test_rdoc_rd_block_parser.rb
  30. +2 −0  test/test_rdoc_rd_inline.rb
  31. +2 −1  test/test_rdoc_rd_inline_parser.rb
  32. +1 −1  test/test_rdoc_rdoc.rb
  33. +3 −1 test/test_rdoc_ri_driver.rb
  34. +4 −0 test/test_rdoc_ri_paths.rb
  35. +3 −3 test/test_rdoc_ri_store.rb
  36. +1 −0  test/test_rdoc_rubygems_hook.rb
  37. +1 −1  test/test_rdoc_stats.rb
  38. +2 −0  test/test_rdoc_task.rb
  39. +2 −8 test/xref_test_case.rb
View
2  lib/rdoc.rb
@@ -145,6 +145,8 @@ def self.const_missing const_name # :nodoc:
autoload :RDoc, 'rdoc/rdoc'
+ autoload :TestCase, 'rdoc/test_case'
+
autoload :CrossReference, 'rdoc/cross_reference'
autoload :ERBIO, 'rdoc/erbio'
autoload :Encoding, 'rdoc/encoding'
View
12 lib/rdoc/test_case.rb
@@ -10,5 +10,17 @@
require 'rdoc'
class RDoc::TestCase < MiniTest::Unit::TestCase
+
+ def setup
+ super
+
+ @RM = RDoc::Markup
+
+ RDoc::RDoc.reset
+ RDoc::Markup::PreProcess.registered.clear
+
+ @pwd = Dir.pwd
+ end
+
end
View
2  test/test_attribute_manager.rb
@@ -3,6 +3,8 @@
class TestAttributeManager < RDoc::TestCase # HACK fix test name
def setup
+ super
+
@am = RDoc::Markup::AttributeManager.new
@klass = RDoc::Markup::AttributeManager
@formatter = RDoc::Markup::Formatter.new
View
2  test/test_rdoc_attr.rb
@@ -3,6 +3,8 @@
class TestRDocAttr < RDoc::TestCase
def setup
+ super
+
@a = RDoc::Attr.new nil, 'attr', 'RW', ''
end
View
6 test/test_rdoc_class_module.rb
@@ -2,12 +2,6 @@
class TestRDocClassModule < XrefTestCase
- def setup
- super
-
- @RM = RDoc::Markup
- end
-
def mu_pp obj
s = ''
s = PP.pp obj, s
View
2  test/test_rdoc_context_section.rb
@@ -3,6 +3,8 @@
class TestRDocContextSection < RDoc::TestCase
def setup
+ super
+
@S = RDoc::Context::Section
@s = @S.new nil, 'section', '# comment'
end
View
2  test/test_rdoc_encoding.rb
@@ -3,6 +3,8 @@
class TestRDocEncoding < RDoc::TestCase
def setup
+ super
+
@tempfile = Tempfile.new 'test_rdoc_encoding'
end
View
6 test/test_rdoc_generator_darkfish.rb
@@ -3,10 +3,10 @@
class TestRDocGeneratorDarkfish < RDoc::TestCase
def setup
- @pwd = Dir.pwd
+ super
+
@lib_dir = "#{@pwd}/lib"
$LOAD_PATH.unshift @lib_dir # ensure we load from this RDoc
- RDoc::TopLevel.reset
@options = RDoc::Options.new
@options.option_parser = OptionParser.new
@@ -49,6 +49,8 @@ def setup
end
def teardown
+ super
+
$LOAD_PATH.shift
Dir.chdir @pwd
FileUtils.rm_rf @tmpdir
View
2  test/test_rdoc_generator_markup.rb
@@ -6,6 +6,8 @@ class TestRDocGeneratorMarkup < RDoc::TestCase
include RDoc::Generator::Markup
def setup
+ super
+
@options = RDoc::Options.new
@rdoc = RDoc::RDoc.new
@rdoc.options = @options
View
7 test/test_rdoc_generator_ri.rb
@@ -3,12 +3,11 @@
class TestRDocGeneratorRI < RDoc::TestCase
def setup
+ super
+
@options = RDoc::Options.new
@options.encoding = Encoding::UTF_8 if Object.const_defined? :Encoding
- @pwd = Dir.pwd
- RDoc::TopLevel.reset
-
@tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
FileUtils.mkdir_p @tmpdir
Dir.chdir @tmpdir
@@ -33,6 +32,8 @@ def setup
end
def teardown
+ super
+
Dir.chdir @pwd
FileUtils.rm_rf @tmpdir
end
View
2  test/test_rdoc_markup_attribute_manager.rb
@@ -3,6 +3,8 @@
class TestRDocMarkupAttributeManager < RDoc::TestCase
def setup
+ super
+
@am = RDoc::Markup::AttributeManager.new
@bold_on = @am.changed_attribute_by_name([], [:BOLD])
View
3  test/test_rdoc_markup_document.rb
@@ -3,7 +3,8 @@
class TestRDocMarkupDocument < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
+
@d = @RM::Document.new
end
View
10 test/test_rdoc_markup_formatter.rb
@@ -33,14 +33,16 @@ def end_accepting
end
def setup
- @markup = RDoc::Markup.new
+ super
+
+ @markup = @RM.new
@markup.add_special(/[A-Z]+/, :CAPS)
@to = ToTest.new @markup
- @caps = RDoc::Markup::Attribute.bitmap_for :CAPS
- @special = RDoc::Markup::Attribute.bitmap_for :_SPECIAL_
- @tt = RDoc::Markup::Attribute.bitmap_for :TT
+ @caps = @RM::Attribute.bitmap_for :CAPS
+ @special = @RM::Attribute.bitmap_for :_SPECIAL_
+ @tt = @RM::Attribute.bitmap_for :TT
end
def test_convert_tt_special
View
2  test/test_rdoc_markup_heading.rb
@@ -3,6 +3,8 @@
class TestRDocMarkupHeading < RDoc::TestCase
def setup
+ super
+
@h = RDoc::Markup::Heading.new 1, 'Hello *Friend*!'
end
View
3  test/test_rdoc_markup_include.rb
@@ -3,7 +3,8 @@
class TestRDocMarkupInclude < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
+
@include = @RM::Include.new 'file', [Dir.tmpdir]
end
View
2  test/test_rdoc_markup_indented_paragraph.rb
@@ -3,6 +3,8 @@
class TestRDocMarkupIndentedParagraph < RDoc::TestCase
def setup
+ super
+
@IP = RDoc::Markup::IndentedParagraph
end
View
3  test/test_rdoc_markup_parser.rb
@@ -5,7 +5,8 @@
class TestRDocMarkupParser < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
+
@RMP = @RM::Parser
end
View
4 test/test_rdoc_markup_pre_process.rb
@@ -5,7 +5,7 @@
class TestRDocMarkupPreProcess < RDoc::TestCase
def setup
- RDoc::Markup::PreProcess.registered.clear
+ super
@tempfile = Tempfile.new 'test_rdoc_markup_pre_process'
@file_name = File.basename @tempfile.path
@@ -15,7 +15,7 @@ def setup
end
def teardown
- RDoc::Markup::PreProcess.registered.clear
+ super
@tempfile.close
end
View
3  test/test_rdoc_markup_raw.rb
@@ -3,7 +3,8 @@
class TestRDocMarkupRaw < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
+
@p = @RM::Raw.new
end
View
2  test/test_rdoc_markup_to_label.rb
@@ -3,6 +3,8 @@
class TestRDocMarkupToLabel < RDoc::TestCase
def setup
+ super
+
@to = RDoc::Markup::ToLabel.new
end
View
1  test/test_rdoc_method_attr.rb
@@ -117,6 +117,5 @@ def test_to_s
assert_equal 'RDoc::AnyMethod: C1::m', @c1__m.to_s
end
-
end
View
4 test/test_rdoc_options.rb
@@ -3,11 +3,15 @@
class TestRDocOptions < RDoc::TestCase
def setup
+ super
+
@options = RDoc::Options.new
@generators = RDoc::RDoc::GENERATORS.dup
end
def teardown
+ super
+
RDoc::RDoc::GENERATORS.replace @generators
end
View
2  test/test_rdoc_parser.rb
@@ -3,6 +3,8 @@
class TestRDocParser < RDoc::TestCase
def setup
+ super
+
@RP = RDoc::Parser
@binary_dat = File.expand_path '../binary.dat', __FILE__
View
7 test/test_rdoc_parser_c.rb
@@ -49,6 +49,8 @@ class RDoc::Parser::C
class TestRDocParserC < RDoc::TestCase
def setup
+ super
+
@tempfile = Tempfile.new self.class.name
filename = @tempfile.path
@@ -56,12 +58,11 @@ def setup
@fn = filename
@options = RDoc::Options.new
@stats = RDoc::Stats.new 0
-
- RDoc::Parser::C.reset
- RDoc::TopLevel.reset
end
def teardown
+ super
+
@tempfile.close
end
View
7 test/test_rdoc_parser_rd.rb
@@ -3,8 +3,9 @@
class TestRDocParserRd < RDoc::TestCase
def setup
+ super
+
@RP = RDoc::Parser
- @RM = RDoc::Markup
@tempfile = Tempfile.new self.class.name
filename = @tempfile.path
@@ -13,11 +14,11 @@ def setup
@fn = filename
@options = RDoc::Options.new
@stats = RDoc::Stats.new 0
-
- RDoc::TopLevel.reset
end
def teardown
+ super
+
@tempfile.close
end
View
4 test/test_rdoc_parser_ruby.rb
@@ -5,6 +5,8 @@
class TestRDocParserRuby < RDoc::TestCase
def setup
+ super
+
@tempfile = Tempfile.new self.class.name
@filename = @tempfile.path
@@ -21,6 +23,8 @@ def setup
end
def teardown
+ super
+
@tempfile.close
@tempfile2.close
end
View
6 test/test_rdoc_parser_simple.rb
@@ -3,6 +3,8 @@
class TestRDocParserSimple < RDoc::TestCase
def setup
+ super
+
@tempfile = Tempfile.new self.class.name
filename = @tempfile.path
@@ -10,11 +12,11 @@ def setup
@fn = filename
@options = RDoc::Options.new
@stats = RDoc::Stats.new 0
-
- RDoc::TopLevel.reset
end
def teardown
+ super
+
@tempfile.close
end
View
4 test/test_rdoc_rd.rb
@@ -2,10 +2,6 @@
class TestRDocRd < RDoc::TestCase
- def setup
- @RM = RDoc::Markup
- end
-
def test_class_parse
expected =
@RM::Document.new(
View
3  test/test_rdoc_rd_block_parser.rb
@@ -3,7 +3,8 @@
class TestRDocRdBlockParser < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
+
@block_parser = RDoc::RD::BlockParser.new
end
View
2  test/test_rdoc_rd_inline.rb
@@ -3,6 +3,8 @@
class TestRDocRdInline < RDoc::TestCase
def setup
+ super
+
@inline = RDoc::RD::Inline.new '+text+', 'text'
end
View
3  test/test_rdoc_rd_inline_parser.rb
@@ -3,7 +3,8 @@
class TestRDocRdInlineParser < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
+
@block_parser = RDoc::RD::BlockParser.new
@block_parser.instance_variable_set :@i, 0
@inline_parser = RDoc::RD::InlineParser.new @block_parser
View
2  test/test_rdoc_rdoc.rb
@@ -3,7 +3,7 @@
class TestRDocRDoc < RDoc::TestCase
def setup
- RDoc::TopLevel.reset
+ super
@rdoc = RDoc::RDoc.new
@rdoc.options = RDoc::Options.new
View
4 test/test_rdoc_ri_driver.rb
@@ -3,7 +3,7 @@
class TestRDocRIDriver < RDoc::TestCase
def setup
- @RM = RDoc::Markup
+ super
@tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_driver_#{$$}"
@home_ri = File.join @tmpdir, 'dot_ri'
@@ -24,6 +24,8 @@ def setup
end
def teardown
+ super
+
ENV['HOME'] = @orig_home
ENV['RI'] = @orig_ri
FileUtils.rm_rf @tmpdir
View
4 test/test_rdoc_ri_paths.rb
@@ -3,10 +3,14 @@
class TestRDocRIPaths < RDoc::TestCase
def setup
+ super
+
RDoc::RI::Paths.instance_variable_set :@gemdirs, %w[/nonexistent/gemdir]
end
def teardown
+ super
+
RDoc::RI::Paths.instance_variable_set :@gemdirs, nil
end
View
6 test/test_rdoc_ri_store.rb
@@ -5,7 +5,7 @@ class TestRDocRIStore < RDoc::TestCase
OBJECT_ANCESTORS = defined?(::BasicObject) ? %w[BasicObject] : []
def setup
- RDoc::TopLevel.reset
+ super
@tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_store_#{$$}"
@s = RDoc::RI::Store.new @tmpdir
@@ -42,11 +42,11 @@ def setup
@nest_klass.add_method @nest_meth
@nest_klass.add_include @nest_incl
-
- @RM = RDoc::Markup
end
def teardown
+ super
+
FileUtils.rm_rf @tmpdir
end
View
1  test/test_rdoc_rubygems_hook.rb
@@ -6,6 +6,7 @@ class TestRDocRubygemsHook < Gem::TestCase
def setup
super
+
skip 'requires RubyGems 1.9+' unless
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
View
2  test/test_rdoc_stats.rb
@@ -3,7 +3,7 @@
class TestRDocStats < RDoc::TestCase
def setup
- RDoc::TopLevel.reset
+ super
@s = RDoc::Stats.new 0
View
2  test/test_rdoc_task.rb
@@ -4,6 +4,8 @@
class TestRDocTask < RDoc::TestCase
def setup
+ super
+
Rake::Task.clear
@t = RDoc::Task.new
View
10 test/xref_test_case.rb
@@ -1,18 +1,12 @@
ENV['RDOC_TEST'] = 'yes'
-require 'rubygems'
-require 'minitest/autorun'
require 'rdoc'
-require 'rdoc/stats'
-require 'rdoc/options'
-require 'rdoc/code_objects'
-require 'rdoc/parser'
require File.expand_path '../xref_data', __FILE__
-class XrefTestCase < MiniTest::Unit::TestCase
+class XrefTestCase < RDoc::TestCase
def setup
- RDoc::TopLevel.reset
+ super
@file_name = 'xref_data.rb'
@xref_data = RDoc::TopLevel.new @file_name
Please sign in to comment.
Something went wrong with that request. Please try again.