summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Hodel <drbrain@segment7.net>2012-02-15 14:06:14 -0800
committerEric Hodel <drbrain@segment7.net>2012-02-15 14:06:14 -0800
commit1154796cc081c93c9297d82fe395e43bdfc05880 (patch)
tree057b93f86a4f7405ee7a4fb5f96655777e17f0ef /test
parent6de29e7652d51863e1e6fcc60c2ec7b2e848fe3e (diff)
downloadhoe-1154796cc081c93c9297d82fe395e43bdfc05880.tar.gz
+ Hoe#with_config merges the local and home configuration atop Hoe::DEFAULT_CONFIG to allow plugins to supply new defaults.
[git-p4: depot-paths = "//src/hoe/dev/": change = 7048]
Diffstat (limited to 'test')
-rw-r--r--test/test_hoe.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_hoe.rb b/test/test_hoe.rb
index 5536b2a..972aea9 100644
--- a/test/test_hoe.rb
+++ b/test/test_hoe.rb
@@ -284,4 +284,49 @@ class TestHoe < MiniTest::Unit::TestCase
ensure
ENV.delete "NOSUDO"
end
+
+ def test_with_config_default
+ home = ENV['HOME']
+ Hoe.files = nil
+
+ Dir.mktmpdir do |path|
+ ENV['HOME'] = path
+
+ hoeconfig = hoe.with_config {|config, _| config }
+
+ assert_equal Hoe::DEFAULT_CONFIG, hoeconfig
+ end
+ ensure
+ ENV['HOME'] = home
+ end
+
+ def test_with_config_overrides
+ 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
+
end