spork 0.9.0-x86-mingw32 → 1.0.0rc0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -1
 - data/README.rdoc +22 -18
 - data/features/diagnostic_mode.feature +1 -2
 - data/features/support/bundler_helpers.rb +2 -8
 - data/features/support/env.rb +7 -94
 - data/features/support/spork_world.rb +84 -0
 - data/features/unknown_app_framework.feature +5 -7
 - data/lib/spork.rb +3 -10
 - data/lib/spork/app_framework.rb +16 -30
 - data/lib/spork/app_framework/unknown.rb +5 -1
 - data/lib/spork/runner.rb +1 -1
 - data/lib/spork/test/cucumber_helpers.rb +5 -0
 - data/lib/spork/test/test_helpers.rb +2 -0
 - data/lib/spork/test_framework.rb +9 -9
 - data/spec/spec_helper.rb +7 -88
 - data/spec/spork/app_framework_spec.rb +0 -7
 - data/spec/spork/diagnoser_spec.rb +0 -1
 - data/spec/spork/test_framework_spec.rb +3 -3
 - data/spec/support/fake_framework.rb +3 -1
 - data/spec/support/should_include_a_string_like.rb +31 -0
 - data/spec/support/test_io_streams.rb +17 -0
 - data/spec/support/tmp_project_helpers.rb +30 -0
 - metadata +26 -37
 - data/assets/bootstrap.rb +0 -49
 - data/features/cucumber_rails_integration.feature +0 -107
 - data/features/gemfiles/rails3.0/Gemfile +0 -14
 - data/features/gemfiles/rails3.0/Gemfile.lock +0 -139
 - data/features/rails_delayed_loading_workarounds.feature +0 -177
 - data/features/rspec_rails_integration.feature +0 -92
 - data/features/steps/rails_steps.rb +0 -67
 - data/lib/spork/app_framework/padrino.rb +0 -22
 - data/lib/spork/app_framework/rails.rb +0 -82
 - data/lib/spork/ext/rails-reloader.rb +0 -14
 - data/lib/spork/gem_helpers.rb +0 -38
 - data/spec/spork/app_framework/rails_spec.rb +0 -22
 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -20,40 +20,44 @@ Spork runs on POSIX systems using fork. It also runs on windows by pre-populatin 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            == Supported Application Frameworks
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
            Spork can work with any application framework, but needs work to prevent application files from being eager loaded.
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            * Padrino
         
     | 
| 
      
 25 
     | 
    
         
            +
            See https://github.com/sporkrb/spork/wiki/Supported-Application-Frameworks for a list of supported frameworks and their gems.
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
27 
     | 
    
         
             
            == INSTALL:
         
     | 
| 
       29 
28 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
            NOTICE:
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
            * Rails support (and other app frameworks) have been extracted. If using spork with rails, you'll want to use spork-rails gem, https://github.com/sporkrb/spork-rails.
         
     | 
| 
       33 
32 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
            * If you wish to use the stable verson of spork 0.9, refer to https://github.com/sporkrb/spork/tree/v0.9.x
         
     | 
| 
       35 
34 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
            === bundler:
         
     | 
| 
      
 35 
     | 
    
         
            +
            === Bundler:
         
     | 
| 
       39 
36 
     | 
    
         | 
| 
       40 
37 
     | 
    
         
             
            Add to your Gemfile:
         
     | 
| 
       41 
38 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
              gem 'spork', '~>  
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
            (Rails 2.x, use this)
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              gem 'spork', '~> 0.8'
         
     | 
| 
      
 39 
     | 
    
         
            +
              gem 'spork', '~> 1.0rc'
         
     | 
| 
       47 
40 
     | 
    
         | 
| 
       48 
41 
     | 
    
         
             
            == Usage
         
     | 
| 
       49 
42 
     | 
    
         | 
| 
       50 
43 
     | 
    
         
             
            From a terminal, change to your project directory.
         
     | 
