diff options
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/actions_test.rb | 28 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 12 | ||||
-rw-r--r-- | railties/test/generators/generators_test_helper.rb | 1 |
3 files changed, 29 insertions, 12 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index cb1fa96e0d..5929db6318 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -36,22 +36,22 @@ class ActionsTest < Rails::Generators::TestCase end def test_plugin_with_git_option_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install #{@git_plugin_uri}", :verbose => false) + generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@git_plugin_uri}", :verbose => false) action :plugin, 'restful-authentication', :git => @git_plugin_uri end def test_plugin_with_svn_option_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install #{@svn_plugin_uri}", :verbose => false) + generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@svn_plugin_uri}", :verbose => false) action :plugin, 'restful-authentication', :svn => @svn_plugin_uri end def test_plugin_with_git_option_and_branch_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install -b stable #{@git_plugin_uri}", :verbose => false) + generator.expects(:run_ruby_script).once.with("script/rails plugin install -b stable #{@git_plugin_uri}", :verbose => false) action :plugin, 'restful-authentication', :git => @git_plugin_uri, :branch => 'stable' end def test_plugin_with_svn_option_and_revision_should_run_plugin_install - generator.expects(:run_ruby_script).once.with("script/plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false) + generator.expects(:run_ruby_script).once.with("script/rails plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false) action :plugin, 'restful-authentication', :svn => @svn_plugin_uri, :revision => 1234 end @@ -103,6 +103,24 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /gem "rspec", :only => \["development", "test"\]/ end + def test_gem_with_version_should_include_version_in_gemfile + run_generator + + action :gem, 'rspec', '>=2.0.0.a5' + + assert_file 'Gemfile', /gem "rspec", ">=2.0.0.a5"/ + end + + def test_gem_should_insert_on_separate_lines + run_generator + + action :gem, 'rspec' + action :gem, 'rspec-rails' + + assert_file 'Gemfile', /gem "rspec"$/ + assert_file 'Gemfile', /gem "rspec-rails"$/ + end + def test_environment_should_include_data_in_environment_initializer_block run_generator load_paths = 'config.load_paths += %w["#{Rails.root}/app/extras"]' @@ -155,7 +173,7 @@ class ActionsTest < Rails::Generators::TestCase end def test_generate_should_run_script_generate_with_argument_and_options - generator.expects(:run_ruby_script).once.with('script/generate model MyModel', :verbose => false) + generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', :verbose => false) action :generate, 'model', 'MyModel' end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 76579adb26..0a746b200f 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -74,13 +74,13 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_config_database_is_added_by_default run_generator assert_file "config/database.yml", /sqlite3/ - assert_file "Gemfile", /^gem "sqlite3-ruby", :require => "sqlite3"$/ + assert_file "Gemfile", /^gem\s+["']sqlite3-ruby["'],\s+:require\s+=>\s+["']sqlite3["']$/ end def test_config_another_database run_generator([destination_root, "-d", "mysql"]) assert_file "config/database.yml", /mysql/ - assert_file "Gemfile", /^gem "mysql"$/ + assert_file "Gemfile", /^gem\s+["']mysql["']$/ end def test_config_database_is_not_added_if_skip_activerecord_is_given @@ -90,7 +90,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given run_generator [destination_root, "--skip-activerecord"] - assert_file "config/boot.rb", /# require "active_record\/railtie"/ + assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ end def test_prototype_and_test_unit_are_added_by_default @@ -158,15 +158,13 @@ class AppGeneratorTest < Rails::Generators::TestCase generator([destination_root], :dev => true).expects(:run).with("bundle install") silence(:stdout){ generator.invoke } rails_path = File.expand_path('../../..', Rails.root) - dev_gem = %(path #{rails_path.inspect}, :glob => "{*/,}*.gemspec") - assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/ + 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 install") silence(:stdout){ generator.invoke } - edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git") - assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/ + assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$/ end protected diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 3cd16a69f9..32be99b144 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -6,6 +6,7 @@ module Rails end end Rails.application.config.root = Rails.root +Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")] require 'rails/generators' require 'rails/generators/test_case' |