spork-rails 3.2.0
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 +14 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +75 -0
- data/features/cucumber_rails_integration.feature +107 -0
- data/features/gemsets/rails3.0/Gemfile +15 -0
- data/features/gemsets/rails3.0/Gemfile.lock +129 -0
- data/features/gemsets/rails3.1/Gemfile +15 -0
- data/features/gemsets/rails3.1/Gemfile.lock +140 -0
- data/features/gemsets/rails3.2/Gemfile +15 -0
- data/features/gemsets/rails3.2/Gemfile.lock +138 -0
- data/features/rails_delayed_loading_workarounds.feature +177 -0
- data/features/rspec_rails_integration.feature +92 -0
- data/features/steps/rails_steps.rb +68 -0
- data/features/support/env.rb +14 -0
- data/lib/spork/app_framework/rails.rb +90 -0
- data/lib/spork/ext/rails-reloader.rb +14 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/spork/app_framework/rails_spec.rb +22 -0
- data/spec/spork/app_framework_spec.rb +12 -0
- data/spec/tmp/config/environment.rb +1 -0
- metadata +110 -0
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source :gemcutter
|
2
|
+
gemspec
|
3
|
+
# rails is required by the gemspec
|
4
|
+
|
5
|
+
gem 'cucumber', '~> 1.0.0'
|
6
|
+
gem 'rspec', '~> 2.8'
|
7
|
+
gem 'rake'
|
8
|
+
gem "spork-rails", :path => "./"
|
9
|
+
|
10
|
+
if RUBY_VERSION =~ /^1\.9/
|
11
|
+
gem 'ruby-debug19'
|
12
|
+
else
|
13
|
+
gem 'ruby-debug'
|
14
|
+
end
|
data/MIT-LICENSE
ADDED
@@ -0,0 +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
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
= Spork Rails
|
2
|
+
|
3
|
+
This plugin is for running spork in Ruby-on-Rails applications.
|
4
|
+
|
5
|
+
== Version compatibility map:
|
6
|
+
|
7
|
+
Versions correspond to the latest Rails minor release. Gem is backwards compatible with rails as far as it makes sense to.
|
8
|
+
|
9
|
+
* spork-rails 3.2.0: Rails 3.0.0 - 3.2.x
|
10
|
+
|
11
|
+
= Usage:
|
12
|
+
|
13
|
+
Add to your Gemfile:
|
14
|
+
|
15
|
+
gem "spork-rails"
|
16
|
+
|
17
|
+
# (Since spork-rails depends on spork, it is not necessary to put both spork and spork-rails in your Gemfile)
|
18
|
+
|
19
|
+
== INSTALL:
|
20
|
+
|
21
|
+
NOTICE: If using spork with rails, use the spork-rails gem.
|
22
|
+
|
23
|
+
=== bundler:
|
24
|
+
|
25
|
+
Add to your Gemfile:
|
26
|
+
|
27
|
+
gem 'spork-rails'
|
28
|
+
|
29
|
+
== Usage
|
30
|
+
|
31
|
+
From a terminal, change to your project directory.
|
32
|
+
|
33
|
+
Then, bootstrap your test helper file. If running rspec,
|
34
|
+
|
35
|
+
spork rspec --bootstrap
|
36
|
+
|
37
|
+
Cucumber:
|
38
|
+
|
39
|
+
spork cucumber --bootstrap
|
40
|
+
|
41
|
+
TestUnit:
|
42
|
+
|
43
|
+
(Install the spork-testunit gem)
|
44
|
+
spork test_unit --bootstrap
|
45
|
+
|
46
|
+
(If you don't specifiy a test framework, spork will find one and pick it.)
|
47
|
+
|
48
|
+
Follow the instructions.
|
49
|
+
|
50
|
+
Finally, run spork. A spec DRb server will be running!
|
51
|
+
|
52
|
+
spork
|
53
|
+
|
54
|
+
== Running tests
|
55
|
+
|
56
|
+
=== Specs
|
57
|
+
|
58
|
+
bundle exec rspec spec
|
59
|
+
|
60
|
+
=== Features (cucumber)
|
61
|
+
|
62
|
+
bundle exec cucumber features
|
63
|
+
|
64
|
+
To run against one a different gemset (see features/gemsets), specifying a name like follows:
|
65
|
+
|
66
|
+
GEMSET=rails3.2 bundle exec cucumber features/
|
67
|
+
|
68
|
+
== TODO
|
69
|
+
|
70
|
+
* Create spork-rails version to work agains Rails 2.x.
|
71
|
+
* Run tests with `rake`
|
72
|
+
|
73
|
+
== See also
|
74
|
+
|
75
|
+
See https://github.com/sporkrb/spork for more instructions.
|
@@ -0,0 +1,107 @@
|
|
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
|
+
ENV["RAILS_ENV"] ||= "test"
|
14
|
+
|
15
|
+
|
16
|
+
Spork.prefork do
|
17
|
+
# Loading more in this block will cause your tests to run faster. However,
|
18
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
19
|
+
# need to restart spork for it take effect.
|
20
|
+
|
21
|
+
# Sets up the Rails environment for Cucumber
|
22
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
23
|
+
|
24
|
+
require 'cucumber'
|
25
|
+
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
26
|
+
require 'rspec/rails'
|
27
|
+
# require 'cucumber/rails/rspec'
|
28
|
+
|
29
|
+
#### this is for this test only #######
|
30
|
+
$loaded_stuff << 'prefork block' ######
|
31
|
+
#######################################
|
32
|
+
end
|
33
|
+
|
34
|
+
Spork.each_run do
|
35
|
+
#### this is for this test only #######
|
36
|
+
$loaded_stuff << 'each_run block' #####
|
37
|
+
#######################################
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
And a file named "features/cucumber_rails.feature" with:
|
41
|
+
"""
|
42
|
+
Feature: cucumber rails
|
43
|
+
Scenario: did it work?
|
44
|
+
Then it should work
|
45
|
+
|
46
|
+
Scenario: did it work again?
|
47
|
+
Then it should work
|
48
|
+
"""
|
49
|
+
And a file named "features/support/cucumber_rails_helper.rb" with:
|
50
|
+
"""
|
51
|
+
$loaded_stuff << 'features/support/cucumber_rails_helper.rb'
|
52
|
+
"""
|
53
|
+
And a file named "config/database.yml" with:
|
54
|
+
"""
|
55
|
+
test:
|
56
|
+
adapter: sqlite3
|
57
|
+
database: db/test.sqlite3
|
58
|
+
timeout: 5000
|
59
|
+
"""
|
60
|
+
And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
|
61
|
+
"""
|
62
|
+
Then "it should work" do
|
63
|
+
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
64
|
+
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
65
|
+
$loaded_stuff.should include('User')
|
66
|
+
$loaded_stuff.should include('UserObserver')
|
67
|
+
$loaded_stuff.should include('ApplicationHelper')
|
68
|
+
$loaded_stuff.should include('config/routes.rb')
|
69
|
+
$loaded_stuff.should include('features/support/cucumber_rails_helper.rb')
|
70
|
+
$loaded_stuff.should include('each_run block')
|
71
|
+
$loaded_stuff.should include('prefork block')
|
72
|
+
puts "It worked!"
|
73
|
+
end
|
74
|
+
|
75
|
+
Alors /ca marche/ do
|
76
|
+
end
|
77
|
+
"""
|
78
|
+
Scenario: Analyzing files were preloaded
|
79
|
+
When I run spork --diagnose
|
80
|
+
Then the output should not contain "user_observer.rb"
|
81
|
+
Then the output should not contain "user.rb"
|
82
|
+
Then the output should not contain "app/controllers/application.rb"
|
83
|
+
Then the output should not contain "app/controllers/application_controller.rb"
|
84
|
+
Then the output should not contain "app/controllers/application_helper.rb"
|
85
|
+
Then the output should not contain "features/step_definitions/cucumber_rails_steps.rb"
|
86
|
+
Then the output should not contain "features/support/cucumber_rails_helper.rb"
|
87
|
+
|
88
|
+
Scenario: Running spork with a rails app and no server
|
89
|
+
When I run cucumber --drb features
|
90
|
+
Then the error output should contain
|
91
|
+
"""
|
92
|
+
WARNING: No DRb server is running. Running features locally
|
93
|
+
"""
|
94
|
+
|
95
|
+
Scenario: Running spork with a rails app and observers
|
96
|
+
When I fire up a spork instance with "spork cucumber"
|
97
|
+
And I run cucumber --drb features
|
98
|
+
Then the error output should be empty
|
99
|
+
And the output should contain "It worked!"
|
100
|
+
And the file "log/test.log" should include "hey there"
|
101
|
+
|
102
|
+
Scenario: Running spork with a rails app and a non-standard port
|
103
|
+
When I fire up a spork instance with "spork cucumber -p 9000"
|
104
|
+
And I run cucumber --drb --port 9000 features
|
105
|
+
Then the error output should be empty
|
106
|
+
And the output should contain "It worked!"
|
107
|
+
And the file "log/test.log" should include "hey there"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source :gemcutter
|
2
|
+
gem 'sqlite3', '~> 1.3.4'
|
3
|
+
gem 'cucumber', '~> 1.0.6'
|
4
|
+
# gem 'cucumber-rails', '~> 1.0.6'
|
5
|
+
gem "rspec", "2.8.0"
|
6
|
+
gem 'rspec-rails'
|
7
|
+
gem 'rails', '~> 3.0.7'
|
8
|
+
|
9
|
+
if RUBY_VERSION =~ /^1\.9/
|
10
|
+
gem 'ruby-debug19'
|
11
|
+
else
|
12
|
+
gem 'ruby-debug', '>= 0.10.3'
|
13
|
+
end
|
14
|
+
gem 'spork', "~> 1.0.0rc0"
|
15
|
+
gem 'spork-rails', :path => "../../../"
|
@@ -0,0 +1,129 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../../
|
3
|
+
specs:
|
4
|
+
spork-rails (3.1.0)
|
5
|
+
rails (>= 3.0.0, < 3.3.0)
|
6
|
+
spork (>= 1.0rc0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
abstract (1.0.0)
|
12
|
+
actionmailer (3.0.11)
|
13
|
+
actionpack (= 3.0.11)
|
14
|
+
mail (~> 2.2.19)
|
15
|
+
actionpack (3.0.11)
|
16
|
+
activemodel (= 3.0.11)
|
17
|
+
activesupport (= 3.0.11)
|
18
|
+
builder (~> 2.1.2)
|
19
|
+
erubis (~> 2.6.6)
|
20
|
+
i18n (~> 0.5.0)
|
21
|
+
rack (~> 1.2.1)
|
22
|
+
rack-mount (~> 0.6.14)
|
23
|
+
rack-test (~> 0.5.7)
|
24
|
+
tzinfo (~> 0.3.23)
|
25
|
+
activemodel (3.0.11)
|
26
|
+
activesupport (= 3.0.11)
|
27
|
+
builder (~> 2.1.2)
|
28
|
+
i18n (~> 0.5.0)
|
29
|
+
activerecord (3.0.11)
|
30
|
+
activemodel (= 3.0.11)
|
31
|
+
activesupport (= 3.0.11)
|
32
|
+
arel (~> 2.0.10)
|
33
|
+
tzinfo (~> 0.3.23)
|
34
|
+
activeresource (3.0.11)
|
35
|
+
activemodel (= 3.0.11)
|
36
|
+
activesupport (= 3.0.11)
|
37
|
+
activesupport (3.0.11)
|
38
|
+
archive-tar-minitar (0.5.2)
|
39
|
+
arel (2.0.10)
|
40
|
+
builder (2.1.2)
|
41
|
+
columnize (0.3.6)
|
42
|
+
cucumber (1.0.6)
|
43
|
+
builder (>= 2.1.2)
|
44
|
+
diff-lcs (>= 1.1.2)
|
45
|
+
gherkin (~> 2.4.18)
|
46
|
+
json (>= 1.4.6)
|
47
|
+
term-ansicolor (>= 1.0.6)
|
48
|
+
diff-lcs (1.1.3)
|
49
|
+
erubis (2.6.6)
|
50
|
+
abstract (>= 1.0.0)
|
51
|
+
gherkin (2.4.21)
|
52
|
+
json (>= 1.4.6)
|
53
|
+
i18n (0.5.0)
|
54
|
+
json (1.6.5)
|
55
|
+
linecache19 (0.5.12)
|
56
|
+
ruby_core_source (>= 0.1.4)
|
57
|
+
mail (2.2.19)
|
58
|
+
activesupport (>= 2.3.6)
|
59
|
+
i18n (>= 0.4.0)
|
60
|
+
mime-types (~> 1.16)
|
61
|
+
treetop (~> 1.4.8)
|
62
|
+
mime-types (1.17.2)
|
63
|
+
polyglot (0.3.3)
|
64
|
+
rack (1.2.5)
|
65
|
+
rack-mount (0.6.14)
|
66
|
+
rack (>= 1.0.0)
|
67
|
+
rack-test (0.5.7)
|
68
|
+
rack (>= 1.0)
|
69
|
+
rails (3.0.11)
|
70
|
+
actionmailer (= 3.0.11)
|
71
|
+
actionpack (= 3.0.11)
|
72
|
+
activerecord (= 3.0.11)
|
73
|
+
activeresource (= 3.0.11)
|
74
|
+
activesupport (= 3.0.11)
|
75
|
+
bundler (~> 1.0)
|
76
|
+
railties (= 3.0.11)
|
77
|
+
railties (3.0.11)
|
78
|
+
actionpack (= 3.0.11)
|
79
|
+
activesupport (= 3.0.11)
|
80
|
+
rake (>= 0.8.7)
|
81
|
+
rdoc (~> 3.4)
|
82
|
+
thor (~> 0.14.4)
|
83
|
+
rake (0.9.2.2)
|
84
|
+
rdoc (3.12)
|
85
|
+
json (~> 1.4)
|
86
|
+
rspec (2.8.0)
|
87
|
+
rspec-core (~> 2.8.0)
|
88
|
+
rspec-expectations (~> 2.8.0)
|
89
|
+
rspec-mocks (~> 2.8.0)
|
90
|
+
rspec-core (2.8.0)
|
91
|
+
rspec-expectations (2.8.0)
|
92
|
+
diff-lcs (~> 1.1.2)
|
93
|
+
rspec-mocks (2.8.0)
|
94
|
+
rspec-rails (2.8.1)
|
95
|
+
actionpack (>= 3.0)
|
96
|
+
activesupport (>= 3.0)
|
97
|
+
railties (>= 3.0)
|
98
|
+
rspec (~> 2.8.0)
|
99
|
+
ruby-debug-base19 (0.11.25)
|
100
|
+
columnize (>= 0.3.1)
|
101
|
+
linecache19 (>= 0.5.11)
|
102
|
+
ruby_core_source (>= 0.1.4)
|
103
|
+
ruby-debug19 (0.11.6)
|
104
|
+
columnize (>= 0.3.1)
|
105
|
+
linecache19 (>= 0.5.11)
|
106
|
+
ruby-debug-base19 (>= 0.11.19)
|
107
|
+
ruby_core_source (0.1.5)
|
108
|
+
archive-tar-minitar (>= 0.5.2)
|
109
|
+
spork (1.0.0rc0)
|
110
|
+
sqlite3 (1.3.5)
|
111
|
+
term-ansicolor (1.0.7)
|
112
|
+
thor (0.14.6)
|
113
|
+
treetop (1.4.10)
|
114
|
+
polyglot
|
115
|
+
polyglot (>= 0.3.1)
|
116
|
+
tzinfo (0.3.31)
|
117
|
+
|
118
|
+
PLATFORMS
|
119
|
+
ruby
|
120
|
+
|
121
|
+
DEPENDENCIES
|
122
|
+
cucumber (~> 1.0.6)
|
123
|
+
rails (~> 3.0.7)
|
124
|
+
rspec (= 2.8.0)
|
125
|
+
rspec-rails
|
126
|
+
ruby-debug19
|
127
|
+
spork (~> 1.0.0rc0)
|
128
|
+
spork-rails!
|
129
|
+
sqlite3 (~> 1.3.4)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source :gemcutter
|
2
|
+
gem 'sqlite3', '~> 1.3.4'
|
3
|
+
gem 'cucumber', '~> 1.0.6'
|
4
|
+
# gem 'cucumber-rails', '~> 1.0.6'
|
5
|
+
gem "rspec", "2.8.0"
|
6
|
+
gem 'rspec-rails'
|
7
|
+
gem 'rails', '~> 3.1.0'
|
8
|
+
|
9
|
+
if RUBY_VERSION =~ /^1\.9/
|
10
|
+
gem 'ruby-debug19'
|
11
|
+
else
|
12
|
+
gem 'ruby-debug', '>= 0.10.3'
|
13
|
+
end
|
14
|
+
gem 'spork', "~> 1.0.0rc0"
|
15
|
+
gem 'spork-rails', :path => "../../../"
|
@@ -0,0 +1,140 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../../
|
3
|
+
specs:
|
4
|
+
spork-rails (3.1.0)
|
5
|
+
rails (>= 3.0.0, < 3.3.0)
|
6
|
+
spork (>= 1.0rc0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.1.3)
|
12
|
+
actionpack (= 3.1.3)
|
13
|
+
mail (~> 2.3.0)
|
14
|
+
actionpack (3.1.3)
|
15
|
+
activemodel (= 3.1.3)
|
16
|
+
activesupport (= 3.1.3)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
i18n (~> 0.6)
|
20
|
+
rack (~> 1.3.5)
|
21
|
+
rack-cache (~> 1.1)
|
22
|
+
rack-mount (~> 0.8.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.0.3)
|
25
|
+
activemodel (3.1.3)
|
26
|
+
activesupport (= 3.1.3)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
i18n (~> 0.6)
|
29
|
+
activerecord (3.1.3)
|
30
|
+
activemodel (= 3.1.3)
|
31
|
+
activesupport (= 3.1.3)
|
32
|
+
arel (~> 2.2.1)
|
33
|
+
tzinfo (~> 0.3.29)
|
34
|
+
activeresource (3.1.3)
|
35
|
+
activemodel (= 3.1.3)
|
36
|
+
activesupport (= 3.1.3)
|
37
|
+
activesupport (3.1.3)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
archive-tar-minitar (0.5.2)
|
40
|
+
arel (2.2.1)
|
41
|
+
builder (3.0.0)
|
42
|
+
columnize (0.3.6)
|
43
|
+
cucumber (1.0.6)
|
44
|
+
builder (>= 2.1.2)
|
45
|
+
diff-lcs (>= 1.1.2)
|
46
|
+
gherkin (~> 2.4.18)
|
47
|
+
json (>= 1.4.6)
|
48
|
+
term-ansicolor (>= 1.0.6)
|
49
|
+
diff-lcs (1.1.3)
|
50
|
+
erubis (2.7.0)
|
51
|
+
gherkin (2.4.21)
|
52
|
+
json (>= 1.4.6)
|
53
|
+
hike (1.2.1)
|
54
|
+
i18n (0.6.0)
|
55
|
+
json (1.6.5)
|
56
|
+
linecache19 (0.5.12)
|
57
|
+
ruby_core_source (>= 0.1.4)
|
58
|
+
mail (2.3.0)
|
59
|
+
i18n (>= 0.4.0)
|
60
|
+
mime-types (~> 1.16)
|
61
|
+
treetop (~> 1.4.8)
|
62
|
+
mime-types (1.17.2)
|
63
|
+
multi_json (1.0.4)
|
64
|
+
polyglot (0.3.3)
|
65
|
+
rack (1.3.6)
|
66
|
+
rack-cache (1.1)
|
67
|
+
rack (>= 0.4)
|
68
|
+
rack-mount (0.8.3)
|
69
|
+
rack (>= 1.0.0)
|
70
|
+
rack-ssl (1.3.2)
|
71
|
+
rack
|
72
|
+
rack-test (0.6.1)
|
73
|
+
rack (>= 1.0)
|
74
|
+
rails (3.1.3)
|
75
|
+
actionmailer (= 3.1.3)
|
76
|
+
actionpack (= 3.1.3)
|
77
|
+
activerecord (= 3.1.3)
|
78
|
+
activeresource (= 3.1.3)
|
79
|
+
activesupport (= 3.1.3)
|
80
|
+
bundler (~> 1.0)
|
81
|
+
railties (= 3.1.3)
|
82
|
+
railties (3.1.3)
|
83
|
+
actionpack (= 3.1.3)
|
84
|
+
activesupport (= 3.1.3)
|
85
|
+
rack-ssl (~> 1.3.2)
|
86
|
+
rake (>= 0.8.7)
|
87
|
+
rdoc (~> 3.4)
|
88
|
+
thor (~> 0.14.6)
|
89
|
+
rake (0.9.2.2)
|
90
|
+
rdoc (3.12)
|
91
|
+
json (~> 1.4)
|
92
|
+
rspec (2.8.0)
|
93
|
+
rspec-core (~> 2.8.0)
|
94
|
+
rspec-expectations (~> 2.8.0)
|
95
|
+
rspec-mocks (~> 2.8.0)
|
96
|
+
rspec-core (2.8.0)
|
97
|
+
rspec-expectations (2.8.0)
|
98
|
+
diff-lcs (~> 1.1.2)
|
99
|
+
rspec-mocks (2.8.0)
|
100
|
+
rspec-rails (2.8.1)
|
101
|
+
actionpack (>= 3.0)
|
102
|
+
activesupport (>= 3.0)
|
103
|
+
railties (>= 3.0)
|
104
|
+
rspec (~> 2.8.0)
|
105
|
+
ruby-debug-base19 (0.11.25)
|
106
|
+
columnize (>= 0.3.1)
|
107
|
+
linecache19 (>= 0.5.11)
|
108
|
+
ruby_core_source (>= 0.1.4)
|
109
|
+
ruby-debug19 (0.11.6)
|
110
|
+
columnize (>= 0.3.1)
|
111
|
+
linecache19 (>= 0.5.11)
|
112
|
+
ruby-debug-base19 (>= 0.11.19)
|
113
|
+
ruby_core_source (0.1.5)
|
114
|
+
archive-tar-minitar (>= 0.5.2)
|
115
|
+
spork (1.0.0rc0)
|
116
|
+
sprockets (2.0.3)
|
117
|
+
hike (~> 1.2)
|
118
|
+
rack (~> 1.0)
|
119
|
+
tilt (~> 1.1, != 1.3.0)
|
120
|
+
sqlite3 (1.3.5)
|
121
|
+
term-ansicolor (1.0.7)
|
122
|
+
thor (0.14.6)
|
123
|
+
tilt (1.3.3)
|
124
|
+
treetop (1.4.10)
|
125
|
+
polyglot
|
126
|
+
polyglot (>= 0.3.1)
|
127
|
+
tzinfo (0.3.31)
|
128
|
+
|
129
|
+
PLATFORMS
|
130
|
+
ruby
|
131
|
+
|
132
|
+
DEPENDENCIES
|
133
|
+
cucumber (~> 1.0.6)
|
134
|
+
rails (~> 3.1.0)
|
135
|
+
rspec (= 2.8.0)
|
136
|
+
rspec-rails
|
137
|
+
ruby-debug19
|
138
|
+
spork (~> 1.0.0rc0)
|
139
|
+
spork-rails!
|
140
|
+
sqlite3 (~> 1.3.4)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source :gemcutter
|
2
|
+
gem 'sqlite3', '~> 1.3.4'
|
3
|
+
gem 'cucumber', '~> 1.0.6'
|
4
|
+
# gem 'cucumber-rails', '~> 1.0.6'
|
5
|
+
gem "rspec", "2.8.0"
|
6
|
+
gem 'rspec-rails'
|
7
|
+
gem 'rails', '~> 3.2.0'
|
8
|
+
|
9
|
+
if RUBY_VERSION =~ /^1\.9/
|
10
|
+
gem 'ruby-debug19'
|
11
|
+
else
|
12
|
+
gem 'ruby-debug', '>= 0.10.3'
|
13
|
+
end
|
14
|
+
gem 'spork', "~> 1.0.0rc0"
|
15
|
+
gem 'spork-rails', :path => "../../../"
|
@@ -0,0 +1,138 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../../
|
3
|
+
specs:
|
4
|
+
spork-rails (3.1.0)
|
5
|
+
rails (>= 3.0.0, < 3.3.0)
|
6
|
+
spork (>= 1.0rc0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.0)
|
12
|
+
actionpack (= 3.2.0)
|
13
|
+
mail (~> 2.4.0)
|
14
|
+
actionpack (3.2.0)
|
15
|
+
activemodel (= 3.2.0)
|
16
|
+
activesupport (= 3.2.0)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.0)
|
20
|
+
rack (~> 1.4.0)
|
21
|
+
rack-cache (~> 1.1)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.1.2)
|
24
|
+
activemodel (3.2.0)
|
25
|
+
activesupport (= 3.2.0)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.0)
|
28
|
+
activemodel (= 3.2.0)
|
29
|
+
activesupport (= 3.2.0)
|
30
|
+
arel (~> 3.0.0)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.0)
|
33
|
+
activemodel (= 3.2.0)
|
34
|
+
activesupport (= 3.2.0)
|
35
|
+
activesupport (3.2.0)
|
36
|
+
i18n (~> 0.6)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
archive-tar-minitar (0.5.2)
|
39
|
+
arel (3.0.0)
|
40
|
+
builder (3.0.0)
|
41
|
+
columnize (0.3.6)
|
42
|
+
cucumber (1.0.6)
|
43
|
+
builder (>= 2.1.2)
|
44
|
+
diff-lcs (>= 1.1.2)
|
45
|
+
gherkin (~> 2.4.18)
|
46
|
+
json (>= 1.4.6)
|
47
|
+
term-ansicolor (>= 1.0.6)
|
48
|
+
diff-lcs (1.1.3)
|
49
|
+
erubis (2.7.0)
|
50
|
+
gherkin (2.4.21)
|
51
|
+
json (>= 1.4.6)
|
52
|
+
hike (1.2.1)
|
53
|
+
i18n (0.6.0)
|
54
|
+
journey (1.0.0)
|
55
|
+
json (1.6.5)
|
56
|
+
linecache19 (0.5.12)
|
57
|
+
ruby_core_source (>= 0.1.4)
|
58
|
+
mail (2.4.1)
|
59
|
+
i18n (>= 0.4.0)
|
60
|
+
mime-types (~> 1.16)
|
61
|
+
treetop (~> 1.4.8)
|
62
|
+
mime-types (1.17.2)
|
63
|
+
multi_json (1.0.4)
|
64
|
+
polyglot (0.3.3)
|
65
|
+
rack (1.4.0)
|
66
|
+
rack-cache (1.1)
|
67
|
+
rack (>= 0.4)
|
68
|
+
rack-ssl (1.3.2)
|
69
|
+
rack
|
70
|
+
rack-test (0.6.1)
|
71
|
+
rack (>= 1.0)
|
72
|
+
rails (3.2.0)
|
73
|
+
actionmailer (= 3.2.0)
|
74
|
+
actionpack (= 3.2.0)
|
75
|
+
activerecord (= 3.2.0)
|
76
|
+
activeresource (= 3.2.0)
|
77
|
+
activesupport (= 3.2.0)
|
78
|
+
bundler (~> 1.0)
|
79
|
+
railties (= 3.2.0)
|
80
|
+
railties (3.2.0)
|
81
|
+
actionpack (= 3.2.0)
|
82
|
+
activesupport (= 3.2.0)
|
83
|
+
rack-ssl (~> 1.3.2)
|
84
|
+
rake (>= 0.8.7)
|
85
|
+
rdoc (~> 3.4)
|
86
|
+
thor (~> 0.14.6)
|
87
|
+
rake (0.9.2.2)
|
88
|
+
rdoc (3.12)
|
89
|
+
json (~> 1.4)
|
90
|
+
rspec (2.8.0)
|
91
|
+
rspec-core (~> 2.8.0)
|
92
|
+
rspec-expectations (~> 2.8.0)
|
93
|
+
rspec-mocks (~> 2.8.0)
|
94
|
+
rspec-core (2.8.0)
|
95
|
+
rspec-expectations (2.8.0)
|
96
|
+
diff-lcs (~> 1.1.2)
|
97
|
+
rspec-mocks (2.8.0)
|
98
|
+
rspec-rails (2.8.1)
|
99
|
+
actionpack (>= 3.0)
|
100
|
+
activesupport (>= 3.0)
|
101
|
+
railties (>= 3.0)
|
102
|
+
rspec (~> 2.8.0)
|
103
|
+
ruby-debug-base19 (0.11.25)
|
104
|
+
columnize (>= 0.3.1)
|
105
|
+
linecache19 (>= 0.5.11)
|
106
|
+
ruby_core_source (>= 0.1.4)
|
107
|
+
ruby-debug19 (0.11.6)
|
108
|
+
columnize (>= 0.3.1)
|
109
|
+
linecache19 (>= 0.5.11)
|
110
|
+
ruby-debug-base19 (>= 0.11.19)
|
111
|
+
ruby_core_source (0.1.5)
|
112
|
+
archive-tar-minitar (>= 0.5.2)
|
113
|
+
spork (1.0.0rc0)
|
114
|
+
sprockets (2.1.2)
|
115
|
+
hike (~> 1.2)
|
116
|
+
rack (~> 1.0)
|
117
|
+
tilt (~> 1.1, != 1.3.0)
|
118
|
+
sqlite3 (1.3.5)
|
119
|
+
term-ansicolor (1.0.7)
|
120
|
+
thor (0.14.6)
|
121
|
+
tilt (1.3.3)
|
122
|
+
treetop (1.4.10)
|
123
|
+
polyglot
|
124
|
+
polyglot (>= 0.3.1)
|
125
|
+
tzinfo (0.3.31)
|
126
|
+
|
127
|
+
PLATFORMS
|
128
|
+
ruby
|
129
|
+
|
130
|
+
DEPENDENCIES
|
131
|
+
cucumber (~> 1.0.6)
|
132
|
+
rails (~> 3.2.0)
|
133
|
+
rspec (= 2.8.0)
|
134
|
+
rspec-rails
|
135
|
+
ruby-debug19
|
136
|
+
spork (~> 1.0.0rc0)
|
137
|
+
spork-rails!
|
138
|
+
sqlite3 (~> 1.3.4)
|
@@ -0,0 +1,177 @@
|
|
1
|
+
Feature: Rails Delayed Work arounds
|
2
|
+
To allow a rails developer to update as many parts of his application as possible without needing to restart Spork
|
3
|
+
Spork automatically tells rails to delay loading certain parts of the application until after the fork occurs
|
4
|
+
|
5
|
+
Background: Rails App with RSpec and Spork
|
6
|
+
|
7
|
+
Given I am in a fresh rails project named "test_rails_project"
|
8
|
+
And a file named "spec/spec_helper.rb" with:
|
9
|
+
"""
|
10
|
+
require 'rubygems'
|
11
|
+
require 'spork'
|
12
|
+
require 'spork/ext/ruby-debug'
|
13
|
+
|
14
|
+
Spork.prefork do
|
15
|
+
require File.dirname(__FILE__) + '/../config/environment.rb'
|
16
|
+
require 'rspec'
|
17
|
+
require 'rspec/rails'
|
18
|
+
end
|
19
|
+
|
20
|
+
Spork.each_run do
|
21
|
+
end
|
22
|
+
"""
|
23
|
+
And the application has a model, observer, route, and application helper
|
24
|
+
|
25
|
+
Given the following code appears in "config/routes.rb" after /routes\.draw/:
|
26
|
+
"""
|
27
|
+
resources :users
|
28
|
+
"""
|
29
|
+
Given a file named "app/helpers/application_helper.rb" with:
|
30
|
+
"""
|
31
|
+
require 'reverseatron'
|
32
|
+
module ApplicationHelper
|
33
|
+
include Reverseatron
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
Given a file named "lib/reverseatron.rb" with:
|
37
|
+
"""
|
38
|
+
module Reverseatron
|
39
|
+
def reverse_text(txt)
|
40
|
+
txt.reverse
|
41
|
+
end
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
Given a file named "app/controllers/users_controller.rb" with:
|
45
|
+
"""
|
46
|
+
class UsersController < ApplicationController
|
47
|
+
$loaded_stuff << 'UsersController'
|
48
|
+
def index
|
49
|
+
@users = []
|
50
|
+
end
|
51
|
+
end
|
52
|
+
"""
|
53
|
+
Given a file named "app/helpers/misc_helper.rb" with:
|
54
|
+
"""
|
55
|
+
module MiscHelper
|
56
|
+
def misc_helper_method
|
57
|
+
'hello miscellaneous'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
"""
|
61
|
+
Given a file named "app/helpers/users_helper.rb" with:
|
62
|
+
"""
|
63
|
+
module UsersHelper
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
Given a file named "app/views/users/index.html.erb" with:
|
67
|
+
"""
|
68
|
+
Original View
|
69
|
+
"""
|
70
|
+
Scenario: respecting custom autoload paths
|
71
|
+
Given the following code appears in "config/application.rb" after /class Application < Rails::Application/:
|
72
|
+
"""
|
73
|
+
config.autoload_paths << './app/models/non_standard'
|
74
|
+
"""
|
75
|
+
|
76
|
+
And a file named "app/models/non_standard/boogie.rb" with:
|
77
|
+
"""
|
78
|
+
class Boogie
|
79
|
+
def boogie
|
80
|
+
'Boogie Robots!'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
"""
|
84
|
+
And a file named "spec/models/non_standard/boogie_spec.rb" with:
|
85
|
+
"""
|
86
|
+
describe Boogie do
|
87
|
+
it 'knows how to boogie' do
|
88
|
+
Boogie.new.boogie.should include('Boogie')
|
89
|
+
puts 'BOOGIE!!!'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
"""
|
93
|
+
When I fire up a spork instance with "spork rspec"
|
94
|
+
And I run rspec --drb spec/models/non_standard/boogie_spec.rb
|
95
|
+
Then the output should contain "BOOGIE!!!"
|
96
|
+
|
97
|
+
Scenario: within a view rendered by a controller, calling helper methods from an included module in ApplicationHelper
|
98
|
+
Given a file named "spec/controllers/users_controller_spec.rb" with:
|
99
|
+
"""
|
100
|
+
require "spec_helper"
|
101
|
+
describe UsersController do
|
102
|
+
render_views
|
103
|
+
it "renders a page, using a method inherited from ApplicationController" do
|
104
|
+
get :index
|
105
|
+
response.body.should_not include('Original View')
|
106
|
+
puts "Views are not being cached when rendering from a controller"
|
107
|
+
|
108
|
+
response.body.should include('listing users')
|
109
|
+
puts "Controller stack is functioning when rendering from a controller"
|
110
|
+
|
111
|
+
response.body.should include('hello miscellaneous')
|
112
|
+
puts "All helper modules were included when rendering from a controller"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
"""
|
116
|
+
Given a file named "spec/views/index.html.erb_spec.rb" with:
|
117
|
+
"""
|
118
|
+
require "spec_helper"
|
119
|
+
describe "/users/index.html.erb" do
|
120
|
+
|
121
|
+
it "renders the view" do
|
122
|
+
render
|
123
|
+
rendered.should_not include('Original View')
|
124
|
+
puts "Views are not being cached when rendering directly"
|
125
|
+
|
126
|
+
rendered.should include('listing users')
|
127
|
+
puts "Controller stack is functioning when rendering directly"
|
128
|
+
|
129
|
+
rendered.should include('hello miscellaneous')
|
130
|
+
puts "All helper modules were included when rendering directly"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
"""
|
134
|
+
When I fire up a spork instance with "spork rspec"
|
135
|
+
And the contents of "app/views/users/index.html.erb" are changed to:
|
136
|
+
"""
|
137
|
+
<%= reverse_text('listing users'.reverse) %>
|
138
|
+
<%= misc_helper_method rescue nil %>
|
139
|
+
<p>Here is a list of users</p>
|
140
|
+
"""
|
141
|
+
|
142
|
+
And I run rspec --drb spec/controllers/users_controller_spec.rb
|
143
|
+
Then the output should contain "Controller stack is functioning when rendering from a controller"
|
144
|
+
And the output should contain "Views are not being cached when rendering from a controller"
|
145
|
+
And the output should contain "All helper modules were included when rendering from a controller"
|
146
|
+
|
147
|
+
When I run rspec --drb spec/views/index.html.erb_spec.rb
|
148
|
+
Then the output should contain "Controller stack is functioning when rendering directly"
|
149
|
+
And the output should contain "Views are not being cached when rendering directly"
|
150
|
+
And the output should contain "All helper modules were included when rendering directly"
|
151
|
+
|
152
|
+
Given the contents of "app/helpers/application_helper.rb" are changed to:
|
153
|
+
"""
|
154
|
+
module ApplicationHelper
|
155
|
+
def make_it_loud(message)
|
156
|
+
message.upcase
|
157
|
+
end
|
158
|
+
end
|
159
|
+
"""
|
160
|
+
And the contents of "app/views/users/index.html.erb" are changed to:
|
161
|
+
"""
|
162
|
+
<%= make_it_loud('listing users') %>
|
163
|
+
"""
|
164
|
+
And the contents of "spec/controllers/users_controller_spec.rb" are changed to:
|
165
|
+
"""
|
166
|
+
require "spec_helper"
|
167
|
+
describe UsersController do
|
168
|
+
render_views
|
169
|
+
it "renders a page, using a method inherited from ApplicationController" do
|
170
|
+
get :index
|
171
|
+
response.body.should include('LISTING USERS')
|
172
|
+
puts "Helpers aren't being cached"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
"""
|
176
|
+
When I run rspec --drb spec/controllers/users_controller_spec.rb
|
177
|
+
Then the output should contain "Helpers aren't being cached"
|
@@ -0,0 +1,92 @@
|
|
1
|
+
Feature: Rails Integration
|
2
|
+
To get a developer up and running quickly
|
3
|
+
Spork automatically integrates with rails
|
4
|
+
Providing default hooks and behaviors
|
5
|
+
|
6
|
+
Background: Rails App with RSpec and Spork
|
7
|
+
Given I am in a fresh rails project named "test_rails_project"
|
8
|
+
And a file named "spec/spec_helper.rb" with:
|
9
|
+
"""
|
10
|
+
require 'rubygems'
|
11
|
+
require 'spork'
|
12
|
+
|
13
|
+
Spork.prefork do
|
14
|
+
# Loading more in this block will cause your specs to run faster. However,
|
15
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
16
|
+
# need to restart spork for it take effect.
|
17
|
+
require File.dirname(__FILE__) + '/../config/environment.rb'
|
18
|
+
require 'rspec'
|
19
|
+
require 'rspec/rails'
|
20
|
+
|
21
|
+
#### this is for this test only #######
|
22
|
+
$loaded_stuff << 'prefork block' ######
|
23
|
+
#######################################
|
24
|
+
end
|
25
|
+
|
26
|
+
Spork.each_run do
|
27
|
+
# This code will be run each time you run your specs.
|
28
|
+
|
29
|
+
#### this is for this test only #######
|
30
|
+
$loaded_stuff << 'each_run block' #####
|
31
|
+
#######################################
|
32
|
+
end
|
33
|
+
"""
|
34
|
+
And the application has a model, observer, route, and application helper
|
35
|
+
Scenario: Analyzing files were preloaded
|
36
|
+
When I run spork --diagnose
|
37
|
+
Then the output should not contain "user_observer.rb"
|
38
|
+
Then the output should not contain "user.rb"
|
39
|
+
Then the output should not contain "app/controllers/application.rb"
|
40
|
+
Then the output should not contain "app/controllers/application_controller.rb"
|
41
|
+
Then the output should not contain "app/controllers/application_helper.rb"
|
42
|
+
# Then the output should not contain "config/routes.rb"
|
43
|
+
|
44
|
+
Scenario: Running spork with a rails app and observers
|
45
|
+
Given a file named "spec/did_it_work_spec.rb" with:
|
46
|
+
"""
|
47
|
+
require 'spec_helper'
|
48
|
+
describe "Did it work?" do
|
49
|
+
it "checks to see if all worked" do
|
50
|
+
Spork.using_spork?.should == true
|
51
|
+
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
52
|
+
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
53
|
+
$loaded_stuff.should include('User')
|
54
|
+
$loaded_stuff.should include('UserObserver')
|
55
|
+
$loaded_stuff.should include('ApplicationHelper')
|
56
|
+
$loaded_stuff.should include('config/routes.rb')
|
57
|
+
$loaded_stuff.should include('each_run block')
|
58
|
+
$loaded_stuff.should include('prefork block')
|
59
|
+
puts "Specs successfully run within spork, and all initialization files were loaded"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
"""
|
63
|
+
When I fire up a spork instance with "spork rspec"
|
64
|
+
And I run rspec --drb spec/did_it_work_spec.rb
|
65
|
+
Then the error output should be empty
|
66
|
+
And the output should contain "Specs successfully run within spork, and all initialization files were loaded"
|
67
|
+
And the file "log/test.log" should include "hey there"
|
68
|
+
|
69
|
+
|
70
|
+
Scenario: Running spork with a rails app and a non-standard port
|
71
|
+
Given a file named "spec/did_it_work_spec.rb" with:
|
72
|
+
"""
|
73
|
+
describe "Did it work?" do
|
74
|
+
it "checks to see if all worked" do
|
75
|
+
Spork.using_spork?.should == true
|
76
|
+
(Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
|
77
|
+
$loaded_stuff.should include('ActiveRecord::Base.establish_connection')
|
78
|
+
$loaded_stuff.should include('User')
|
79
|
+
$loaded_stuff.should include('UserObserver')
|
80
|
+
$loaded_stuff.should include('ApplicationHelper')
|
81
|
+
$loaded_stuff.should include('config/routes.rb')
|
82
|
+
$loaded_stuff.should include('each_run block')
|
83
|
+
$loaded_stuff.should include('prefork block')
|
84
|
+
puts "Specs successfully run within spork, and all initialization files were loaded"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
"""
|
88
|
+
When I fire up a spork instance with "spork rspec --port 7000"
|
89
|
+
And I run rspec --drb --drb-port 7000 spec/did_it_work_spec.rb
|
90
|
+
Then the error output should be empty
|
91
|
+
And the output should contain "Specs successfully run within spork, and all initialization files were loaded"
|
92
|
+
And the file "log/test.log" should include "hey there"
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Given /^I am in a fresh rails project named "(.+)"$/ do |folder_name|
|
2
|
+
@current_dir = SporkWorld::SANDBOX_DIR
|
3
|
+
# version_argument = ENV['RAILS_VERSION'] ? "_#{ENV['RAILS_VERSION']}_" : nil
|
4
|
+
# run("#{SporkWorld::RUBY_BINARY} #{%x{which rails}.chomp} #{folder_name}")
|
5
|
+
run(["rails", "new", folder_name].compact * " ")
|
6
|
+
|
7
|
+
if last_exit_status != 0
|
8
|
+
puts "Couldn't generate project. Output:\nSTDERR:\n-------\n#{last_stderr}\n------\n\nSTDOUT:\n-------\n#{last_stdout}\n\n"
|
9
|
+
last_exit_status.should == 0
|
10
|
+
end
|
11
|
+
@current_dir = File.join(File.join(SporkWorld::SANDBOX_DIR, folder_name))
|
12
|
+
in_current_dir do
|
13
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
14
|
+
FileUtils.ln_sf(gemfile, "Gemfile")
|
15
|
+
FileUtils.ln_sf("#{gemfile}.lock", "Gemfile.lock")
|
16
|
+
FileUtils.ln_sf("#{File.dirname(gemfile)}/.bundle", ".bundle")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
Given "the application has a model, observer, route, and application helper" do
|
22
|
+
Given 'the following code appears in "config/application.rb" after /^end/:',
|
23
|
+
"""
|
24
|
+
ActiveRecord::Base.observers = [:user_observer]
|
25
|
+
"""
|
26
|
+
Given 'a file named "app/models/user.rb" with:',
|
27
|
+
"""
|
28
|
+
class User < ActiveRecord::Base
|
29
|
+
$loaded_stuff << 'User'
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
Given 'a file named "app/models/user_observer.rb" with:',
|
33
|
+
"""
|
34
|
+
class UserObserver < ActiveRecord::Observer
|
35
|
+
$loaded_stuff << 'UserObserver'
|
36
|
+
end
|
37
|
+
"""
|
38
|
+
Given 'a file named "app/helpers/application_helper.rb" with:',
|
39
|
+
"""
|
40
|
+
module ApplicationHelper
|
41
|
+
$loaded_stuff << 'ApplicationHelper'
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
Given 'the following code appears in "config/environment.rb" after /Rails::Initializer.run/:',
|
45
|
+
"""
|
46
|
+
config.active_record.observers = :user_observer
|
47
|
+
"""
|
48
|
+
Given 'the following code appears in "config/routes.rb" after /^end/:',
|
49
|
+
"""
|
50
|
+
$loaded_stuff << 'config/routes.rb'
|
51
|
+
"""
|
52
|
+
Given 'a file named "config/initializers/initialize_loaded_stuff.rb" with:',
|
53
|
+
"""
|
54
|
+
$loaded_stuff ||= []
|
55
|
+
"""
|
56
|
+
Given 'a file named "config/initializers/log_establish_connection_calls.rb" with:',
|
57
|
+
"""
|
58
|
+
class ActiveRecord::Base
|
59
|
+
class << self
|
60
|
+
def establish_connection_with_load_logging(*args)
|
61
|
+
$loaded_stuff << 'ActiveRecord::Base.establish_connection'
|
62
|
+
establish_connection_without_load_logging(*args)
|
63
|
+
end
|
64
|
+
alias_method_chain :establish_connection, :load_logging
|
65
|
+
end
|
66
|
+
end
|
67
|
+
"""
|
68
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spork/test/cucumber_helpers.rb"
|
2
|
+
|
3
|
+
APP_ROOT = Pathname.new(File.expand_path('../../', File.dirname(__FILE__)))
|
4
|
+
SANDBOX_DIR = APP_ROOT + "tmp/sandbox"
|
5
|
+
|
6
|
+
BundlerHelpers.set_gemfile(APP_ROOT + "features/gemsets/#{ENV["GEMSET"] || 'rails3.1'}/Gemfile")
|
7
|
+
|
8
|
+
World do
|
9
|
+
SporkWorld.new
|
10
|
+
end
|
11
|
+
|
12
|
+
# FileUtils.rm_rf SporkWorld::SANDBOX_DIR
|
13
|
+
Before { reset_sandbox_dir }
|
14
|
+
After { terminate_background_jobs }
|
@@ -0,0 +1,90 @@
|
|
1
|
+
class Spork::AppFramework::Rails < Spork::AppFramework
|
2
|
+
|
3
|
+
def preload(&block)
|
4
|
+
STDERR.puts "Preloading Rails environment"
|
5
|
+
STDERR.flush
|
6
|
+
ENV["RAILS_ENV"] ||= 'test'
|
7
|
+
preload_rails
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
|
11
|
+
def entry_point
|
12
|
+
@entry_point ||= File.expand_path("config/environment.rb", Dir.pwd)
|
13
|
+
end
|
14
|
+
|
15
|
+
alias :environment_file :entry_point
|
16
|
+
|
17
|
+
def boot_file
|
18
|
+
@boot_file ||= File.join(File.dirname(environment_file), 'boot')
|
19
|
+
end
|
20
|
+
|
21
|
+
def application_file
|
22
|
+
@application_file ||= File.join(File.dirname(environment_file), 'application')
|
23
|
+
end
|
24
|
+
|
25
|
+
def environment_contents
|
26
|
+
@environment_contents ||= File.read(environment_file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def vendor
|
30
|
+
@vendor ||= File.expand_path("vendor/rails", Dir.pwd)
|
31
|
+
end
|
32
|
+
|
33
|
+
def deprecated_version
|
34
|
+
@version ||= (
|
35
|
+
if /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/.match(environment_contents)
|
36
|
+
$1
|
37
|
+
else
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def preload_rails
|
44
|
+
if deprecated_version && (not /^3/.match(deprecated_version))
|
45
|
+
puts "This version of spork only supports Rails 3.0. To use spork with rails 2.3.x, downgrade to spork 0.8.x."
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
require application_file
|
49
|
+
::Rails.application
|
50
|
+
::Rails::Engine.class_eval do
|
51
|
+
def eager_load!
|
52
|
+
# turn off eager_loading, all together
|
53
|
+
end
|
54
|
+
end
|
55
|
+
# Spork.trap_method(::AbstractController::Helpers::ClassMethods, :helper)
|
56
|
+
Spork.trap_method(::ActiveModel::Observing::ClassMethods, :instantiate_observers)
|
57
|
+
Spork.each_run { ActiveRecord::Base.establish_connection rescue nil } if Object.const_defined?(:ActiveRecord)
|
58
|
+
|
59
|
+
|
60
|
+
AbstractController::Helpers::ClassMethods.module_eval do
|
61
|
+
def helper(*args, &block)
|
62
|
+
([args].flatten - [:all]).each do |arg|
|
63
|
+
next unless arg.is_a?(String)
|
64
|
+
filename = arg + "_helper"
|
65
|
+
unless ::ActiveSupport::Dependencies.search_for_file(filename)
|
66
|
+
# this error message must raise in the format such that LoadError#path returns the filename
|
67
|
+
raise LoadError.new("Missing helper file helpers/%s.rb" % filename)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Spork.each_run(false) do
|
72
|
+
modules_for_helpers(args).each do |mod|
|
73
|
+
add_template_helper(mod)
|
74
|
+
end
|
75
|
+
|
76
|
+
_helpers.module_eval(&block) if block_given?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.present?
|
83
|
+
# TODO - Simplifiy this to only target Rails 3.1
|
84
|
+
File.exist?("config/environment.rb") &&
|
85
|
+
(File.read("config/environment.rb").include?('RAILS_GEM_VERSION') ||
|
86
|
+
(File.exist?("config/application.rb") &&
|
87
|
+
File.read("config/application.rb").include?("Rails::Application")))
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Spork.each_run do
|
2
|
+
::ActiveSupport.const_defined?(:Dependencies) ?
|
3
|
+
::ActiveSupport::Dependencies.mechanism = :load :
|
4
|
+
::Dependencies.mechanism = :load
|
5
|
+
|
6
|
+
require 'action_controller/dispatcher'
|
7
|
+
dispatcher = ::ActionController::Dispatcher.new($stdout)
|
8
|
+
|
9
|
+
if ::ActionController::Dispatcher.respond_to?(:reload_application)
|
10
|
+
::ActionController::Dispatcher.reload_application
|
11
|
+
else
|
12
|
+
dispatcher.reload_application
|
13
|
+
end
|
14
|
+
end if Spork.using_spork?
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spork'
|
3
|
+
require 'spork/app_framework'
|
4
|
+
|
5
|
+
SPEC_TMP_DIR = File.expand_path('tmp', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require "spork/test/test_helpers"
|
8
|
+
|
9
|
+
Dir.glob("#{File.dirname(__FILE__)}/support/*.rb").each { |f| require(f) }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
include(TmpProjectHelpers)
|
13
|
+
|
14
|
+
config.before(:each) do
|
15
|
+
TestIOStreams.set_streams(StringIO.new, StringIO.new)
|
16
|
+
|
17
|
+
@current_dir = nil
|
18
|
+
clear_tmp_dir
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require '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 '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
|
+
end
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
RAILS_GEM_VERSION = '2.1.0'
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spork-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tim Harper
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-22 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: spork
|
16
|
+
requirement: &70340520923580 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0rc0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70340520923580
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &70340520906520 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- - <
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.3.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *70340520906520
|
39
|
+
description: Plugin for Spork to support Rails.
|
40
|
+
email:
|
41
|
+
- timcharper+spork@gmail.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files:
|
45
|
+
- MIT-LICENSE
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- README.rdoc
|
50
|
+
- MIT-LICENSE
|
51
|
+
- lib/spork/app_framework/rails.rb
|
52
|
+
- lib/spork/ext/rails-reloader.rb
|
53
|
+
- features/cucumber_rails_integration.feature
|
54
|
+
- features/gemsets/rails3.0/Gemfile
|
55
|
+
- features/gemsets/rails3.0/Gemfile.lock
|
56
|
+
- features/gemsets/rails3.1/Gemfile
|
57
|
+
- features/gemsets/rails3.1/Gemfile.lock
|
58
|
+
- features/gemsets/rails3.2/Gemfile
|
59
|
+
- features/gemsets/rails3.2/Gemfile.lock
|
60
|
+
- features/rails_delayed_loading_workarounds.feature
|
61
|
+
- features/rspec_rails_integration.feature
|
62
|
+
- features/steps/rails_steps.rb
|
63
|
+
- features/support/env.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- spec/spork/app_framework/rails_spec.rb
|
66
|
+
- spec/spork/app_framework_spec.rb
|
67
|
+
- spec/tmp/config/environment.rb
|
68
|
+
homepage: http://github.com/timcharper/spork-rails
|
69
|
+
licenses: []
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --main
|
73
|
+
- README.rdoc
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project: spork
|
90
|
+
rubygems_version: 1.8.7
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: spork
|
94
|
+
test_files:
|
95
|
+
- features/cucumber_rails_integration.feature
|
96
|
+
- features/gemsets/rails3.0/Gemfile
|
97
|
+
- features/gemsets/rails3.0/Gemfile.lock
|
98
|
+
- features/gemsets/rails3.1/Gemfile
|
99
|
+
- features/gemsets/rails3.1/Gemfile.lock
|
100
|
+
- features/gemsets/rails3.2/Gemfile
|
101
|
+
- features/gemsets/rails3.2/Gemfile.lock
|
102
|
+
- features/rails_delayed_loading_workarounds.feature
|
103
|
+
- features/rspec_rails_integration.feature
|
104
|
+
- features/steps/rails_steps.rb
|
105
|
+
- features/support/env.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
- spec/spork/app_framework/rails_spec.rb
|
108
|
+
- spec/spork/app_framework_spec.rb
|
109
|
+
- spec/tmp/config/environment.rb
|
110
|
+
has_rdoc:
|