test/test_hoe.rb in hoe-3.11.0 vs test/test_hoe.rb in hoe-3.12.0
- old
+ new
@@ -9,14 +9,18 @@
end
$rakefile = nil # shuts up a warning in rdoctask.rb
class TestHoe < Minitest::Test
- def hoe
- @hoe ||= Hoe.spec("blah") do
- developer 'author', 'email'
- license 'MIT'
+ def hoe(*skips, &b)
+ @hoe ||= Hoe.spec "blah" do
+ developer "author", "email"
+ license "MIT" unless skips.include? :skip_license
+ self.version = "1.0" unless skips.include? :skip_version
+ self.readme_file = "README.rdoc" unless skips.include? :skip_files
+ self.history_file = "History.rdoc" unless skips.include? :skip_files
+ self.instance_eval(&b) if b
end
end
def teardown
Rake.application.clear
@@ -149,16 +153,10 @@
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'
- license 'MIT'
- 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
@@ -176,17 +174,11 @@
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'
- license 'MIT'
- end
-
- assert_equal 'README.ja.rdoc', hoe.readme_file
+ assert_equal 'README.ja.rdoc', hoe(:skip_files).readme_file
end
end
end
def test_file_read_utf
@@ -235,14 +227,13 @@
assert_equal exp, hoe.parse_urls(hash)
end
def test_possibly_better
t = Gem::Specification::TODAY
- hoe = Hoe.spec("blah") do
+
+ hoe = self.hoe do
self.version = '1.2.3'
- developer 'author', 'email'
- license 'MIT'
end
files = File.read("Manifest.txt").split(/\n/) + [".gemtest"]
spec = hoe.spec
@@ -256,11 +247,11 @@
"other" => "http://github.com/jbarnette/hoe-plugin-examples",
}
assert_equal urls, hoe.urls
- text_files = files.grep(/txt$/).reject { |f| f =~ /template/ }
+ text_files = files.grep(/(txt|rdoc)$/).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
@@ -270,11 +261,11 @@
assert_equal ['email'], spec.email
assert_equal ['sow'], spec.executables
assert_equal text_files, spec.extra_rdoc_files
assert_equal files.sort, spec.files.sort
assert_equal urls["home"], spec.homepage
- assert_equal ['--main', 'README.txt'], spec.rdoc_options
+ assert_equal ['--main', 'README.rdoc'], spec.rdoc_options
assert_equal ['lib'], spec.require_paths
assert_equal Gem::RubyGemsVersion, spec.rubygems_version
assert_match(/^Hoe.*Rakefiles$/, spec.summary)
assert_equal files.grep(/^test/).sort, spec.test_files.sort
@@ -290,51 +281,36 @@
}
end
def test_no_license
out, err = capture_io do
- hoe = Hoe.spec("blah") do
- self.version = '1.2.3'
- developer 'author', 'email'
- end
-
- assert_equal ["MIT"], hoe.spec.licenses
+ assert_equal ["MIT"], self.hoe(:skip_license).spec.licenses
end
assert_equal "", out
assert_match "Defaulting gemspec to MIT", err
end
def test_license
- hoe = Hoe.spec("blah") do
- self.version = '1.2.3'
- developer 'author', 'email'
- license 'MIT'
- end
+ spec = self.hoe.spec
- spec = hoe.spec
-
assert_equal %w(MIT), spec.licenses
end
def test_multiple_calls_to_license
- hoe = Hoe.spec("blah") do
- self.version = '1.2.3'
- developer 'author', 'email'
+ hoe = self.hoe :skip_license do
license 'MIT'
license 'GPL-2'
end
spec = hoe.spec
assert_equal %w(MIT GPL-2), spec.licenses
end
def test_setting_licenses
- hoe = Hoe.spec("blah") do
- self.version = '1.2.3'
- developer 'author', 'email'
+ hoe = self.hoe :skip_license do
self.licenses = ['MIT', 'GPL-2']
end
spec = hoe.spec
@@ -350,15 +326,10 @@
Hoe.plugin :first, :second
assert_equal before + [:first, :second], Hoe.plugins
end
def test_read_manifest
- hoe = Hoe.spec 'blah' do
- developer 'author', 'email'
- license 'MIT'
- end
-
expected = File.read_utf('Manifest.txt').split
assert_equal expected, hoe.read_manifest
end
@@ -372,15 +343,11 @@
assert_equal %w(two-words two/words Two::Words TestTwo::TestWords), Hoe.normalize_names('two-words')
assert_equal %w(two_words two_words TwoWords TestTwoWords), Hoe.normalize_names('two_words')
end
def test_nosudo
- hoe = Hoe.spec("blah") do
- self.version = '1.2.3'
- developer 'author', 'email'
- license 'MIT'
-
+ hoe = self.hoe do
def system cmd
cmd
end
end
@@ -431,7 +398,6 @@
end
ensure
File.delete overrides_rcfile if File.exist?( overrides_rcfile )
ENV['HOME'] = home
end
-
end