test/test_hoe.rb in hoe-2.13.1 vs test/test_hoe.rb in hoe-2.14.0
- old
+ new
@@ -139,10 +139,58 @@
Hoe.send :remove_const, :Hoerc
$LOAD_PATH.replace load_path
ENV['HOME'] = home
end
+ def test_initialize_intuit
+ Dir.mktmpdir do |path|
+ Dir.chdir path do
+ open 'Manifest.txt', 'w' do |io| # sorted
+ io.puts 'FAQ.rdoc'
+ io.puts 'History.rdoc'
+ io.puts 'README.rdoc'
+ end
+
+ open 'README.rdoc', 'w' do |io| io.puts '= blah' end
+ open 'History.rdoc', 'w' do |io| io.puts '=== 1.0' end
+
+ hoe = Hoe.spec 'blah' do
+ self.version = '1.0'
+ developer 'nobody', 'nobody@example'
+ end
+
+ assert_equal 'History.rdoc', hoe.history_file
+ assert_equal 'README.rdoc', hoe.readme_file
+ assert_equal %w[FAQ.rdoc History.rdoc README.rdoc],
+ hoe.spec.extra_rdoc_files
+ end
+ end
+ end
+
+ def test_initialize_intuit_ambiguous
+ Dir.mktmpdir do |path|
+ Dir.chdir path do
+ open 'Manifest.txt', 'w' do |io|
+ io.puts 'History.rdoc' # sorted
+ io.puts 'README.ja.rdoc'
+ io.puts 'README.rdoc'
+ end
+
+ open 'README.rdoc', 'w' do |io| io.puts '= blah' end
+ open 'README.ja.rdoc', 'w' do |io| io.puts '= blah' end
+ open 'History.rdoc', 'w' do |io| io.puts '=== 1.0' end
+
+ hoe = Hoe.spec 'blah' do
+ self.version = '1.0'
+ developer 'nobody', 'nobody@example'
+ end
+
+ assert_equal 'README.ja.rdoc', hoe.readme_file
+ end
+ end
+ end
+
def test_file_read_utf
Tempfile.open 'BOM' do |io|
io.write "\xEF\xBB\xBFBOM"
io.rewind
@@ -255,10 +303,20 @@
assert_equal before + [:first, :second], Hoe.plugins
ensure
Hoe.plugins.replace before
end
+ def test_read_manifest
+ hoe = Hoe.spec 'blah' do
+ developer 'author', 'email'
+ end
+
+ expected = File.read_utf('Manifest.txt').split
+
+ assert_equal expected, hoe.read_manifest
+ end
+
def test_rename
# project, file_name, klass = Hoe.normalize_names 'project_name'
assert_equal %w( word word Word), Hoe.normalize_names('word')
assert_equal %w( word word Word), Hoe.normalize_names('Word')
@@ -282,6 +340,51 @@
ENV['NOSUDO'] = '1'
assert_match(/^j?gem.*/, hoe.install_gem('foo'))
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