invo-sporknife 0.1.0.1 → 0.1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.rdoc +12 -40
  2. data/bin/{spork → sporknife} +0 -0
  3. data/features/at_exit_during_each_run.feature +2 -3
  4. data/features/cucumber_rails_integration.feature +18 -7
  5. data/features/rails_delayed_loading_workarounds.feature +13 -48
  6. data/features/rspec_rails_integration.feature +9 -8
  7. data/features/spork_debugger.feature +6 -6
  8. data/features/steps/rails_steps.rb +4 -18
  9. data/features/steps/sandbox_steps.rb +5 -5
  10. data/features/support/env.rb +19 -13
  11. data/lib/spork.rb +12 -12
  12. data/lib/spork/app_framework.rb +1 -4
  13. data/lib/spork/app_framework/rails.rb +117 -41
  14. data/lib/spork/app_framework/rails_stub_files/application.rb +1 -0
  15. data/lib/spork/app_framework/rails_stub_files/application_controller.rb +22 -0
  16. data/lib/spork/app_framework/rails_stub_files/application_helper.rb +3 -0
  17. data/lib/spork/run_strategy.rb +1 -1
  18. data/lib/spork/run_strategy/magazine.rb +25 -44
  19. data/lib/spork/run_strategy/magazine/magazine_slave_provider.rb +19 -16
  20. data/lib/spork/runner.rb +1 -1
  21. data/lib/spork/server.rb +0 -2
  22. data/lib/spork/test_framework.rb +5 -5
  23. data/lib/spork/test_framework/cucumber.rb +4 -4
  24. data/spec/spec_helper.rb +2 -7
  25. data/spec/spork/app_framework/rails_spec.rb +4 -4
  26. data/spec/spork/forker_spec.rb +1 -1
  27. data/spec/spork/run_strategy/forking_spec.rb +1 -1
  28. data/spec/spork/test_framework/cucumber_spec.rb +1 -1
  29. data/spec/spork/test_framework/rspec_spec.rb +1 -1
  30. data/spec/spork/test_framework_spec.rb +24 -0
  31. data/spec/spork_spec.rb +5 -7
  32. metadata +12 -18
  33. data/Gemfile +0 -6
  34. data/features/gemfiles/rails3.0/Gemfile +0 -10
  35. data/features/gemfiles/rails3.0/Gemfile.lock +0 -116
  36. data/features/support/bundler_helpers.rb +0 -41
  37. data/spec/spork/test_framework_shared_examples.rb +0 -23
data/README.rdoc CHANGED
@@ -12,14 +12,6 @@ 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
-
23
15
  == Supported Testing Frameworks
24
16
 
25
17
  * Rspec
@@ -30,22 +22,22 @@ And more to come! Vote for your favorite at http://github.com/timcharper/spork/
30
22
 
31
23
  == Supported Application Frameworks
32
24
 
33
- Actually, Spork ~can~ work with any application framework. But, it ships with hooks and helpers to make an "out of the box" experience.
25
+ 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"
34
26
 
35
- * Rails 3.0 (for Rails 2.{1,2,3}.x, please try spork 0.8.x)
36
- * Padrino
27
+ * Rails
37
28
 
38
- == INSTALL:
29
+ More can be added! Vote for your favorite at http://github.com/timcharper/spork/issues
39
30
 
40
- === rubygems:
31
+ == INSTALL:
41
32
 
42
33
  [sudo] gem install spork
43
34
 
44
- === bundler:
45
-
46
- Add to your Gemfile:
35
+ alternatively:
47
36
 
48
- gem "spork"
37
+ git clone git://github.com/timcharper/spork.git
38
+ cd spork
39
+ gem build spork.gemspec
40
+ sudo gem install spork.gemspec
49
41
 
50
42
  == Usage
51
43
 
@@ -80,7 +72,7 @@ To get the TextMate RSpec bundle to use spork, go to config->advanced->shell var
80
72
 
81
73
  To run from the command line, use:
82
74
 
83
- rspec --drb spec/lib/my_spec.rb
75
+ spec --drb spec/lib/my_spec.rb
84
76
 
85
77
  Or, you could add the following flag to your +spec.opts+ file.
86
78
 
@@ -96,26 +88,6 @@ Use this as a guideline when "Sporking" your features/support/env.rb file
96
88
 
97
89
  http://gist.github.com/123370
98
90
 
