diff options
Diffstat (limited to 'railties/test/generators/app_generator_test.rb')
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index f3071843e2..d13dc8d4ac 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -83,6 +83,16 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_equal false, $?.success? end + def test_application_new_show_help_message_inside_existing_rails_directory + app_root = File.join(destination_root, 'myfirstapp') + run_generator [app_root] + output = Dir.chdir(app_root) do + `rails new --help` + end + assert_match /rails new APP_PATH \[options\]/, output + assert_equal true, $?.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") @@ -202,6 +212,8 @@ class AppGeneratorTest < Rails::Generators::TestCase run_generator [destination_root, "--skip-active-record"] assert_no_file "config/database.yml" assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ + assert_file "config/application.rb", /#\s+config\.active_record\.whitelist_attributes = true/ + assert_file "config/application.rb", /#\s+config\.active_record\.dependent_restrict_raises = false/ assert_file "test/test_helper.rb" do |helper_content| assert_no_match(/fixtures :all/, helper_content) end @@ -211,7 +223,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_generator_if_skip_sprockets_is_given run_generator [destination_root, "--skip-sprockets"] assert_file "config/application.rb" do |content| - assert_match(/#\s+require\s+["']sprockets\/railtie["']/, content) + assert_match(/#\s+require\s+["']sprockets\/rails\/railtie["']/, content) assert_no_match(/config\.assets\.enabled = true/, content) end assert_file "Gemfile" do |content| @@ -234,10 +246,17 @@ class AppGeneratorTest < Rails::Generators::TestCase if defined?(JRUBY_VERSION) assert_file "Gemfile", /gem\s+["']therubyrhino["']$/ else - assert_file "Gemfile", /# gem\s+["']therubyracer["']$/ + assert_file "Gemfile", /# gem\s+["']therubyracer["']+, platform: :ruby$/ end end + def test_generator_if_skip_index_html_is_given + run_generator [destination_root, "--skip-index-html"] + assert_no_file "public/index.html" + assert_no_file "app/assets/images/rails.png" + assert_file "app/assets/images/.gitkeep" + end + def test_creation_of_a_test_directory run_generator assert_file 'test' @@ -282,10 +301,10 @@ class AppGeneratorTest < Rails::Generators::TestCase end end - def test_inclusion_of_ruby_debug19 + def test_inclusion_of_debugger run_generator assert_file "Gemfile" do |contents| - assert_match(/gem 'ruby-debug19', :require => 'ruby-debug'/, contents) + assert_match(/gem 'debugger'/, contents) end end @@ -300,7 +319,7 @@ class AppGeneratorTest < Rails::Generators::TestCase end def test_default_usage - File.expects(:exist?).returns(false) + Rails::Generators::AppGenerator.expects(:usage_path).returns(nil) assert_match(/Create rails files for app generator/, Rails::Generators::AppGenerator.desc) end @@ -349,12 +368,26 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_active_record_whitelist_attributes_is_present_application_config + run_generator + assert_file "config/application.rb", /config\.active_record\.whitelist_attributes = true/ + end + + def test_active_record_dependent_restrict_raises_is_present_application_config + run_generator + assert_file "config/application.rb", /config\.active_record\.dependent_restrict_raises = false/ + end + + def test_pretend_option + output = run_generator [File.join(destination_root, "myapp"), "--pretend"] + assert_no_match(/run bundle install/, output) + end + protected def action(*args, &block) silence(:stdout) { generator.send(*args, &block) } end - end class CustomAppGeneratorTest < Rails::Generators::TestCase |