Permalink
Browse files

Don't load ActiveSupport before the environment has been initialized …

…since it can hide problems in the plugin being tested

Tag 0.1.5 release
  • Loading branch information...
obrie committed Jul 13, 2008
1 parent a93e940 commit eaddfc795cee22987b487a55f6c459ace4f7d34b
Showing with 30 additions and 13 deletions.
  1. +3 −0 CHANGELOG.rdoc
  2. +1 −1 Rakefile
  3. +2 −2 lib/plugin_test_helper.rb
  4. +19 −10 lib/plugin_test_helper/extensions/initializer.rb
  5. +5 −0 test/test_helper.rb
View
@@ -1,5 +1,8 @@
== master
+== 0.1.5 / 2008-07-13
+
+* Don't load ActiveSupport before the environment has been initialized since it can hide problems in the plugin being tested
* Simplify how to determine which routing file to use
== 0.1.4 / 2008-06-22
View
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
spec = Gem::Specification.new do |s|
s.name = 'plugin_test_helper'
- s.version = '0.1.4'
+ s.version = '0.1.5'
s.platform = Gem::Platform::RUBY
s.summary = 'Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.'
@@ -16,8 +16,8 @@
require 'plugin_test_helper/extensions/initializer'
# Load the Rails environment and testing framework
-require_or_load 'config/environment'
-require_or_load 'test_help'
+require 'config/environment'
+require 'test_help'
# Undo changes to RAILS_ENV
silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
@@ -1,4 +1,3 @@
-require 'active_support'
require 'plugin_test_helper/plugin_locator'
module PluginAWeek #:nodoc:
@@ -9,7 +8,8 @@ module Extensions #:nodoc:
module Initializer
def self.included(base)
base.class_eval do
- alias_method_chain :require_frameworks, :test_helper
+ alias_method :require_frameworks_without_test_helper, :require_frameworks
+ alias_method :require_frameworks, :require_frameworks_with_test_helper
end
end
@@ -26,14 +26,23 @@ def require_frameworks_with_test_helper
# using the helper
module Configuration
def self.included(base) #:nodoc:
- base.class_eval do
- alias_method_chain :environment_path, :test_helper
- alias_method_chain :default_load_paths, :test_helper
- alias_method_chain :default_database_configuration_file, :test_helper
- alias_method_chain :default_routes_configuration_file, :test_helper
- alias_method_chain :default_controller_paths, :test_helper
- alias_method_chain :default_plugin_locators, :test_helper
- alias_method_chain :default_plugin_paths, :test_helper
+ alias_method_chain base, :environment_path, :test_helper
+ alias_method_chain base, :default_load_paths, :test_helper
+ alias_method_chain base, :default_database_configuration_file, :test_helper
+ alias_method_chain base, :default_routes_configuration_file, :test_helper
+ alias_method_chain base, :default_controller_paths, :test_helper
+ alias_method_chain base, :default_plugin_locators, :test_helper
+ alias_method_chain base, :default_plugin_paths, :test_helper
+ end
+
+ # Defines a "lite" version of ActiveSupport's alias chaining extensions.
+ # This is defined here and acts on a particular class so as to not conflict
+ # with other classes that we have no control over
+ def self.alias_method_chain(klass, target, feature)
+ with_method, without_method = "#{target}_with_#{feature}", "#{target}_without_#{feature}"
+ klass.class_eval do
+ alias_method without_method, target
+ alias_method target, with_method
end
end
View
@@ -26,5 +26,10 @@ def teardown_app
ActiveRecord::Base.reset_subclasses
Dependencies.clear
ActiveRecord::Base.clear_reloadable_connections!
+
+ # Forget that the environment files were loaded so that a new app environment
+ # can be set up again
+ $".delete('config/environment.rb')
+ $".delete('test_help.rb')
end
end

0 comments on commit eaddfc7

Please sign in to comment.