Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
From 3b857c2663c516f3c63774b7b4c90dbb93935642 Mon Sep 17 00:00:00 2001
From: Daniel Schierbeck <daniel.schierbeck@gmail.com>
Date: Sat, 31 Oct 2009 01:51:48 +0100
Subject: [PATCH] Allow for Rails.root instead of RAILS_ROOT
RAILS_ROOT is being deprecated in Rails 3.0
---
lib/shoulda/rails.rb | 3 +++
lib/shoulda/test_unit.rb | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/shoulda/rails.rb b/lib/shoulda/rails.rb
index ddb2fcc..05330e3 100644
--- a/lib/shoulda/rails.rb
+++ b/lib/shoulda/rails.rb
@@ -10,4 +10,7 @@ require 'shoulda/action_mailer' if defined? ActionMailer::Base
if defined?(RAILS_ROOT)
# load in the 3rd party macros from vendorized plugins and gems
Shoulda.autoload_macros RAILS_ROOT, File.join("vendor", "{plugins,gems}", "*")
+elsif defined?(Rails) && Rails.respond_to?(:root)
+ # load in the 3rd party macros from vendorized plugins and gems
+ Shoulda.autoload_macros Rails.root, File.join("vendor", "{plugins,gems}", "*")
end
diff --git a/lib/shoulda/test_unit.rb b/lib/shoulda/test_unit.rb
index 0464c23..9ec9b30 100644
--- a/lib/shoulda/test_unit.rb
+++ b/lib/shoulda/test_unit.rb
@@ -7,6 +7,7 @@ require 'shoulda/macros'
require 'shoulda/helpers'
require 'shoulda/autoload_macros'
require 'shoulda/rails' if defined? RAILS_ROOT
+require 'shoulda/rails' if defined? Rails && Rails.responds_to?(:root)
module Test # :nodoc: all
module Unit
--
1.6.3.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment