test/test_hoe.rb in hoe-3.6.0 vs test/test_hoe.rb in hoe-3.6.1

- old
+ new

@@ -76,56 +76,21 @@ def define_hoerc_tasks; end end EOM end - open File.join(path, '.hoerc'), 'w' do |io| - io.write YAML.dump('plugins' => %w[hoerc]) - end + write_hoerc path, 'plugins' => %w[hoerc] methods = hoe.methods.grep(/^initialize/).map { |s| s.to_s } assert_includes methods, 'initialize_hoerc' assert_includes Hoe.plugins, :hoerc end ensure - Hoe.instance_variable_get(:@loaded).delete :hoerc - Hoe.plugins.delete :hoerc - Hoe.send :remove_const, :Hoerc - $LOAD_PATH.replace load_path - ENV['HOME'] = home + reset_hoe load_path, home end - def test_perproject_hoerc - overrides = { - 'exclude' => Regexp.union( Hoe::DEFAULT_CONFIG["exclude"], /\.hg/ ), - 'plugins' => ['tweedledee', 'tweedledum'] - } - overrides_rcfile = File.join(Dir.pwd, '.hoerc') - - home = ENV['HOME'] - Hoe.files = nil - - Dir.mktmpdir do |path| - ENV['HOME'] = path - - open File.join(path, '.hoerc'), 'w' do |io| - io.write YAML.dump( Hoe::DEFAULT_CONFIG ) - end - open overrides_rcfile, File::CREAT|File::EXCL|File::WRONLY do |io| - io.write YAML.dump( overrides ) - end - - hoeconfig = hoe.with_config {|config, _| config } - - assert_equal Hoe::DEFAULT_CONFIG.merge(overrides), hoeconfig - end - ensure - File.delete overrides_rcfile if File.exist?( overrides_rcfile ) - ENV['HOME'] = home - end - def test_have_gem_eh assert hoe.have_gem? 'rake' refute hoe.have_gem? 'nonexistent' end @@ -146,20 +111,28 @@ def define_hoerc_tasks; end end EOM end - open File.join(path, '.hoerc'), 'w' do |io| - io.write YAML.dump('plugins' => %w[hoerc]) - end + write_hoerc path, 'plugins' => %w[hoerc] methods = hoe.instance_variables.map(&:to_s) assert_includes(methods, '@hoerc_plugin_initialized', "Hoerc plugin wasn't initialized") assert_includes Hoe.plugins, :hoerc end ensure + reset_hoe load_path, home + end + + def write_hoerc path, data + open File.join(path, '.hoerc'), 'w' do |io| + io.write YAML.dump data + end + end + + def reset_hoe load_path, home Hoe.instance_variable_get(:@loaded).delete :hoerc Hoe.plugins.delete :hoerc Hoe.send :remove_const, :Hoerc $LOAD_PATH.replace load_path ENV['HOME'] = home @@ -441,12 +414,11 @@ Hoe.files = nil Dir.mktmpdir do |path| ENV['HOME'] = path - open File.join(path, '.hoerc'), 'w' do |io| - io.write YAML.dump( Hoe::DEFAULT_CONFIG ) - end + write_hoerc path, Hoe::DEFAULT_CONFIG + open overrides_rcfile, File::CREAT|File::EXCL|File::WRONLY do |io| io.write YAML.dump( overrides ) end hoeconfig = hoe.with_config {|config, _| config }