test/test_hoe.rb in hoe-2.9.6 vs test/test_hoe.rb in hoe-2.10.0

- old
+ new

@@ -9,10 +9,16 @@ end $rakefile = nil # shuts up a warning in rdoctask.rb class TestHoe < MiniTest::Unit::TestCase + def hoe + @hoe ||= Hoe.spec("blah") do + developer 'author', 'email' + end + end + def setup Rake.application.clear end def test_class_load_plugins @@ -22,14 +28,10 @@ assert_includes loaded.keys, :debug assert_includes loaded.keys, :deps end def test_activate_plugins - hoe = Hoe.spec 'blah' do - developer 'author', 'email' - end - initializers = hoe.methods.grep(/^initialize/).map { |s| s.to_s } assert_includes initializers, 'initialize_clean' assert_includes initializers, 'initialize_flay' assert_includes initializers, 'initialize_flog' @@ -54,16 +56,12 @@ open File.join(path, '.hoerc'), 'w' do |io| io.write YAML.dump('plugins' => %w[hoerc]) end - spec = Hoe.spec 'blah' do - developer 'author', 'email' - end + methods = hoe.methods.grep(/^initialize/).map { |s| s.to_s } - methods = spec.methods.grep(/^initialize/).map { |s| s.to_s } - assert_includes methods, 'initialize_hoerc' end ensure Hoe.instance_variable_get(:@loaded).delete :hoerc Hoe.plugins.delete :hoerc @@ -88,16 +86,13 @@ open File.join(path, '.hoerc'), 'w' do |io| io.write YAML.dump('plugins' => %w[hoerc]) end - spec = Hoe.spec 'blah' do - developer 'author', 'email' - end - - assert_includes spec.instance_variables.map(&:to_s), '@hoerc_plugin_initialized', - "Hoerc plugin wasn't initialized" + methods = hoe.instance_variables.map(&:to_s) + assert_includes(methods, '@hoerc_plugin_initialized', + "Hoerc plugin wasn't initialized") end ensure Hoe.instance_variable_get(:@loaded).delete :hoerc Hoe.plugins.delete :hoerc Hoe.send :remove_const, :Hoerc @@ -111,10 +106,42 @@ io.rewind assert_equal 'BOM', File.read_utf(io.path) end end + def test_parse_urls_ary + ary = ["* https://github.com/seattlerb/hoe", + "* http://seattlerb.rubyforge.org/hoe/", + "* http://seattlerb.rubyforge.org/hoe/Hoe.pdf", + "* http://github.com/jbarnette/hoe-plugin-examples"].join "\n" + + exp = ["https://github.com/seattlerb/hoe", + "http://seattlerb.rubyforge.org/hoe/", + "http://seattlerb.rubyforge.org/hoe/Hoe.pdf", + "http://github.com/jbarnette/hoe-plugin-examples"] + + assert_equal exp, hoe.parse_urls(ary) + end + + def test_parse_urls_hash + hash = [ + "home :: https://github.com/seattlerb/hoe", + "rdoc :: http://seattlerb.rubyforge.org/hoe/", + "doco :: http://seattlerb.rubyforge.org/hoe/Hoe.pdf", + "other :: http://github.com/jbarnette/hoe-plugin-examples", + ].join "\n" + + exp = { + "home" => "https://github.com/seattlerb/hoe", + "rdoc" => "http://seattlerb.rubyforge.org/hoe/", + "doco" => "http://seattlerb.rubyforge.org/hoe/Hoe.pdf", + "other" => "http://github.com/jbarnette/hoe-plugin-examples", + } + + assert_equal exp, hoe.parse_urls(hash) + end + def test_possibly_better t = Gem::Specification::TODAY hoe = Hoe.spec("blah") do self.version = '1.2.3' developer 'author', 'email' @@ -122,10 +149,20 @@ files = File.read("Manifest.txt").split(/\n/) + [".gemtest"] spec = hoe.spec + urls = { + "home" => "https://github.com/seattlerb/hoe", + "rdoc" => "http://seattlerb.rubyforge.org/hoe/", + "doco" => "http://seattlerb.rubyforge.org/hoe/Hoe.pdf", + "other" => "http://github.com/jbarnette/hoe-plugin-examples", + } + + assert_equal "https://github.com/seattlerb/hoe", hoe.url + assert_equal urls, hoe.urls + text_files = files.grep(/txt$/).reject { |f| f =~ /template/ } assert_equal 'blah', spec.name assert_equal '1.2.3', spec.version.to_s assert_equal '>= 0', spec.required_rubygems_version.to_s @@ -135,11 +172,12 @@ assert_match(/Hoe.*Rakefiles/, spec.description) assert_equal ['email'], spec.email assert_equal ['sow'], spec.executables assert_equal text_files, spec.extra_rdoc_files assert_equal files, spec.files - assert_equal "http://rubyforge.org/projects/seattlerb/", spec.homepage + assert_equal "https://github.com/seattlerb/hoe", spec.homepage + # TODO: assert_equal "https://github.com/seattlerb/hoe", spec.metadata assert_equal ['--main', 'README.txt'], spec.rdoc_options assert_equal ['lib'], spec.require_paths assert_equal 'blah', spec.rubyforge_project assert_equal Gem::RubyGemsVersion, spec.rubygems_version assert_match(/^Hoe.*Rakefiles$/, spec.summary) @@ -153,9 +191,11 @@ defined? ::RubyForge assert_equal expected, deps.map { |dep| [dep.name, dep.type, dep.requirement.to_s] } + + # flunk "not yet" end def test_plugins before = Hoe.plugins.dup Hoe.plugin :first, :second