bmabey-spork 0.4.4 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.rdoc +51 -23
  2. data/assets/bootstrap.rb +1 -1
  3. data/bin/spork +0 -0
  4. data/features/cucumber_rails_integration.feature +113 -0
  5. data/features/diagnostic_mode.feature +41 -0
  6. data/features/rails_delayed_loading_workarounds.feature +80 -0
  7. data/features/rspec_rails_integration.feature +90 -0
  8. data/features/steps/rails_steps.rb +53 -0
  9. data/features/steps/sandbox_steps.rb +98 -0
  10. data/features/support/env.rb +98 -0
  11. data/features/unknown_app_framework.feature +42 -0
  12. data/lib/spork.rb +85 -26
  13. data/lib/spork/app_framework.rb +74 -0
  14. data/lib/spork/app_framework/rails.rb +158 -0
  15. data/lib/spork/app_framework/rails_stub_files/application.rb +3 -0
  16. data/lib/spork/app_framework/rails_stub_files/application_controller.rb +3 -0
  17. data/lib/spork/app_framework/rails_stub_files/application_helper.rb +3 -0
  18. data/lib/spork/app_framework/unknown.rb +6 -0
  19. data/lib/spork/custom_io_streams.rb +25 -0
  20. data/lib/spork/diagnoser.rb +103 -0
  21. data/lib/spork/forker.rb +70 -0
  22. data/lib/spork/runner.rb +28 -10
  23. data/lib/spork/server.rb +88 -46
  24. data/lib/spork/server/cucumber.rb +21 -9
  25. data/lib/spork/server/rspec.rb +1 -1
  26. data/spec/spec_helper.rb +93 -35
  27. data/spec/spork/app_framework/rails_spec.rb +22 -0
  28. data/spec/spork/app_framework/unknown_spec.rb +12 -0
  29. data/spec/spork/app_framework_spec.rb +16 -0
  30. data/spec/spork/diagnoser_spec.rb +105 -0
  31. data/spec/spork/forker_spec.rb +44 -0
  32. data/spec/spork/runner_spec.rb +2 -2
  33. data/spec/spork/server/cucumber_spec.rb +25 -0
  34. data/spec/spork/server/rspec_spec.rb +17 -3
  35. data/spec/spork/server_spec.rb +32 -17
  36. data/spec/spork_spec.rb +112 -13
  37. metadata +33 -3
