diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-08-14 18:11:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-14 18:11:46 -0400 |
commit | bef68862ae14244fb93e0abb4c16d06eec535c2d (patch) | |
tree | 4b6bf0b5397a4d602b023928ce89bad3811f8c3d /railties/test | |
parent | ccd973366bf2c9a103f28ade0862426d74951c87 (diff) | |
parent | 6df78be9bb7035ec73837e9be41781e563da2ab4 (diff) | |
download | rails-bef68862ae14244fb93e0abb4c16d06eec535c2d.tar.gz rails-bef68862ae14244fb93e0abb4c16d06eec535c2d.tar.bz2 rails-bef68862ae14244fb93e0abb4c16d06eec535c2d.zip |
Merge pull request #30219 from yhirano55/fix_app_generator_api_options
Refactor `--api` option of the app generator
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/api_app_generator_test.rb | 55 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 8 |
2 files changed, 41 insertions, 22 deletions
diff --git a/railties/test/generators/api_app_generator_test.rb b/railties/test/generators/api_app_generator_test.rb index 58617510d7..ba7f7bb5f3 100644 --- a/railties/test/generators/api_app_generator_test.rb +++ b/railties/test/generators/api_app_generator_test.rb @@ -35,26 +35,26 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase def test_api_modified_files run_generator + assert_file ".gitignore" do |content| + assert_no_match(/\/public\/asserts/, content) + end + assert_file "Gemfile" do |content| assert_no_match(/gem 'coffee-rails'/, content) assert_no_match(/gem 'sass-rails'/, content) assert_no_match(/gem 'web-console'/, content) + assert_no_match(/gem 'capybara'/, content) + assert_no_match(/gem 'selenium-webdriver'/, content) assert_match(/# gem 'jbuilder'/, content) + assert_match(/# gem 'rack-cors'/, content) end - assert_file "config/application.rb" do |content| - assert_match(/config.api_only = true/, content) - end - - assert_file "config/initializers/cors.rb" - - assert_file "config/initializers/wrap_parameters.rb" - + assert_file "config/application.rb", /config\.api_only = true/ assert_file "app/controllers/application_controller.rb", /ActionController::API/ end def test_generator_if_skip_action_cable_is_given - run_generator [destination_root, "--skip-action-cable"] + run_generator [destination_root, "--api", "--skip-action-cable"] assert_file "config/application.rb", /#\s+require\s+["']action_cable\/engine["']/ assert_no_file "config/cable.yml" assert_no_file "app/channels" @@ -87,20 +87,49 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase private def default_files - files = %W( - .gitignore + %w(.gitignore + .ruby-version + README.md Gemfile Rakefile config.ru + app/channels app/controllers app/mailers app/models + app/views/layouts app/views/layouts/mailer.html.erb app/views/layouts/mailer.text.erb + bin/bundle + bin/rails + bin/rake + bin/setup + bin/update + config/application.rb + config/boot.rb + config/cable.yml + config/environment.rb config/environments + config/environments/development.rb + config/environments/production.rb + config/environments/test.rb config/initializers + config/initializers/application_controller_renderer.rb + config/initializers/backtrace_silencers.rb + config/initializers/cors.rb + config/initializers/filter_parameter_logging.rb + config/initializers/inflections.rb + config/initializers/mime_types.rb + config/initializers/wrap_parameters.rb config/locales + config/locales/en.yml + config/puma.rb + config/routes.rb + config/secrets.yml + config/spring.rb + config/storage.yml db + db/seeds.rb lib lib/tasks log @@ -111,8 +140,6 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase tmp vendor ) - files.concat %w(bin/bundle bin/rails bin/rake) - files end def skipped_files @@ -130,7 +157,7 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase public/500.html public/apple-touch-icon-precomposed.png public/apple-touch-icon.png - public/favicon.icon + public/favicon.ico package.json ) end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index ccb437c74d..1183dcd34d 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -537,14 +537,6 @@ class AppGeneratorTest < Rails::Generators::TestCase end end - def test_generator_if_api_is_given - run_generator [destination_root, "--api"] - assert_file "Gemfile" do |content| - assert_no_match(/capybara/, content) - assert_no_match(/selenium-webdriver/, content) - end - end - def test_inclusion_of_javascript_runtime run_generator if defined?(JRUBY_VERSION) |