99
- == Running the Spork test suite
100
-
101
- If you wish to hack on spork, you will want to run the automated test suite to make sure your changes don't break anything. Spork uses bundler to manage and install dependencies. To start:
102
-
103
- bundle install
104
-
105
- Then, to run the specs:
106
-
107
- bundle exec rspec spec/
108
-
109
- (or, alternatively...)
110
-
111
- bundle exec rake
112
-
113
- === running features ===
114
-
115
- Essentially:
116
-
117
- bundle exec cucumber features
118
-
119
91
  == Some potential issues and ways to overcome them:
120
92
 
121
93
  See http://wiki.github.com/timcharper/spork/troubleshooting
@@ -124,6 +96,6 @@ See http://wiki.github.com/timcharper/spork/troubleshooting
124
96
 
125
97
  * Ben Mabey - help with documentation, testing, suggestions, patches, and bringing Cucumber support.
126
98
  * David Chelimsky - for the fine RSpec testing framework, and the original rspec-rails spec_server implementation, which Spork has built upon.
127
- * LeadTune - just for being an awesome place to work.
99
+ * Lead Media Partners - just for being an awesome place to work.
128
100
 
129
- Spork (c) 2010 Tim Harper, released under the MIT license
101
+ Spork (c) 2009 Tim Harper, released under the MIT license
File without changes
@@ -7,7 +7,7 @@ Feature: At exit during each run
7
7
  Given a file named "spec/spec_helper.rb" with:
8
8
  """
9
9
  require 'rubygems'
10
- require 'rspec'
10
+ require 'spec'
11
11
  Spork.prefork do
12
12
  puts "loading"
13
13
  at_exit { puts "prefork at_exit called" }
@@ -23,7 +23,6 @@ Feature: At exit during each run
23
23
 
24
24
  And a file named "spec/did_it_work_spec.rb" with:
25
25
  """
26
- require 'spec_helper'
27
26
  describe "Did it work?" do
28
27
  it "checks to see if all worked" do
29
28
  puts "ran specs"
@@ -31,6 +30,6 @@ Feature: At exit during each run
31
30
  end
32
31
  """
33
32
  When I fire up a spork instance with "spork rspec"
34
- And I run rspec --drb spec/did_it_work_spec.rb
33
+ And I run spec --drb spec/did_it_work_spec.rb
35
34
  Then the output should contain "second first"
36
35
  Then the output should not contain "prefork at_exit called"
@@ -10,8 +10,6 @@ Feature: Cucumber integration with rails
10
10
  """
11
11
  require 'rubygems'
12
12
  require 'spork'
13
- ENV["RAILS_ENV"] ||= "test"
14
-
15
13
 
16
14
  Spork.prefork do
17
15
  # Loading more in this block will cause your tests to run faster. However,
@@ -19,11 +17,12 @@ Feature: Cucumber integration with rails
19
17
  # need to restart spork for it take effect.
20
18
 
21
19
  # Sets up the Rails environment for Cucumber
20
+ ENV['RAILS_ENV'] = "features"
22
21
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
23
22
 
24
23
  require 'cucumber'
25
24
  require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
26
- require 'rspec/rails'
25
+ require 'spec/rails'
27
26
  require 'cucumber/rails/rspec'
28
27
 
29
28
  #### this is for this test only #######
@@ -46,15 +45,26 @@ Feature: Cucumber integration with rails
46
45
  Scenario: did it work again?
47
46
  Then it should work
48
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
+ """
49
55
  And a file named "features/support/cucumber_rails_helper.rb" with:
50
56
  """
51
57
  $loaded_stuff << 'features/support/cucumber_rails_helper.rb'
52
58
  """
59
+ And a file named "config/environments/features.rb" with:
60
+ """
61
+ # your cucumber env here
62
+ """
53
63
  And a file named "config/database.yml" with:
54
64
  """
55
- test:
65
+ features:
56
66
  adapter: sqlite3
57
- database: db/test.sqlite3
67
+ database: db/features.sqlite3
58
68
  timeout: 5000