| 
       51 
44 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
            Then, bootstrap your  
     | 
| 
      
 45 
     | 
    
         
            +
            Then, bootstrap your test helper file. If running rspec,
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              spork rspec --bootstrap
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            Cucumber:
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              spork cucumber --bootstrap
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            TestUnit:
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              (Install the spork-testunit gem)
         
     | 
| 
      
 56 
     | 
    
         
            +
              spork test_unit --bootstrap
         
     | 
| 
       53 
57 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
            (If you don't specifiy a test framework, spork will find one and pick it.)
         
     | 
| 
       55 
59 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
            Follow the instructions.
         
     | 
| 
       57 
61 
     | 
    
         | 
| 
       58 
62 
     | 
    
         
             
            Finally, run spork.  A spec DRb server will be running!
         
     | 
| 
       59 
63 
     | 
    
         | 
| 
         @@ -131,4 +135,4 @@ See http://wiki.github.com/sporkrb/spork/troubleshooting 
     | 
|
| 
       131 
135 
     | 
    
         
             
            * Roger Pack - JRuby support / Windows
         
     | 
| 
       132 
136 
     | 
    
         
             
            * Donald Parish - Windows support (Magazine strategy)
         
     | 
| 
       133 
137 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
            Spork (c)  
     | 
| 
      
 138 
     | 
    
         
            +
            Spork (c) 2012 Tim Harper, released under the MIT license
         
     | 
| 
         @@ -11,7 +11,7 @@ Feature: Diagnostic Mode 
     | 
|
| 
       11 
11 
     | 
    
         
             
                  require 'spork'
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                  Spork.prefork do
         
     | 
| 
       14 
     | 
    
         
            -
                    require 'lib/awesome.rb'
         
     | 
| 
      
 14 
     | 
    
         
            +
                    require './lib/awesome.rb'
         
     | 
| 
       15 
15 
     | 
    
         
             
                    require '../external_dependency/super_duper.rb'
         
     | 
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
         @@ -38,4 +38,3 @@ Feature: Diagnostic Mode 
     | 
|
| 
       38 
38 
     | 
    
         
             
                And the output should contain "spec/spec_helper.rb:5"
         
     | 
| 
       39 
39 
     | 
    
         
             
                And the output should not contain "super_duper.rb"
         
     | 
| 
       40 
40 
     | 
    
         
             
                And the output should not contain "diagnose.rb"
         
     | 
| 
       41 
     | 
    
         
            -
                 
         
     | 
| 
         @@ -1,4 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'bundler'
         
     | 
| 
       2 
1 
     | 
    
         
             
            module BundlerHelpers
         
     | 
| 
       3 
2 
     | 
    
         
             
              extend self
         
     | 
| 
       4 
3 
     | 
    
         
             
              def install_bundle(dir)
         
     | 
| 
         @@ -19,7 +18,7 @@ module BundlerHelpers 
     | 
|
| 
       19 
18 
     | 
    
         
             
                  FileUtils.rm(gemfile_lock)
         
     | 
| 
       20 
19 
     | 
    
         
             
                  FileUtils.rm_rf(dir + "/.bundle")
         
     | 
| 
       21 
20 
     | 
    
         
             
                when ! File.exist?(bundle_environment)
         
     | 
| 
       22 
     | 
    
         
            -
                  puts " 
     | 
| 
      
 21 
     | 
    
         
            +
                  puts "Installing bundle #{gemfile}..."
         
     | 
| 
       23 
22 
     | 
    
         
             
                when File.mtime(bundle_environment) < File.mtime(gemfile_lock)
         
     | 
| 
       24 
23 
     | 
    
         
             
                  puts "#{gemfile_lock} is newer than #{bundle_environment}.  Reinstalling"
         
     | 
| 
       25 
24 
     | 
    
         
             
                else
         
     | 
| 
         @@ -28,13 +27,8 @@ module BundlerHelpers 
     | 
|
| 
       28 
27 
     | 
    
         
             
                install_bundle(dir)
         
     | 
| 
       29 
28 
     | 
    
         
             
              end
         
     | 
| 
       30 
29 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
              def expand_gemfile(gemfile)
         
     | 
| 
       32 
     | 
    
         
            -
                possibilities = [File.expand_path(gemfile, Dir.pwd), SporkWorld::GEMFILES_ROOT + gemfile + "Gemfile"]
         
     | 
| 
       33 
     | 
    
         
            -
                possibilities.detect {|f| File.exist?(f)} || raise(RuntimeError, %(Gemfile not found:\n #{possibilities * "\n"}))
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
30 
     | 
    
         
             
              def set_gemfile(gemfile)
         
     | 
| 
       37 
     | 
    
         
            -
                gemfile =  
     | 
| 
      
 31 
     | 
    
         
            +
                gemfile = File.expand_path(gemfile)
         
     | 
| 
       38 
32 
     | 
    
         
             
                ensure_installed(File.dirname(gemfile))
         
     | 
| 
       39 
33 
     | 
    
         
             
                ENV["BUNDLE_GEMFILE"] = gemfile.to_s
         
     | 
| 
       40 
34 
     | 
    
         
             
              end
         
     | 
    
        data/features/support/env.rb
    CHANGED
    
    | 
         @@ -1,105 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'pathname'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'fileutils'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'forwardable'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'tempfile'
         
     | 
| 
       6 
3 
     | 
    
         
             
            require 'rspec/expectations'
         
     | 
| 
       7 
4 
     | 
    
         
             
            require 'timeout'
         
     | 
| 
       8 
5 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            SPORK_ROOT    = Pathname.new(File.expand_path('../../', File.dirname(__FILE__)))
         
     | 
| 
       12 
     | 
    
         
            -
            class SporkWorld
         
     | 
| 
       13 
     | 
    
         
            -
              RUBY_BINARY   = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
         
     | 
| 
       14 
     | 
    
         
            -
              BINARY        = SPORK_ROOT + 'bin/spork'
         
     | 
| 
       15 
     | 
    
         
            -
              SANDBOX_DIR   = SPORK_ROOT + "tmp/sandbox"
         
     | 
| 
       16 
     | 
    
         
            -
              GEMFILES_ROOT = SPORK_ROOT + "features/gemfiles"
         
     | 
| 
       17 
     | 
    
         
            -
              SPORK_LIBDIR  = SPORK_ROOT + "lib"
         
     | 
| 
       18 
     | 
    
         
            -
              
         
     | 
| 
       19 
     | 
    
         
            -
              extend Forwardable
         
     | 
| 
       20 
     | 
    
         
            -
              def_delegators SporkWorld, :sandbox_dir, :spork_lib_dir
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
              def spork_lib_dir
         
     | 
| 
       23 
     | 
    
         
            -
                @spork_lib_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              def initialize
         
     | 
| 
       27 
     | 
    
         
            -
                @current_dir = SANDBOX_DIR
         
     | 
| 
       28 
     | 
    
         
            -
                @background_jobs = []
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              private
         
     | 
| 
       32 
     | 
    
         
            -
              attr_reader :last_exit_status, :last_stderr, :last_stdout, :background_jobs
         
     | 
| 
       33 
     | 
    
         
            -
              def last_stderr
         
     | 
| 
       34 
     | 
    
         
            -
                return @last_stderr if @last_stderr
         
     | 
| 
       35 
     | 
    
         
            -
                if @background_job
         
     | 
| 
       36 
     | 
    
         
            -
                  @last_stderr = @background_job.stderr.read
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              def last_stdout
         
     | 
| 
       42 
     | 
    
         
            -
                return @last_stdout if @last_stdout
         
     | 
| 
       43 
     | 
    
         
            -
                if @background_job
         
     | 
| 
       44 
     | 
    
         
            -
                  @last_stdout = @background_job.stdout.read
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
              end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
              def create_file(file_name, file_content)
         
     | 
| 
       49 
     | 
    
         
            -
                file_content.gsub!("SPORK_LIB", "'#{spork_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
         
     | 
| 
       50 
     | 
    
         
            -
                in_current_dir do
         
     | 
| 
       51 
     | 
    
         
            -
                  FileUtils.mkdir_p(File.dirname(file_name))
         
     | 
| 
       52 
     | 
    
         
            -
                  File.open(file_name, 'w') { |f| f << file_content }
         
     | 
| 
       53 
     | 
    
         
            -
                end
         
     | 
| 
       54 
     | 
    
         
            -
              end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
              def in_current_dir(&block)
         
     | 
| 
       57 
     | 
    
         
            -
                Dir.chdir(@current_dir, &block)
         
     | 
| 
       58 
     | 
    
         
            -
              end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
              def run(command)
         
     | 
| 
       61 
     | 
    
         
            -
                stderr_file = Tempfile.new('spork')
         
     | 
| 
       62 
     | 
    
         
            -
                stderr_file.close
         
     | 
| 
       63 
     | 
    
         
            -
                in_current_dir do
         
     | 
| 
       64 
     | 
    
         
            -
                  @last_stdout = `env RUBYOPT= bundle exec #{command} 2> #{stderr_file.path}`
         
     | 
| 
       65 
     | 
    
         
            -
                  @last_exit_status = $?.exitstatus
         
     | 
| 
       66 
     | 
    
         
            -
                end
         
     | 
| 
       67 
     | 
    
         
            -
                @last_stderr = IO.read(stderr_file.path)
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
              def run_in_background(command)
         
     | 
| 
       71 
     | 
    
         
            -
                in_current_dir do
         
     | 
| 
       72 
     | 
    
         
            -
                  @background_job = BackgroundJob.run("env RUBYOPT= bundle exec " +  command)
         
     | 
| 
       73 
     | 
    
         
            -
                end
         
     | 
| 
       74 
     | 
    
         
            -
                @background_jobs << @background_job
         
     | 
| 
       75 
     | 
    
         
            -
                @background_job
         
     | 
| 
       76 
     | 
    
         
            -
              end
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
              def terminate_background_jobs
         
     | 
| 
       79 
     | 
    
         
            -
                if @background_jobs
         
     | 
| 
       80 
     | 
    
         
            -
                  @background_jobs.each do |background_job|
         
     | 
| 
       81 
     | 
    
         
            -
                    background_job.kill
         
     | 
| 
       82 
     | 
    
         
            -
                  end
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
                @background_jobs.clear
         
     | 
| 
       85 
     | 
    
         
            -
                @background_job = nil
         
     | 
| 
       86 
     | 
    
         
            -
              end
         
     | 
| 
       87 
     | 
    
         
            -
            end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            require((SPORK_ROOT + "features/support/bundler_helpers.rb").to_s)
         
     | 
| 
       90 
     | 
    
         
            -
            BundlerHelpers.set_gemfile(ENV["GEMFILE"])
         
     | 
| 
      
 6 
     | 
    
         
            +
            APP_ROOT    = Pathname.new(File.expand_path('../../', File.dirname(__FILE__)))
         
     | 
| 
      
 7 
     | 
    
         
            +
            SANDBOX_DIR = APP_ROOT + "tmp/sandbox"
         
     | 
| 
       91 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
            require(APP_ROOT + "features/support/background_job.rb")
         
     | 
| 
      
 10 
     | 
    
         
            +
            require(APP_ROOT + "features/support/spork_world.rb")
         
     | 
| 
       92 
11 
     | 
    
         | 
| 
       93 
12 
     | 
    
         
             
            World do
         
     | 
| 
       94 
13 
     | 
    
         
             
              SporkWorld.new
         
     | 
| 
       95 
14 
     | 
    
         
             
            end
         
     | 
| 
       96 
15 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
               
     | 
| 
       100 
     | 
    
         
            -
            end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
            After do
         
     | 
| 
       103 
     | 
    
         
            -
              # FileUtils.rm_rf SporkWorld::SANDBOX_DIR
         
     | 
| 
       104 
     | 
    
         
            -
              terminate_background_jobs
         
     | 
| 
       105 
     | 
    
         
            -
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
            # FileUtils.rm_rf SporkWorld::SANDBOX_DIR
         
     | 
| 
      
 17 
     | 
    
         
            +
            Before { reset_sandbox_dir }
         
     | 
| 
      
 18 
     | 
    
         
            +
            After  { terminate_background_jobs }
         
     | 
| 
         @@ -0,0 +1,84 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'forwardable'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'tempfile'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'pathname'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class SporkWorld
         
     | 
| 
      
 7 
     | 
    
         
            +
              SPORK_ROOT    = Pathname.new(File.expand_path('../../', File.dirname(__FILE__)))
         
     | 
| 
      
 8 
     | 
    
         
            +
              RUBY_BINARY   = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
         
     | 
| 
      
 9 
     | 
    
         
            +
              BINARY        = SPORK_ROOT + 'bin/spork'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              extend Forwardable
         
     | 
| 
      
 12 
     | 
    
         
            +
              def_delegators SporkWorld, :sandbox_dir, :spork_lib_dir
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def spork_lib_dir
         
     | 
| 
      
 15 
     | 
    
         
            +
                @spork_lib_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 19 
     | 
    
         
            +
                @current_dir = SANDBOX_DIR
         
     | 
| 
      
 20 
     | 
    
         
            +
                @background_jobs = []
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              private
         
     | 
| 
      
 24 
     | 
    
         
            +
              attr_reader :last_exit_status, :last_stderr, :last_stdout, :background_jobs
         
     | 
| 
      
 25 
     | 
    
         
            +
              def last_stderr
         
     | 
| 
      
 26 
     | 
    
         
            +
                return @last_stderr if @last_stderr
         
     | 
| 
      
 27 
     | 
    
         
            +
                if @background_job
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @last_stderr = @background_job.stderr.read
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def last_stdout
         
     | 
| 
      
 34 
     | 
    
         
            +
                return @last_stdout if @last_stdout
         
     | 
| 
      
 35 
     | 
    
         
            +
                if @background_job
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @last_stdout = @background_job.stdout.read
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              def create_file(file_name, file_content)
         
     | 
| 
      
 41 
     | 
    
         
            +
                file_content.gsub!("SPORK_LIB", "'#{spork_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
         
     | 
| 
      
 42 
     | 
    
         
            +
                in_current_dir do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  FileUtils.mkdir_p(File.dirname(file_name))
         
     | 
| 
      
 44 
     | 
    
         
            +
                  File.open(file_name, 'w') { |f| f << file_content }
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              def in_current_dir(&block)
         
     | 
| 
      
 49 
     | 
    
         
            +
                Dir.chdir(@current_dir, &block)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              def run(command)
         
     | 
| 
      
 53 
     | 
    
         
            +
                stderr_file = Tempfile.new('spork')
         
     | 
| 
      
 54 
     | 
    
         
            +
                stderr_file.close
         
     | 
| 
      
 55 
     | 
    
         
            +
                in_current_dir do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @last_stdout = `env RUBYOPT= bundle exec #{command} 2> #{stderr_file.path}`
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @last_exit_status = $?.exitstatus
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
                @last_stderr = IO.read(stderr_file.path)
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              def run_in_background(command)
         
     | 
| 
      
 63 
     | 
    
         
            +
                in_current_dir do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  @background_job = BackgroundJob.run("env RUBYOPT= bundle exec " +  command)
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
                @background_jobs << @background_job
         
     | 
| 
      
 67 
     | 
    
         
            +
                @background_job
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
              def terminate_background_jobs
         
     | 
| 
      
 71 
     | 
    
         
            +
                if @background_jobs
         
     | 
| 
      
 72 
     | 
    
         
            +
                  @background_jobs.each do |background_job|
         
     | 
| 
      
 73 
     | 
    
         
            +
                    background_job.kill
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
                @background_jobs.clear
         
     | 
| 
      
 77 
     | 
    
         
            +
                @background_job = nil
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              def reset_sandbox_dir
         
     | 
| 
      
 81 
     | 
    
         
            +
                FileUtils.rm_rf SANDBOX_DIR
         
     | 
| 
      
 82 
     | 
    
         
            +
                FileUtils.mkdir_p SANDBOX_DIR
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -7,7 +7,7 @@ Feature: Unknown app frameworks 
     | 
|
| 
       7 
7 
     | 
    
         
             
                Given a file named "spec/spec_helper.rb" with:
         
     | 
| 
       8 
8 
     | 
    
         
             
                  """
         
     | 
| 
       9 
9 
     | 
    
         
             
                  require 'rubygems'
         
     | 
| 
       10 
     | 
    
         
            -
                  require ' 
     | 
| 
      
 10 
     | 
    
         
            +
                  require 'rspec'
         
     | 
| 
       11 
11 
     | 
    
         
             
                  """
         
     | 
| 
       12 
12 
     | 
    
         
             
                When I run spork
         
     | 
| 
       13 
13 
     | 
    
         
             
                Then the error output should contain "Using RSpec"
         
     | 
| 
         @@ -16,11 +16,10 @@ Feature: Unknown app frameworks 
     | 
|
| 
       16 
16 
     | 
    
         
             
              Scenario: Sporked spec_helper
         
     | 
| 
       17 
17 
     | 
    
         
             
                Given a file named "spec/spec_helper.rb" with:
         
     | 
| 
       18 
18 
     | 
    
         
             
                  """
         
     | 
| 
       19 
     | 
    
         
            -
                  require 'rubygems'
         
     | 
| 
       20 
19 
     | 
    
         
             
                  require 'spork'
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
       22 
21 
     | 
    
         
             
                  Spork.prefork do
         
     | 
| 
       23 
     | 
    
         
            -
                    require ' 
     | 
| 
      
 22 
     | 
    
         
            +
                    require 'rspec'
         
     | 
| 
       24 
23 
     | 
    
         
             
                  end
         
     | 
| 
       25 
24 
     | 
    
         | 
| 
       26 
25 
     | 
    
         
             
                  Spork.each_run do
         
     | 
| 
         @@ -31,12 +30,11 @@ Feature: Unknown app frameworks 
     | 
|
| 
       31 
30 
     | 
    
         
             
                  """
         
     | 
| 
       32 
31 
     | 
    
         
             
                  describe "Did it work?" do
         
     | 
| 
       33 
32 
     | 
    
         
             
                    it "checks to see if all worked" do
         
     | 
| 
       34 
     | 
    
         
            -
                      Spork. 
     | 
| 
       35 
     | 
    
         
            -
                      puts  
     | 
| 
      
 33 
     | 
    
         
            +
                      Spork.using_spork?.should == true
         
     | 
| 
      
 34 
     | 
    
         
            +
                      puts 'Specs successfully run within spork'
         
     | 
| 
       36 
35 
     | 
    
         
             
                    end
         
     | 
| 
       37 
36 
     | 
    
         
             
                  end
         
     | 
| 
       38 
37 
     | 
    
         
             
                  """
         
     | 
| 
       39 
38 
     | 
    
         
             
                When I fire up a spork instance with "spork rspec"
         
     | 
| 
       40 
     | 
    
         
            -
                And I run  
     | 
| 
      
 39 
     | 
    
         
            +
                And I run rspec --drb spec/did_it_work_spec.rb
         
     | 
| 
       41 
40 
     | 
    
         
             
                Then the output should contain "Specs successfully run within spork"
         
     | 
| 
       42 
     | 
    
         
            -
              
         
     | 
    
        data/lib/spork.rb
    CHANGED
    
    | 
         @@ -11,7 +11,6 @@ module Spork 
     | 
|
| 
       11 
11 
     | 
    
         
             
              autoload :Runner,        (LIBDIR + 'spork/runner').to_s
         
     | 
| 
       12 
12 
     | 
    
         
             
              autoload :Forker,        (LIBDIR + 'spork/forker').to_s
         
     | 
| 
       13 
13 
     | 
    
         
             
              autoload :Diagnoser,     (LIBDIR + 'spork/diagnoser').to_s
         
     | 
| 
       14 
     | 
    
         
            -
              autoload :GemHelpers,    (LIBDIR + 'spork/gem_helpers').to_s
         
     | 
| 
       15 
14 
     | 
    
         | 
| 
       16 
15 
     | 
    
         
             
              class << self
         
     | 
| 
       17 
16 
     | 
    
         
             
                # 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.
         
     | 
| 
         @@ -98,15 +97,9 @@ module Spork 
     | 
|
| 
       98 
97 
     | 
    
         
             
                end
         
     | 
| 
       99 
98 
     | 
    
         | 
| 
       100 
99 
     | 
    
         
             
                def detect_and_require(subfolder)
         
     | 
| 
       101 
     | 
    
         
            -
                  ( 
     | 
| 
       102 
     | 
    
         
            -
                     
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                end
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
                # This method is used to auto-discover peer plugins such as spork-testunit.
         
     | 
| 
       107 
     | 
    
         
            -
                def other_spork_gem_load_paths
         
     | 
| 
       108 
     | 
    
         
            -
                  @other_spork_gem_load_paths ||= Spork::GemHelpers.latest_load_paths.grep(/spork/).select do |g|
         
     | 
| 
       109 
     | 
    
         
            -
                    not g.match(%r{/spork-[0-9\-.]+/lib}) # don't include other versions of spork
         
     | 
| 
      
 100 
     | 
    
         
            +
                  Gem.find_files(subfolder).uniq.each do |path|
         
     | 
| 
      
 101 
     | 
    
         
            +
                    next if path.match(/_spec\.rb/)
         
     | 
| 
      
 102 
     | 
    
         
            +
                    require path
         
     | 
| 
       110 
103 
     | 
    
         
             
                  end
         
     | 
| 
       111 
104 
     | 
    
         
             
                end
         
     | 
| 
       112 
105 
     | 
    
         | 
    
        data/lib/spork/app_framework.rb
    CHANGED
    
    | 
         @@ -1,41 +1,23 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Spork::AppFramework
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
               
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       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 
     | 
    
         
            -
                :Padrino => lambda {
         
     | 
| 
       9 
     | 
    
         
            -
                  File.exist?("config/boot.rb") && File.read("config/boot.rb").include?('PADRINO')
         
     | 
| 
       10 
     | 
    
         
            -
                },
         
     | 
| 
       11 
     | 
    
         
            -
                :Rails => lambda {
         
     | 
| 
       12 
     | 
    
         
            -
                  File.exist?("config/environment.rb") && (
         
     | 
| 
       13 
     | 
    
         
            -
                    File.read("config/environment.rb").include?('RAILS_GEM_VERSION') ||
         
     | 
| 
       14 
     | 
    
         
            -
                    (File.exist?("config/application.rb") && File.read("config/application.rb").include?("Rails::Application"))
         
     | 
| 
       15 
     | 
    
         
            -
                  )
         
     | 
| 
       16 
     | 
    
         
            -
                }
         
     | 
| 
       17 
     | 
    
         
            -
              } unless defined? SUPPORTED_FRAMEWORKS
         
     | 
| 
       18 
     | 
    
         
            -
              
         
     | 
| 
       19 
     | 
    
         
            -
              def self.setup_autoload
         
     | 
| 
       20 
     | 
    
         
            -
                ([:Unknown] + SUPPORTED_FRAMEWORKS.keys).each do |name|
         
     | 
| 
       21 
     | 
    
         
            -
                  autoload name, File.join(File.dirname(__FILE__), "app_framework", name.to_s.downcase)
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
      
 2 
     | 
    
         
            +
              APP_FRAMEWORKS = []
         
     | 
| 
      
 3 
     | 
    
         
            +
              def self.inherited(child)
         
     | 
| 
      
 4 
     | 
    
         
            +
                APP_FRAMEWORKS << child
         
     | 
| 
       23 
5 
     | 
    
         
             
              end
         
     | 
| 
       24 
     | 
    
         
            -
              
         
     | 
| 
       25 
6 
     | 
    
         
             
              # Iterates through all SUPPORTED_FRAMEWORKS and returns the symbolic name of the project application framework detected.  Otherwise, returns :Unknown
         
     | 
| 
       26 
7 
     | 
    
         
             
              def self.detect_framework_name
         
     | 
| 
       27 
     | 
    
         
            -
                 
     | 
| 
       28 
     | 
    
         
            -
                  return key if value.call
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
                :Unknown
         
     | 
| 
      
 8 
     | 
    
         
            +
                detect_framework.short_name
         
     | 
| 
       31 
9 
     | 
    
         
             
              end
         
     | 
| 
       32 
10 
     | 
    
         | 
| 
       33 
11 
     | 
    
         
             
              # Same as detect_framework_name, but returns an instance of the specific AppFramework class.
         
     | 
| 
       34 
     | 
    
         
            -
              def self. 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                self[name]
         
     | 
| 
      
 12 
     | 
    
         
            +
              def self.detect_framework_class
         
     | 
| 
      
 13 
     | 
    
         
            +
                APP_FRAMEWORKS.select(&:present?).first || Spork::AppFramework::Unknown
         
     | 
| 
       37 
14 
     | 
    
         
             
              end
         
     | 
| 
       38 
15 
     | 
    
         | 
| 
      
 16 
     | 
    
         
            +
              # Same as detect_framework_name, but returns an instance of the specific AppFramework class.
         
     | 
| 
      
 17 
     | 
    
         
            +
              def self.detect_framework
         
     | 
| 
      
 18 
     | 
    
         
            +
                detect_framework_class.new
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       39 
21 
     | 
    
         
             
              # Initializes, stores, and returns a singleton instance of the named AppFramework.
         
     | 
| 
       40 
22 
     | 
    
         
             
              #
         
     | 
| 
       41 
23 
     | 
    
         
             
              # == Parameters
         
     | 
| 
         @@ -70,6 +52,10 @@ class Spork::AppFramework 
     | 
|
| 
       70 
52 
     | 
    
         
             
              def short_name
         
     | 
| 
       71 
53 
     | 
    
         
             
                self.class.short_name
         
     | 
| 
       72 
54 
     | 
    
         
             
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              def self.present?
         
     | 
| 
      
 57 
     | 
    
         
            +
                raise "#{self} should have defined #{self}.present?, but didn't"
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
       73 
59 
     | 
    
         | 
| 
       74 
60 
     | 
    
         
             
              protected
         
     | 
| 
       75 
61 
     | 
    
         
             
                def self.instances
         
     | 
| 
         @@ -77,4 +63,4 @@ class Spork::AppFramework 
     | 
|
| 
       77 
63 
     | 
    
         
             
                end
         
     | 
| 
       78 
64 
     | 
    
         
             
            end
         
     | 
| 
       79 
65 
     | 
    
         | 
| 
       80 
     | 
    
         
            -
            Spork 
     | 
| 
      
 66 
     | 
    
         
            +
            Spork.detect_and_require('spork/app_framework/*.rb')
         
     |