Permalink
Browse files

extract rails support to spork-rails

  • Loading branch information...
1 parent ff24425 commit 9dfc1d9959eeb332090a05a5dc80723e41725646 @timcharper timcharper committed Jan 21, 2012
View
@@ -8,3 +8,4 @@ tmp/
ext/Rakefile
.bundle
TAGS
+*.gem
View
@@ -1,7 +1,9 @@
source :gemcutter
+gemspec
gem 'cucumber', '~> 1.0.0'
-gem 'rspec', '~> 2.6'
+gem 'rspec', '~> 2.8'
gem 'rake'
+gem "spork", :path => File.expand_path("../", __FILE__)
if RUBY_VERSION =~ /^1\.9/
gem 'ruby-debug19'
View
@@ -1,30 +1,40 @@
+PATH
+ remote: .
+ specs:
+ spork (0.9.0)
+
+PATH
+ remote: .
+ specs:
+ spork (0.9.0)
+
GEM
remote: http://rubygems.org/
specs:
archive-tar-minitar (0.5.2)
builder (3.0.0)
columnize (0.3.6)
- cucumber (1.0.0)
+ cucumber (1.0.6)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
- gherkin (~> 2.4.1)
+ gherkin (~> 2.4.18)
json (>= 1.4.6)
- term-ansicolor (>= 1.0.5)
- diff-lcs (1.1.2)
- gherkin (2.4.1)
+ term-ansicolor (>= 1.0.6)
+ diff-lcs (1.1.3)
+ gherkin (2.4.21)
json (>= 1.4.6)
- json (1.5.3)
+ json (1.6.5)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
- rake (0.8.7)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.3)
- rspec-expectations (2.6.0)
+ rake (0.9.2.2)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
+ rspec-mocks (2.8.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
@@ -35,13 +45,14 @@ GEM
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
- term-ansicolor (1.0.5)
+ term-ansicolor (1.0.7)
PLATFORMS
ruby
DEPENDENCIES
cucumber (~> 1.0.0)
rake
- rspec (~> 2.6)
+ rspec (~> 2.8)
ruby-debug19
+ spork!
View
@@ -20,40 +20,42 @@ Spork runs on POSIX systems using fork. It also runs on windows by pre-populatin
== Supported Application Frameworks
-Actually, Spork ~can~ work with any application framework. But, it ships with hooks and helpers to make an "out of the box" experience.
+Spork can work with any application framework, but needs work to prevent application files from being eager loaded.
-* Rails 3.0 (for Rails 2.{1,2,3}.x, please try spork 0.8.x)
-* Padrino
+See https://github.com/sporkrb/spork/wiki/Supported-Application-Frameworks for a list of supported frameworks and their gems.
== INSTALL:
=== rubygems:
- [sudo] gem install spork --prerelease
-
-(Rails 2.x)
-
- [sudo] gem install spork --version 0.8.4
+ [sudo] gem install spork
=== bundler:
Add to your Gemfile:
- gem 'spork', '~> 0.9.0.rc'
-
-(Rails 2.x, use this)
-
- gem 'spork', '~> 0.8'
+ gem 'spork', '~> 0.9.0'
== Usage
From a terminal, change to your project directory.
-Then, bootstrap your spec/spec_helper.rb file.
+Then, bootstrap your test helper file. If running rspec,
+
+ spork rspec --bootstrap
+
+Cucumber:
+
+ spork cucumber --bootstrap
+
+TestUnit:
+
+ (Install the spork-testunit gem)
+ spork test_unit --bootstrap
- spork --bootstrap
+If you don't specifiy a test framework, spork will find one and pick it.
-Next, edit spec/spec_helper.rb and follow the instructions that were put at the top.
+Follow the instructions.
Finally, run spork. A spec DRb server will be running!
@@ -131,4 +133,4 @@ See http://wiki.github.com/sporkrb/spork/troubleshooting
* Roger Pack - JRuby support / Windows
* Donald Parish - Windows support (Magazine strategy)
-Spork (c) 2011 Tim Harper, released under the MIT license
+Spork (c) 2012 Tim Harper, released under the MIT license
@@ -1,107 +0,0 @@
-Feature: Cucumber integration with rails
- As a developer using cucumber and rails
- I want to use Spork with Cucumber
- In order to eliminate the startup cost of my application each time I run them
-
- Background: Sporked env.rb
- Given I am in a fresh rails project named "test_rails_project"
- And the application has a model, observer, route, and application helper
- And a file named "features/support/env.rb" with:
- """
- require 'rubygems'
- require 'spork'
- ENV["RAILS_ENV"] ||= "test"
-
-
- Spork.prefork do
- # Loading more in this block will cause your tests to run faster. However,
- # if you change any configuration or code from libraries loaded here, you'll
- # need to restart spork for it take effect.
-
- # Sets up the Rails environment for Cucumber
- require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
-
- require 'cucumber'
- require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
- require 'rspec/rails'
- require 'cucumber/rails/rspec'
-
- #### this is for this test only #######
- $loaded_stuff << 'prefork block' ######
- #######################################
- end
-
- Spork.each_run do
- #### this is for this test only #######
- $loaded_stuff << 'each_run block' #####
- #######################################
- end
- """
- And a file named "features/cucumber_rails.feature" with:
- """
- Feature: cucumber rails
- Scenario: did it work?
- Then it should work
-
- Scenario: did it work again?
- Then it should work
- """
- And a file named "features/support/cucumber_rails_helper.rb" with:
- """
- $loaded_stuff << 'features/support/cucumber_rails_helper.rb'
- """
- And a file named "config/database.yml" with:
- """
- test:
- adapter: sqlite3
- database: db/test.sqlite3
- timeout: 5000
- """
- And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
- """
- Then "it should work" do
- (Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
- $loaded_stuff.should include('ActiveRecord::Base.establish_connection')
- $loaded_stuff.should include('User')
- $loaded_stuff.should include('UserObserver')
- $loaded_stuff.should include('ApplicationHelper')
- $loaded_stuff.should include('config/routes.rb')
- $loaded_stuff.should include('features/support/cucumber_rails_helper.rb')
- $loaded_stuff.should include('each_run block')
- $loaded_stuff.should include('prefork block')
- puts "It worked!"
- end
-
- Alors /ca marche/ do
- end
- """
- Scenario: Analyzing files were preloaded
- When I run spork --diagnose
- Then the output should not contain "user_observer.rb"
- Then the output should not contain "user.rb"
- Then the output should not contain "app/controllers/application.rb"
- Then the output should not contain "app/controllers/application_controller.rb"
- Then the output should not contain "app/controllers/application_helper.rb"
- Then the output should not contain "features/step_definitions/cucumber_rails_steps.rb"
- Then the output should not contain "features/support/cucumber_rails_helper.rb"
-
- Scenario: Running spork with a rails app and no server
- When I run cucumber --drb features
- Then the error output should contain
- """
- WARNING: No DRb server is running. Running features locally
- """
-
- Scenario: Running spork with a rails app and observers
- When I fire up a spork instance with "spork cucumber"
- And I run cucumber --drb features
- Then the error output should be empty
- And the output should contain "It worked!"
- And the file "log/test.log" should include "hey there"
-
- Scenario: Running spork with a rails app and a non-standard port
- When I fire up a spork instance with "spork cucumber -p 9000"
- And I run cucumber --drb --port 9000 features
- Then the error output should be empty
- And the output should contain "It worked!"
- And the file "log/test.log" should include "hey there"
@@ -11,7 +11,7 @@ Feature: Diagnostic Mode
require 'spork'
Spork.prefork do
- require 'lib/awesome.rb'
+ require './lib/awesome.rb'
require '../external_dependency/super_duper.rb'
end
@@ -38,4 +38,3 @@ Feature: Diagnostic Mode
And the output should contain "spec/spec_helper.rb:5"
And the output should not contain "super_duper.rb"
And the output should not contain "diagnose.rb"
-
@@ -1,14 +0,0 @@
-source :gemcutter
-gem 'sqlite3-ruby', '1.2.5'
-gem 'cucumber', '~> 1.0.0'
-gem 'cucumber-rails', '~> 1.0.0'
-gem "rspec", "2.5.0"
-gem 'rspec-rails', "2.5.0"
-gem 'rails', '3.0.7'
-
-if RUBY_VERSION =~ /^1\.9/
- gem 'ruby-debug19'
-else
- gem 'ruby-debug', '>= 0.10.3'
-end
-gem 'spork', :path => File.expand_path("../../..", File.dirname(__FILE__))
Oops, something went wrong.

0 comments on commit 9dfc1d9

Please sign in to comment.