59
69
  """
60
70
  And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
@@ -82,6 +92,7 @@ Feature: Cucumber integration with rails
82
92
  Then the output should not contain "app/controllers/application.rb"
83
93
  Then the output should not contain "app/controllers/application_controller.rb"
84
94
  Then the output should not contain "app/controllers/application_helper.rb"
95
+ Then the output should not contain "config/routes.rb"
85
96
  Then the output should not contain "features/step_definitions/cucumber_rails_steps.rb"
86
97
  Then the output should not contain "features/support/cucumber_rails_helper.rb"
87
98
 
@@ -97,11 +108,11 @@ Feature: Cucumber integration with rails
97
108
  And I run cucumber --drb features
98
109
  Then the error output should be empty
99
110
  And the output should contain "It worked!"
100
- And the file "log/test.log" should include "hey there"
111
+ And the file "log/features.log" should include "hey there"
101
112
 
102
113
  Scenario: Running spork with a rails app and a non-standard port
103
114
  When I fire up a spork instance with "spork cucumber -p 9000"
104
115
  And I run cucumber --drb --port 9000 features
105
116
  Then the error output should be empty
106
117
  And the output should contain "It worked!"
107
- And the file "log/test.log" should include "hey there"
118
+ And the file "log/features.log" should include "hey there"
@@ -1,6 +1,7 @@
1
1
  Feature: Rails Delayed Work arounds
2
2
  To allow a rails developer to update as many parts of his application as possible without needing to restart Spork
3
3
  Spork automatically tells rails to delay loading certain parts of the application until after the fork occurs
4
+ Providing work arounds
4
5
 
5
6
  Background: Rails App with RSpec and Spork
6
7
 
@@ -9,26 +10,19 @@ Feature: Rails Delayed Work arounds
9
10
  """
10
11
  require 'rubygems'
11
12
  require 'spork'
12
- require 'spork/ext/ruby-debug'
13
13
 
14
14
  Spork.prefork do
15
15
  require File.dirname(__FILE__) + '/../config/environment.rb'
16
- require 'rspec'
17
- require 'rspec/rails'
16
+ require 'spec'
17
+ require 'spec/rails'
18
18
  end
19
19
 
20
20
  Spork.each_run do
21
21
  end
22
22
  """
23
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
24
  Given a file named "app/helpers/application_helper.rb" with:
30
25
  """
31
- require 'reverseatron'
32
26
  module ApplicationHelper
33
27
  include Reverseatron
34
28
  end
@@ -70,9 +64,8 @@ Feature: Rails Delayed Work arounds
70
64
  Scenario: within a view rendered by a controller, calling helper methods from an included module in ApplicationHelper
71
65
  Given a file named "spec/controllers/users_controller_spec.rb" with:
72
66
  """
73
- require "spec_helper"
74
67
  describe UsersController do
75
- render_views
68
+ integrate_views
76
69
  it "renders a page, using a method inherited from ApplicationController" do
77
70
  get :index
78
71
  response.body.should_not include('Original View')
@@ -88,18 +81,17 @@ Feature: Rails Delayed Work arounds
88
81
  """
89
82
  Given a file named "spec/views/index.html.erb_spec.rb" with:
90
83
  """
91
- require "spec_helper"
92
84
  describe "/users/index.html.erb" do
93
85
 
94
86
  it "renders the view" do
95
87
  render
96
- rendered.should_not include('Original View')
88
+ response.body.should_not include('Original View')
97
89
  puts "Views are not being cached when rendering directly"
98
90
 
99
- rendered.should include('listing users')
91
+ response.body.should include('listing users')
100
92
  puts "Controller stack is functioning when rendering directly"
101
93
 
102
- rendered.should include('hello miscellaneous')
94
+ response.body.should include('hello miscellaneous')
103
95
  puts "All helper modules were included when rendering directly"
104
96
  end
105
97
  end
@@ -112,39 +104,12 @@ Feature: Rails Delayed Work arounds
112
104
  <p>Here is a list of users</p>
113
105
  """
114
106
 
115
- And I run rspec --drb spec/controllers/users_controller_spec.rb
107
+ And I run spec --drb spec/controllers/users_controller_spec.rb
116
108
  Then the output should contain "Controller stack is functioning when rendering from a controller"
117
- And the output should contain "Views are not being cached when rendering from a controller"
118
- And the output should contain "All helper modules were included when rendering from a controller"
109
+ Then the output should contain "Views are not being cached when rendering from a controller"
110
+ Then the output should contain "All helper modules were included when rendering from a controller"
119
111
 
120
- When I run rspec --drb spec/views/index.html.erb_spec.rb
112
+ And I run spec --drb spec/views/index.html.erb_spec.rb
121
113
  Then the output should contain "Controller stack is functioning when rendering directly"
