2007-11-10 10:48:56 +03:00
|
|
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
|
|
|
require 'rubygems/commands/build_command'
|
|
|
|
require 'rubygems/format'
|
|
|
|
|
|
|
|
class TestGemCommandsBuildCommand < RubyGemTestCase
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
2007-12-20 11:39:12 +03:00
|
|
|
@gem = quick_gem 'some_gem' do |s|
|
|
|
|
s.rubyforge_project = 'example'
|
|
|
|
end
|
|
|
|
|
2007-11-10 10:48:56 +03:00
|
|
|
@cmd = Gem::Commands::BuildCommand.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute
|
2007-12-20 11:39:12 +03:00
|
|
|
gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
|
2007-11-10 10:48:56 +03:00
|
|
|
|
|
|
|
File.open gemspec_file, 'w' do |gs|
|
2007-12-20 11:39:12 +03:00
|
|
|
gs.write @gem.to_ruby
|
2007-11-10 10:48:56 +03:00
|
|
|
end
|
|
|
|
|
2007-12-20 11:39:12 +03:00
|
|
|
util_test_build_gem @gem, gemspec_file
|
2007-11-10 10:48:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_yaml
|
2007-12-20 11:39:12 +03:00
|
|
|
gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
|
2007-11-10 10:48:56 +03:00
|
|
|
|
|
|
|
File.open gemspec_file, 'w' do |gs|
|
2007-12-20 11:39:12 +03:00
|
|
|
gs.write @gem.to_yaml
|
2007-11-10 10:48:56 +03:00
|
|
|
end
|
|
|
|
|
2007-12-20 11:39:12 +03:00
|
|
|
util_test_build_gem @gem, gemspec_file
|
2007-11-10 10:48:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_bad_gem
|
|
|
|
@cmd.options[:args] = %w[some_gem]
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal '', @ui.output
|
|
|
|
assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
|
|
|
|
end
|
|
|
|
|
|
|
|
def util_test_build_gem(gem, gemspec_file)
|
|
|
|
@cmd.options[:args] = [gemspec_file]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
Dir.chdir @tempdir do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
output = @ui.output.split "\n"
|
|
|
|
assert_equal " Successfully built RubyGem", output.shift
|
|
|
|
assert_equal " Name: some_gem", output.shift
|
2007-12-20 11:39:12 +03:00
|
|
|
assert_equal " Version: 2", output.shift
|
|
|
|
assert_equal " File: some_gem-2.gem", output.shift
|
2007-11-10 10:48:56 +03:00
|
|
|
assert_equal [], output
|
|
|
|
assert_equal '', @ui.error
|
|
|
|
|
|
|
|
gem_file = File.join @tempdir, "#{gem.full_name}.gem"
|
|
|
|
assert File.exist?(gem_file)
|
|
|
|
|
|
|
|
spec = Gem::Format.from_file_by_path(gem_file).spec
|
|
|
|
|
|
|
|
assert_equal "some_gem", spec.name
|
|
|
|
assert_equal "this is a summary", spec.summary
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|