bmabey-spork 0.4.4 → 0.5.9
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/README.rdoc +51 -23
- data/assets/bootstrap.rb +1 -1
- data/bin/spork +0 -0
- data/features/cucumber_rails_integration.feature +113 -0
- data/features/diagnostic_mode.feature +41 -0
- data/features/rails_delayed_loading_workarounds.feature +80 -0
- data/features/rspec_rails_integration.feature +90 -0
- data/features/steps/rails_steps.rb +53 -0
- data/features/steps/sandbox_steps.rb +98 -0
- data/features/support/env.rb +98 -0
- data/features/unknown_app_framework.feature +42 -0
- data/lib/spork.rb +85 -26
- data/lib/spork/app_framework.rb +74 -0
- data/lib/spork/app_framework/rails.rb +158 -0
- data/lib/spork/app_framework/rails_stub_files/application.rb +3 -0
- data/lib/spork/app_framework/rails_stub_files/application_controller.rb +3 -0
- data/lib/spork/app_framework/rails_stub_files/application_helper.rb +3 -0
- data/lib/spork/app_framework/unknown.rb +6 -0
- data/lib/spork/custom_io_streams.rb +25 -0
- data/lib/spork/diagnoser.rb +103 -0
- data/lib/spork/forker.rb +70 -0
- data/lib/spork/runner.rb +28 -10
- data/lib/spork/server.rb +88 -46
- data/lib/spork/server/cucumber.rb +21 -9
- data/lib/spork/server/rspec.rb +1 -1
- data/spec/spec_helper.rb +93 -35
- 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/runner_spec.rb +2 -2
- data/spec/spork/server/cucumber_spec.rb +25 -0
- data/spec/spork/server/rspec_spec.rb +17 -3
- data/spec/spork/server_spec.rb +32 -17
- data/spec/spork_spec.rb +112 -13
- metadata +33 -3
@@ -2,10 +2,24 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe Spork::Server::RSpec do
|
4
4
|
before(:each) do
|
5
|
-
@
|
5
|
+
@server = Spork::Server::RSpec.new
|
6
6
|
end
|
7
7
|
|
8
|
-
it "uses the RSPEC_PORT for it's port" do
|
9
|
-
@
|
8
|
+
it "uses the RSPEC_PORT for it's default port" do
|
9
|
+
@server.port.should == Spork::Server::RSpec::RSPEC_PORT
|
10
|
+
end
|
11
|
+
|
12
|
+
it "uses ENV['RSPEC_DRB'] as port if present" do
|
13
|
+
orig = ENV['RSPEC_DRB']
|
14
|
+
begin
|
15
|
+
ENV['RSPEC_DRB'] = "9000"
|
16
|
+
@server.port.should == 9000
|
17
|
+
ensure
|
18
|
+
ENV['RSPEC_DRB'] = orig
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "uses the RSPEC_HELPER_FILE for it's helper_file" do
|
23
|
+
@server.helper_file.should == Spork::Server::RSpec::RSPEC_HELPER_FILE
|
10
24
|
end
|
11
25
|
end
|
data/spec/spork/server_spec.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
+
|
3
4
|
class FakeServer < Spork::Server
|
4
5
|
attr_accessor :wait_time
|
6
|
+
|
7
|
+
include Spork::TestIOStreams
|
8
|
+
|
5
9
|
def self.helper_file
|
6
10
|
SPEC_TMP_DIR + "/fake/test_helper.rb"
|
7
11
|
end
|
@@ -10,16 +14,9 @@ class FakeServer < Spork::Server
|
|
10
14
|
1000
|
11
15
|
end
|
12
16
|
|
13
|
-
def self.puts(string)
|
14
|
-
$test_stdout.puts(string)
|
15
|
-
end
|
16
|
-
|
17
|
-
def puts(string)
|
18
|
-
$test_stdout.puts(string)
|
19
|
-
end
|
20
|
-
|
21
17
|
def run_tests(argv, input, output)
|
22
18
|
sleep(@wait_time || 0.5)
|
19
|
+
true
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
@@ -57,8 +54,7 @@ describe Spork::Server do
|
|
57
54
|
|
58
55
|
describe "a fake server" do
|
59
56
|
def create_helper_file
|
60
|
-
|
61
|
-
FileUtils.touch(FakeServer.helper_file)
|
57
|
+
create_file(FakeServer.helper_file, "# stub spec helper file")
|
62
58
|
end
|
63
59
|
|
64
60
|
before(:each) do
|
@@ -93,19 +89,19 @@ describe Spork::Server do
|
|
93
89
|
create_helper_file
|
94
90
|
FakeServer.bootstrap
|
95
91
|
|
96
|
-
$
|
97
|
-
$
|
98
|
-
$
|
92
|
+
$test_stderr.string.should include("Bootstrapping")
|
93
|
+
$test_stderr.string.should include("Edit")
|
94
|
+
$test_stderr.string.should include("favorite text editor")
|
99
95
|
|
100
96
|
File.read(FakeServer.helper_file).should include(File.read(FakeServer::BOOTSTRAP_FILE))
|
101
97
|
end
|
102
98
|
|
103
|
-
it "
|
99
|
+
it "aborts the current running thread when another run is started" do
|
104
100
|
create_helper_file
|
105
101
|
@fake.wait_time = 0.25
|
106
|
-
first_run = Thread.new { @fake.run("test", STDOUT, STDIN).should ==
|
102
|
+
first_run = Thread.new { @fake.run("test", STDOUT, STDIN).should == nil }
|
107
103
|
sleep(0.05)
|
108
|
-
@fake.run("test", STDOUT, STDIN).should ==
|
104
|
+
@fake.run("test", STDOUT, STDIN).should == true
|
109
105
|
|
110
106
|
# wait for the first to finish
|
111
107
|
first_run.join
|
@@ -119,8 +115,27 @@ describe Spork::Server do
|
|
119
115
|
sleep(0.05)
|
120
116
|
@fake.send(:abort)
|
121
117
|
sleep(0.01) while @fake.running?
|
122
|
-
|
118
|
+
|
123
119
|
(Time.now - started_at).should < @fake.wait_time
|
124
120
|
end
|
121
|
+
|
122
|
+
it "returns the result of the run_tests method from the forked child" do
|
123
|
+
create_helper_file
|
124
|
+
@fake.stub!(:run_tests).and_return("tests were ran")
|
125
|
+
@fake.run("test", STDOUT, STDIN).should == "tests were ran"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "accepts a port" do
|
129
|
+
create_helper_file
|
130
|
+
@fake.class.port = 12345
|
131
|
+
@fake.port.should == 12345
|
132
|
+
end
|
133
|
+
|
134
|
+
it "falls back to a default port" do
|
135
|
+
create_helper_file
|
136
|
+
@fake.class.port = nil
|
137
|
+
@fake.port.should == FakeServer.port
|
138
|
+
end
|
139
|
+
|
125
140
|
end
|
126
141
|
end
|
data/spec/spork_spec.rb
CHANGED
@@ -3,8 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
Spork.class_eval do
|
4
4
|
def self.reset!
|
5
5
|
@state = nil
|
6
|
-
@
|
7
|
-
@already_preforked = nil
|
6
|
+
@already_ran = nil
|
8
7
|
end
|
9
8
|
end
|
10
9
|
|
@@ -14,31 +13,131 @@ describe Spork do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def spec_helper_simulator
|
17
|
-
ran
|
16
|
+
@ran ||= []
|
18
17
|
Spork.prefork do
|
19
|
-
ran << :prefork
|
18
|
+
@ran << :prefork
|
20
19
|
end
|
21
20
|
|
22
21
|
Spork.each_run do
|
23
|
-
ran << :each_run
|
22
|
+
@ran << :each_run
|
24
23
|
end
|
25
|
-
ran
|
24
|
+
@ran
|
26
25
|
end
|
27
26
|
|
28
27
|
it "only runs the preload block when preforking" do
|
29
|
-
|
30
|
-
|
31
|
-
spec_helper_simulator.should == [:prefork]
|
28
|
+
Spork.exec_prefork { spec_helper_simulator }
|
29
|
+
@ran.should == [:prefork]
|
32
30
|
end
|
33
31
|
|
34
32
|
it "only runs the each_run block when running" do
|
35
|
-
Spork.
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
Spork.exec_prefork { spec_helper_simulator }
|
34
|
+
@ran.should == [:prefork]
|
35
|
+
|
36
|
+
Spork.exec_each_run
|
37
|
+
@ran.should == [:prefork, :each_run]
|
39
38
|
end
|
40
39
|
|
41
40
|
it "runs both blocks when Spork not activated" do
|
42
41
|
spec_helper_simulator.should == [:prefork, :each_run]
|
43
42
|
end
|
43
|
+
|
44
|
+
it "prevents blocks from being ran twice" do
|
45
|
+
Spork.exec_prefork { spec_helper_simulator }
|
46
|
+
Spork.exec_each_run
|
47
|
+
@ran.clear
|
48
|
+
Spork.exec_prefork { spec_helper_simulator }
|
49
|
+
Spork.exec_each_run
|
50
|
+
@ran.should == []
|
51
|
+
end
|
52
|
+
|
53
|
+
it "runs multiple prefork and each_run blocks at different locations" do
|
54
|
+
Spork.prefork { }
|
55
|
+
Spork.each_run { }
|
56
|
+
spec_helper_simulator.should == [:prefork, :each_run]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "expands a caller line, preserving the line number" do
|
60
|
+
Spork.send(:expanded_caller, "/boo/../yah.rb:31").should == "/yah.rb:31"
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#trap_method" do
|
64
|
+
before(:each) do
|
65
|
+
Spork.using_spork!
|
66
|
+
|
67
|
+
Object.class_eval do
|
68
|
+
class TrapTest
|
69
|
+
def self.output
|
70
|
+
@output ||= []
|
71
|
+
end
|
72
|
+
|
73
|
+
def hello
|
74
|
+
TrapTest.output << 'hello'
|
75
|
+
end
|
76
|
+
|
77
|
+
def goodbye
|
78
|
+
TrapTest.output << 'goodbye'
|
79
|
+
end
|
80
|
+
|
81
|
+
def say_something!
|
82
|
+
TrapTest.output << 'something'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
@trap_test = TrapTest.new
|
87
|
+
end
|
88
|
+
|
89
|
+
after(:each) do
|
90
|
+
Object.send(:remove_const, :TrapTest)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "delays execution of a method until after Spork.exec_each_run is called" do
|
94
|
+
Spork.using_spork!
|
95
|
+
Spork.trap_method(TrapTest, :hello)
|
96
|
+
@trap_test.hello
|
97
|
+
@trap_test.goodbye
|
98
|
+
Spork.exec_each_run
|
99
|
+
TrapTest.output.should == ['goodbye', 'hello']
|
100
|
+
end
|
101
|
+
|
102
|
+
it "works with methods that have punctuation" do
|
103
|
+
Spork.trap_method(TrapTest, :say_something!)
|
104
|
+
@trap_test.say_something!
|
105
|
+
TrapTest.output.should == []
|
106
|
+
Spork.exec_each_run
|
107
|
+
TrapTest.output.should == ['something']
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#trap_class_method" do
|
112
|
+
before(:each) do
|
113
|
+
Object.class_eval do
|
114
|
+
class TrapTest
|
115
|
+
def self.output
|
116
|
+
@output ||= []
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.hello
|
120
|
+
output << 'hello'
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.goodbye
|
124
|
+
output << 'goodbye'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
after(:each) do
|
131
|
+
Object.send(:remove_const, :TrapTest)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "delays execution of a method until after Spork.exec_each_run is called" do
|
135
|
+
Spork.using_spork!
|
136
|
+
Spork.trap_class_method(TrapTest, :hello)
|
137
|
+
TrapTest.hello
|
138
|
+
TrapTest.goodbye
|
139
|
+
Spork.exec_each_run
|
140
|
+
TrapTest.output.should == ['goodbye', 'hello']
|
141
|
+
end
|
142
|
+
end
|
44
143
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmabey-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Harper
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-15 00:00:00 -07:00
|
13
13
|
default_executable: spork
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -27,18 +27,42 @@ files:
|
|
27
27
|
- MIT-LICENSE
|
28
28
|
- README.rdoc
|
29
29
|
- assets/bootstrap.rb
|
30
|
+
- features/cucumber_rails_integration.feature
|
31
|
+
- features/diagnostic_mode.feature
|
32
|
+
- features/rails_delayed_loading_workarounds.feature
|
33
|
+
- features/rspec_rails_integration.feature
|
34
|
+
- features/steps/rails_steps.rb
|
35
|
+
- features/steps/sandbox_steps.rb
|
36
|
+
- features/support/env.rb
|
37
|
+
- features/unknown_app_framework.feature
|
30
38
|
- lib/spork.rb
|
39
|
+
- lib/spork/app_framework.rb
|
40
|
+
- lib/spork/app_framework/rails.rb
|
41
|
+
- lib/spork/app_framework/rails_stub_files/application.rb
|
42
|
+
- lib/spork/app_framework/rails_stub_files/application_controller.rb
|
43
|
+
- lib/spork/app_framework/rails_stub_files/application_helper.rb
|
44
|
+
- lib/spork/app_framework/unknown.rb
|
45
|
+
- lib/spork/custom_io_streams.rb
|
46
|
+
- lib/spork/diagnoser.rb
|
47
|
+
- lib/spork/forker.rb
|
31
48
|
- lib/spork/runner.rb
|
32
49
|
- lib/spork/server.rb
|
33
50
|
- lib/spork/server/cucumber.rb
|
34
51
|
- lib/spork/server/rspec.rb
|
35
52
|
- spec/spec_helper.rb
|
53
|
+
- spec/spork/app_framework/rails_spec.rb
|
54
|
+
- spec/spork/app_framework/unknown_spec.rb
|
55
|
+
- spec/spork/app_framework_spec.rb
|
56
|
+
- spec/spork/diagnoser_spec.rb
|
57
|
+
- spec/spork/forker_spec.rb
|
36
58
|
- spec/spork/runner_spec.rb
|
59
|
+
- spec/spork/server/cucumber_spec.rb
|
37
60
|
- spec/spork/server/rspec_spec.rb
|
38
61
|
- spec/spork/server_spec.rb
|
39
62
|
- spec/spork_spec.rb
|
40
63
|
has_rdoc: false
|
41
64
|
homepage: http://github.com/timcharper/spork
|
65
|
+
licenses:
|
42
66
|
post_install_message:
|
43
67
|
rdoc_options:
|
44
68
|
- --main
|
@@ -60,13 +84,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
84
|
requirements: []
|
61
85
|
|
62
86
|
rubyforge_project: spork
|
63
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.3.5
|
64
88
|
signing_key:
|
65
89
|
specification_version: 3
|
66
90
|
summary: spork
|
67
91
|
test_files:
|
68
92
|
- spec/spec_helper.rb
|
93
|
+
- spec/spork/app_framework/rails_spec.rb
|
94
|
+
- spec/spork/app_framework/unknown_spec.rb
|
95
|
+
- spec/spork/app_framework_spec.rb
|
96
|
+
- spec/spork/diagnoser_spec.rb
|
97
|
+
- spec/spork/forker_spec.rb
|
69
98
|
- spec/spork/runner_spec.rb
|
99
|
+
- spec/spork/server/cucumber_spec.rb
|
70
100
|
- spec/spork/server/rspec_spec.rb
|
71
101
|
- spec/spork/server_spec.rb
|
72
102
|
- spec/spork_spec.rb
|