Skip to content

Commit e2bc2b2

Browse files
committed
Append '.gemspec' extension only when it is not present.
This avoids confusing messages such as: ~~~ $ gem build *.gemspec ERROR: Gemspec file not found: *.gemspec.gemspec ~~~ Please note that the `TestGemCommandsBuildCommand#test_can_find_gemspecs_without_dot_gemspec` testcase was probably wrong from the beginning, trying to apply `.gemspec` extension to `@gem.spec_name`, which already contains the extension. Fixes #3953
1 parent 15e431b commit e2bc2b2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/rubygems/commands/build_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def find_gemspec
7979
end
8080

8181
def build_gem(gem_name)
82-
gemspec = File.exist?(gem_name) ? gem_name : "#{gem_name}.gemspec"
82+
gemspec = File.extname(gem_name) == ".gemspec" ? gem_name : "#{gem_name}.gemspec"
8383

8484
if File.exist?(gemspec)
8585
spec = Gem::Specification.load(gemspec)

test/rubygems/test_gem_commands_build_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_execute_outside_dir
273273
end
274274

275275
def test_can_find_gemspecs_without_dot_gemspec
276-
gemspec_file = File.join(@tempdir, @gem.spec_name)
276+
gemspec_file = File.join(@tempdir, @gem.name)
277277

278278
File.open gemspec_file + ".gemspec", 'w' do |gs|
279279
gs.write @gem.to_ruby

0 commit comments

Comments
 (0)