diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-12-07 07:01:32 +0100 |
---|---|---|
committer | Yuji Yaginuma <yuuji.yaginuma@gmail.com> | 2018-12-07 15:01:32 +0900 |
commit | f173ec77fc35ce57e94398310308e868689366bb (patch) | |
tree | 6e638c281c1f0a6e5b95b11c1c4628aa26b450bc /railties/test | |
parent | b86f65a816546ff8eea39d25b62c995c7efc21dc (diff) | |
download | rails-f173ec77fc35ce57e94398310308e868689366bb.tar.gz rails-f173ec77fc35ce57e94398310308e868689366bb.tar.bz2 rails-f173ec77fc35ce57e94398310308e868689366bb.zip |
Abort early if generator command fails (#34420)
* No need to go through ruby
* Abort early if a generator command fails
* Reuse `rails_command` method
* Bump thor minimum dependency to 0.20.3
* Add some minimal docs
* Add a changelog entry
* Restore original logging
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/actions_test.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index a2b35124c5..af475400a1 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -303,9 +303,21 @@ class ActionsTest < Rails::Generators::TestCase end def test_generate_should_run_script_generate_with_argument_and_options - assert_called_with(generator, :run_ruby_script, ["bin/rails generate model MyModel", verbose: false]) do - action :generate, "model", "MyModel" + run_generator + action :generate, "model", "MyModel" + assert_file "app/models/my_model.rb", /MyModel/ + end + + def test_generate_aborts_when_subprocess_fails_if_requested + run_generator + content = capture(:stderr) do + assert_raises SystemExit do + action :generate, "model", "MyModel:ADsad", abort_on_failure: true + action :generate, "model", "MyModel" + end end + assert_match(/wrong constant name MyModel:aDsad/, content) + assert_no_file "app/models/my_model.rb" end def test_rake_should_run_rake_command_with_default_env |