1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# This is a test helper file that simulates a rails application being
# boot from scratch in vendored mode. This file should really only be
# required in test cases that use the isolation helper so that requires
# can be reset correctly.
RAILS_ROOT = File.join(File.dirname(__FILE__), "root")
RAILS_FRAMEWORK_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
require 'rubygems'
gem 'rack', '~> 1.0.0'
require "test/unit"
# We are purposely avoiding adding things to the load path to catch bugs that only happen in the genuine article
require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'isolation')
require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'declarative')
class Test::Unit::TestCase
extend ActiveSupport::Testing::Declarative
def assert_stderr(match)
$stderr = StringIO.new
yield
$stderr.rewind
err = $stderr.read
assert_match match, err
ensure
$stderr = STDERR
end
end
# Fake boot.rb
module Rails
class << self
attr_accessor :vendor_rails
def vendor_rails?
@vendor_rails
end
def boot!
# Require the initializer
require File.join(RAILS_FRAMEWORK_ROOT, 'railties', 'lib', 'initializer')
# Run the initializer the same way boot.rb does it
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
Rails::Initializer.run(:set_load_path)
end
end
end
# All that for this:
Rails.boot!
|