diff options
author | Jon Leighton <j@jonathanleighton.com> | 2013-12-04 01:13:27 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2013-12-04 01:13:27 -0800 |
commit | 6f72a6b53afda51a73af69194ed0060ea5048fa9 (patch) | |
tree | db7fe1fc64a7e75cf0ad9e66b9f6e159743d5301 /railties/test | |
parent | a25cb53939f7625c570a5082a583104f6d74d19a (diff) | |
parent | df50e3064abc3099adc524f381ffced0dab84869 (diff) | |
download | rails-6f72a6b53afda51a73af69194ed0060ea5048fa9.tar.gz rails-6f72a6b53afda51a73af69194ed0060ea5048fa9.tar.bz2 rails-6f72a6b53afda51a73af69194ed0060ea5048fa9.zip |
Merge pull request #12958 from jonleighton/spring
Install Spring preloader when generating new applications
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 28 | ||||
-rw-r--r-- | railties/test/generators/shared_generator_tests.rb | 16 |
2 files changed, 38 insertions, 6 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 257d07f514..7c2040470f 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -437,6 +437,34 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "foo bar/config/initializers/session_store.rb", /key: '_foo_bar/ end + def test_spring + run_generator + assert_file "Gemfile", /gem 'spring'/ + end + + def test_spring_binstubs + generator.stubs(:bundle_command).with('install') + generator.expects(:bundle_command).with('exec spring binstub --all').once + quietly { generator.invoke_all } + end + + def test_spring_no_fork + Process.stubs(:respond_to?).with(:fork).returns(false) + run_generator + + assert_file "Gemfile" do |content| + assert_no_match(/spring/, content) + end + end + + def test_skip_spring + run_generator [destination_root, "--skip-spring"] + + assert_file "Gemfile" do |content| + assert_no_match(/spring/, content) + end + end + protected def action(*args, &block) diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 7184639d23..8e198d5fe1 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -26,11 +26,17 @@ module SharedGeneratorTests default_files.each { |path| assert_file path } end - def test_generation_runs_bundle_install - generator([destination_root]).expects(:bundle_command).with('install').once + def assert_generates_with_bundler(options = {}) + generator([destination_root], options) + generator.expects(:bundle_command).with('install').once + generator.stubs(:bundle_command).with('exec spring binstub --all') quietly { generator.invoke_all } end + def test_generation_runs_bundle_install + assert_generates_with_bundler + end + def test_plugin_new_generate_pretend run_generator ["testapp", "--pretend"] default_files.each{ |path| assert_no_file File.join("testapp",path) } @@ -96,15 +102,13 @@ module SharedGeneratorTests end def test_dev_option - generator([destination_root], dev: true).expects(:bundle_command).with('install').once - quietly { generator.invoke_all } + assert_generates_with_bundler dev: true rails_path = File.expand_path('../../..', Rails.root) assert_file 'Gemfile', /^gem\s+["']rails["'],\s+path:\s+["']#{Regexp.escape(rails_path)}["']$/ end def test_edge_option - generator([destination_root], edge: true).expects(:bundle_command).with('install').once - quietly { generator.invoke_all } + assert_generates_with_bundler edge: true assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$} end |