122
- And the output should contain "Views are not being cached when rendering directly"
123
- And the output should contain "All helper modules were included when rendering directly"
124
-
125
- Given the contents of "app/helpers/application_helper.rb" are changed to:
126
- """
127
- module ApplicationHelper
128
- def make_it_loud(message)
129
- message.upcase
130
- end
131
- end
132
- """
133
- And the contents of "app/views/users/index.html.erb" are changed to:
134
- """
135
- <%= make_it_loud('listing users') %>
136
- """
137
- And the contents of "spec/controllers/users_controller_spec.rb" are changed to:
138
- """
139
- require "spec_helper"
140
- describe UsersController do
141
- render_views
142
- it "renders a page, using a method inherited from ApplicationController" do
143
- get :index
144
- response.body.should include('LISTING USERS')
145
- puts "Helpers aren't being cached"
146
- end
147
- end
148
- """
149
- When I run rspec --drb spec/controllers/users_controller_spec.rb
150
- Then the output should contain "Helpers aren't being cached"
114
+ Then the output should contain "Views are not being cached when rendering directly"
115
+ Then the output should contain "All helper modules were included when rendering directly"
@@ -4,6 +4,7 @@ Feature: Rails Integration
4
4
  Providing default hooks and behaviors
5
5
 
6
6
  Background: Rails App with RSpec and Spork
7
+
7
8
  Given I am in a fresh rails project named "test_rails_project"
8
9
  And a file named "spec/spec_helper.rb" with:
9
10
  """
@@ -15,8 +16,8 @@ Feature: Rails Integration
15
16
  # if you change any configuration or code from libraries loaded here, you'll
16
17
  # need to restart spork for it take effect.
17
18
  require File.dirname(__FILE__) + '/../config/environment.rb'
18
- require 'rspec'
19
- require 'rspec/rails'
19
+ require 'spec'
20
+ require 'spec/rails'
20
21
 
21
22
  #### this is for this test only #######
22
23
  $loaded_stuff << 'prefork block' ######
@@ -39,15 +40,14 @@ Feature: Rails Integration
39
40
  Then the output should not contain "app/controllers/application.rb"
40
41
  Then the output should not contain "app/controllers/application_controller.rb"
41
42
  Then the output should not contain "app/controllers/application_helper.rb"
42
- # Then the output should not contain "config/routes.rb"
43
+ Then the output should not contain "config/routes.rb"
43
44
 
44
45
  Scenario: Running spork with a rails app and observers
45
46
  Given a file named "spec/did_it_work_spec.rb" with:
46
47
  """
47
- require 'spec_helper'
48
48
  describe "Did it work?" do
49
49
  it "checks to see if all worked" do
50
- Spork.using_spork?.should == true
50
+ Spork.state.should == :using_spork
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')
@@ -61,18 +61,19 @@ Feature: Rails Integration
61
61
  end
62
62
  """
63
63
  When I fire up a spork instance with "spork rspec"
64
- And I run rspec --drb spec/did_it_work_spec.rb
64
+ And I run spec --drb spec/did_it_work_spec.rb
65
65
  Then the error output should be empty
66
66
  And the output should contain "Specs successfully run within spork, and all initialization files were loaded"
67
67
  And the file "log/test.log" should include "hey there"
68
68
 
69
69
 
70
70
  Scenario: Running spork with a rails app and a non-standard port
71
+ Given this scenario is pending until rspec releases a version that supports --port
71
72
  Given a file named "spec/did_it_work_spec.rb" with:
72
73
  """
73
74
  describe "Did it work?" do
74
75
  it "checks to see if all worked" do
