2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/builder'
|
2011-05-31 23:45:05 -04:00
|
|
|
require 'rubygems/package'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemBuilder < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
def test_build
|
2011-03-07 03:44:45 -05:00
|
|
|
builder = Gem::Builder.new quick_spec('a')
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
Dir.chdir @tempdir do
|
|
|
|
builder.build
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_match %r|Successfully built RubyGem\n Name: a|, @ui.output
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_build_validates
|
|
|
|
builder = Gem::Builder.new Gem::Specification.new
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
assert_raises Gem::InvalidSpecificationException do
|
2007-11-10 02:48:56 -05:00
|
|
|
builder.build
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def test_build_specification_result
|
|
|
|
util_make_gems
|
|
|
|
|
|
|
|
spec = build_gem_and_yield_spec @a1
|
|
|
|
|
|
|
|
assert_operator @a1, :eql?, spec
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def build_gem_and_yield_spec(spec)
|
|
|
|
builder = Gem::Builder.new spec
|
|
|
|
|
|
|
|
spec = Dir.chdir @tempdir do
|
|
|
|
FileUtils.mkdir 'lib'
|
|
|
|
File.open('lib/code.rb', 'w') { |f| f << "something" }
|
|
|
|
Gem::Package.open(File.open(builder.build, 'rb')) { |x| x.metadata }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|