2 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3 require 'rubygems/commands/build_command'
4 require 'rubygems/format'
6 class TestGemCommandsBuildCommand < RubyGemTestCase
11 @gem = quick_gem 'some_gem' do |s|
12 s.rubyforge_project = 'example'
15 @cmd = Gem::Commands::BuildCommand.new
19 gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
21 File.open gemspec_file, 'w' do |gs|
25 util_test_build_gem @gem, gemspec_file
29 gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
31 File.open gemspec_file, 'w' do |gs|
35 util_test_build_gem @gem, gemspec_file
38 def test_execute_bad_gem
39 @cmd.options[:args] = %w[some_gem]
44 assert_equal '', @ui.output
45 assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
48 def util_test_build_gem(gem, gemspec_file)
49 @cmd.options[:args] = [gemspec_file]
57 output = @ui.output.split "\n"
58 assert_equal " Successfully built RubyGem", output.shift
59 assert_equal " Name: some_gem", output.shift
60 assert_equal " Version: 2", output.shift
61 assert_equal " File: some_gem-2.gem", output.shift
62 assert_equal [], output
63 assert_equal '', @ui.error
65 gem_file = File.join @tempdir, "#{gem.full_name}.gem"
66 assert File.exist?(gem_file)
68 spec = Gem::Format.from_file_by_path(gem_file).spec
70 assert_equal "some_gem", spec.name
71 assert_equal "this is a summary", spec.summary