summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_build_command.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-10 20:18:31 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-28 14:54:22 +0900
commit0629e695e3130f875641542ad2593b19b56703ef (patch)
tree9fcab4edb8df8c74c695118838b48ab6a44d7a22 /test/rubygems/test_gem_commands_build_command.rb
parent67ae1d441dbc2d944a08b95178f99d2cf67169e1 (diff)
Added `--platform` option to `build` command
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3599
Diffstat (limited to 'test/rubygems/test_gem_commands_build_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb32
1 files changed, 28 insertions, 4 deletions
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index 3d1f7596a4..01f3487ad4 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -37,6 +37,8 @@ class TestGemCommandsBuildCommand < Gem::TestCase
assert @cmd.options[:force]
assert @cmd.options[:strict]
+ assert @cmd.handles?(%W[--platform #{Gem::Platform.local}])
+ assert_includes Gem.platforms, Gem::Platform.local
end
def test_options_filename
@@ -86,6 +88,26 @@ class TestGemCommandsBuildCommand < Gem::TestCase
util_test_build_gem @gem
end
+ def test_execute_platform
+ gemspec_file = File.join(@tempdir, @gem.spec_name)
+
+ File.open gemspec_file, 'w' do |gs|
+ gs.write @gem.to_ruby
+ end
+
+ @cmd.options[:args] = [gemspec_file]
+
+ platforms = Gem.platforms.dup
+ begin
+ Gem.platforms << Gem::Platform.new("java")
+
+ spec = util_test_build_gem @gem, suffix: "java"
+ ensure
+ Gem.platforms.replace(platforms)
+ end
+ assert_match spec.platform, "java"
+ end
+
def test_execute_bad_name
[".", "-", "_"].each do |special_char|
gem = util_spec 'some_gem_with_bad_name' do |s|
@@ -327,27 +349,29 @@ class TestGemCommandsBuildCommand < Gem::TestCase
refute File.exist?(expected_gem)
end
- def util_test_build_gem(gem)
+ def util_test_build_gem(gem, suffix: nil)
use_ui @ui do
Dir.chdir @tempdir do
@cmd.execute
end
end
-
+ suffix &&= "-#{suffix}"
+ gem_file = "some_gem-2#{suffix}.gem"
output = @ui.output.split "\n"
assert_equal " Successfully built RubyGem", output.shift
assert_equal " Name: some_gem", output.shift
assert_equal " Version: 2", output.shift
- assert_equal " File: some_gem-2.gem", output.shift
+ assert_equal " File: #{gem_file}", output.shift
assert_equal [], output
- gem_file = File.join(@tempdir, File.basename(gem.cache_file))
+ gem_file = File.join(@tempdir, gem_file)
assert File.exist?(gem_file)
spec = Gem::Package.new(gem_file).spec
assert_equal "some_gem", spec.name
assert_equal "this is a summary", spec.summary
+ spec
end
def test_execute_force