75
- Spork.using_spork?.should == true
76
+ Spork.state.should == :using_spork
76
77
  (Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
77
78
  $loaded_stuff.should include('ActiveRecord::Base.establish_connection')
78
79
  $loaded_stuff.should include('User')
@@ -86,7 +87,7 @@ Feature: Rails Integration
86
87
  end
87
88
  """
88
89
  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
+ And I run spec --drb --port 7000 spec/did_it_work_spec.rb
90
91
  Then the error output should be empty
91
92
  And the output should contain "Specs successfully run within spork, and all initialization files were loaded"
92
93
  And the file "log/test.log" should include "hey there"
@@ -10,12 +10,12 @@ Feature: Spork Debugger integration
10
10
  require 'spork'
11
11
  require 'spork/ext/ruby-debug'
12
12
 
13
- Spork.prefork { require 'rspec' }
13
+ Spork.prefork { require 'spec' }
14
14
  Spork.each_run { }
15
15
  """
16
16
  And a file named "spec/debugger_spec.rb" with:
17
17
  """
18
- require 'spec_helper.rb'
18
+ require File.dirname(__FILE__) + '/spec_helper.rb'
19
19
 
20
20
  describe "Debugger" do
21
21
  it "should debug" do
@@ -30,7 +30,7 @@ Feature: Spork Debugger integration
30
30
  """
31
31
 
32
32
  When I fire up a spork instance with "spork rspec"
33
- And I run this in the background: rspec --drb spec/debugger_spec.rb
33
+ And I run this in the background: spec --drb spec/debugger_spec.rb
34
34
 
35
35
  Then the spork window should output a line containing "Debug Session Started"
36
36
 
@@ -57,7 +57,7 @@ Feature: Spork Debugger integration
57
57
 
58
58
  require 'spork/ext/ruby-debug'
59
59
 
60
- Spork.prefork { require 'rspec' }
60
+ Spork.prefork { require 'spec' }
61
61
  Spork.each_run { }
62
62
  """
63
63
 
@@ -75,7 +75,7 @@ Feature: Spork Debugger integration
75
75
  """
76
76
 
77
77
  When I fire up a spork instance with "spork rspec"
78
- And I run this in the background: rspec --drb spec/debugger_spec.rb
78
+ And I run this in the background: spec --drb spec/debugger_spec.rb
79
79
 
80
80
  Then the spork window should output a line containing "Debug Session Started"
81
81
 
@@ -97,7 +97,7 @@ Feature: Spork Debugger integration
97
97
  STDERR.puts("Spork is ready and listening") # trick out the start spork step to believe spork is ready... naughty, but effective.
98
98
  @message = "it worked"
99
99
  debugger
100
- Spork.prefork { require 'rspec' }
100
+ Spork.prefork { require 'spec' }
101
101
  Spork.each_run { }
102
102
  """
103
103
 
@@ -1,27 +1,13 @@
1
1
  Given /^I am in a fresh rails project named "(.+)"$/ do |folder_name|
2
2
  @current_dir = SporkWorld::SANDBOX_DIR
3
- # version_argument = ENV['RAILS_VERSION'] ? "_#{ENV['RAILS_VERSION']}_" : nil
3
+ version_argument = ENV['RAILS_VERSION'] ? "_#{ENV['RAILS_VERSION']}_" : nil
4
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
5
+ run([SporkWorld::RUBY_BINARY, '-I', Cucumber::LIBDIR, %x{which rails}.chomp, version_argument, folder_name].compact * " ")
11
6
  @current_dir = File.join(File.join(SporkWorld::SANDBOX_DIR, folder_name))
12
- in_current_dir do
13
- FileUtils.ln_sf(ENV["BUNDLE_GEMFILE"], "Gemfile")
14
- FileUtils.ln_sf(ENV["BUNDLE_GEMFILE"] + ".lock", "Gemfile.lock")
15
- FileUtils.ln_sf(File.dirname(ENV["BUNDLE_GEMFILE"]) + "/.bundle", ".bundle")
16
- end
17
7
  end
18
8
 
19
9
 
20
10
  Given "the application has a model, observer, route, and application helper" do
21
- Given 'the following code appears in "config/application.rb" after /^end/:',
22
- """
23
- ActiveRecord::Base.observers = [:user_observer]
24
- """
25
11
  Given 'a file named "app/models/user.rb" with:',
26
12
  """
27
13
  class User < ActiveRecord::Base
@@ -57,11 +43,11 @@ Given "the application has a model, observer, route, and application helper" do
57
43
  class ActiveRecord::Base
58
44
  class << self
59
45
  def establish_connection_with_load_logging(*args)
60
- $loaded_stuff << 'ActiveRecord::Base.establish_connection'
61
46
  establish_connection_without_load_logging(*args)
47
+ $loaded_stuff << 'ActiveRecord::Base.establish_connection'
62
48
  end
63
49
  alias_method_chain :establish_connection, :load_logging
64
50
  end
65
51
  end
66
52
  """
67
- end
53
+ end