aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2013-03-09 16:03:09 -0500
committerPrem Sichanugrist <s@sikac.hu>2013-03-09 17:38:39 -0500
commit3ed41e579e45464aa6e6342783b77f9ec29e339c (patch)
tree77d2b30e6f0f7b9ec2790b30c0cb116e2dc5329c /railties/test
parentb51673fbd9563bd3ffa22e22255ca1cef80cfb6d (diff)
downloadrails-3ed41e579e45464aa6e6342783b77f9ec29e339c.tar.gz
rails-3ed41e579e45464aa6e6342783b77f9ec29e339c.tar.bz2
rails-3ed41e579e45464aa6e6342783b77f9ec29e339c.zip
Make sure that `rails test` load test in test env
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/test_runner_test.rb45
1 files changed, 44 insertions, 1 deletions
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 810748682a..7a5a428845 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -191,6 +191,39 @@ module ApplicationTests
end
end
+ def test_run_different_environment_using_env_var
+ app_file 'test/unit/env_test.rb', <<-RUBY
+ require 'test_helper'
+
+ class EnvTest < ActiveSupport::TestCase
+ def test_env
+ puts Rails.env
+ end
+ end
+ RUBY
+
+ assert_match /development/, Dir.chdir(app_path) { `RAILS_ENV=development bundle exec rails test test/unit/env_test.rb` }
+ end
+
+ def test_run_different_environment_using_e_tag
+ app_file 'test/unit/env_test.rb', <<-RUBY
+ require 'test_helper'
+
+ class EnvTest < ActiveSupport::TestCase
+ def test_env
+ puts Rails.env
+ end
+ end
+ RUBY
+
+ assert_match /development/, run_test_command('-e development test/unit/env_test.rb')
+ end
+
+ def test_generated_scaffold_works_with_rails_test
+ create_scaffold
+ assert_match /0 failures, 0 errors, 0 skips/, run_test_command('')
+ end
+
private
def run_test_command(arguments = 'test/unit/test_test.rb')
Dir.chdir(app_path) { `bundle exec rails test #{arguments}` }
@@ -211,7 +244,7 @@ module ApplicationTests
name: Tsubasa Hanekawa
YAML
- Dir.chdir(app_path) { `bundle exec rake db:migrate` }
+ run_migration
end
def create_fixture_test(path = :unit, name = 'test')
@@ -251,5 +284,15 @@ module ApplicationTests
end
RUBY
end
+
+ def create_scaffold
+ script 'generate scaffold user name:string'
+ Dir.chdir(app_path) { File.exist?('app/models/user.rb') }
+ run_migration
+ end
+
+ def run_migration
+ Dir.chdir(app_path) { `bundle exec rake db:migrate` }
+ end
end
end