spork 0.9.0-x86-mswin32 → 1.0.0rc0-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- 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/app_framework/unknown.rb +5 -1
- data/lib/spork/app_framework.rb +16 -30
- 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/lib/spork.rb +3 -10
- 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/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')
|
data/lib/spork/runner.rb
CHANGED
@@ -56,7 +56,7 @@ module Spork
|
|
56
56
|
def run
|
57
57
|
return false unless test_framework = find_test_framework
|
58
58
|
ENV["DRB"] = 'true'
|
59
|
-
@error.puts "Using #{test_framework.short_name}"
|
59
|
+
@error.puts "Using #{test_framework.short_name}, #{test_framework.app_framework.short_name}"
|
60
60
|
@error.flush
|
61
61
|
|
62
62
|
case
|
@@ -0,0 +1,5 @@
|
|
1
|
+
SPORK_CUCUMBER_DIR = File.expand_path( "../../../features/", File.dirname(__FILE__))
|
2
|
+
require("#{SPORK_CUCUMBER_DIR}/support/background_job.rb")
|
3
|
+
require("#{SPORK_CUCUMBER_DIR}/support/spork_world.rb")
|
4
|
+
require("#{SPORK_CUCUMBER_DIR}/support/bundler_helpers.rb")
|
5
|
+
Dir.glob("#{SPORK_CUCUMBER_DIR}/steps/**/*.rb").each { |f| load f }
|
data/lib/spork/test_framework.rb
CHANGED
@@ -122,16 +122,16 @@ class Spork::TestFramework
|
|
122
122
|
stderr.puts "#{helper_file} has not been bootstrapped. Run spork --bootstrap to do so."
|
123
123
|
stderr.flush
|
124
124
|
|
125
|
-
if
|
126
|
-
stderr.puts "I can't do anything for you by default for the framework you're using: #{
|
125
|
+
if app_framework.bootstrap_required?
|
126
|
+
stderr.puts "I can't do anything for you by default for the app framework you're using: #{app_framework.short_name}.\nYou must bootstrap #{helper_file} to continue."
|
127
127
|
stderr.flush
|
128
128
|
return false
|
129
129
|
else
|
130
|
-
load(
|
130
|
+
load(app_framework.entry_point)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
|
134
|
+
app_framework.preload do
|
135
135
|
if bootstrapped?
|
136
136
|
stderr.puts "Loading Spork.prefork block..."
|
137
137
|
stderr.flush
|
@@ -147,21 +147,21 @@ class Spork::TestFramework
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def entry_point
|
150
|
-
bootstrapped? ? helper_file :
|
150
|
+
bootstrapped? ? helper_file : app_framework.entry_point
|
151
151
|
end
|
152
152
|
|
153
153
|
def default_port
|
154
154
|
self.class.default_port
|
155
155
|
end
|
156
156
|
|
157
|
+
def app_framework
|
158
|
+
@app_framework ||= Spork::AppFramework.detect_framework
|
159
|
+
end
|
160
|
+
|
157
161
|
protected
|
158
162
|
def self.inherited(subclass)
|
159
163
|
@@supported_test_frameworks << subclass
|
160
164
|
end
|
161
|
-
|
162
|
-
def framework
|
163
|
-
@framework ||= Spork::AppFramework.detect_framework
|
164
|
-
end
|
165
165
|
end
|
166
166
|
|
167
167
|
Spork.detect_and_require('spork/test_framework/*.rb')
|
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/spec/spec_helper.rb
CHANGED
@@ -6,102 +6,21 @@ require 'stringio'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'rspec'
|
8
8
|
|
9
|
+
Dir.glob("#{File.dirname(__FILE__)}/support/*.rb").each { |f| require(f) }
|
10
|
+
|
9
11
|
RSpec.configure do |config|
|
12
|
+
include(TmpProjectHelpers)
|
13
|
+
|
10
14
|
config.before(:each) do
|
11
|
-
|
12
|
-
|
15
|
+
TestIOStreams.set_streams(StringIO.new, StringIO.new)
|
16
|
+
|
13
17
|
@current_dir = nil
|
14
|
-
|
15
|
-
|
16
|
-
config.after(:each) do
|
17
|
-
FileUtils.rm_rf(SPEC_TMP_DIR) if File.directory?(SPEC_TMP_DIR)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_file(filename, contents)
|
22
|
-
FileUtils.mkdir_p(SPEC_TMP_DIR) unless File.directory?(SPEC_TMP_DIR)
|
23
|
-
|
24
|
-
in_current_dir do
|
25
|
-
FileUtils.mkdir_p(File.dirname(filename))
|
26
|
-
File.open(filename, 'wb') { |f| f << contents }
|
18
|
+
clear_tmp_dir
|
27
19
|
end
|
28
20
|
end
|
29
21
|
|
30
|
-
def create_helper_file(test_framework = FakeFramework)
|
31
|
-
create_file(test_framework.helper_file, "# stub spec helper file")
|
32
|
-
end
|
33
|
-
|
34
|
-
def in_current_dir(&block)
|
35
|
-
Dir.chdir(current_dir, &block)
|
36
|
-
end
|
37
|
-
|
38
|
-
def current_dir
|
39
|
-
@current_dir ||= SPEC_TMP_DIR
|
40
|
-
end
|
41
|
-
|
42
|
-
def change_current_dir(sub_path)
|
43
|
-
@current_dir = File.expand_path(sub_path, SPEC_TMP_DIR)
|
44
|
-
end
|
45
22
|
|
46
23
|
def windows?
|
47
24
|
ENV['OS'] == 'Windows_NT'
|
48
25
|
end
|
49
26
|
|
50
|
-
|
51
|
-
module RSpec
|
52
|
-
module Matchers
|
53
|
-
class IncludeAStringLike
|
54
|
-
def initialize(substring_or_regex)
|
55
|
-
case substring_or_regex
|
56
|
-
when String
|
57
|
-
@regex = Regexp.new(Regexp.escape(substring_or_regex))
|
58
|
-
when Regexp
|
59
|
-
@regex = substring_or_regex
|
60
|
-
else
|
61
|
-
raise ArgumentError, "don't know what to do with the #{substring_or_regex.class} you provided"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def matches?(list_of_strings)
|
66
|
-
@list_of_strings = list_of_strings
|
67
|
-
@list_of_strings.any? { |s| s =~ @regex }
|
68
|
-
end
|
69
|
-
def failure_message
|
70
|
-
"#{@list_of_strings.inspect} expected to include a string like #{@regex.inspect}"
|
71
|
-
end
|
72
|
-
def negative_failure_message
|
73
|
-
"#{@list_of_strings.inspect} expected to not include a string like #{@regex.inspect}, but did"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def include_a_string_like(substring_or_regex)
|
78
|
-
IncludeAStringLike.new(substring_or_regex)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
module Spork::TestIOStreams
|
84
|
-
def self.included(klass)
|
85
|
-
klass.send(:extend, ::Spork::TestIOStreams::ClassMethods)
|
86
|
-
end
|
87
|
-
|
88
|
-
def stderr
|
89
|
-
self.class.stderr
|
90
|
-
end
|
91
|
-
|
92
|
-
def stdout
|
93
|
-
self.class.stdout
|
94
|
-
end
|
95
|
-
|
96
|
-
module ClassMethods
|
97
|
-
def stderr
|
98
|
-
$test_stderr
|
99
|
-
end
|
100
|
-
|
101
|
-
def stdout
|
102
|
-
$test_stdout
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
Dir.glob(File.dirname(__FILE__) + "/support/*.rb").each { |f| require(f) }
|
@@ -2,13 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Spork::AppFramework do
|
4
4
|
describe ".detect_framework" do
|
5
|
-
it "detects when rails is installed and available" do
|
6
|
-
create_file("config/environment.rb", "RAILS_GEM_VERSION = '2.1.0'")
|
7
|
-
in_current_dir do
|
8
|
-
Spork::AppFramework.detect_framework.short_name.should == "Rails"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
5
|
it "returns Unknown when no framework known detected" do
|
13
6
|
Spork::AppFramework.detect_framework.short_name.should == "Unknown"
|
14
7
|
end
|
@@ -66,9 +66,9 @@ describe Spork::TestFramework do
|
|
66
66
|
create_helper_file
|
67
67
|
@fake.bootstrap
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
TestIOStreams.stderr.string.should include("Bootstrapping")
|
70
|
+
TestIOStreams.stderr.string.should include("Edit")
|
71
|
+
TestIOStreams.stderr.string.should include("favorite text editor")
|
72
72
|
|
73
73
|
File.read(@fake.helper_file).should include(File.read(FakeFramework::BOOTSTRAP_FILE))
|
74
74
|
end
|