summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRyan Davis <ryand@zenspider.com>2013-05-09 16:57:42 -0800
committerRyan Davis <ryand@zenspider.com>2013-05-09 16:57:42 -0800
commite237e4449465a0956754df95d6b9e98e18af6051 (patch)
tree3ab5fd3c7503d14f45257d0f55f5245e3e12a28f /test
parent35d17031cec026af05d73d575a6b55cbff4ad07f (diff)
downloadhoe-e237e4449465a0956754df95d6b9e98e18af6051.tar.gz
test cleanup and refactoring
[git-p4: depot-paths = "//src/hoe/dev/": change = 8522]
Diffstat (limited to 'test')
-rw-r--r--test/test_hoe.rb58
1 files changed, 15 insertions, 43 deletions
diff --git a/test/test_hoe.rb b/test/test_hoe.rb
index 9eae569..1b8f6bc 100644
--- a/test/test_hoe.rb
+++ b/test/test_hoe.rb
@@ -78,9 +78,7 @@ class TestHoe < MiniTest::Unit::TestCase
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 }
@@ -88,40 +86,7 @@ class TestHoe < MiniTest::Unit::TestCase
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
- 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
+ reset_hoe load_path, home
end
def test_have_gem_eh
@@ -148,9 +113,7 @@ class TestHoe < MiniTest::Unit::TestCase
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',
@@ -158,6 +121,16 @@ class TestHoe < MiniTest::Unit::TestCase
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
@@ -443,9 +416,8 @@ class TestHoe < MiniTest::Unit::TestCase
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