class AppGeneratorTest
Public Instance Methods
default_files()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 101 def default_files ::DEFAULT_APP_FILES end
test_action_cable_redis_gems()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 404 def test_action_cable_redis_gems run_generator assert_file "Gemfile", /^# gem 'redis'/ end
test_after_bundle_callback()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 730 def test_after_bundle_callback path = "http://example.org/quails_template" template = %{ after_bundle { run 'echo ran after_bundle' } }.dup template.instance_eval "def read; self; end" # Make the string respond to read check_open = -> *args do assert_equal [ path, "Accept" => "application/x-thor-template" ], args template end sequence = ["git init", "install", "exec spring binstub --all", "echo ran after_bundle"] @sequence_step ||= 0 ensure_bundler_first = -> command do assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}" @sequence_step += 1 end generator([destination_root], template: path).stub(:open, check_open, template) do generator.stub(:bundle_command, ensure_bundler_first) do generator.stub(:run, ensure_bundler_first) do quietly { generator.invoke_all } end end end assert_equal 4, @sequence_step end
test_app_update_create_new_framework_defaults()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 244 def test_app_update_create_new_framework_defaults app_root = File.join(destination_root, "myapp") run_generator [app_root] assert_no_file "#{app_root}/config/initializers/new_framework_defaults_5_2.rb" stub_quails_application(app_root) do generator = Quails::Generators::AppGenerator.new ["quails"], { update: true }, { destination_root: app_root, shell: @shell } generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "#{app_root}/config/initializers/new_framework_defaults_5_2.rb" end end
test_app_update_does_not_create_rack_cors()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 259 def test_app_update_does_not_create_rack_cors app_root = File.join(destination_root, "myapp") run_generator [app_root] stub_quails_application(app_root) do generator = Quails::Generators::AppGenerator.new ["quails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_no_file "#{app_root}/config/initializers/cors.rb" end end
test_app_update_does_not_generate_action_cable_contents_when_skip_action_cable_is_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 285 def test_app_update_does_not_generate_action_cable_contents_when_skip_action_cable_is_given app_root = File.join(destination_root, "myapp") run_generator [app_root, "--skip-action-cable"] FileUtils.cd(app_root) do # For avoid conflict file FileUtils.rm("#{app_root}/config/secrets.yml") quietly { system("bin/quails app:update") } end assert_no_file "#{app_root}/config/cable.yml" assert_file "#{app_root}/config/environments/production.rb" do |content| assert_no_match(/config\.action_cable/, content) end end
test_app_update_does_not_remove_rack_cors_if_already_present()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 271 def test_app_update_does_not_remove_rack_cors_if_already_present app_root = File.join(destination_root, "myapp") run_generator [app_root] FileUtils.touch("#{app_root}/config/initializers/cors.rb") stub_quails_application(app_root) do generator = Quails::Generators::AppGenerator.new ["quails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "#{app_root}/config/initializers/cors.rb" end end
test_app_update_generates_correct_session_key()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 178 def test_app_update_generates_correct_session_key app_root = File.join(destination_root, "myapp") run_generator [app_root] stub_quails_application(app_root) do generator = Quails::Generators::AppGenerator.new ["quails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } end end
test_application_job_file_present()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 114 def test_application_job_file_present run_generator assert_file("app/jobs/application_job.rb") end
test_application_name_is_detected_if_it_exists_and_app_folder_renamed()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 156 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") run_generator [app_root] stub_quails_application(app_moved_root) do Quails.application.stub(:is_a?, -> *args { Quails::Application }) do FileUtils.mv(app_root, app_moved_root) # make sure we are in correct dir FileUtils.cd(app_moved_root) generator = Quails::Generators::AppGenerator.new ["quails"], [], destination_root: app_moved_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "myapp_moved/config/environment.rb", /Quails\.application\.initialize!/ end end end
test_application_name_with_spaces()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 565 def test_application_name_with_spaces path = File.join(destination_root, "foo bar") # This also applies to MySQL apps but not with SQLite run_generator [path, "-d", "postgresql"] assert_file "foo bar/config/database.yml", /database: foo_bar_development/ end
test_application_names_are_not_singularized()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 301 def test_application_names_are_not_singularized run_generator [File.join(destination_root, "hats")] assert_file "hats/config/environment.rb", /Quails\.application\.initialize!/ end
test_application_new_exits_with_message_and_non_zero_code_when_generating_inside_existing_quails_directory()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 135 def test_application_new_exits_with_message_and_non_zero_code_when_generating_inside_existing_quails_directory app_root = File.join(destination_root, "myfirstapp") run_generator [app_root] output = nil Dir.chdir(app_root) do output = `quails new mysecondapp` end assert_equal "Can't initialize a new Quails application within the directory of another, please change to a non-Quails directory first.\nType 'quails' for help.\n", output assert_equal false, $?.success? end
test_application_new_exits_with_non_zero_code_on_invalid_application_name()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 130 def test_application_new_exits_with_non_zero_code_on_invalid_application_name quietly { system "quails new test --no-rc" } assert_equal false, $?.success? end
test_application_new_show_help_message_inside_existing_quails_directory()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 146 def test_application_new_show_help_message_inside_existing_quails_directory app_root = File.join(destination_root, "myfirstapp") run_generator [app_root] output = Dir.chdir(app_root) do `quails new --help` end assert_match(/quails new APP_PATH \[options\]/, output) assert_equal true, $?.success? end
test_assets()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 105 def test_assets run_generator assert_file("app/views/layouts/application.html.erb", /stylesheet_link_tag\s+'application', media: 'all', 'data-turbolinks-track': 'reload'/) assert_file("app/views/layouts/application.html.erb", /javascript_include_tag\s+'application', 'data-turbolinks-track': 'reload'/) assert_file("app/assets/stylesheets/application.css") assert_file("app/assets/javascripts/application.js") end
test_coffeescript_is_skipped_if_required()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 483 def test_coffeescript_is_skipped_if_required run_generator [destination_root, "--skip-coffee"] assert_file "Gemfile" do |content| assert_no_match(/coffee-quails/, content) assert_match(/uglifier/, content) end end
test_config_another_database()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 326 def test_config_another_database run_generator([destination_root, "-d", "mysql"]) assert_file "config/database.yml", /mysql/ if defined?(JRUBY_VERSION) assert_gem "activerecord-jdbcmysql-adapter" else assert_gem "mysql2", "'>= 0.3.18', '< 0.5'" end end
test_config_database_app_name_with_period()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 336 def test_config_database_app_name_with_period run_generator [File.join(destination_root, "common.usage.com"), "-d", "postgresql"] assert_file "common.usage.com/config/database.yml", /common_usage_com/ end
test_config_database_is_added_by_default()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 316 def test_config_database_is_added_by_default run_generator assert_file "config/database.yml", /sqlite3/ if defined?(JRUBY_VERSION) assert_gem "activerecord-jdbcsqlite3-adapter" else assert_gem "sqlite3" end end
test_config_jdbc_database()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 369 def test_config_jdbc_database run_generator([destination_root, "-d", "jdbc"]) assert_file "config/database.yml", /jdbc/ assert_file "config/database.yml", /mssql/ assert_gem "activerecord-jdbc-adapter" end
test_config_jdbc_database_when_no_option_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 377 def test_config_jdbc_database_when_no_option_given run_generator assert_file "config/database.yml", /sqlite3/ assert_gem "activerecord-jdbcsqlite3-adapter" end
test_config_jdbcmysql_database()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 351 def test_config_jdbcmysql_database run_generator([destination_root, "-d", "jdbcmysql"]) assert_file "config/database.yml", /mysql/ assert_gem "activerecord-jdbcmysql-adapter" end
test_config_jdbcpostgresql_database()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 363 def test_config_jdbcpostgresql_database run_generator([destination_root, "-d", "jdbcpostgresql"]) assert_file "config/database.yml", /postgresql/ assert_gem "activerecord-jdbcpostgresql-adapter" end
test_config_jdbcsqlite3_database()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 357 def test_config_jdbcsqlite3_database run_generator([destination_root, "-d", "jdbcsqlite3"]) assert_file "config/database.yml", /sqlite3/ assert_gem "activerecord-jdbcsqlite3-adapter" end
test_config_postgresql_database()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 341 def test_config_postgresql_database run_generator([destination_root, "-d", "postgresql"]) assert_file "config/database.yml", /postgresql/ if defined?(JRUBY_VERSION) assert_gem "activerecord-jdbcpostgresql-adapter" else assert_gem "pg", "'~> 0.18'" end end
test_create_keeps()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 694 def test_create_keeps run_generator folders_with_keep = %w( app/assets/images app/controllers/concerns app/models/concerns lib/tasks lib/assets log test/fixtures test/fixtures/files test/controllers test/mailers test/models test/helpers test/integration tmp ) folders_with_keep.each do |folder| assert_file("#{folder}/.keep") end end
test_default_namespace()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 550 def test_default_namespace assert_match "quails:app", Quails::Generators::AppGenerator.namespace end
test_default_usage()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 544 def test_default_usage assert_called(Quails::Generators::AppGenerator, :usage_path, returns: nil) do assert_match(/Create quails files for app generator/, Quails::Generators::AppGenerator.desc) end end
test_dev_option()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 601 def test_dev_option assert_generates_with_bundler dev: true quails_path = File.expand_path("../../..", Quails.root) assert_file "Gemfile", /^gem\s+["']quails["'],\s+path:\s+["']#{Regexp.escape(quails_path)}["']$/ end
test_does_not_generate_system_test_files_if_skip_system_test_is_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 434 def test_does_not_generate_system_test_files_if_skip_system_test_is_given run_generator [destination_root, "--skip-system-test"] Dir.chdir(destination_root) do quietly { `./bin/quails g scaffold User` } assert_no_file("test/application_system_test_case.rb") assert_no_file("test/system/users_test.rb") end end
test_edge_option()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 607 def test_edge_option assert_generates_with_bundler edge: true assert_file "Gemfile", %r{^gem\s+["']quails["'],\s+github:\s+["']#{Regexp.escape("quails/quails")}["']$} end
test_evented_file_update_checker_config()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 522 def test_evented_file_update_checker_config run_generator assert_file "config/environments/development.rb" do |content| if RbConfig::CONFIG["host_os"] =~ /darwin|linux/ assert_match(/^\s*config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content) else assert_match(/^\s*# config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content) end end end
test_file_is_added_for_backwards_compatibility()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 554 def test_file_is_added_for_backwards_compatibility action :file, "lib/test_file.rb", "heres test data" assert_file "lib/test_file.rb", "heres test data" end
test_gemfile_has_no_whitespace_errors()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 306 def test_gemfile_has_no_whitespace_errors run_generator absolute = File.expand_path("Gemfile", destination_root) File.open(absolute, "r") do |f| f.each_line do |line| assert_no_match %r{/^[ \t]+$/}, line end end end
test_generation_runs_bundle_install()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 597 def test_generation_runs_bundle_install assert_generates_with_bundler end
test_generator_defaults_to_puma_version()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 384 def test_generator_defaults_to_puma_version run_generator [destination_root] assert_gem "puma", "'~> 3.7'" end
test_generator_has_assets_gems()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 397 def test_generator_has_assets_gems run_generator assert_gem "sass-quails" assert_gem "uglifier" end
test_generator_if_skip_puma_is_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 389 def test_generator_if_skip_puma_is_given run_generator [destination_root, "--skip-puma"] assert_no_file "config/puma.rb" assert_file "Gemfile" do |content| assert_no_match(/puma/, content) end end
test_generator_if_skip_system_test_is_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 422 def test_generator_if_skip_system_test_is_given run_generator [destination_root, "--skip-system-test"] assert_file "Gemfile" do |content| assert_no_match(/capybara/, content) assert_no_match(/selenium-webdriver/, content) end assert_directory("test") assert_no_directory("test/system") end
test_generator_if_skip_test_is_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 409 def test_generator_if_skip_test_is_given run_generator [destination_root, "--skip-test"] assert_file "config/application.rb", /#\s+require\s+["']quails\/test_unit\/railtie["']/ assert_file "Gemfile" do |content| assert_no_match(/capybara/, content) assert_no_match(/selenium-webdriver/, content) end assert_no_directory("test") end
test_generator_if_skip_turbolinks_is_given()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 664 def test_generator_if_skip_turbolinks_is_given run_generator [destination_root, "--skip-turbolinks"] assert_file "Gemfile" do |content| assert_no_match(/turbolinks/, content) end assert_file "app/views/layouts/application.html.erb" do |content| assert_no_match(/data-turbolinks-track/, content) end assert_file "app/assets/javascripts/application.js" do |content| assert_no_match(/turbolinks/, content) end end
test_inclusion_of_a_debugger()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 497 def test_inclusion_of_a_debugger run_generator if defined?(JRUBY_VERSION) || RUBY_ENGINE == "rbx" assert_file "Gemfile" do |content| assert_no_match(/byebug/, content) end else assert_gem "byebug" end end
test_inclusion_of_javascript_runtime()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 445 def test_inclusion_of_javascript_runtime run_generator if defined?(JRUBY_VERSION) assert_gem "therubyrhino" elsif RUBY_PLATFORM =~ /mingw|mswin/ assert_gem "duktape" else assert_file "Gemfile", /# gem 'mini_racer', platforms: :ruby/ end end
test_inclusion_of_jbuilder()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 492 def test_inclusion_of_jbuilder run_generator assert_gem "jbuilder" end
test_inclusion_of_ruby_version()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 678 def test_inclusion_of_ruby_version run_generator assert_file "Gemfile" do |content| assert_match(/ruby '#{RUBY_VERSION}'/, content) end assert_file ".ruby-version" do |content| assert_match(/#{RUBY_VERSION}/, content) end end
test_invalid_application_name_is_fixed()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 124 def test_invalid_application_name_is_fixed run_generator [File.join(destination_root, "things-43")] assert_file "things-43/config/environment.rb", /Quails\.application\.initialize!/ assert_file "things-43/config/application.rb", /^module Things43$/ end
test_invalid_application_name_raises_an_error()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 119 def test_invalid_application_name_raises_an_error content = capture(:stderr) { run_generator [File.join(destination_root, "43-things")] } assert_equal "Invalid application name 43-things. Please give a name which does not start with numbers.\n", content end
test_javascript_is_skipped_if_required()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 463 def test_javascript_is_skipped_if_required run_generator [destination_root, "--skip-javascript"] assert_no_file "app/assets/javascripts" assert_file "app/views/layouts/application.html.erb" do |contents| assert_match(/stylesheet_link_tag\s+'application', media: 'all' %>/, contents) assert_no_match(/javascript_include_tag\s+'application' \%>/, contents) end assert_file "Gemfile" do |content| assert_no_match(/coffee-quails/, content) assert_no_match(/uglifier/, content) end assert_file "config/environments/production.rb" do |content| assert_no_match(/config\.assets\.js_compressor = :uglifier/, content) end end
test_new_application_doesnt_need_defaults()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 201 def test_new_application_doesnt_need_defaults assert_no_file "config/initializers/new_framework_defaults_5_2.rb" end
test_new_application_load_defaults()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 205 def test_new_application_load_defaults app_root = File.join(destination_root, "myfirstapp") run_generator [app_root] output = nil Dir.chdir(app_root) do output = `./bin/quails r "puts Quails.application.config.assets.unknown_asset_fallback"` end assert_equal "false\n", output end
test_new_application_not_include_api_initializers()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 195 def test_new_application_not_include_api_initializers run_generator assert_no_file "config/initializers/cors.rb" end
test_new_application_use_json_serialzier()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 189 def test_new_application_use_json_serialzier run_generator assert_file("config/initializers/cookies_serializer.rb", /Quails\.application\.config\.action_dispatch\.cookies_serializer = :json/) end
test_pretend_option()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 559 def test_pretend_option output = run_generator [File.join(destination_root, "myapp"), "--pretend"] assert_no_match(/run bundle install/, output) assert_no_match(/run git init/, output) end
test_psych_gem()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 717 def test_psych_gem run_generator gem_regex = /gem 'psych',\s+'~> 2\.0',\s+platforms: :rbx/ assert_file "Gemfile" do |content| if defined?(Rubinius) assert_match(gem_regex, content) else assert_no_match(gem_regex, content) end end end
test_quails_ujs_is_the_default_ujs_library()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 456 def test_quails_ujs_is_the_default_ujs_library run_generator assert_file "app/assets/javascripts/application.js" do |contents| assert_match %r{^//= require quails-ujs}, contents end end
test_skip_spring()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 647 def test_skip_spring run_generator [destination_root, "--skip-spring"] assert_no_file "config/spring.rb" assert_file "Gemfile" do |content| assert_no_match(/spring/, content) end end
test_spring()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 612 def test_spring run_generator assert_gem "spring" end
test_spring_binstubs()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 617 def test_spring_binstubs jruby_skip "spring doesn't run on JRuby" command_check = -> command do @binstub_called ||= 0 case command when "install" # Called when running bundle, we just want to stub it so nothing to do here. when "exec spring binstub --all" @binstub_called += 1 assert_equal 1, @binstub_called, "exec spring binstub --all expected to be called once, but was called #{@install_called} times." end end generator.stub :bundle_command, command_check do quietly { generator.invoke_all } end end
test_spring_no_fork()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 636 def test_spring_no_fork jruby_skip "spring doesn't run on JRuby" assert_called_with(Process, :respond_to?, [[:fork], [:fork]], returns: false) do run_generator assert_file "Gemfile" do |content| assert_no_match(/spring/, content) end end end
test_spring_with_dev_option()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 656 def test_spring_with_dev_option run_generator [destination_root, "--dev"] assert_file "Gemfile" do |content| assert_no_match(/spring/, content) end end
test_system_tests_directory_generated()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 758 def test_system_tests_directory_generated run_generator assert_file("test/system/.keep") assert_directory("test/system") end
test_template_from_dir_pwd()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 533 def test_template_from_dir_pwd FileUtils.cd(Quails.root) assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"])) end
test_usage_read_from_file()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 538 def test_usage_read_from_file assert_called(File, :read, returns: "USAGE FROM FILE") do assert_equal "USAGE FROM FILE", Quails::Generators::AppGenerator.desc end end
test_version_control_initializes_git_repo()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 689 def test_version_control_initializes_git_repo run_generator [destination_root] assert_directory ".git" end
test_web_console()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 574 def test_web_console run_generator assert_gem "web-console" end
test_web_console_with_dev_option()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 579 def test_web_console_with_dev_option run_generator [destination_root, "--dev"] assert_file "Gemfile" do |content| assert_match(/gem 'web-console',\s+github: 'quails\/web-console'/, content) assert_no_match(/\Agem 'web-console', '>= 3\.3\.0'\z/, content) end end
test_web_console_with_edge_option()
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 588 def test_web_console_with_edge_option run_generator [destination_root, "--edge"] assert_file "Gemfile" do |content| assert_match(/gem 'web-console',\s+github: 'quails\/web-console'/, content) assert_no_match(/\Agem 'web-console', '>= 3\.3\.0'\z/, content) end end
Private Instance Methods
action(*args, &block)
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 773 def action(*args, &block) capture(:stdout) { generator.send(*args, &block) } end
assert_gem(gem, constraint = nil)
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 777 def assert_gem(gem, constraint = nil) if constraint assert_file "Gemfile", /^\s*gem\s+["']#{gem}["'], #{constraint}$*/ else assert_file "Gemfile", /^\s*gem\s+["']#{gem}["']$*/ end end
assert_generates_with_bundler(options = {})
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 804 def assert_generates_with_bundler(options = {}) generator([destination_root], options) command_check = -> command do @install_called ||= 0 case command when "install" @install_called += 1 assert_equal 1, @install_called, "install expected to be called once, but was called #{@install_called} times" when "exec spring binstub --all" # Called when running tests with spring, let through unscathed. end end generator.stub :bundle_command, command_check do quietly { generator.invoke_all } end end
stub_quails_application(root) { || ... }
click to toggle source
# File railties/test/generators/app_generator_test.rb, line 766 def stub_quails_application(root) Quails.application.config.root = root Quails.application.class.stub(:name, "Myapp") do yield end end