milhouse-spork 0.7.5 → 0.7.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +19 -19
- data/README.rdoc +99 -99
- data/assets/bootstrap.rb +29 -29
- data/bin/spork +20 -20
- data/features/cucumber_rails_integration.feature +118 -118
- data/features/diagnostic_mode.feature +40 -40
- data/features/rails_delayed_loading_workarounds.feature +115 -115
- data/features/rspec_rails_integration.feature +93 -93
- data/features/spork_debugger.feature +108 -108
- data/features/steps/general_steps.rb +3 -3
- data/features/steps/rails_steps.rb +52 -52
- data/features/steps/sandbox_steps.rb +115 -115
- data/features/support/background_job.rb +63 -63
- data/features/support/env.rb +111 -111
- data/features/unknown_app_framework.feature +41 -41
- data/geminstaller.yml +9 -9
- data/lib/spork/app_framework/rails.rb +157 -157
- data/lib/spork/app_framework/rails_stub_files/application.rb +1 -1
- data/lib/spork/app_framework/rails_stub_files/application_controller.rb +22 -22
- data/lib/spork/app_framework/rails_stub_files/application_helper.rb +2 -2
- data/lib/spork/app_framework/unknown.rb +5 -5
- data/lib/spork/app_framework.rb +73 -73
- data/lib/spork/custom_io_streams.rb +24 -24
- data/lib/spork/diagnoser.rb +103 -103
- data/lib/spork/ext/ruby-debug.rb +150 -150
- data/lib/spork/forker.rb +70 -70
- data/lib/spork/run_strategy/forking.rb +29 -29
- data/lib/spork/run_strategy/magazine/magazine_slave.rb +0 -0
- data/lib/spork/run_strategy/magazine/magazine_slave_provider.rb +0 -0
- data/lib/spork/run_strategy/magazine/ring_server.rb +0 -0
- data/lib/spork/run_strategy/magazine.rb +0 -0
- data/lib/spork/run_strategy.rb +44 -44
- data/lib/spork/runner.rb +90 -90
- data/lib/spork/server.rb +74 -74
- data/lib/spork/test_framework/cucumber.rb +24 -24
- data/lib/spork/test_framework/rspec.rb +14 -14
- data/lib/spork/test_framework.rb +167 -167
- data/lib/spork.rb +126 -126
- data/spec/spec_helper.rb +108 -108
- data/spec/spork/app_framework/rails_spec.rb +22 -22
- data/spec/spork/app_framework/unknown_spec.rb +12 -12
- data/spec/spork/app_framework_spec.rb +16 -16
- data/spec/spork/diagnoser_spec.rb +105 -105
- data/spec/spork/forker_spec.rb +44 -44
- data/spec/spork/run_strategy/forking_spec.rb +38 -38
- data/spec/spork/runner_spec.rb +50 -50
- data/spec/spork/server_spec.rb +15 -15
- data/spec/spork/test_framework/cucumber_spec.rb +11 -11
- data/spec/spork/test_framework/rspec_spec.rb +10 -10
- data/spec/spork/test_framework_spec.rb +114 -114
- data/spec/spork_spec.rb +151 -151
- data/spec/support/fake_framework.rb +15 -15
- data/spec/support/fake_run_strategy.rb +21 -21
- metadata +19 -20
data/MIT-LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2009 Tim Harper
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Copyright (c) 2009 Tim Harper
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,100 +1,100 @@
|
|
1
|
-
= Spork
|
2
|
-
|
3
|
-
* Repository: http://github.com/timcharper/spork
|
4
|
-
* Issues: http://github.com/timcharper/spork/issues
|
5
|
-
* Changes: http://github.com/timcharper/spork/blob/master/History.txt
|
6
|
-
* Mailing list: http://groups.google.com/group/sporkgem
|
7
|
-
* Wiki: http://wiki.github.com/timcharper/spork
|
8
|
-
|
9
|
-
== SYNOPSIS:
|
10
|
-
|
11
|
-
Spork is Tim Harper's implementation of test server (similar to the script/spec_server provided by rspec-rails), except rather than using the Rails constant unloading to reload your files, it forks a copy of the server each time you run your tests. The result? Spork runs more solid: it doesn't get corrupted over time, and it properly handles modules and any voo-doo meta programming you may have put in your app.
|
12
|
-
|
13
|
-
Because Spork uses Kernel.fork, it only works on POSIX systems. This means Windows users are not invited to this party. Sorry :(
|
14
|
-
|
15
|
-
== Supported Testing Frameworks
|
16
|
-
|
17
|
-
* Rspec
|
18
|
-
* Cucumber
|
19
|
-
|
20
|
-
And more to come! Vote for your favorite at http://github.com/timcharper/spork/issues
|
21
|
-
|
22
|
-
== Supported Application Frameworks
|
23
|
-
|
24
|
-
Actually, Spork ~can~ work with any application framework. But, it ships with hooks and helpers to help make the experience much more "out of the box"
|
25
|
-
|
26
|
-
* Rails
|
27
|
-
|
28
|
-
More can be added! Vote for your favorite at http://github.com/timcharper/spork/issues
|
29
|
-
|
30
|
-
== INSTALL:
|
31
|
-
|
32
|
-
[sudo] gem install spork
|
33
|
-
|
34
|
-
alternatively:
|
35
|
-
|
36
|
-
git clone git://github.com/timcharper/spork.git
|
37
|
-
cd spork
|
38
|
-
gem build spork.gemspec
|
39
|
-
sudo gem install spork.gemspec
|
40
|
-
|
41
|
-
== Usage
|
42
|
-
|
43
|
-
From a terminal, change to your project directory.
|
44
|
-
|
45
|
-
Then, bootstrap your spec/spec_helper.rb file.
|
46
|
-
|
47
|
-
spork --bootstrap
|
48
|
-
|
49
|
-
Next, edit spec/spec_helper.rb and follow the instructions that were put at the top.
|
50
|
-
|
51
|
-
Finally, run spork. A spec DRb server will be running!
|
52
|
-
|
53
|
-
spork
|
54
|
-
|
55
|
-
== Diagnostic mode
|
56
|
-
|
57
|
-
Initially, you may find that a few files don't reload automatically. This is because they are being loaded during Spork startup. To identify which project files are being pre-loaded, and why, run:
|
58
|
-
|
59
|
-
spork --diagnose
|
60
|
-
(or spork -d, for short)
|
61
|
-
|
62
|
-
It will output a lot of stuff. At the top you'll find a summary of all project files loaded. Down below, the stack trace for each file (how it got loaded). Spork hooks into Rails and does some magic (TM) to prevent ApplicationController observers, etc from pre-loading. Similar hooks for other ruby frameworks may come as support demands.
|
63
|
-
|
64
|
-
== Running specs over Spork
|
65
|
-
|
66
|
-
=== RSpec
|
67
|
-
|
68
|
-
To get the TextMate RSpec bundle to use spork, go to config->advanced->shell variables, and add:
|
69
|
-
|
70
|
-
TM_RSPEC_OPTS=--drb.
|
71
|
-
|
72
|
-
To run from the command line, use:
|
73
|
-
|
74
|
-
spec --drb spec/lib/my_spec.rb
|
75
|
-
|
76
|
-
Or, you could add the following flag to your +spec.opts+ file.
|
77
|
-
|
78
|
-
--drb
|
79
|
-
|
80
|
-
=== Cucumber
|
81
|
-
|
82
|
-
Cucumber has DRb support (see http://wiki.github.com/aslakhellesoy/cucumber/spork-and-drb )
|
83
|
-
|
84
|
-
cucumber --drb
|
85
|
-
|
86
|
-
Use this as a guideline when "Sporking" your features/support/env.rb file
|
87
|
-
|
88
|
-
http://gist.github.com/123370
|
89
|
-
|
90
|
-
== Some potential issues and ways to overcome them:
|
91
|
-
|
92
|
-
See http://wiki.github.com/timcharper/spork/troubleshooting
|
93
|
-
|
94
|
-
== Kudos to
|
95
|
-
|
96
|
-
* Ben Mabey - help with documentation, testing, suggestions, patches, and bringing Cucumber support.
|
97
|
-
* David Chelimsky - for the fine RSpec testing framework, and the original rspec-rails spec_server implementation, which Spork has built upon.
|
98
|
-
* Lead Media Partners - just for being an awesome place to work.
|
99
|
-
|
1
|
+
= Spork
|
2
|
+
|
3
|
+
* Repository: http://github.com/timcharper/spork
|
4
|
+
* Issues: http://github.com/timcharper/spork/issues
|
5
|
+
* Changes: http://github.com/timcharper/spork/blob/master/History.txt
|
6
|
+
* Mailing list: http://groups.google.com/group/sporkgem
|
7
|
+
* Wiki: http://wiki.github.com/timcharper/spork
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
Spork is Tim Harper's implementation of test server (similar to the script/spec_server provided by rspec-rails), except rather than using the Rails constant unloading to reload your files, it forks a copy of the server each time you run your tests. The result? Spork runs more solid: it doesn't get corrupted over time, and it properly handles modules and any voo-doo meta programming you may have put in your app.
|
12
|
+
|
13
|
+
Because Spork uses Kernel.fork, it only works on POSIX systems. This means Windows users are not invited to this party. Sorry :(
|
14
|
+
|
15
|
+
== Supported Testing Frameworks
|
16
|
+
|
17
|
+
* Rspec
|
18
|
+
* Cucumber
|
19
|
+
|
20
|
+
And more to come! Vote for your favorite at http://github.com/timcharper/spork/issues
|
21
|
+
|
22
|
+
== Supported Application Frameworks
|
23
|
+
|
24
|
+
Actually, Spork ~can~ work with any application framework. But, it ships with hooks and helpers to help make the experience much more "out of the box"
|
25
|
+
|
26
|
+
* Rails
|
27
|
+
|
28
|
+
More can be added! Vote for your favorite at http://github.com/timcharper/spork/issues
|
29
|
+
|
30
|
+
== INSTALL:
|
31
|
+
|
32
|
+
[sudo] gem install spork
|
33
|
+
|
34
|
+
alternatively:
|
35
|
+
|
36
|
+
git clone git://github.com/timcharper/spork.git
|
37
|
+
cd spork
|
38
|
+
gem build spork.gemspec
|
39
|
+
sudo gem install spork.gemspec
|
40
|
+
|
41
|
+
== Usage
|
42
|
+
|
43
|
+
From a terminal, change to your project directory.
|
44
|
+
|
45
|
+
Then, bootstrap your spec/spec_helper.rb file.
|
46
|
+
|
47
|
+
spork --bootstrap
|
48
|
+
|
49
|
+
Next, edit spec/spec_helper.rb and follow the instructions that were put at the top.
|
50
|
+
|
51
|
+
Finally, run spork. A spec DRb server will be running!
|
52
|
+
|
53
|
+
spork
|
54
|
+
|
55
|
+
== Diagnostic mode
|
56
|
+
|
57
|
+
Initially, you may find that a few files don't reload automatically. This is because they are being loaded during Spork startup. To identify which project files are being pre-loaded, and why, run:
|
58
|
+
|
59
|
+
spork --diagnose
|
60
|
+
(or spork -d, for short)
|
61
|
+
|
62
|
+
It will output a lot of stuff. At the top you'll find a summary of all project files loaded. Down below, the stack trace for each file (how it got loaded). Spork hooks into Rails and does some magic (TM) to prevent ApplicationController observers, etc from pre-loading. Similar hooks for other ruby frameworks may come as support demands.
|
63
|
+
|
64
|
+
== Running specs over Spork
|
65
|
+
|
66
|
+
=== RSpec
|
67
|
+
|
68
|
+
To get the TextMate RSpec bundle to use spork, go to config->advanced->shell variables, and add:
|
69
|
+
|
70
|
+
TM_RSPEC_OPTS=--drb.
|
71
|
+
|
72
|
+
To run from the command line, use:
|
73
|
+
|
74
|
+
spec --drb spec/lib/my_spec.rb
|
75
|
+
|
76
|
+
Or, you could add the following flag to your +spec.opts+ file.
|
77
|
+
|
78
|
+
--drb
|
79
|
+
|
80
|
+
=== Cucumber
|
81
|
+
|
82
|
+
Cucumber has DRb support (see http://wiki.github.com/aslakhellesoy/cucumber/spork-and-drb )
|
83
|
+
|
84
|
+
cucumber --drb
|
85
|
+
|
86
|
+
Use this as a guideline when "Sporking" your features/support/env.rb file
|
87
|
+
|
88
|
+
http://gist.github.com/123370
|
89
|
+
|
90
|
+
== Some potential issues and ways to overcome them:
|
91
|
+
|
92
|
+
See http://wiki.github.com/timcharper/spork/troubleshooting
|
93
|
+
|
94
|
+
== Kudos to
|
95
|
+
|
96
|
+
* Ben Mabey - help with documentation, testing, suggestions, patches, and bringing Cucumber support.
|
97
|
+
* David Chelimsky - for the fine RSpec testing framework, and the original rspec-rails spec_server implementation, which Spork has built upon.
|
98
|
+
* Lead Media Partners - just for being an awesome place to work.
|
99
|
+
|
100
100
|
Spork (c) 2009 Tim Harper, released under the MIT license
|
data/assets/bootstrap.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'spork'
|
3
|
-
|
4
|
-
Spork.prefork do
|
5
|
-
# Loading more in this block will cause your tests to run faster. However,
|
6
|
-
# if you change any configuration or code from libraries loaded here, you'll
|
7
|
-
# need to restart spork for it take effect.
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
Spork.each_run do
|
12
|
-
# This code will be run each time you run your specs.
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# --- Instructions ---
|
17
|
-
# - Sort through your spec_helper file. Place as much environment loading
|
18
|
-
# code that you don't normally modify during development in the
|
19
|
-
# Spork.prefork block.
|
20
|
-
# - Place the rest under Spork.each_run block
|
21
|
-
# - Any code that is left outside of the blocks will be ran during preforking
|
22
|
-
# and during each_run!
|
23
|
-
# - These instructions should self-destruct in 10 seconds. If they don't,
|
24
|
-
# feel free to delete them.
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
|
4
|
+
Spork.prefork do
|
5
|
+
# Loading more in this block will cause your tests to run faster. However,
|
6
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
7
|
+
# need to restart spork for it take effect.
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
Spork.each_run do
|
12
|
+
# This code will be run each time you run your specs.
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
# --- Instructions ---
|
17
|
+
# - Sort through your spec_helper file. Place as much environment loading
|
18
|
+
# code that you don't normally modify during development in the
|
19
|
+
# Spork.prefork block.
|
20
|
+
# - Place the rest under Spork.each_run block
|
21
|
+
# - Any code that is left outside of the blocks will be ran during preforking
|
22
|
+
# and during each_run!
|
23
|
+
# - These instructions should self-destruct in 10 seconds. If they don't,
|
24
|
+
# feel free to delete them.
|
25
|
+
#
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
data/bin/spork
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
|
5
|
-
|
6
|
-
require 'spork'
|
7
|
-
require 'spork/runner'
|
8
|
-
|
9
|
-
begin
|
10
|
-
success = Spork::Runner.run(ARGV, STDOUT, STDERR)
|
11
|
-
Kernel.exit(success ? 0 : 1)
|
12
|
-
rescue SystemExit => e
|
13
|
-
Kernel.exit(e.status)
|
14
|
-
rescue Exception => e
|
15
|
-
STDERR.puts("#{e.message} (#{e.class})")
|
16
|
-
STDERR.puts(e.backtrace.join("\n"))
|
17
|
-
Kernel.exit 1
|
18
|
-
end
|
19
|
-
|
20
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
|
5
|
+
|
6
|
+
require 'spork'
|
7
|
+
require 'spork/runner'
|
8
|
+
|
9
|
+
begin
|
10
|
+
success = Spork::Runner.run(ARGV, STDOUT, STDERR)
|
11
|
+
Kernel.exit(success ? 0 : 1)
|
12
|
+
rescue SystemExit => e
|
13
|
+
Kernel.exit(e.status)
|
14
|
+
rescue Exception => e
|
15
|
+
STDERR.puts("#{e.message} (#{e.class})")
|
16
|
+
STDERR.puts(e.backtrace.join("\n"))
|
17
|
+
Kernel.exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
|
@@ -1,118 +1,118 @@
|
|
1
|
-
Feature: Cucumber integration with rails
|
2
|
-
As a developer using cucumber and rails
|
3
|
-
I want to use Spork with Cucumber
|
4
|
-
In order to eliminate the startup cost of my application each time I run them
|
5
|
-
|
6
|
-
Background: Sporked env.rb
|
7
|
-
Given I am in a fresh rails project named "test_rails_project"
|
8
|
-
And the application has a model, observer, route, and application helper
|
9
|
-
And a file named "features/support/env.rb" with:
|
10
|
-
"""
|
11
|
-
require 'rubygems'
|
12
|
-
require 'spork'
|
13
|
-
|
14
|
-
Spork.prefork do
|
15
|
-
# Loading more in this block will cause your tests to run faster. However,
|
16
|
-
# if you change any configuration or code from libraries loaded here, you'll
|
17
|
-
# need to restart spork for it take effect.
|
18
|
-
|
19
|
-
# Sets up the Rails environment for Cucumber
|
20
|
-
ENV['RAILS_ENV'] = "features"
|
21
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
22
|
-
|
23
|
-
require 'cucumber'
|
24
|
-
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
25
|
-
require 'spec/rails'
|
26
|
-
require 'cucumber/rails/rspec'
|
27
|
-
|
28
|
-
#### this is for this test only #######
|
29
|
-
$loaded_stuff << 'prefork block' ######
|
30
|
-
#######################################
|
31
|
-
end
|
32
|
-
|
33
|
-
Spork.each_run do
|
34
|
-
#### this is for this test only #######
|
35
|
-
$loaded_stuff << 'each_run block' #####
|
36
|
-
#######################################
|
37
|
-
end
|
38
|
-
"""
|
39
|
-
And a file named "features/cucumber_rails.feature" with:
|
40
|
-
"""
|
41
|
-
Feature: cucumber rails
|
42
|
-
Scenario: did it work?
|
43
|
-
Then it should work
|
44
|
-
|
45
|
-
Scenario: did it work again?
|
46
|
-
Then it should work
|
47
|
-
"""
|
48
|
-
And a file named "features/cucumber_rails_fr.feature" with:
|
49
|
-
"""
|
50
|
-
# language: fr
|
51
|
-
Fonction: French
|
52
|
-
Scénario: ca marche?
|
53
|
-
Alors ca marche
|
54
|
-
"""
|
55
|
-
And a file named "features/support/cucumber_rails_helper.rb" with:
|
56
|
-
"""
|
57
|
-
$loaded_stuff << 'features/support/cucumber_rails_helper.rb'
|
58
|
-
"""
|
59
|
-
And a file named "config/environments/features.rb" with:
|
60
|
-
"""
|
61
|
-
# your cucumber env here
|
62
|
-
"""
|
63
|
-
And a file named "config/database.yml" with:
|
64
|
-
"""
|
65
|
-
features:
|
66
|
-
adapter: sqlite3
|
67
|
-
database: db/features.sqlite3
|
68
|
-
timeout: 5000
|
69
|
-
"""
|
70
|
-
And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
|
71
|
-
"""
|
72
|
-
Then "it should work" do
|
73
|
-
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
74
|
-
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
75
|
-
$loaded_stuff.should include('User')
|
76
|
-
$loaded_stuff.should include('UserObserver')
|
77
|
-
$loaded_stuff.should include('ApplicationHelper')
|
78
|
-
$loaded_stuff.should include('config/routes.rb')
|
79
|
-
$loaded_stuff.should include('features/support/cucumber_rails_helper.rb')
|
80
|
-
$loaded_stuff.should include('each_run block')
|
81
|
-
$loaded_stuff.should include('prefork block')
|
82
|
-
puts "It worked!"
|
83
|
-
end
|
84
|
-
|
85
|
-
Alors /ca marche/ do
|
86
|
-
end
|
87
|
-
"""
|
88
|
-
Scenario: Analyzing files were preloaded
|
89
|
-
When I run spork --diagnose
|
90
|
-
Then the output should not contain "user_observer.rb"
|
91
|
-
Then the output should not contain "user.rb"
|
92
|
-
Then the output should not contain "app/controllers/application.rb"
|
93
|
-
Then the output should not contain "app/controllers/application_controller.rb"
|
94
|
-
Then the output should not contain "app/controllers/application_helper.rb"
|
95
|
-
Then the output should not contain "config/routes.rb"
|
96
|
-
Then the output should not contain "features/step_definitions/cucumber_rails_steps.rb"
|
97
|
-
Then the output should not contain "features/support/cucumber_rails_helper.rb"
|
98
|
-
|
99
|
-
Scenario: Running spork with a rails app and no server
|
100
|
-
When I run cucumber --drb features
|
101
|
-
Then the error output should contain
|
102
|
-
"""
|
103
|
-
WARNING: No DRb server is running. Running features locally
|
104
|
-
"""
|
105
|
-
|
106
|
-
Scenario: Running spork with a rails app and observers
|
107
|
-
When I fire up a spork instance with "spork cucumber"
|
108
|
-
And I run cucumber --drb features
|
109
|
-
Then the error output should be empty
|
110
|
-
And the output should contain "It worked!"
|
111
|
-
And the file "log/features.log" should include "hey there"
|
112
|
-
|
113
|
-
Scenario: Running spork with a rails app and a non-standard port
|
114
|
-
When I fire up a spork instance with "spork cucumber -p 9000"
|
115
|
-
And I run cucumber --drb --port 9000 features
|
116
|
-
Then the error output should be empty
|
117
|
-
And the output should contain "It worked!"
|
118
|
-
And the file "log/features.log" should include "hey there"
|
1
|
+
Feature: Cucumber integration with rails
|
2
|
+
As a developer using cucumber and rails
|
3
|
+
I want to use Spork with Cucumber
|
4
|
+
In order to eliminate the startup cost of my application each time I run them
|
5
|
+
|
6
|
+
Background: Sporked env.rb
|
7
|
+
Given I am in a fresh rails project named "test_rails_project"
|
8
|
+
And the application has a model, observer, route, and application helper
|
9
|
+
And a file named "features/support/env.rb" with:
|
10
|
+
"""
|
11
|
+
require 'rubygems'
|
12
|
+
require 'spork'
|
13
|
+
|
14
|
+
Spork.prefork do
|
15
|
+
# Loading more in this block will cause your tests to run faster. However,
|
16
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
17
|
+
# need to restart spork for it take effect.
|
18
|
+
|
19
|
+
# Sets up the Rails environment for Cucumber
|
20
|
+
ENV['RAILS_ENV'] = "features"
|
21
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
22
|
+
|
23
|
+
require 'cucumber'
|
24
|
+
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
25
|
+
require 'spec/rails'
|
26
|
+
require 'cucumber/rails/rspec'
|
27
|
+
|
28
|
+
#### this is for this test only #######
|
29
|
+
$loaded_stuff << 'prefork block' ######
|
30
|
+
#######################################
|
31
|
+
end
|
32
|
+
|
33
|
+
Spork.each_run do
|
34
|
+
#### this is for this test only #######
|
35
|
+
$loaded_stuff << 'each_run block' #####
|
36
|
+
#######################################
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
And a file named "features/cucumber_rails.feature" with:
|
40
|
+
"""
|
41
|
+
Feature: cucumber rails
|
42
|
+
Scenario: did it work?
|
43
|
+
Then it should work
|
44
|
+
|
45
|
+
Scenario: did it work again?
|
46
|
+
Then it should work
|
47
|
+
"""
|
48
|
+
And a file named "features/cucumber_rails_fr.feature" with:
|
49
|
+
"""
|
50
|
+
# language: fr
|
51
|
+
Fonction: French
|
52
|
+
Scénario: ca marche?
|
53
|
+
Alors ca marche
|
54
|
+
"""
|
55
|
+
And a file named "features/support/cucumber_rails_helper.rb" with:
|
56
|
+
"""
|
57
|
+
$loaded_stuff << 'features/support/cucumber_rails_helper.rb'
|
58
|
+
"""
|
59
|
+
And a file named "config/environments/features.rb" with:
|
60
|
+
"""
|
61
|
+
# your cucumber env here
|
62
|
+
"""
|
63
|
+
And a file named "config/database.yml" with:
|
64
|
+
"""
|
65
|
+
features:
|
66
|
+
adapter: sqlite3
|
67
|
+
database: db/features.sqlite3
|
68
|
+
timeout: 5000
|
69
|
+
"""
|
70
|
+
And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
|
71
|
+
"""
|
72
|
+
Then "it should work" do
|
73
|
+
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
74
|
+
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
75
|
+
$loaded_stuff.should include('User')
|
76
|
+
$loaded_stuff.should include('UserObserver')
|
77
|
+
$loaded_stuff.should include('ApplicationHelper')
|
78
|
+
$loaded_stuff.should include('config/routes.rb')
|
79
|
+
$loaded_stuff.should include('features/support/cucumber_rails_helper.rb')
|
80
|
+
$loaded_stuff.should include('each_run block')
|
81
|
+
$loaded_stuff.should include('prefork block')
|
82
|
+
puts "It worked!"
|
83
|
+
end
|
84
|
+
|
85
|
+
Alors /ca marche/ do
|
86
|
+
end
|
87
|
+
"""
|
88
|
+
Scenario: Analyzing files were preloaded
|
89
|
+
When I run spork --diagnose
|
90
|
+
Then the output should not contain "user_observer.rb"
|
91
|
+
Then the output should not contain "user.rb"
|
92
|
+
Then the output should not contain "app/controllers/application.rb"
|
93
|
+
Then the output should not contain "app/controllers/application_controller.rb"
|
94
|
+
Then the output should not contain "app/controllers/application_helper.rb"
|
95
|
+
Then the output should not contain "config/routes.rb"
|
96
|
+
Then the output should not contain "features/step_definitions/cucumber_rails_steps.rb"
|
97
|
+
Then the output should not contain "features/support/cucumber_rails_helper.rb"
|
98
|
+
|
99
|
+
Scenario: Running spork with a rails app and no server
|
100
|
+
When I run cucumber --drb features
|
101
|
+
Then the error output should contain
|
102
|
+
"""
|
103
|
+
WARNING: No DRb server is running. Running features locally
|
104
|
+
"""
|
105
|
+
|
106
|
+
Scenario: Running spork with a rails app and observers
|
107
|
+
When I fire up a spork instance with "spork cucumber"
|
108
|
+
And I run cucumber --drb features
|
109
|
+
Then the error output should be empty
|
110
|
+
And the output should contain "It worked!"
|
111
|
+
And the file "log/features.log" should include "hey there"
|
112
|
+
|
113
|
+
Scenario: Running spork with a rails app and a non-standard port
|
114
|
+
When I fire up a spork instance with "spork cucumber -p 9000"
|
115
|
+
And I run cucumber --drb --port 9000 features
|
116
|
+
Then the error output should be empty
|
117
|
+
And the output should contain "It worked!"
|
118
|
+
And the file "log/features.log" should include "hey there"
|
@@ -1,41 +1,41 @@
|
|
1
|
-
Feature: Diagnostic Mode
|
2
|
-
To help a developer quickly pinpoint why files are being loaded
|
3
|
-
Spork provides a diagnostic mode
|
4
|
-
That provides a list of which project files were loaded during prefork, and who loaded them.
|
5
|
-
|
6
|
-
Scenario: Running spork --diagnose
|
7
|
-
Given I am in the directory "test_project"
|
8
|
-
And a file named "spec/spec_helper.rb" with:
|
9
|
-
"""
|
10
|
-
require 'rubygems'
|
11
|
-
require 'spork'
|
12
|
-
|
13
|
-
Spork.prefork do
|
14
|
-
require 'lib/awesome.rb'
|
15
|
-
require '../external_dependency/super_duper.rb'
|
16
|
-
end
|
17
|
-
|
18
|
-
Spork.each_run do
|
19
|
-
puts "I'm loading the stuff just for this run..."
|
20
|
-
end
|
21
|
-
"""
|
22
|
-
And a file named "lib/awesome.rb" with:
|
23
|
-
"""
|
24
|
-
class Awesome
|
25
|
-
end
|
26
|
-
"""
|
27
|
-
And a file named "../external_dependency/super_duper.rb" with:
|
28
|
-
"""
|
29
|
-
class Awesome
|
30
|
-
end
|
31
|
-
"""
|
32
|
-
When I run spork --diagnose
|
33
|
-
Then the error output should contain
|
34
|
-
"""
|
35
|
-
Loading Spork.prefork block...
|
36
|
-
"""
|
37
|
-
And the output should contain "lib/awesome.rb"
|
38
|
-
And the output should contain "spec/spec_helper.rb:5"
|
39
|
-
And the output should not contain "super_duper.rb"
|
40
|
-
And the output should not contain "diagnose.rb"
|
1
|
+
Feature: Diagnostic Mode
|
2
|
+
To help a developer quickly pinpoint why files are being loaded
|
3
|
+
Spork provides a diagnostic mode
|
4
|
+
That provides a list of which project files were loaded during prefork, and who loaded them.
|
5
|
+
|
6
|
+
Scenario: Running spork --diagnose
|
7
|
+
Given I am in the directory "test_project"
|
8
|
+
And a file named "spec/spec_helper.rb" with:
|
9
|
+
"""
|
10
|
+
require 'rubygems'
|
11
|
+
require 'spork'
|
12
|
+
|
13
|
+
Spork.prefork do
|
14
|
+
require 'lib/awesome.rb'
|
15
|
+
require '../external_dependency/super_duper.rb'
|
16
|
+
end
|
17
|
+
|
18
|
+
Spork.each_run do
|
19
|
+
puts "I'm loading the stuff just for this run..."
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
And a file named "lib/awesome.rb" with:
|
23
|
+
"""
|
24
|
+
class Awesome
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
And a file named "../external_dependency/super_duper.rb" with:
|
28
|
+
"""
|
29
|
+
class Awesome
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
When I run spork --diagnose
|
33
|
+
Then the error output should contain
|
34
|
+
"""
|
35
|
+
Loading Spork.prefork block...
|
36
|
+
"""
|
37
|
+
And the output should contain "lib/awesome.rb"
|
38
|
+
And the output should contain "spec/spec_helper.rb:5"
|
39
|
+
And the output should not contain "super_duper.rb"
|
40
|
+
And the output should not contain "diagnose.rb"
|
41
41
|
|