@@ -310,6 +310,37 @@ def test_execute_outside_dir_with_glob_argument
310310 assert_equal "this is a summary" , spec . summary
311311 end
312312
313+ def test_execute_outside_dir_no_gemspec_present
314+ gemspec_dir = File . join @tempdir , 'build_command_gem'
315+ gemspec_file = File . join @tempdir , @gem . spec_name
316+ readme_file = File . join gemspec_dir , 'README.md'
317+
318+ FileUtils . mkdir_p gemspec_dir
319+
320+ File . open readme_file , 'w' do |f |
321+ f . write "My awesome gem"
322+ end
323+
324+ File . open gemspec_file , 'w' do |gs |
325+ gs . write @gem . to_ruby
326+ end
327+
328+ @cmd . options [ :build_path ] = gemspec_dir
329+ @cmd . options [ :args ] = [ "*.gemspec" ]
330+
331+ use_ui @ui do
332+ assert_raises Gem ::MockGemUi ::TermError do
333+ @cmd . execute
334+ end
335+ end
336+
337+ assert_equal "" , @ui . output
338+ assert_equal "ERROR: No Gemspec in #{ gemspec_dir } \n " , @ui . error
339+
340+ gem_file = File . join gemspec_dir , File . basename ( @gem . cache_file )
341+ refute File . exist? ( gem_file )
342+ end
343+
313344 def test_execute_outside_dir_without_gem_name
314345 gemspec_dir = File . join ( @tempdir , 'build_command_gem' )
315346 gemspec_file = File . join ( gemspec_dir , @gem . spec_name )
0 commit comments