aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/shared_generator_tests.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-05-13 00:43:43 +0200
committerXavier Noria <fxn@hashref.com>2011-05-13 01:06:27 +0200
commitc88dddbe4d40c9e0590df4d6f76c02c46448264d (patch)
treedd8ba047a85432af3d89937a10fcb54f7d296d82 /railties/test/generators/shared_generator_tests.rb
parent55d87d2b5c2d9176752ef62eaf0e8ef2e37ca52c (diff)
downloadrails-c88dddbe4d40c9e0590df4d6f76c02c46448264d.tar.gz
rails-c88dddbe4d40c9e0590df4d6f76c02c46448264d.tar.bz2
rails-c88dddbe4d40c9e0590df4d6f76c02c46448264d.zip
application and plugin generation run bundle check unless --skip-gemfile
The purpose of this feature is that the user knows whether dependencies are satisfied. In particular, if they are not he will be warned upfront, rather than finding out himself in an abrupt way by trying to run something.
Diffstat (limited to 'railties/test/generators/shared_generator_tests.rb')
-rw-r--r--railties/test/generators/shared_generator_tests.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index 3fcf75883c..524aa2a05f 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -6,7 +6,6 @@ module SharedGeneratorTests
Rails.application = TestApp::Application
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
- @bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
Kernel::silence_warnings do
Thor::Base.shell.send(:attr_accessor, :always_force)
@@ -24,7 +23,12 @@ module SharedGeneratorTests
def test_skeleton_is_created
run_generator
- default_files.each{ |path| assert_file path }
+ default_files.each { |path| assert_file path }
+ end
+
+ def test_generation_runs_bundle_check
+ generator([destination_root]).expects(:bundle_command).with('check').once
+ silence(:stdout) { generator.invoke_all }
end
def test_plugin_new_generate_pretend
@@ -112,17 +116,23 @@ module SharedGeneratorTests
end
def test_dev_option
- generator([destination_root], :dev => true).expects(:run).with("#{@bundle_command} install")
- silence(:stdout){ generator.invoke_all }
+ generator([destination_root], :dev => true).expects(:bundle_command).with('install').once
+ silence(:stdout) { generator.invoke_all }
rails_path = File.expand_path('../../..', Rails.root)
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/
end
def test_edge_option
- generator([destination_root], :edge => true).expects(:run).with("#{@bundle_command} install")
- silence(:stdout){ generator.invoke_all }
+ generator([destination_root], :edge => true).expects(:bundle_command).with('install').once
+ silence(:stdout) { generator.invoke_all }
assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$}
end
+
+ def test_skip_gemfile
+ generator([destination_root], :skip_gemfile => true).expects(:bundle_command).never
+ silence(:stdout) { generator.invoke_all }
+ assert_no_file 'Gemfile'
+ end
end
module SharedCustomGeneratorTests
@@ -130,7 +140,6 @@ module SharedCustomGeneratorTests
Rails.application = TestApp::Application
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
- @bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
end
def teardown