spork 0.9.0.rc → 0.9.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.rdoc +8 -0
- data/features/cucumber_rails_integration.feature +6 -10
- data/features/gemfiles/rails3.0/Gemfile +3 -3
- data/features/gemfiles/rails3.0/Gemfile.lock +15 -15
- data/features/rspec_rails_integration.feature +2 -2
- data/features/steps/rails_steps.rb +1 -1
- data/features/steps/sandbox_steps.rb +2 -2
- data/features/support/bundler_helpers.rb +0 -1
- data/features/support/env.rb +1 -13
- data/lib/spork.rb +1 -7
- data/lib/spork/app_framework/rails.rb +3 -3
- data/lib/spork/runner.rb +0 -1
- data/spec/spec_helper.rb +3 -2
- data/spec/spork/app_framework/rails_spec.rb +4 -4
- data/spec/spork/test_framework/cucumber_spec.rb +1 -1
- data/spec/spork/test_framework/rspec_spec.rb +1 -1
- data/spec/spork/test_framework_shared_examples.rb +23 -0
- data/spec/spork/test_framework_spec.rb +0 -24
- data/spec/spork_spec.rb +7 -5
- metadata +6 -4
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -12,6 +12,14 @@ Spork is Tim Harper's implementation of test server (similar to the script/spec_
|
|
12
12
|
|
13
13
|
Spork runs on POSIX systems using fork. It also runs on windows by pre-populating a pool of ready processes (referred to here as the "magazine" strategy).
|
14
14
|
|
15
|
+
== RAILS 3
|
16
|
+
|
17
|
+
Rails 3.0 support is in progress, but is not ready. The master branch is stable and works with rails 2.3.x.
|
18
|
+
|
19
|
+
Rspec 2.x support is not ready either.
|
20
|
+
|
21
|
+
If you want to help, see the rails3 branch.
|
22
|
+
|
15
23
|
== Supported Testing Frameworks
|
16
24
|
|
17
25
|
* Rspec
|
@@ -10,6 +10,8 @@ Feature: Cucumber integration with rails
|
|
10
10
|
"""
|
11
11
|
require 'rubygems'
|
12
12
|
require 'spork'
|
13
|
+
ENV["RAILS_ENV"] ||= "test"
|
14
|
+
|
13
15
|
|
14
16
|
Spork.prefork do
|
15
17
|
# Loading more in this block will cause your tests to run faster. However,
|
@@ -17,7 +19,6 @@ Feature: Cucumber integration with rails
|
|
17
19
|
# need to restart spork for it take effect.
|
18
20
|
|
19
21
|
# Sets up the Rails environment for Cucumber
|
20
|
-
ENV['RAILS_ENV'] = "features"
|
21
22
|
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
22
23
|
|
23
24
|
require 'cucumber'
|
@@ -49,15 +50,11 @@ Feature: Cucumber integration with rails
|
|
49
50
|
"""
|
50
51
|
$loaded_stuff << 'features/support/cucumber_rails_helper.rb'
|
51
52
|
"""
|
52
|
-
And a file named "config/environments/features.rb" with:
|
53
|
-
"""
|
54
|
-
# your cucumber env here
|
55
|
-
"""
|
56
53
|
And a file named "config/database.yml" with:
|
57
54
|
"""
|
58
|
-
|
55
|
+
test:
|
59
56
|
adapter: sqlite3
|
60
|
-
database: db/
|
57
|
+
database: db/test.sqlite3
|
61
58
|
timeout: 5000
|
62
59
|
"""
|
63
60
|
And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
|
@@ -85,7 +82,6 @@ Feature: Cucumber integration with rails
|
|
85
82
|
Then the output should not contain "app/controllers/application.rb"
|
86
83
|
Then the output should not contain "app/controllers/application_controller.rb"
|
87
84
|
Then the output should not contain "app/controllers/application_helper.rb"
|
88
|
-
Then the output should not contain "config/routes.rb"
|
89
85
|
Then the output should not contain "features/step_definitions/cucumber_rails_steps.rb"
|
90
86
|
Then the output should not contain "features/support/cucumber_rails_helper.rb"
|
91
87
|
|
@@ -101,11 +97,11 @@ Feature: Cucumber integration with rails
|
|
101
97
|
And I run cucumber --drb features
|
102
98
|
Then the error output should be empty
|
103
99
|
And the output should contain "It worked!"
|
104
|
-
And the file "log/
|
100
|
+
And the file "log/test.log" should include "hey there"
|
105
101
|
|
106
102
|
Scenario: Running spork with a rails app and a non-standard port
|
107
103
|
When I fire up a spork instance with "spork cucumber -p 9000"
|
108
104
|
And I run cucumber --drb --port 9000 features
|
109
105
|
Then the error output should be empty
|
110
106
|
And the output should contain "It worked!"
|
111
|
-
And the file "log/
|
107
|
+
And the file "log/test.log" should include "hey there"
|
@@ -1,8 +1,8 @@
|
|
1
1
|
source :gemcutter
|
2
2
|
gem 'sqlite3-ruby', '1.2.5'
|
3
|
-
gem 'cucumber', '0.
|
4
|
-
gem 'cucumber-rails', '0.3.
|
5
|
-
gem "gherkin", "1.
|
3
|
+
gem 'cucumber', '0.8.5'
|
4
|
+
gem 'cucumber-rails', '0.3.2'
|
5
|
+
gem "gherkin", "2.1.4"
|
6
6
|
gem "rspec", "2.0.0.beta.20"
|
7
7
|
gem 'rspec-rails', "2.0.0.beta.20"
|
8
8
|
gem 'rails', '3.0.0'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/timcharper/projects/spork
|
3
3
|
specs:
|
4
|
-
spork (0.
|
4
|
+
spork (0.9.0.rc)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -37,23 +37,23 @@ GEM
|
|
37
37
|
activesupport (~> 3.0.0)
|
38
38
|
builder (2.1.2)
|
39
39
|
columnize (0.3.1)
|
40
|
-
cucumber (0.
|
41
|
-
builder (
|
42
|
-
diff-lcs (
|
43
|
-
gherkin (
|
44
|
-
json_pure (
|
45
|
-
term-ansicolor (
|
46
|
-
cucumber-rails (0.3.
|
47
|
-
cucumber (>= 0.
|
40
|
+
cucumber (0.8.5)
|
41
|
+
builder (~> 2.1.2)
|
42
|
+
diff-lcs (~> 1.1.2)
|
43
|
+
gherkin (~> 2.1.4)
|
44
|
+
json_pure (~> 1.4.3)
|
45
|
+
term-ansicolor (~> 1.0.4)
|
46
|
+
cucumber-rails (0.3.2)
|
47
|
+
cucumber (>= 0.8.0)
|
48
48
|
diff-lcs (1.1.2)
|
49
49
|
erubis (2.6.6)
|
50
50
|
abstract (>= 1.0.0)
|
51
|
-
gherkin (1.
|
52
|
-
trollop (
|
51
|
+
gherkin (2.1.4)
|
52
|
+
trollop (~> 1.16.2)
|
53
53
|
i18n (0.4.1)
|
54
54
|
json_pure (1.4.6)
|
55
55
|
linecache (0.43)
|
56
|
-
mail (2.2.6)
|
56
|
+
mail (2.2.6.1)
|
57
57
|
activesupport (>= 2.3.6)
|
58
58
|
mime-types
|
59
59
|
treetop (>= 1.4.5)
|
@@ -105,9 +105,9 @@ PLATFORMS
|
|
105
105
|
ruby
|
106
106
|
|
107
107
|
DEPENDENCIES
|
108
|
-
cucumber (= 0.
|
109
|
-
cucumber-rails (= 0.3.
|
110
|
-
gherkin (= 1.
|
108
|
+
cucumber (= 0.8.5)
|
109
|
+
cucumber-rails (= 0.3.2)
|
110
|
+
gherkin (= 2.1.4)
|
111
111
|
rails (= 3.0.0)
|
112
112
|
rspec (= 2.0.0.beta.20)
|
113
113
|
rspec-rails (= 2.0.0.beta.20)
|
@@ -47,7 +47,7 @@ Feature: Rails Integration
|
|
47
47
|
require 'spec_helper'
|
48
48
|
describe "Did it work?" do
|
49
49
|
it "checks to see if all worked" do
|
50
|
-
Spork.
|
50
|
+
Spork.using_spork?.should == true
|
51
51
|
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
52
52
|
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
53
53
|
$loaded_stuff.should include('User')
|
@@ -72,7 +72,7 @@ Feature: Rails Integration
|
|
72
72
|
"""
|
73
73
|
describe "Did it work?" do
|
74
74
|
it "checks to see if all worked" do
|
75
|
-
Spork.
|
75
|
+
Spork.using_spork?.should == true
|
76
76
|
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
77
77
|
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
78
78
|
$loaded_stuff.should include('User')
|
@@ -57,8 +57,8 @@ Given "the application has a model, observer, route, and application helper" do
|
|
57
57
|
class ActiveRecord::Base
|
58
58
|
class << self
|
59
59
|
def establish_connection_with_load_logging(*args)
|
60
|
-
establish_connection_without_load_logging(*args)
|
61
60
|
$loaded_stuff << 'ActiveRecord::Base.establish_connection'
|
61
|
+
establish_connection_without_load_logging(*args)
|
62
62
|
end
|
63
63
|
alias_method_chain :establish_connection, :load_logging
|
64
64
|
end
|
@@ -32,11 +32,11 @@ Given /^the following code appears in "([^\"]*)" after \/([^\/]*)\/:$/ do |file_
|
|
32
32
|
end
|
33
33
|
|
34
34
|
When /^I run (spork|rspec|cucumber)(| .*)$/ do |command, args|
|
35
|
-
run(
|
35
|
+
run("#{command} #{args}")
|
36
36
|
end
|
37
37
|
|
38
38
|
When /^I run this in the background: (spork|rspec|cucumber)(| .*)$/ do |command, args|
|
39
|
-
@background_script = run_in_background(
|
39
|
+
@background_script = run_in_background("#{command} #{args}")
|
40
40
|
end
|
41
41
|
|
42
42
|
When /^I fire up a spork instance with "spork(.*)"$/ do |spork_opts|
|
data/features/support/env.rb
CHANGED
@@ -3,7 +3,7 @@ require 'pathname'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'forwardable'
|
5
5
|
require 'tempfile'
|
6
|
-
require '
|
6
|
+
require 'rspec/expectations'
|
7
7
|
require 'timeout'
|
8
8
|
|
9
9
|
require(File.dirname(__FILE__) + '/background_job.rb')
|
@@ -57,18 +57,6 @@ class SporkWorld
|
|
57
57
|
Dir.chdir(@current_dir, &block)
|
58
58
|
end
|
59
59
|
|
60
|
-
def localized_command(command, args)
|
61
|
-
case command
|
62
|
-
when 'spork'
|
63
|
-
command = SporkWorld::BINARY
|
64
|
-
when 'cucumber'
|
65
|
-
command = Cucumber::BINARY
|
66
|
-
else
|
67
|
-
command = %x{which #{command}}.chomp
|
68
|
-
end
|
69
|
-
"#{SporkWorld::RUBY_BINARY} -I #{Cucumber::LIBDIR} #{command} #{args}"
|
70
|
-
end
|
71
|
-
|
72
60
|
def run(command)
|
73
61
|
stderr_file = Tempfile.new('spork')
|
74
62
|
stderr_file.close
|
data/lib/spork.rb
CHANGED
@@ -47,13 +47,8 @@ module Spork
|
|
47
47
|
after_each_run_procs << block
|
48
48
|
end
|
49
49
|
|
50
|
-
# Used by the server. Sets the state to activate spork. Otherwise, prefork and each_run are run in passive mode, allowing specs without a Spork server.
|
51
|
-
def using_spork!
|
52
|
-
@using_spork = true
|
53
|
-
end
|
54
|
-
|
55
50
|
def using_spork?
|
56
|
-
|
51
|
+
state != :not_using_spork
|
57
52
|
end
|
58
53
|
|
59
54
|
def state
|
@@ -62,7 +57,6 @@ module Spork
|
|
62
57
|
|
63
58
|
# Used by the server. Called when loading the prefork blocks of the code.
|
64
59
|
def exec_prefork(&block)
|
65
|
-
using_spork!
|
66
60
|
@state = :prefork
|
67
61
|
yield
|
68
62
|
end
|
@@ -54,9 +54,9 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
54
54
|
end
|
55
55
|
# Spork.trap_method(::AbstractController::Helpers::ClassMethods, :helper)
|
56
56
|
Spork.trap_method(::ActiveModel::Observing::ClassMethods, :instantiate_observers)
|
57
|
-
Spork.each_run { ActiveRecord::Base.establish_connection } if Object.const_defined?(:ActiveRecord)
|
58
|
-
|
59
|
-
|
57
|
+
Spork.each_run { ActiveRecord::Base.establish_connection rescue nil } if Object.const_defined?(:ActiveRecord)
|
58
|
+
|
59
|
+
|
60
60
|
AbstractController::Helpers::ClassMethods.module_eval do
|
61
61
|
def helper(*args, &block)
|
62
62
|
([args].flatten - [:all]).each do |arg|
|
data/lib/spork/runner.rb
CHANGED
@@ -70,7 +70,6 @@ module Spork
|
|
70
70
|
Spork::Diagnoser.output_results(@output)
|
71
71
|
return true
|
72
72
|
else
|
73
|
-
Spork.using_spork!
|
74
73
|
run_strategy = Spork::RunStrategy.factory(test_framework)
|
75
74
|
return(false) unless run_strategy.preload
|
76
75
|
Spork::Server.run(:port => @options[:port] || test_framework.default_port, :run_strategy => run_strategy)
|
data/spec/spec_helper.rb
CHANGED
@@ -8,8 +8,9 @@ unless $spec_helper_loaded
|
|
8
8
|
require 'spork'
|
9
9
|
require 'stringio'
|
10
10
|
require 'fileutils'
|
11
|
+
require 'rspec'
|
11
12
|
|
12
|
-
|
13
|
+
RSpec.configure do |config|
|
13
14
|
config.before(:each) do
|
14
15
|
$test_stdout = StringIO.new
|
15
16
|
$test_stderr = StringIO.new
|
@@ -48,7 +49,7 @@ unless $spec_helper_loaded
|
|
48
49
|
end
|
49
50
|
|
50
51
|
|
51
|
-
module
|
52
|
+
module RSpec
|
52
53
|
module Matchers
|
53
54
|
class IncludeAStringLike
|
54
55
|
def initialize(substring_or_regex)
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
3
|
describe Spork::AppFramework::Rails do
|
4
|
-
describe ".
|
4
|
+
describe ".deprecated_version" do
|
5
5
|
it "detects the current version of rails" do
|
6
6
|
create_file("config/environment.rb", "RAILS_GEM_VERSION = '2.1.0'")
|
7
7
|
in_current_dir do
|
8
|
-
Spork::AppFramework::Rails.new.
|
8
|
+
Spork::AppFramework::Rails.new.deprecated_version.should == "2.1.0"
|
9
9
|
end
|
10
10
|
|
11
11
|
create_file("config/environment.rb", 'RAILS_GEM_VERSION = "2.1.0"')
|
12
12
|
in_current_dir do
|
13
|
-
Spork::AppFramework::Rails.new.
|
13
|
+
Spork::AppFramework::Rails.new.deprecated_version.should == "2.1.0"
|
14
14
|
end
|
15
15
|
|
16
16
|
create_file("config/environment.rb", 'RAILS_GEM_VERSION = "> 2.1.0"')
|
17
17
|
in_current_dir do
|
18
|
-
Spork::AppFramework::Rails.new.
|
18
|
+
Spork::AppFramework::Rails.new.deprecated_version.should == "> 2.1.0"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
shared_examples_for "a TestFramework" do
|
2
|
+
describe ".default_port" do
|
3
|
+
it "uses the DEFAULT_PORT when the environment variable is not set" do
|
4
|
+
@klass.default_port.should == @klass::DEFAULT_PORT
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'uses ENV["#{short_name.upcase}_DRB"] as port if present' do
|
8
|
+
env_name = "#{@klass.short_name.upcase}_DRB"
|
9
|
+
orig, ENV[env_name] = ENV[env_name], "9000"
|
10
|
+
begin
|
11
|
+
@klass.default_port.should == 9000
|
12
|
+
ensure
|
13
|
+
ENV[env_name] = orig
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".helper_file" do
|
19
|
+
it "returns ::HELPER_FILE for the TestFramework" do
|
20
|
+
@klass.helper_file.should == @klass::HELPER_FILE
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,29 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
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
3
|
describe Spork::TestFramework do
|
28
4
|
|
29
5
|
before(:each) do
|
data/spec/spork_spec.rb
CHANGED
@@ -3,17 +3,19 @@ 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
|
+
@using_spork = false
|
6
7
|
@already_ran = nil
|
8
|
+
@each_run_procs = nil
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
10
12
|
describe Spork do
|
11
13
|
before(:each) do
|
12
14
|
Spork.reset!
|
15
|
+
@ran = []
|
13
16
|
end
|
14
17
|
|
15
18
|
def spec_helper_simulator
|
16
|
-
@ran ||= []
|
17
19
|
Spork.prefork do
|
18
20
|
@ran << :prefork
|
19
21
|
end
|
@@ -63,14 +65,14 @@ describe Spork do
|
|
63
65
|
describe "#using_spork?" do
|
64
66
|
it "returns true if Spork is being used" do
|
65
67
|
Spork.using_spork?.should be_false
|
66
|
-
Spork.
|
68
|
+
Spork.exec_prefork { }
|
67
69
|
Spork.using_spork?.should be_true
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
73
|
describe "#trap_method" do
|
72
74
|
before(:each) do
|
73
|
-
Spork.
|
75
|
+
Spork.exec_prefork { }
|
74
76
|
|
75
77
|
Object.class_eval do
|
76
78
|
class TrapTest
|
@@ -99,7 +101,7 @@ describe Spork do
|
|
99
101
|
end
|
100
102
|
|
101
103
|
it "delays execution of a method until after Spork.exec_each_run is called" do
|
102
|
-
Spork.
|
104
|
+
Spork.exec_prefork { }
|
103
105
|
Spork.trap_method(TrapTest, :hello)
|
104
106
|
@trap_test.hello
|
105
107
|
@trap_test.goodbye
|
@@ -140,7 +142,7 @@ describe Spork do
|
|
140
142
|
end
|
141
143
|
|
142
144
|
it "delays execution of a method until after Spork.exec_each_run is called" do
|
143
|
-
Spork.
|
145
|
+
Spork.exec_prefork { }
|
144
146
|
Spork.trap_class_method(TrapTest, :hello)
|
145
147
|
TrapTest.hello
|
146
148
|
TrapTest.goodbye
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 977940487
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.9.0.
|
10
|
+
- rc2
|
11
|
+
version: 0.9.0.rc2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Tim Harper
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-09-
|
20
|
+
date: 2010-09-13 00:00:00 -06:00
|
21
21
|
default_executable: spork
|
22
22
|
dependencies: []
|
23
23
|
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- spec/spork/server_spec.rb
|
87
87
|
- spec/spork/test_framework/cucumber_spec.rb
|
88
88
|
- spec/spork/test_framework/rspec_spec.rb
|
89
|
+
- spec/spork/test_framework_shared_examples.rb
|
89
90
|
- spec/spork/test_framework_spec.rb
|
90
91
|
- spec/spork_spec.rb
|
91
92
|
- spec/support/fake_framework.rb
|
@@ -154,6 +155,7 @@ test_files:
|
|
154
155
|
- spec/spork/server_spec.rb
|
155
156
|
- spec/spork/test_framework/cucumber_spec.rb
|
156
157
|
- spec/spork/test_framework/rspec_spec.rb
|
158
|
+
- spec/spork/test_framework_shared_examples.rb
|
157
159
|
- spec/spork/test_framework_spec.rb
|
158
160
|
- spec/spork_spec.rb
|
159
161
|
- spec/support/fake_framework.rb
|