aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_commands_build_command.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-10 07:48:56 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-10 07:48:56 +0000
commitfbf59bdbea63efd34ccc144e648467d2f52e7345 (patch)
tree244f0e7ae112cc7dd135e5d1ac24e6c70ba71b4a /test/rubygems/test_gem_commands_build_command.rb
parent7a4aad75356496559460041a6c063bdb736c7236 (diff)
downloadruby-fbf59bdbea63efd34ccc144e648467d2f52e7345.tar.gz
Import RubyGems trunk revision 1493.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_build_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
new file mode 100644
index 0000000000..f1fd1503ba
--- /dev/null
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -0,0 +1,75 @@
+require 'test/unit'
+require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
+require 'rubygems/commands/build_command'
+require 'rubygems/format'
+
+class TestGemCommandsBuildCommand < RubyGemTestCase
+
+ def setup
+ super
+
+ @cmd = Gem::Commands::BuildCommand.new
+ end
+
+ def test_execute
+ gem = quick_gem 'some_gem'
+
+ gemspec_file = File.join(@tempdir, "#{gem.full_name}.gemspec")
+
+ File.open gemspec_file, 'w' do |gs|
+ gs.write gem.to_ruby
+ end
+
+ util_test_build_gem gem, gemspec_file
+ end
+
+ def test_execute_yaml
+ gem = quick_gem 'some_gem'
+
+ gemspec_file = File.join(@tempdir, "#{gem.full_name}.gemspec")
+
+ File.open gemspec_file, 'w' do |gs|
+ gs.write gem.to_yaml
+ end
+
+ util_test_build_gem gem, gemspec_file
+ 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
+ assert_equal " Version: 0.0.2", output.shift
+ assert_equal " File: some_gem-0.0.2.gem", output.shift
+ 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
+