From e61d6afbab24163d37a73b25262ef73119b99a78 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Fri, 2 Sep 2011 13:31:00 +0400 Subject: fix indent for generator environment method --- railties/test/generators/actions_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index e4a8000425..56cb53c1ad 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -106,7 +106,7 @@ class ActionsTest < Rails::Generators::TestCase run_generator autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]' action :environment, autoload_paths - assert_file 'config/application.rb', /#{Regexp.escape(autoload_paths)}/ + assert_file 'config/application.rb', / class Application < Rails::Application\n #{Regexp.escape(autoload_paths)}/ end def test_environment_should_include_data_in_environment_initializer_block_with_env_option -- cgit v1.2.3 From 47bc5d0cc8dec79c0c64ade7d453b60f846424a9 Mon Sep 17 00:00:00 2001 From: Wojciech Mach Date: Sun, 4 Sep 2011 10:14:53 +0200 Subject: Add gem_group support to generators --- railties/test/generators/actions_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 56cb53c1ad..94e9abb3cc 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -102,6 +102,20 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /gem "rspec-rails"$/ end + def test_gem_group_should_wrap_gems_in_a_group + run_generator + + action :gem_group, :development, :test do + gem 'rspec-rails' + end + + action :gem_group, :test do + gem 'fakeweb' + end + + assert_file 'Gemfile', /\ngroup :development, :test do\n gem "rspec-rails"\nend\n\ngroup :test do\n gem "fakeweb"\nend/ + end + def test_environment_should_include_data_in_environment_initializer_block run_generator autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]' -- cgit v1.2.3 From 148e4a541361f140f13aa35bb43b3d57c95831d6 Mon Sep 17 00:00:00 2001 From: Dmitriy Kiriyenko Date: Thu, 29 Sep 2011 15:35:25 +0300 Subject: Honour RAILS_ENV environment variable when running rake. --- railties/test/generators/actions_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 94e9abb3cc..e621f7f6f7 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -189,6 +189,22 @@ class ActionsTest < Rails::Generators::TestCase action :rake, 'log:clear', :env => 'production' end + def test_rake_with_rails_env_variable_should_run_rake_command_in_env + generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false) + old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "production" + action :rake, 'log:clear' + ensure + ENV["RAILS_ENV"] = old_env + end + + def test_env_option_should_win_over_rails_env_variable_when_running_rake + generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false) + old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "staging" + action :rake, 'log:clear', :env => 'production' + ensure + ENV["RAILS_ENV"] = old_env + end + def test_rake_with_sudo_option_should_run_rake_command_with_sudo generator.expects(:run).once.with('sudo rake log:clear RAILS_ENV=development', :verbose => false) action :rake, 'log:clear', :sudo => true -- cgit v1.2.3 From 4888aba15f98b630d624645f7bba5a53bfdabb2f Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 8 Oct 2011 13:09:28 -0700 Subject: The generator invokes rake with either the :env option, ENV['RAILS_ENV'], or development. So if Travis has exported RAILS_ENV=test, it'll be used instead of development, breaking these brittle expectations. --- railties/test/generators/actions_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index e621f7f6f7..d5301dcdb2 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -179,8 +179,9 @@ class ActionsTest < Rails::Generators::TestCase action :generate, 'model', 'MyModel' end - def test_rake_should_run_rake_command_with_development_env - generator.expects(:run).once.with('rake log:clear RAILS_ENV=development', :verbose => false) + def test_rake_should_run_rake_command_with_default_env + expected_env = ENV['RAILS_ENV'] || 'development' + generator.expects(:run).once.with("rake log:clear RAILS_ENV=#{expected_env}", :verbose => false) action :rake, 'log:clear' end @@ -206,7 +207,8 @@ class ActionsTest < Rails::Generators::TestCase end def test_rake_with_sudo_option_should_run_rake_command_with_sudo - generator.expects(:run).once.with('sudo rake log:clear RAILS_ENV=development', :verbose => false) + expected_env = ENV['RAILS_ENV'] || 'development' + generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=#{expected_env}", :verbose => false) action :rake, 'log:clear', :sudo => true end -- cgit v1.2.3 From f655895e87c8e013caac649986510eff4d3b03d9 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sat, 8 Oct 2011 16:27:22 -0500 Subject: Isolate rake action tests that should be run under default env --- railties/test/generators/actions_test.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index d5301dcdb2..51fa2fe16f 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -180,9 +180,11 @@ class ActionsTest < Rails::Generators::TestCase end def test_rake_should_run_rake_command_with_default_env - expected_env = ENV['RAILS_ENV'] || 'development' - generator.expects(:run).once.with("rake log:clear RAILS_ENV=#{expected_env}", :verbose => false) + generator.expects(:run).once.with("rake log:clear RAILS_ENV=development", :verbose => false) + old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil action :rake, 'log:clear' + ensure + ENV["RAILS_ENV"] = old_env end def test_rake_with_env_option_should_run_rake_command_in_env @@ -207,9 +209,11 @@ class ActionsTest < Rails::Generators::TestCase end def test_rake_with_sudo_option_should_run_rake_command_with_sudo - expected_env = ENV['RAILS_ENV'] || 'development' - generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=#{expected_env}", :verbose => false) + generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=development", :verbose => false) + old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil action :rake, 'log:clear', :sudo => true + ensure + ENV["RAILS_ENV"] = old_env end def test_capify_should_run_the_capify_command -- cgit v1.2.3 From c8d7291b6b5736562b112007365317648ae2b790 Mon Sep 17 00:00:00 2001 From: ganesh Date: Fri, 25 Nov 2011 14:55:28 +0530 Subject: Added tests for #3751 --- railties/test/generators/actions_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 51fa2fe16f..917b196777 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -113,7 +113,7 @@ class ActionsTest < Rails::Generators::TestCase gem 'fakeweb' end - assert_file 'Gemfile', /\ngroup :development, :test do\n gem "rspec-rails"\nend\n\ngroup :test do\n gem "fakeweb"\nend/ + assert_file 'Gemfile', /\ngroup :development, :test do\n \ngem "rspec-rails"\nend\n\ngroup :test do\n \ngem "fakeweb"\nend/ end def test_environment_should_include_data_in_environment_initializer_block -- cgit v1.2.3 From 95e9b5fbfd87b81bf2d2b16a6df6d9ddbfdb686d Mon Sep 17 00:00:00 2001 From: John Donahue Date: Fri, 25 Nov 2011 09:06:14 -0800 Subject: Updating newline fix to maintain existing linebreaks and indentation and test for b/eol on inserts --- railties/test/generators/actions_test.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'railties/test/generators/actions_test.rb') diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 917b196777..c1fd6a38f1 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -95,11 +95,13 @@ class ActionsTest < Rails::Generators::TestCase def test_gem_should_insert_on_separate_lines run_generator + File.open('Gemfile', 'a') {|f| f.write('# Some content...') } + action :gem, 'rspec' action :gem, 'rspec-rails' - assert_file 'Gemfile', /gem "rspec"$/ - assert_file 'Gemfile', /gem "rspec-rails"$/ + assert_file 'Gemfile', /^gem "rspec"$/ + assert_file 'Gemfile', /^gem "rspec-rails"$/ end def test_gem_group_should_wrap_gems_in_a_group @@ -112,8 +114,8 @@ class ActionsTest < Rails::Generators::TestCase action :gem_group, :test do gem 'fakeweb' end - - assert_file 'Gemfile', /\ngroup :development, :test do\n \ngem "rspec-rails"\nend\n\ngroup :test do\n \ngem "fakeweb"\nend/ + + assert_file 'Gemfile', /\ngroup :development, :test do\n gem "rspec-rails"\nend\n\ngroup :test do\n gem "fakeweb"\nend/ end def test_environment_should_include_data_in_environment_initializer_block -- cgit v1.2.3