Do you mean moving the following line into all the individual railties (like activerecord/railtie, action_controller/railtie, etc)?:

```ruby
if defined?(Rake) && Rake.application.top_level_tasks.grep(/^(default$|test(:|$))/).any?
  ENV['RAILS_ENV'] ||= 'test'
end
```