@@ -0,0 +1,98 @@
1
+ Given /^I am in the directory "(.*)"$/ do |sandbox_dir_relative_path|
2
+ path = File.join(SporkWorld::SANDBOX_DIR, sandbox_dir_relative_path)
3
+ FileUtils.mkdir_p(path)
4
+ @current_dir = File.join(path)
5
+ end
6
+
7
+ Given /^a file named "([^\"]*)"$/ do |file_name|
8
+ create_file(file_name, '')
9
+ end
10
+
11
+ Given /^a file named "([^\"]*)" with:$/ do |file_name, file_content|
12
+ create_file(file_name, file_content)
13
+ end
14
+
15
+ When /^the contents of "([^\"]*)" are changed to:$/ do |file_name, file_content|
16
+ create_file(file_name, file_content)
17
+ end
18
+
19
+ # the following code appears in "config/environment.rb" after /Rails::Initializer.run/:
20
+ Given /^the following code appears in "([^\"]*)" after \/([^\\\/]*)\/:$/ do |file_name, regex, content|
21
+ # require 'ruby-debug'; Debugger.start; Debugger.start_control; debugger
22
+
23
+ regex = Regexp.new(regex)
24
+ in_current_dir do
25
+ content_lines = File.read(file_name).split("\n")
26
+ 0.upto(content_lines.length - 1) do |line_index|
27
+ if regex.match(content_lines[line_index])
28
+ content_lines.insert(line_index + 1, content)
29
+ break
30
+ end
31
+ end
32
+ File.open(file_name, 'wb') { |f| f << (content_lines * "\n") }
33
+ end
34
+ end
35
+
36
+ When /^I run (spork|spec|cucumber)($| .*$)/ do |command, spork_opts|
37
+ case command
38
+ when 'spork'
39
+ command = SporkWorld::BINARY
40
+ when 'cucumber'
41
+ command = Cucumber::BINARY
42
+ else
43
+ command = %x{which #{command}}.chomp
44
+ end
45
+ run "#{SporkWorld::RUBY_BINARY} -I #{Cucumber::LIBDIR} #{command} #{spork_opts}"
46
+ end
47
+
48
+ When /^I fire up a spork instance with "spork(.*)"$/ do |spork_opts|
49
+ run_in_background "#{SporkWorld::RUBY_BINARY} -I #{Cucumber::LIBDIR} #{SporkWorld::BINARY} #{spork_opts}"
50
+ output = ""
51
+ begin
52
+ status = Timeout::timeout(15) do
53
+ # Something that should be interrupted if it takes too much time...
54
+ while line = @bg_stderr.gets
55
+ output << line
56
+ puts line
57
+ break if line.include?("Spork is ready and listening")
58
+ end
59
+ end
60
+ rescue Timeout::Error
61
+ puts "I can't seem to launch Spork properly. Output was:\n#{output}"
62
+ true.should == false
63
+ end
64
+ end
65
+
66
+ Then /the file "([^\"]*)" should include "([^\"]*)"/ do |filename, content|
67
+ in_current_dir do
68
+ File.read(filename).should include(content)
69
+ end
70
+ end
71
+
72
+ Then /^the (error output|output) should contain$/ do |which, text|
73
+ (which == "error output" ? last_stderr : last_stdout).should include(text)
74
+ end
75
+
76
+ Then /^the (error output|output) should contain "(.+)"$/ do |which, text|
77
+ (which == "error output" ? last_stderr : last_stdout).should include(text)
78
+ end
79
+
80
+ Then /^the (error output|output) should match \/(.+)\/$/ do |which, regex|
81
+ (which == "error output" ? last_stderr : last_stdout).should match(Regexp.new(regex))
82
+ end
83
+
84
+ Then /^the (error output|output) should not contain$/ do |which, text|
85
+ (which == "error output" ? last_stderr : last_stdout).should_not include(text)
86
+ end
87
+
88
+ Then /^the (error output|output) should not contain "(.+)"$/ do |which, text|
89
+ (which == "error output" ? last_stderr : last_stdout).should_not include(text)
90
+ end
91
+
92
+ Then /^the (error output|output) should be empty$/ do |which|
93
+ (which == "error output" ? last_stderr : last_stdout).should == ""
94
+ end
95
+
96
+ Then /^the (error output|output) should be$/ do |which, text|
97
+ (which == "error output" ? last_stderr : last_stdout).should == text
98
+ end
@@ -0,0 +1,98 @@
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+ require 'forwardable'
4
+ require 'tempfile'
5
+ require 'spec/expectations'
6
+ require 'timeout'
7
+ require 'spork'
8
+
9
+ class SporkWorld
10
+ BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/spork')
11
+ RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
12
+ SANDBOX_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../../tmp/sandbox'))
13
+
14
+ extend Forwardable
15
+ def_delegators SporkWorld, :sandbox_dir, :spork_lib_dir
16
+
17
+ def spork_lib_dir
18
+ @spork_lib_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
19
+ end
20
+
21
+ def initialize
22
+ @current_dir = SANDBOX_DIR
23
+ @background_jobs = []
24
+ end
25
+
26
+ private
27
+ attr_reader :last_exit_status, :last_stderr, :last_stdout, :background_jobs
28
+
29
+ def create_file(file_name, file_content)
30
+ file_content.gsub!("SPORK_LIB", "'#{spork_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
31
+ in_current_dir do
32
+ FileUtils.mkdir_p(File.dirname(file_name))
33
+ File.open(file_name, 'w') { |f| f << file_content }
34
+ end
35
+ end
36
+
37
+ def in_current_dir(&block)
38
+ Dir.chdir(@current_dir, &block)
39
+ end
40
+
41
+ def run(command)
42
+ stderr_file = Tempfile.new('spork')
43
+ stderr_file.close
44
+ in_current_dir do
45
+ @last_stdout = `#{command} 2> #{stderr_file.path}`
46
+ @last_exit_status = $?.exitstatus
47
+ end
48
+ @last_stderr = IO.read(stderr_file.path)
49
+ end
50
+
51
+ def run_in_background(command)
52
+ child_stdin, parent_stdin = IO::pipe
53
+ parent_stdout, child_stdout = IO::pipe
54
+ parent_stderr, child_stderr = IO::pipe
55
+
56
+ background_jobs << Kernel.fork do
57
+ [parent_stdin, parent_stdout, parent_stderr].each { |io| io.close }
58
+
59
+ STDIN.reopen(child_stdin)
60
+ STDOUT.reopen(child_stdout)
61
+ STDERR.reopen(child_stderr)
62
+
63
+ [child_stdin, child_stdout, child_stderr].each { |io| io.close }
64
+
65
+ in_current_dir do
66
+ exec command
67
+ end
68
+ end
69
+
70
+ [child_stdin, child_stdout, child_stderr].each { |io| io.close }
71
+ parent_stdin.sync = true
72
+
73
+ @bg_stdin, @bg_stdout, @bg_stderr = [parent_stdin, parent_stdout, parent_stderr]
74
+ end
75
+
76
+ def terminate_background_jobs
77
+ if @background_jobs
78
+ @background_jobs.each do |pid|
79
+ Process.kill(Signal.list['TERM'], pid)
80
+ end
81
+ end
82
+ end
83
+
84
+ end
85
+
86
+ World do
87
+ SporkWorld.new
88
+ end
89
+
90
+ Before do
91
+ FileUtils.rm_rf SporkWorld::SANDBOX_DIR
92
+ FileUtils.mkdir_p SporkWorld::SANDBOX_DIR
93
+ end
94
+
95
+ After do
96
+ # FileUtils.rm_rf SporkWorld::SANDBOX_DIR
97
+ terminate_background_jobs
98
+ end
@@ -0,0 +1,42 @@
1
+ Feature: Unknown app frameworks
2
+ To increase to usefulness of Spork
3
+ Spork will work with unknown (or no) application frameworks
4
+
5
+ Scenario: Unsporked spec_helper
6
+
7
+ Given a file named "spec/spec_helper.rb" with:
8
+ """
9
+ require 'rubygems'
10
+ require 'spec'
11
+ """
12
+ When I run spork
13
+ Then the error output should contain "Using RSpec"
14
+ Then the error output should match /You must bootstrap .+spec\/spec_helper\.rb to continue/
15
+
16
+ Scenario: Sporked spec_helper
17
+ Given a file named "spec/spec_helper.rb" with:
18
+ """
19
+ require 'rubygems'
20
+ require 'spork'
21
+
22
+ Spork.prefork do
23
+ require 'spec'
24
+ end
25
+
26
+ Spork.each_run do
27
+ $each_run
28
+ end
29
+ """
30
+ And a file named "spec/did_it_work_spec.rb" with:
31
+ """
32
+ describe "Did it work?" do
33
+ it "checks to see if all worked" do
34
+ Spork.state.should == :using_spork
35
+ puts "Specs successfully run within spork"
36
+ end
37
+ end
38
+ """
39
+ When I fire up a spork instance with "spork rspec"
40
+ And I run spec --drb spec/did_it_work_spec.rb
41
+ Then the output should contain "Specs successfully run within spork"
42
+
@@ -1,40 +1,99 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
2
2
  module Spork
3
- SPEC_HELPER_FILE = File.join(Dir.pwd, "spec/spec_helper.rb")
4
-
3
+ BINARY = File.expand_path(File.dirname(__FILE__) + '/../bin/spork')
4
+ LIBDIR = File.expand_path(File.dirname(__FILE__))
5
+
5
6
  class << self
6
- def prefork(&block)
7
- return if @already_preforked
8
- @already_preforked = true
7
+ # Run a block, during prefork mode. By default, if prefork is called twice in the same file and line number, the supplied block will only be ran once.
8
+ #
9
+ # == Parameters
10
+ #
11
+ # * +prevent_double_run+ - Pass false to disable double run prevention
12
+ def prefork(prevent_double_run = true, &block)
13
+ return if prevent_double_run && already_ran?(caller.first)
9
14
  yield
10
15
  end
11
-
12
- def each_run(&block)
13
- return if @state == :preforking || (@state != :not_using_spork && @already_run)
14
- @already_run = true
15
- yield
16
- end
17
-
18
- def preforking!
19
- @state = :preforking
16
+
17
+ # Run a block AFTER the fork occurs. By default, if prefork is called twice in the same file and line number, the supplied block will only be ran once.
18
+ #
19
+ # == Parameters
20
+ #
21
+ # * +prevent_double_run+ - Pass false to disable double run prevention
22
+ def each_run(prevent_double_run = true, &block)
23
+ return if prevent_double_run && already_ran?(caller.first)
24
+ if @state == :using_spork
25
+ each_run_procs << block
26
+ else
27
+ yield
28
+ end
20
29
  end
21
-
22
- def running!
23
- @state = :running
30
+
31
+ # Used by the server. Sets the state to activate spork. Otherwise, prefork and each_run are run in passive mode, allowing specs without a Spork server.
32
+ def using_spork!
33
+ @state = :using_spork
24
34
  end
25
-
35
+
36
+ # Used by the server. Returns the current state of Spork.
26
37
  def state
27
38
  @state ||= :not_using_spork
28
39
  end
29
-
30
- def exec_prefork(helper_file)
31
- preforking!
32
- load(helper_file)
40
+
41
+ # Used by the server. Called when loading the prefork blocks of the code.
42
+ def exec_prefork(&block)
43
+ using_spork!
44
+ yield
45
+ end
46
+
47
+ # Used by the server. Called to run all of the prefork blocks.
48
+ def exec_each_run(&block)
49
+ each_run_procs.each { |p| p.call }
50
+ each_run_procs.clear
51
+ yield if block_given?
52
+ end
53
+
54
+ # Traps an instance method of a class (or module) so any calls to it don't actually run until Spork.exec_each_run
55
+ def trap_method(klass, method_name)
56
+ method_name_without_spork, method_name_with_spork = alias_method_names(method_name, :spork)
57
+
58
+ klass.class_eval <<-EOF, __FILE__, __LINE__ + 1
59
+ alias :#{method_name_without_spork} :#{method_name} unless method_defined?(:#{method_name_without_spork})
60
+ def #{method_name}(*args)
61
+ Spork.each_run(false) do
62
+ #{method_name_without_spork}(*args)
63
+ end
64
+ end
65
+ EOF
33
66
  end
34
-
35
- def exec_each_run(helper_file)
36
- running!
37
- load(helper_file)
67
+
68
+ # Same as trap_method, but for class methods instead
69
+ def trap_class_method(klass, method_name)
70
+ trap_method((class << klass; self; end), method_name)
38
71
  end
72
+
73
+ private
74
+ def alias_method_names(method_name, feature)
75
+ /^(.+?)([\?\!]{0,1})$/.match(method_name.to_s)
76
+ ["#{$1}_without_spork#{$2}", "#{$1}_with_spork#{$2}"]
77
+ end
78
+
79
+ def already_ran
80
+ @already_ran ||= []
81
+ end
82
+
83
+ def expanded_caller(caller_line)
84
+ file, line = caller_line.split(":")
85
+ line.gsub(/:.+/, '')
86
+ File.expand_path(file, Dir.pwd) + ":" + line
87
+ end
88
+
89
+ def already_ran?(caller_script_and_line)
90
+ return true if already_ran.include?(expanded_caller(caller_script_and_line))
91
+ already_ran << expanded_caller(caller_script_and_line)
92
+ false
93
+ end
94
+
95
+ def each_run_procs
96
+ @each_run_procs ||= []
97
+ end
39
98
  end
40
99
  end
@@ -0,0 +1,74 @@
1
+ class Spork::AppFramework
2
+ # A hash of procs where the key is the class name, and the proc takes no arguments and returns true if it detects that said application framework is being used in the project.
3
+ #
4
+ # The key :Rails maps to Spork::AppFramework::Rails
5
+ #
6
+ # This is used to reduce the amount of code needed to be loaded - only the detected application framework's support code is loaded.
7
+ SUPPORTED_FRAMEWORKS = {
8
+ :Rails => lambda {
9
+ File.exist?("config/environment.rb") && File.read("config/environment.rb").include?('RAILS_GEM_VERSION')
10
+ }
11
+ }
12
+
13
+ def self.setup_autoload
14
+ ([:Unknown] + SUPPORTED_FRAMEWORKS.keys).each do |name|
15
+ autoload name, File.join(File.dirname(__FILE__), "app_framework", name.to_s.downcase)
16
+ end
17
+ end
18
+
19
+ # Iterates through all SUPPORTED_FRAMEWORKS and returns the symbolic name of the project application framework detected. Otherwise, returns :Unknown
20
+ def self.detect_framework_name
21
+ SUPPORTED_FRAMEWORKS.each do |key, value|
22
+ return key if value.call
23
+ end
24
+ :Unknown
25
+ end
26
+
27
+ # Same as detect_framework_name, but returns an instance of the specific AppFramework class.
28
+ def self.detect_framework
29
+ name = detect_framework_name
30
+ self[name]
31
+ end
32
+
33
+ # Initializes, stores, and returns a singleton instance of the named AppFramework.
34
+ #
35
+ # == Parameters
36
+ #
37
+ # # +name+ - A symbolic name of a AppFramework subclass
38
+ #
39
+ # == Example
40
+ #
41
+ # Spork::AppFramework[:Rails]
42
+ def self.[](name)
43
+ instances[name] ||= const_get(name).new
44
+ end
45
+
46
+ def self.short_name
47
+ name.gsub('Spork::AppFramework::', '')
48
+ end
49
+
50
+ # If there is some stuff out of the box that the Spork can do to speed up tests without the test helper file being bootstrapped, this should return false.
51
+ def bootstrap_required?
52
+ entry_point.nil?
53
+ end
54
+
55
+ # Abstract: The path to the file that loads the project environment, ie config/environment.rb. Returns nil if there is none.
56
+ def entry_point
57
+ raise NotImplemented
58
+ end
59
+
60
+ def preload(&block)
61
+ yield
62
+ end
63
+
64
+ def short_name
65
+ self.class.short_name
66
+ end
67
+
68
+ protected
69
+ def self.instances
70
+ @instances ||= {}
71
+ end
72
+ end
73
+
74
+ Spork::AppFramework.setup_autoload
@@ -0,0 +1,158 @@
1
+ class Spork::AppFramework::Rails < Spork::AppFramework
2
+
3
+ # TODO - subclass this out to handle different versions of rails
4
+ # Also... this is the nastiest duck punch ever. Clean this up.
5
+ module NinjaPatcher
6
+ def self.included(klass)
7
+ klass.class_eval do
8
+ unless method_defined?(:load_environment_without_spork)
9
+ alias :load_environment_without_spork :load_environment
10
+ alias :load_environment :load_environment_with_spork
11
+ end
12
+
13
+ def self.run_with_spork(*args, &block) # it's all fun and games until someone gets an eye poked out
14
+ if ENV['RAILS_ENV']
15
+ Object.send(:remove_const, :RAILS_ENV)
16
+ Object.const_set(:RAILS_ENV, ENV['RAILS_ENV'].dup)
17
+ end
18
+ run_without_spork(*args, &block)
19
+ end
20
+
21
+ class << self
22
+ unless method_defined?(:run_without_spork)
23
+ alias :run_without_spork :run
24
+ alias :run :run_with_spork
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ def load_environment_with_spork
31
+ result = load_environment_without_spork
32
+ install_hooks
33
+ result
34
+ end
35
+
36
+ def install_hooks
37
+ auto_reestablish_db_connection
38
+ delay_observer_loading
39
+ delay_app_preload
40
+ delay_application_controller_loading
41
+ delay_route_loading
42
+ delay_eager_view_loading
43
+ end
44
+
45
+ def reset_rails_env
46
+ return unless ENV['RAILS_ENV']
47
+ Object.send(:remove_const, :RAILS_ENV)
48
+ Object.const_set(:RAILS_ENV, ENV['RAILS_ENV'].dup)
49
+ end
50
+
51
+ def delay_observer_loading
52
+ if ::Rails::Initializer.instance_methods.include?('load_observers')
53
+ Spork.trap_method(::Rails::Initializer, :load_observers)
54
+ end
55
+ if Object.const_defined?(:ActionController)
56
+ require "action_controller/dispatcher.rb"
57
+ Spork.trap_class_method(::ActionController::Dispatcher, :define_dispatcher_callbacks) if ActionController::Dispatcher.respond_to?(:define_dispatcher_callbacks)
58
+ end
59
+ end
60
+
61
+ def delay_app_preload
62
+ if ::Rails::Initializer.instance_methods.include?('load_application_classes')
63
+ Spork.trap_method(::Rails::Initializer, :load_application_classes)
64
+ end
65
+ end
66
+
67
+ def delay_application_controller_loading
68
+ if application_controller_source = ["#{Dir.pwd}/app/controllers/application.rb", "#{Dir.pwd}/app/controllers/application_controller.rb"].find { |f| File.exist?(f) }
69
+ application_helper_source = "#{Dir.pwd}/app/helpers/application_helper.rb"
70
+ load_paths = (::ActiveSupport.const_defined?(:Dependencies) ? ::ActiveSupport::Dependencies : ::Dependencies).load_paths
71
+ load_paths.unshift(File.expand_path('rails_stub_files', File.dirname(__FILE__)))
72
+ Spork.each_run do
73
+ require application_controller_source
74
+ require application_helper_source if File.exist?(application_helper_source)
75
+ # update the rails magic to refresh the module
76
+ ApplicationController.send(:helper, ApplicationHelper)
77
+ end
78
+ end
79
+ end
80
+
81
+ def auto_reestablish_db_connection
82
+ if Object.const_defined?(:ActiveRecord)
83
+ Spork.each_run do
84
+ # rails lib/test_help.rb is very aggressive about overriding RAILS_ENV and will switch it back to test after the cucumber env was loaded
85
+ reset_rails_env
86
+ ActiveRecord::Base.establish_connection
87
+ end
88
+ end
89
+ end
90
+
91
+ def delay_route_loading
92
+ if ::Rails::Initializer.instance_methods.include?('initialize_routing')
93
+ Spork.trap_method(::Rails::Initializer, :initialize_routing)
94
+ end
95
+ end
96
+
97
+ def delay_eager_view_loading
98
+ # So, in testing mode it seems it would be optimal to not eager load
99
+ # views (as your may only run a test that uses one or two views).
100
+ # However, I decided to delay eager loading rather than force it to
101
+ # disable because you may wish to eager load your views (I.E. you're
102
+ # testing concurrency)
103
+
104
+ # Rails 2.3.x +
105
+ if defined?(::ActionView::Template::EagerPath)
106
+ Spork.trap_method(::ActionView::Template::EagerPath, :load!)
107
+ end
108
+ # Rails 2.2.x
109
+ if defined?(::ActionView::PathSet::Path)
110
+ Spork.trap_method(::ActionView::PathSet::Path, :load)
111
+ end
112
+ # Rails 2.0.5 - 2.1.x don't appear to eager cache views.
113
+ end
114
+ end
115
+
116
+ def preload(&block)
117
+ STDERR.puts "Preloading Rails environment"
118
+ STDERR.flush
119
+ ENV["RAILS_ENV"] ||= 'test'
120
+ preload_rails
121
+ yield
122
+ end
123
+
124
+ def entry_point
125
+ @entry_point ||= File.expand_path("config/environment.rb", Dir.pwd)
126
+ end
127
+
128
+ alias :environment_file :entry_point
129
+
130
+ def boot_file
131
+ @boot_file ||= File.join(File.dirname(environment_file), 'boot')
132
+ end
133
+
134
+ def environment_contents
135
+ @environment_contents ||= File.read(environment_file)
136
+ end
137
+
138
+ def vendor
139
+ @vendor ||= File.expand_path("vendor/rails", Dir.pwd)
140
+ end
141
+
142
+ def version
143
+ @version ||= (
144
+ if /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/.match(environment_contents)
145
+ $1
146
+ else
147
+ nil
148
+ end
149
+ )
150
+ end
151
+
152
+ def preload_rails
153
+ Object.const_set(:RAILS_GEM_VERSION, version) if version
154
+ require boot_file
155
+ ::Rails::Initializer.send(:include, Spork::AppFramework::Rails::NinjaPatcher)
156
+ end
157
+
158
+ end