pietervisser-spork 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +11 -0
- data/assets/bootstrap.rb +29 -0
- data/bin/spork +20 -0
- data/features/cucumber_rails_integration.feature +118 -0
- data/features/diagnostic_mode.feature +41 -0
- data/features/rails_delayed_loading_workarounds.feature +115 -0
- data/features/rspec_rails_integration.feature +93 -0
- data/features/spork_debugger.feature +108 -0
- data/features/steps/general_steps.rb +3 -0
- data/features/steps/rails_steps.rb +53 -0
- data/features/steps/sandbox_steps.rb +115 -0
- data/features/support/background_job.rb +63 -0
- data/features/support/env.rb +111 -0
- data/features/unknown_app_framework.feature +42 -0
- data/geminstaller.yml +9 -0
- data/lib/spork/app_framework/rails.rb +158 -0
- data/lib/spork/app_framework/rails_stub_files/application.rb +1 -0
- data/lib/spork/app_framework/rails_stub_files/application_controller.rb +22 -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/app_framework.rb +74 -0
- data/lib/spork/custom_io_streams.rb +25 -0
- data/lib/spork/diagnoser.rb +103 -0
- data/lib/spork/ext/ruby-debug.rb +150 -0
- data/lib/spork/forker.rb +70 -0
- data/lib/spork/run_strategy/forking.rb +30 -0
- data/lib/spork/run_strategy.rb +40 -0
- data/lib/spork/runner.rb +90 -0
- data/lib/spork/server.rb +74 -0
- data/lib/spork/test_framework/cucumber.rb +24 -0
- data/lib/spork/test_framework/rspec.rb +14 -0
- data/lib/spork/test_framework.rb +167 -0
- data/lib/spork.rb +130 -0
- data/spec/spec_helper.rb +108 -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_spec.rb +114 -0
- data/spec/spork_spec.rb +157 -0
- data/spec/support/fake_framework.rb +15 -0
- data/spec/support/fake_run_strategy.rb +21 -0
- metadata +119 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Spork::Server do
|
4
|
+
describe "a fake server" do
|
5
|
+
before(:each) do
|
6
|
+
@fake_run_strategy = FakeRunStrategy.new
|
7
|
+
@server = Spork::Server.new(:run_strategy => @fake_run_strategy)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "accepts a port" do
|
11
|
+
@server.port = 12345
|
12
|
+
@server.port.should == 12345
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../test_framework_spec"
|
3
|
+
|
4
|
+
describe Spork::TestFramework::Cucumber do
|
5
|
+
before(:each) do
|
6
|
+
@klass = Spork::TestFramework::Cucumber
|
7
|
+
@server = @klass.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "a TestFramework"
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + "/../test_framework_spec"
|
3
|
+
|
4
|
+
describe Spork::TestFramework::RSpec do
|
5
|
+
before(:each) do
|
6
|
+
@klass = Spork::TestFramework::RSpec
|
7
|
+
end
|
8
|
+
|
9
|
+
it_should_behave_like "a TestFramework"
|
10
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "a TestFramework", :shared => true do
|
4
|
+
describe ".default_port" do
|
5
|
+
it "uses the DEFAULT_PORT when the environment variable is not set" do
|
6
|
+
@klass.default_port.should == @klass::DEFAULT_PORT
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'uses ENV["#{short_name.upcase}_DRB"] as port if present' do
|
10
|
+
env_name = "#{@klass.short_name.upcase}_DRB"
|
11
|
+
orig, ENV[env_name] = ENV[env_name], "9000"
|
12
|
+
begin
|
13
|
+
@klass.default_port.should == 9000
|
14
|
+
ensure
|
15
|
+
ENV[env_name] = orig
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".helper_file" do
|
21
|
+
it "returns ::HELPER_FILE for the TestFramework" do
|
22
|
+
@klass.helper_file.should == @klass::HELPER_FILE
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe Spork::TestFramework do
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
@fake = FakeFramework.new
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".available_test_frameworks" do
|
34
|
+
before(:each) do
|
35
|
+
Spork::TestFramework.supported_test_frameworks.each { |s| s.stub!(:available?).and_return(false) }
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns a list of all available servers" do
|
39
|
+
Spork::TestFramework.available_test_frameworks.should == []
|
40
|
+
Spork::TestFramework::RSpec.stub!(:available?).and_return(true)
|
41
|
+
Spork::TestFramework.available_test_frameworks.should == [Spork::TestFramework::RSpec]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns rspec before cucumber when both are available" do
|
45
|
+
Spork::TestFramework::RSpec.stub!(:available?).and_return(true)
|
46
|
+
Spork::TestFramework::Cucumber.stub!(:available?).and_return(true)
|
47
|
+
Spork::TestFramework.available_test_frameworks.should == [Spork::TestFramework::RSpec, Spork::TestFramework::Cucumber]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".supported_test_frameworks" do
|
52
|
+
it "returns all defined servers" do
|
53
|
+
Spork::TestFramework.supported_test_frameworks.should include(Spork::TestFramework::RSpec)
|
54
|
+
Spork::TestFramework.supported_test_frameworks.should include(Spork::TestFramework::Cucumber)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns a list of servers matching a case-insensitive prefix" do
|
58
|
+
Spork::TestFramework.supported_test_frameworks("rspec").should == [Spork::TestFramework::RSpec]
|
59
|
+
Spork::TestFramework.supported_test_frameworks("rs").should == [Spork::TestFramework::RSpec]
|
60
|
+
Spork::TestFramework.supported_test_frameworks("cuc").should == [Spork::TestFramework::Cucumber]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ".short_name" do
|
65
|
+
it "returns the name of the framework, without the namespace prefix" do
|
66
|
+
Spork::TestFramework::Cucumber.short_name.should == "Cucumber"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".available?" do
|
71
|
+
it "returns true when the helper_file exists" do
|
72
|
+
FakeFramework.available?.should == false
|
73
|
+
create_helper_file(FakeFramework)
|
74
|
+
FakeFramework.available?.should == true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".bootstrapped?" do
|
79
|
+
it "recognizes if the helper_file has been bootstrapped" do
|
80
|
+
bootstrap_contents = File.read(FakeFramework::BOOTSTRAP_FILE)
|
81
|
+
File.stub!(:read).with(@fake.helper_file).and_return("")
|
82
|
+
@fake.bootstrapped?.should == false
|
83
|
+
File.stub!(:read).with(@fake.helper_file).and_return(bootstrap_contents)
|
84
|
+
@fake.bootstrapped?.should == true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe ".bootstrap" do
|
89
|
+
it "bootstraps a file" do
|
90
|
+
create_helper_file
|
91
|
+
@fake.bootstrap
|
92
|
+
|
93
|
+
$test_stderr.string.should include("Bootstrapping")
|
94
|
+
$test_stderr.string.should include("Edit")
|
95
|
+
$test_stderr.string.should include("favorite text editor")
|
96
|
+
|
97
|
+
File.read(@fake.helper_file).should include(File.read(FakeFramework::BOOTSTRAP_FILE))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe ".factory" do
|
102
|
+
it "defaults to use rspec over cucumber" do
|
103
|
+
Spork::TestFramework::RSpec.stub!(:available?).and_return(true)
|
104
|
+
Spork::TestFramework::Cucumber.stub!(:available?).and_return(true)
|
105
|
+
Spork::TestFramework.factory(STDOUT, STDERR).class.should == Spork::TestFramework::RSpec
|
106
|
+
end
|
107
|
+
|
108
|
+
it "defaults to use cucumber when rspec not available" do
|
109
|
+
Spork::TestFramework::RSpec.stub!(:available?).and_return(false)
|
110
|
+
Spork::TestFramework::Cucumber.stub!(:available?).and_return(true)
|
111
|
+
Spork::TestFramework.factory(STDOUT, STDERR).class.should == Spork::TestFramework::Cucumber
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/spec/spork_spec.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
Spork.class_eval do
|
4
|
+
def self.reset!
|
5
|
+
@state = nil
|
6
|
+
@already_ran = nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Spork do
|
11
|
+
before(:each) do
|
12
|
+
Spork.reset!
|
13
|
+
end
|
14
|
+
|
15
|
+
def spec_helper_simulator
|
16
|
+
@ran ||= []
|
17
|
+
Spork.prefork do
|
18
|
+
@ran << :prefork
|
19
|
+
end
|
20
|
+
|
21
|
+
Spork.each_run do
|
22
|
+
@ran << :each_run
|
23
|
+
end
|
24
|
+
@ran
|
25
|
+
end
|
26
|
+
|
27
|
+
it "only runs the preload block when preforking" do
|
28
|
+
Spork.exec_prefork { spec_helper_simulator }
|
29
|
+
@ran.should == [:prefork]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "only runs the each_run block when running" do
|
33
|
+
Spork.exec_prefork { spec_helper_simulator }
|
34
|
+
@ran.should == [:prefork]
|
35
|
+
|
36
|
+
Spork.exec_each_run
|
37
|
+
@ran.should == [:prefork, :each_run]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "runs both blocks when Spork not activated" do
|
41
|
+
spec_helper_simulator.should == [:prefork, :each_run]
|
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
|
+
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
|
64
|
+
it "expands a windows caller line, preserving the line number" do
|
65
|
+
Spork.send(:expanded_caller, "c:/boo/../yah.rb:31").should == "c:/yah.rb:31"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#using_spork?" do
|
70
|
+
it "returns true if Spork is being used" do
|
71
|
+
Spork.using_spork?.should be_false
|
72
|
+
Spork.using_spork!
|
73
|
+
Spork.using_spork?.should be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#trap_method" do
|
78
|
+
before(:each) do
|
79
|
+
Spork.using_spork!
|
80
|
+
|
81
|
+
Object.class_eval do
|
82
|
+
class TrapTest
|
83
|
+
def self.output
|
84
|
+
@output ||= []
|
85
|
+
end
|
86
|
+
|
87
|
+
def hello
|
88
|
+
TrapTest.output << 'hello'
|
89
|
+
end
|
90
|
+
|
91
|
+
def goodbye
|
92
|
+
TrapTest.output << 'goodbye'
|
93
|
+
end
|
94
|
+
|
95
|
+
def say_something!
|
96
|
+
TrapTest.output << 'something'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
@trap_test = TrapTest.new
|
101
|
+
end
|
102
|
+
|
103
|
+
after(:each) do
|
104
|
+
Object.send(:remove_const, :TrapTest)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "delays execution of a method until after Spork.exec_each_run is called" do
|
108
|
+
Spork.using_spork!
|
109
|
+
Spork.trap_method(TrapTest, :hello)
|
110
|
+
@trap_test.hello
|
111
|
+
@trap_test.goodbye
|
112
|
+
Spork.exec_each_run
|
113
|
+
TrapTest.output.should == ['goodbye', 'hello']
|
114
|
+
end
|
115
|
+
|
116
|
+
it "works with methods that have punctuation" do
|
117
|
+
Spork.trap_method(TrapTest, :say_something!)
|
118
|
+
@trap_test.say_something!
|
119
|
+
TrapTest.output.should == []
|
120
|
+
Spork.exec_each_run
|
121
|
+
TrapTest.output.should == ['something']
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#trap_class_method" do
|
126
|
+
before(:each) do
|
127
|
+
Object.class_eval do
|
128
|
+
class TrapTest
|
129
|
+
def self.output
|
130
|
+
@output ||= []
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.hello
|
134
|
+
output << 'hello'
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.goodbye
|
138
|
+
output << 'goodbye'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
after(:each) do
|
145
|
+
Object.send(:remove_const, :TrapTest)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "delays execution of a method until after Spork.exec_each_run is called" do
|
149
|
+
Spork.using_spork!
|
150
|
+
Spork.trap_class_method(TrapTest, :hello)
|
151
|
+
TrapTest.hello
|
152
|
+
TrapTest.goodbye
|
153
|
+
Spork.exec_each_run
|
154
|
+
TrapTest.output.should == ['goodbye', 'hello']
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class FakeFramework < Spork::TestFramework
|
2
|
+
include Spork::TestIOStreams
|
3
|
+
|
4
|
+
attr_accessor :wait_time
|
5
|
+
DEFAULT_PORT = 1000
|
6
|
+
|
7
|
+
def self.helper_file
|
8
|
+
SPEC_TMP_DIR + "/fake/test_helper.rb"
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_tests(argv, input, output)
|
12
|
+
sleep(@wait_time || 0.5)
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class FakeRunStrategy < Spork::RunStrategy
|
2
|
+
def initialize(*args)
|
3
|
+
end
|
4
|
+
|
5
|
+
def self.available?
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
def run(argv, stderr, stdout)
|
10
|
+
sleep(@wait_time || 0.5)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def running?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def preload
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pietervisser-spork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Harper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-23 00:00:00 +01:00
|
13
|
+
default_executable: spork
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Fork of A forking Drb spec server
|
17
|
+
email:
|
18
|
+
- info@illusoft.com
|
19
|
+
executables:
|
20
|
+
- spork
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- MIT-LICENSE
|
25
|
+
- README.rdoc
|
26
|
+
files:
|
27
|
+
- MIT-LICENSE
|
28
|
+
- README.rdoc
|
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/spork_debugger.feature
|
35
|
+
- features/steps/general_steps.rb
|
36
|
+
- features/steps/rails_steps.rb
|
37
|
+
- features/steps/sandbox_steps.rb
|
38
|
+
- features/support/background_job.rb
|
39
|
+
- features/support/env.rb
|
40
|
+
- features/unknown_app_framework.feature
|
41
|
+
- geminstaller.yml
|
42
|
+
- lib/spork.rb
|
43
|
+
- lib/spork/app_framework.rb
|
44
|
+
- lib/spork/app_framework/rails.rb
|
45
|
+
- lib/spork/app_framework/rails_stub_files/application.rb
|
46
|
+
- lib/spork/app_framework/rails_stub_files/application_controller.rb
|
47
|
+
- lib/spork/app_framework/rails_stub_files/application_helper.rb
|
48
|
+
- lib/spork/app_framework/unknown.rb
|
49
|
+
- lib/spork/custom_io_streams.rb
|
50
|
+
- lib/spork/diagnoser.rb
|
51
|
+
- lib/spork/ext/ruby-debug.rb
|
52
|
+
- lib/spork/forker.rb
|
53
|
+
- lib/spork/run_strategy.rb
|
54
|
+
- lib/spork/run_strategy/forking.rb
|
55
|
+
- lib/spork/runner.rb
|
56
|
+
- lib/spork/server.rb
|
57
|
+
- lib/spork/test_framework.rb
|
58
|
+
- lib/spork/test_framework/cucumber.rb
|
59
|
+
- lib/spork/test_framework/rspec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- spec/spork/app_framework/rails_spec.rb
|
62
|
+
- spec/spork/app_framework/unknown_spec.rb
|
63
|
+
- spec/spork/app_framework_spec.rb
|
64
|
+
- spec/spork/diagnoser_spec.rb
|
65
|
+
- spec/spork/forker_spec.rb
|
66
|
+
- spec/spork/run_strategy/forking_spec.rb
|
67
|
+
- spec/spork/runner_spec.rb
|
68
|
+
- spec/spork/server_spec.rb
|
69
|
+
- spec/spork/test_framework/cucumber_spec.rb
|
70
|
+
- spec/spork/test_framework/rspec_spec.rb
|
71
|
+
- spec/spork/test_framework_spec.rb
|
72
|
+
- spec/spork_spec.rb
|
73
|
+
- spec/support/fake_framework.rb
|
74
|
+
- spec/support/fake_run_strategy.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: http://github.com/pietervisser/spork
|
77
|
+
licenses: []
|
78
|
+
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options:
|
81
|
+
- --main
|
82
|
+
- README.rdoc
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
requirements: []
|
98
|
+
|
99
|
+
rubyforge_project: spork
|
100
|
+
rubygems_version: 1.3.5
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: spork
|
104
|
+
test_files:
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
- spec/spork/app_framework/rails_spec.rb
|
107
|
+
- spec/spork/app_framework/unknown_spec.rb
|
108
|
+
- spec/spork/app_framework_spec.rb
|
109
|
+
- spec/spork/diagnoser_spec.rb
|
110
|
+
- spec/spork/forker_spec.rb
|
111
|
+
- spec/spork/run_strategy/forking_spec.rb
|
112
|
+
- spec/spork/runner_spec.rb
|
113
|
+
- spec/spork/server_spec.rb
|
114
|
+
- spec/spork/test_framework/cucumber_spec.rb
|
115
|
+
- spec/spork/test_framework/rspec_spec.rb
|
116
|
+
- spec/spork/test_framework_spec.rb
|
117
|
+
- spec/spork_spec.rb
|
118
|
+
- spec/support/fake_framework.rb
|
119
|
+
- spec/support/fake_run_strategy.rb
|