From 3ed41e579e45464aa6e6342783b77f9ec29e339c Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Sat, 9 Mar 2013 16:03:09 -0500 Subject: Make sure that `rails test` load test in test env --- railties/lib/rails/commands/test_runner.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/commands/test_runner.rb') diff --git a/railties/lib/rails/commands/test_runner.rb b/railties/lib/rails/commands/test_runner.rb index 92c4d4e593..d8857bd183 100644 --- a/railties/lib/rails/commands/test_runner.rb +++ b/railties/lib/rails/commands/test_runner.rb @@ -56,6 +56,10 @@ module Rails exit end + opts.on '-e', '--environment NAME', String, 'Specifies the environment to run this test under' do |e| + options[:environment] = e + end + opts.on '-f', '--fixtures', 'Load fixtures in test/fixtures/ before running the tests' do options[:fixtures] = true end @@ -68,8 +72,8 @@ module Rails options[:verbose] = true end - opts.on '-n', '--name PATTERN', "Filter test names on pattern (e.g. /foo/)" do |a| - options[:filter] = a + opts.on '-n', '--name PATTERN', "Filter test names on pattern (e.g. /foo/)" do |n| + options[:filter] = n end opts.separator "" @@ -94,7 +98,9 @@ module Rails # Creates a new +TestRunner+ object with a list of test file paths. def initialize(files, options) @files = files - Rake::Task['test:prepare'].invoke + + Rails.application.load_tasks + Rake::Task['db:test:load'].invoke if options.delete(:fixtures) if defined?(ActiveRecord::Base) -- cgit v1.2.3