2011-01-19 00:08:49 +00:00
|
|
|
######################################################################
|
|
|
|
# This file is imported from the rubygems project.
|
|
|
|
# DO NOT make modifications in this repo. They _will_ be reverted!
|
|
|
|
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
|
|
|
|
######################################################################
|
|
|
|
|
2011-01-28 23:46:47 +00:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 07:48:56 +00:00
|
|
|
require 'rubygems/builder'
|
2011-06-01 03:45:05 +00:00
|
|
|
require 'rubygems/package'
|
2007-11-10 07:48:56 +00:00
|
|
|
|
2011-01-28 23:46:47 +00:00
|
|
|
class TestGemBuilder < Gem::TestCase
|
2007-11-10 07:48:56 +00:00
|
|
|
|
|
|
|
def test_build
|
2011-03-07 08:44:45 +00:00
|
|
|
builder = Gem::Builder.new quick_spec('a')
|
2007-11-10 07:48:56 +00: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 10:13:50 +00:00
|
|
|
assert_raises Gem::InvalidSpecificationException do
|
2007-11-10 07:48:56 +00:00
|
|
|
builder.build
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-01 03:45:05 +00: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 07:48:56 +00:00
|
|
|
|
2011-06-01 03:45:05 +00: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
|