nimboids-spork 0.8.99
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 +6 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +129 -0
- data/assets/bootstrap.rb +29 -0
- data/bin/spork +20 -0
- data/ext/mkrf_conf.rb +26 -0
- data/features/at_exit_during_each_run.feature +36 -0
- data/features/cucumber_rails_integration.feature +107 -0
- data/features/diagnostic_mode.feature +41 -0
- data/features/gemfiles/rails3.0/Gemfile +10 -0
- data/features/gemfiles/rails3.0/Gemfile.lock +116 -0
- data/features/rails_delayed_loading_workarounds.feature +150 -0
- data/features/rspec_rails_integration.feature +92 -0
- data/features/spork_debugger.feature +108 -0
- data/features/steps/general_steps.rb +3 -0
- data/features/steps/rails_steps.rb +67 -0
- data/features/steps/sandbox_steps.rb +115 -0
- data/features/support/background_job.rb +63 -0
- data/features/support/bundler_helpers.rb +41 -0
- data/features/support/env.rb +105 -0
- data/features/unknown_app_framework.feature +42 -0
- data/lib/spork.rb +155 -0
- data/lib/spork/app_framework.rb +80 -0
- data/lib/spork/app_framework/padrino.rb +22 -0
- data/lib/spork/app_framework/rails.rb +82 -0
- data/lib/spork/app_framework/unknown.rb +6 -0
- data/lib/spork/custom_io_streams.rb +25 -0
- data/lib/spork/diagnoser.rb +105 -0
- data/lib/spork/ext/rails-reloader.rb +14 -0
- data/lib/spork/ext/ruby-debug.rb +150 -0
- data/lib/spork/forker.rb +71 -0
- data/lib/spork/run_strategy.rb +44 -0
- data/lib/spork/run_strategy/forking.rb +32 -0
- data/lib/spork/run_strategy/magazine.rb +141 -0
- data/lib/spork/run_strategy/magazine/magazine_slave.rb +30 -0
- data/lib/spork/run_strategy/magazine/magazine_slave_provider.rb +27 -0
- data/lib/spork/run_strategy/magazine/ring_server.rb +10 -0
- data/lib/spork/runner.rb +90 -0
- data/lib/spork/server.rb +76 -0
- data/lib/spork/test_framework.rb +167 -0
- data/lib/spork/test_framework/cucumber.rb +24 -0
- data/lib/spork/test_framework/rspec.rb +14 -0
- data/spec/spec_helper.rb +113 -0
- data/spec/spork/app_framework/rails_spec.rb +22 -0
- data/spec/spork/app_framework/unknown_spec.rb +12 -0
- data/spec/spork/app_framework_spec.rb +16 -0
- data/spec/spork/diagnoser_spec.rb +105 -0
- data/spec/spork/forker_spec.rb +44 -0
- data/spec/spork/run_strategy/forking_spec.rb +38 -0
- data/spec/spork/runner_spec.rb +50 -0
- data/spec/spork/server_spec.rb +15 -0
- data/spec/spork/test_framework/cucumber_spec.rb +11 -0
- data/spec/spork/test_framework/rspec_spec.rb +10 -0
- data/spec/spork/test_framework_shared_examples.rb +23 -0
- data/spec/spork/test_framework_spec.rb +90 -0
- data/spec/spork_spec.rb +153 -0
- data/spec/support/fake_framework.rb +15 -0
- data/spec/support/fake_run_strategy.rb +21 -0
- metadata +158 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
class Spork::TestFramework
|
2
|
+
LOAD_PREFERENCE = ['RSpec', 'Cucumber']
|
3
|
+
BOOTSTRAP_FILE = File.dirname(__FILE__) + "/../../assets/bootstrap.rb"
|
4
|
+
|
5
|
+
@@supported_test_frameworks = []
|
6
|
+
attr_reader :stdout, :stderr
|
7
|
+
|
8
|
+
class FactoryException < Exception; end
|
9
|
+
|
10
|
+
class NoFrameworksAvailable < FactoryException
|
11
|
+
def message
|
12
|
+
"I can\'t find any testing frameworks to use. Are you running me from a project directory?"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class FrameworkNotAvailable < FactoryException
|
17
|
+
def initialize(framework)
|
18
|
+
@framework = framework
|
19
|
+
end
|
20
|
+
|
21
|
+
def message
|
22
|
+
"I can\'t find the file #{@framework.helper_file} for the #{@framework.short_name} testing framework.\nAre you running me from the project directory?"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class NoFrameworkMatched < FactoryException
|
27
|
+
def initialize(beginning_with)
|
28
|
+
@beginning_with = beginning_with
|
29
|
+
end
|
30
|
+
|
31
|
+
def message
|
32
|
+
"Couldn\'t find a supported test framework that begins with '#{@beginning_with}'"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(stdout = STDOUT, stderr = STDERR)
|
37
|
+
@stdout, @stderr = stdout, stderr
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.factory(output = STDOUT, error = STDERR, beginning_with = nil)
|
41
|
+
if beginning_with
|
42
|
+
@klass = supported_test_frameworks(beginning_with).first
|
43
|
+
raise(NoFrameworkMatched.new(beginning_with)) if @klass.nil?
|
44
|
+
raise(FrameworkNotAvailable.new(@klass)) unless @klass.available?
|
45
|
+
else
|
46
|
+
@klass = available_test_frameworks.first
|
47
|
+
raise(NoFrameworksAvailable.new) unless @klass
|
48
|
+
end
|
49
|
+
@klass.new(output, error)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.helper_file
|
53
|
+
self::HELPER_FILE
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.default_port
|
57
|
+
(ENV["#{short_name.upcase}_DRB"] || self::DEFAULT_PORT).to_i
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.short_name
|
61
|
+
self.name.gsub('Spork::TestFramework::', '')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns a list of all testing servers that have detected their testing framework being used in the project.
|
65
|
+
def self.available_test_frameworks
|
66
|
+
supported_test_frameworks.select { |s| s.available? }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns a list of all servers that have been implemented (it keeps track of them automatically via Class.inherited)
|
70
|
+
def self.supported_test_frameworks(starting_with = nil)
|
71
|
+
@@supported_test_frameworks.sort! { |a,b| a.load_preference_index <=> b.load_preference_index }
|
72
|
+
return @@supported_test_frameworks if starting_with.nil?
|
73
|
+
@@supported_test_frameworks.select do |s|
|
74
|
+
s.short_name.match(/^#{Regexp.escape(starting_with)}/i)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def short_name
|
79
|
+
self.class.short_name
|
80
|
+
end
|
81
|
+
|
82
|
+
def helper_file
|
83
|
+
self.class.helper_file
|
84
|
+
end
|
85
|
+
|
86
|
+
# Detects if the test helper has been bootstrapped.
|
87
|
+
def bootstrapped?
|
88
|
+
File.read(helper_file).include?("Spork.prefork")
|
89
|
+
end
|
90
|
+
|
91
|
+
# Bootstraps the current test helper file by prepending a Spork.prefork and Spork.each_run block at the beginning.
|
92
|
+
def bootstrap
|
93
|
+
if bootstrapped?
|
94
|
+
stderr.puts "Already bootstrapped!"
|
95
|
+
return
|
96
|
+
end
|
97
|
+
stderr.puts "Bootstrapping #{helper_file}."
|
98
|
+
contents = File.read(helper_file)
|
99
|
+
bootstrap_code = File.read(BOOTSTRAP_FILE)
|
100
|
+
File.open(helper_file, "wb") do |f|
|
101
|
+
f.puts bootstrap_code
|
102
|
+
f.puts contents
|
103
|
+
end
|
104
|
+
|
105
|
+
stderr.puts "Done. Edit #{helper_file} now with your favorite text editor and follow the instructions."
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns true if the testing frameworks helper file exists. Override if this is not sufficient to detect your testing framework.
|
110
|
+
def self.available?
|
111
|
+
File.exist?(helper_file)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Used to specify
|
115
|
+
def self.load_preference_index
|
116
|
+
LOAD_PREFERENCE.index(short_name) || LOAD_PREFERENCE.length
|
117
|
+
end
|
118
|
+
|
119
|
+
def preload
|
120
|
+
Spork.exec_prefork do
|
121
|
+
if not bootstrapped?
|
122
|
+
stderr.puts "#{helper_file} has not been bootstrapped. Run spork --bootstrap to do so."
|
123
|
+
stderr.flush
|
124
|
+
|
125
|
+
if framework.bootstrap_required?
|
126
|
+
stderr.puts "I can't do anything for you by default for the framework you're using: #{framework.short_name}.\nYou must bootstrap #{helper_file} to continue."
|
127
|
+
stderr.flush
|
128
|
+
return false
|
129
|
+
else
|
130
|
+
load(framework.entry_point)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
framework.preload do
|
135
|
+
if bootstrapped?
|
136
|
+
stderr.puts "Loading Spork.prefork block..."
|
137
|
+
stderr.flush
|
138
|
+
load(helper_file)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
true
|
143
|
+
end
|
144
|
+
|
145
|
+
def run_tests(argv, stderr, stdout)
|
146
|
+
raise NotImplementedError
|
147
|
+
end
|
148
|
+
|
149
|
+
def entry_point
|
150
|
+
bootstrapped? ? helper_file : framework.entry_point
|
151
|
+
end
|
152
|
+
|
153
|
+
def default_port
|
154
|
+
self.class.default_port
|
155
|
+
end
|
156
|
+
|
157
|
+
protected
|
158
|
+
def self.inherited(subclass)
|
159
|
+
@@supported_test_frameworks << subclass
|
160
|
+
end
|
161
|
+
|
162
|
+
def framework
|
163
|
+
@framework ||= Spork::AppFramework.detect_framework
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
Spork.detect_and_require('spork/test_framework/*.rb')
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Spork::TestFramework::Cucumber < Spork::TestFramework
|
2
|
+
DEFAULT_PORT = 8990
|
3
|
+
HELPER_FILE = File.join(Dir.pwd, "features/support/env.rb")
|
4
|
+
|
5
|
+
class << self
|
6
|
+
# REMOVE WHEN SUPPORT FOR 0.3.95 AND EARLIER IS DROPPED
|
7
|
+
attr_accessor :mother_object
|
8
|
+
end
|
9
|
+
|
10
|
+
def preload
|
11
|
+
require 'cucumber'
|
12
|
+
begin
|
13
|
+
@step_mother = ::Cucumber::StepMother.new
|
14
|
+
@step_mother.load_programming_language('rb')
|
15
|
+
rescue NoMethodError => pre_cucumber_0_4 # REMOVE WHEN SUPPORT FOR PRE-0.4 IS DROPPED
|
16
|
+
@step_mother = Spork::Server::Cucumber.mother_object
|
17
|
+
end
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def run_tests(argv, stderr, stdout)
|
22
|
+
::Cucumber::Cli::Main.new(argv, stdout, stderr).execute!(@step_mother)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Spork::TestFramework::RSpec < Spork::TestFramework
|
2
|
+
DEFAULT_PORT = 8989
|
3
|
+
HELPER_FILE = File.join(Dir.pwd, "spec/spec_helper.rb")
|
4
|
+
|
5
|
+
def run_tests(argv, stderr, stdout)
|
6
|
+
::Spec::Runner::CommandLine.run(
|
7
|
+
::Spec::Runner::OptionParser.parse(
|
8
|
+
argv,
|
9
|
+
stderr,
|
10
|
+
stdout
|
11
|
+
)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
unless $spec_helper_loaded
|
4
|
+
$spec_helper_loaded = true
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
7
|
+
SPEC_TMP_DIR = File.expand_path('tmp', File.dirname(__FILE__))
|
8
|
+
require 'spork'
|
9
|
+
require 'stringio'
|
10
|
+
require 'fileutils'
|
11
|
+
require 'rspec'
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.before(:each) do
|
15
|
+
$test_stdout = StringIO.new
|
16
|
+
$test_stderr = StringIO.new
|
17
|
+
@current_dir = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
config.after(:each) do
|
21
|
+
FileUtils.rm_rf(SPEC_TMP_DIR) if File.directory?(SPEC_TMP_DIR)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_file(filename, contents)
|
26
|
+
FileUtils.mkdir_p(SPEC_TMP_DIR) unless File.directory?(SPEC_TMP_DIR)
|
27
|
+
|
28
|
+
in_current_dir do
|
29
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
30
|
+
File.open(filename, 'wb') { |f| f << contents }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_helper_file(test_framework = FakeFramework)
|
35
|
+
create_file(test_framework.helper_file, "# stub spec helper file")
|
36
|
+
end
|
37
|
+
|
38
|
+
def in_current_dir(&block)
|
39
|
+
Dir.chdir(current_dir, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def current_dir
|
43
|
+
@current_dir ||= SPEC_TMP_DIR
|
44
|
+
end
|
45
|
+
|
46
|
+
def change_current_dir(sub_path)
|
47
|
+
@current_dir = File.expand_path(sub_path, SPEC_TMP_DIR)
|
48
|
+
end
|
49
|
+
|
50
|
+
def windows?
|
51
|
+
ENV['OS'] == 'Windows_NT'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
module RSpec
|
57
|
+
module Matchers
|
58
|
+
class IncludeAStringLike
|
59
|
+
def initialize(substring_or_regex)
|
60
|
+
case substring_or_regex
|
61
|
+
when String
|
62
|
+
@regex = Regexp.new(Regexp.escape(substring_or_regex))
|
63
|
+
when Regexp
|
64
|
+
@regex = substring_or_regex
|
65
|
+
else
|
66
|
+
raise ArgumentError, "don't know what to do with the #{substring_or_regex.class} you provided"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def matches?(list_of_strings)
|
71
|
+
@list_of_strings = list_of_strings
|
72
|
+
@list_of_strings.any? { |s| s =~ @regex }
|
73
|
+
end
|
74
|
+
def failure_message
|
75
|
+
"#{@list_of_strings.inspect} expected to include a string like #{@regex.inspect}"
|
76
|
+
end
|
77
|
+
def negative_failure_message
|
78
|
+
"#{@list_of_strings.inspect} expected to not include a string like #{@regex.inspect}, but did"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def include_a_string_like(substring_or_regex)
|
83
|
+
IncludeAStringLike.new(substring_or_regex)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
module Spork::TestIOStreams
|
89
|
+
def self.included(klass)
|
90
|
+
klass.send(:extend, ::Spork::TestIOStreams::ClassMethods)
|
91
|
+
end
|
92
|
+
|
93
|
+
def stderr
|
94
|
+
self.class.stderr
|
95
|
+
end
|
96
|
+
|
97
|
+
def stdout
|
98
|
+
self.class.stdout
|
99
|
+
end
|
100
|
+
|
101
|
+
module ClassMethods
|
102
|
+
def stderr
|
103
|
+
$test_stderr
|
104
|
+
end
|
105
|
+
|
106
|
+
def stdout
|
107
|
+
$test_stdout
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
Dir.glob(File.dirname(__FILE__) + "/support/*.rb").each { |f| require(f) }
|
113
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Spork::AppFramework::Rails do
|
4
|
+
describe ".deprecated_version" do
|
5
|
+
it "detects the current version of rails" do
|
6
|
+
create_file("config/environment.rb", "RAILS_GEM_VERSION = '2.1.0'")
|
7
|
+
in_current_dir do
|
8
|
+
Spork::AppFramework::Rails.new.deprecated_version.should == "2.1.0"
|
9
|
+
end
|
10
|
+
|
11
|
+
create_file("config/environment.rb", 'RAILS_GEM_VERSION = "2.1.0"')
|
12
|
+
in_current_dir do
|
13
|
+
Spork::AppFramework::Rails.new.deprecated_version.should == "2.1.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
create_file("config/environment.rb", 'RAILS_GEM_VERSION = "> 2.1.0"')
|
17
|
+
in_current_dir do
|
18
|
+
Spork::AppFramework::Rails.new.deprecated_version.should == "> 2.1.0"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Spork::AppFramework::Unknown do
|
4
|
+
it "requires bootstrapping" do
|
5
|
+
Spork::AppFramework::Unknown.new.bootstrap_required?.should == true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "has no known entry point" do
|
9
|
+
Spork::AppFramework::Unknown.new.entry_point.should be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Spork::AppFramework do
|
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
|
+
it "returns Unknown when no framework known detected" do
|
13
|
+
Spork::AppFramework.detect_framework.short_name.should == "Unknown"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Spork::Diagnoser do
|
5
|
+
after(:each) do
|
6
|
+
Spork::Diagnoser.remove_hook!
|
7
|
+
Spork::Diagnoser.loaded_files.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_simulation(directory, filename = nil, contents = nil, &block)
|
11
|
+
FileUtils.mkdir_p(directory)
|
12
|
+
Dir.chdir(directory) do
|
13
|
+
if filename
|
14
|
+
File.open(filename, 'wb') { |f| f << contents }
|
15
|
+
Spork::Diagnoser.install_hook!
|
16
|
+
require filename
|
17
|
+
end
|
18
|
+
yield if block_given?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "installs it's hook and tells you when files have been loaded" do
|
23
|
+
run_simulation(SPEC_TMP_DIR, 'my_awesome_library_include.rb', '1 + 5')
|
24
|
+
Spork::Diagnoser.loaded_files.keys.should include_a_string_like('my_awesome_library_include')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'excludes files outside of Dir.pwd' do
|
28
|
+
run_simulation(SPEC_TMP_DIR + '/project_root', '../external_dependency.rb', '1 + 5')
|
29
|
+
Spork::Diagnoser.loaded_files.keys.should_not include_a_string_like('external_dependency')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "excludes files outside of Dir.pwd but in ruby's include path" do
|
33
|
+
directory = SPEC_TMP_DIR + '/project_root'
|
34
|
+
external_dependency_dir = SPEC_TMP_DIR + '/external_dependency'
|
35
|
+
$: << external_dependency_dir
|
36
|
+
FileUtils.mkdir_p(directory)
|
37
|
+
FileUtils.mkdir_p(external_dependency_dir)
|
38
|
+
Dir.chdir(directory) do
|
39
|
+
File.open(external_dependency_dir + '/the_most_awesome_external_dependency_ever.rb', 'wb') { |f| f << 'funtimes = true' }
|
40
|
+
Spork::Diagnoser.install_hook!
|
41
|
+
require 'the_most_awesome_external_dependency_ever'
|
42
|
+
end
|
43
|
+
|
44
|
+
Spork::Diagnoser.loaded_files.keys.should_not include_a_string_like('the_most_awesome_external_dependency_ever')
|
45
|
+
$:.pop
|
46
|
+
end
|
47
|
+
|
48
|
+
it "expands files to their fully their fully qualified path" do
|
49
|
+
directory = SPEC_TMP_DIR + '/project_root'
|
50
|
+
lib_directory = directory + '/lib'
|
51
|
+
$: << lib_directory
|
52
|
+
FileUtils.mkdir_p(lib_directory)
|
53
|
+
Dir.chdir(directory) do
|
54
|
+
File.open(lib_directory + "/the_most_awesome_lib_file_ever.rb", "wb") { |f| f << "funtimes = true" }
|
55
|
+
Spork::Diagnoser.install_hook!
|
56
|
+
require 'the_most_awesome_lib_file_ever'
|
57
|
+
end
|
58
|
+
|
59
|
+
Spork::Diagnoser.loaded_files.keys.should include_a_string_like('lib/the_most_awesome_lib_file_ever')
|
60
|
+
$:.pop
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can tell the difference between a folder in the project path and a file in an external path" do
|
64
|
+
directory = SPEC_TMP_DIR + '/project_root'
|
65
|
+
external_dependency_dir = SPEC_TMP_DIR + '/external_dependency'
|
66
|
+
$: << external_dependency_dir
|
67
|
+
FileUtils.mkdir_p(directory)
|
68
|
+
FileUtils.mkdir_p(external_dependency_dir)
|
69
|
+
Dir.chdir(directory) do
|
70
|
+
FileUtils.mkdir_p(directory + '/a_popular_folder_name')
|
71
|
+
File.open(external_dependency_dir + '/a_popular_folder_name.rb', 'wb') { |f| f << 'funtimes = true' }
|
72
|
+
Spork::Diagnoser.install_hook!
|
73
|
+
require 'a_popular_folder_name'
|
74
|
+
end
|
75
|
+
|
76
|
+
Spork::Diagnoser.loaded_files.keys.should_not include_a_string_like('a_popular_folder_name')
|
77
|
+
$:.pop
|
78
|
+
end
|
79
|
+
|
80
|
+
it "filters backtrace beyond the last line matching the entry point" do
|
81
|
+
Spork::Diagnoser.install_hook!("test_filter/environment.rb")
|
82
|
+
create_file("test_filter/environment.rb", "require 'test_filter/app.rb'")
|
83
|
+
create_file("test_filter/app.rb", "require 'test_filter/my_model.rb'")
|
84
|
+
create_file("test_filter/my_model.rb", "'my model here'")
|
85
|
+
in_current_dir do
|
86
|
+
require 'test_filter/environment.rb'
|
87
|
+
end
|
88
|
+
f = Spork::Diagnoser.loaded_files
|
89
|
+
f[f.keys.grep(/app.rb/).first].last.should include('test_filter/environment.rb')
|
90
|
+
f[f.keys.grep(/my_model.rb/).first].last.should include('test_filter/environment.rb')
|
91
|
+
f[f.keys.grep(/environment.rb/).first].should == []
|
92
|
+
end
|
93
|
+
|
94
|
+
describe ".output_results" do
|
95
|
+
it "outputs the results relative to the current directory" do
|
96
|
+
Spork::Diagnoser.loaded_files["/project_path/lib/file.rb"] = "/project_path/lib/parent_file.rb:35"
|
97
|
+
Dir.stub!(:pwd).and_return("/project_path")
|
98
|
+
out = StringIO.new
|
99
|
+
Spork::Diagnoser.output_results(out)
|
100
|
+
out.string.should =~ %r([^/]lib/file.rb)
|
101
|
+
out.string.should =~ %r([^/]lib/parent_file.rb)
|
102
|
+
out.string.should_not include("/project_path/")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|