Skip to content
Browse files

Test non zero exit code and that a message still appears when generat…

…ing inside an existing Rails directory.
  • Loading branch information...
1 parent a812cb6 commit 99f751ffef3e2feb6baf2778f66a32e86ae18956 @parndt parndt committed with josevalim
Showing with 11 additions and 0 deletions.
  1. +11 −0 railties/test/generators/app_generator_test.rb
11 railties/test/generators/app_generator_test.rb
@@ -70,6 +70,17 @@ def test_application_new_exits_with_non_zero_code_on_invalid_application_name
assert_equal false, $?.success?
+ def test_application_new_exits_with_message_and_non_zero_code_when_generating_inside_existing_rails_directory
+ app_root = File.join(destination_root, 'myfirstapp')
+ run_generator [app_root]
+ output = nil
+ Dir.chdir(app_root) do
+ output = `rails new mysecondapp`
+ end
+ assert_equal "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\nType 'rails' for help.\n", output
+ assert_equal false, $?.success?
+ end
def test_application_name_is_detected_if_it_exists_and_app_folder_renamed
app_root = File.join(destination_root, "myapp")
app_moved_root = File.join(destination_root, "myapp_moved")

0 comments on commit 99f751f

Please sign in to comment.
Something went wrong with that request. Please try again.