Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

version 3.2.0 - works against rails 3.0.0 to 3.2.0

  • Loading branch information...
commit b85d17630e8404b123c481c7a39a14e8bbd8f3a6 1 parent 671efa4
@timcharper timcharper authored
View
1  .gitignore
@@ -0,0 +1 @@
+tmp
View
14 Gemfile
@@ -0,0 +1,14 @@
+source :gemcutter
+gemspec
+# rails is required by the gemspec
+
+gem 'cucumber', '~> 1.0.0'
+gem 'rspec', '~> 2.8'
+gem 'rake'
+gem "spork-rails", :path => "./"
+
+if RUBY_VERSION =~ /^1\.9/
+ gem 'ruby-debug19'
+else
+ gem 'ruby-debug'
+end
View
136 Gemfile.lock
@@ -0,0 +1,136 @@
+PATH
+ remote: .
+ specs:
+ spork-rails (3.1.0)
+ rails (>= 3.0.0, < 3.3.0)
+ spork (>= 1.0rc0)
+
+PATH
+ remote: .
+ specs:
+ spork-rails (3.1.0)
+ rails (>= 3.0.0, < 3.3.0)
+ spork (>= 1.0rc0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.2.0)
+ actionpack (= 3.2.0)
+ mail (~> 2.4.0)
+ actionpack (3.2.0)
+ activemodel (= 3.2.0)
+ activesupport (= 3.2.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.0)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.0)
+ activesupport (= 3.2.0)
+ builder (~> 3.0.0)
+ activerecord (3.2.0)
+ activemodel (= 3.2.0)
+ activesupport (= 3.2.0)
+ arel (~> 3.0.0)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.0)
+ activemodel (= 3.2.0)
+ activesupport (= 3.2.0)
+ activesupport (3.2.0)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ archive-tar-minitar (0.5.2)
+ arel (3.0.0)
+ builder (3.0.0)
+ columnize (0.3.6)
+ cucumber (1.0.6)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.4.18)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ gherkin (2.4.21)
+ json (>= 1.4.6)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.0)
+ json (1.6.5)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.4.1)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.4.0)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.0)
+ actionmailer (= 3.2.0)
+ actionpack (= 3.2.0)
+ activerecord (= 3.2.0)
+ activeresource (= 3.2.0)
+ activesupport (= 3.2.0)
+ bundler (~> 1.0)
+ railties (= 3.2.0)
+ railties (3.2.0)
+ actionpack (= 3.2.0)
+ activesupport (= 3.2.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ 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.8.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ spork (1.0.0rc0)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ term-ansicolor (1.0.7)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ cucumber (~> 1.0.0)
+ rake
+ rspec (~> 2.8)
+ ruby-debug19
+ spork-rails!
View
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Tim Harper
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
56 README.rdoc
@@ -0,0 +1,56 @@
+= Spork Rails
+
+This plugin is for running spork in Ruby-on-Rails applications.
+
+== Version compatibility map:
+
+Versions correspond to the latest Rails minor release. Gem is backwards compatible with rails as far as it makes sense to.
+
+* spork-rails 3.2.0: Rails 3.0.0 - 3.2.x
+
+= Usage:
+
+Add to your Gemfile:
+
+ gem "spork-rails"
+
+ # (Since spork-rails depends on spork, it is not necessary to put both spork and spork-rails in your Gemfile)
+
+== INSTALL:
+
+NOTICE: If using spork with rails, use the spork-rails gem.
+
+=== bundler:
+
+Add to your Gemfile:
+
+ gem 'spork-rails'
+
+== Usage
+
+From a terminal, change to your project directory.
+
+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
+
+(If you don't specifiy a test framework, spork will find one and pick it.)
+
+Follow the instructions.
+
+Finally, run spork. A spec DRb server will be running!
+
+ spork
+
+== See also
+
+See https://github.com/sporkrb/spork for more instructions.
View
107 features/cucumber_rails_integration.feature
@@ -0,0 +1,107 @@
+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"
View
15 features/gemsets/rails3.0/Gemfile
@@ -0,0 +1,15 @@
+source :gemcutter
+gem 'sqlite3', '~> 1.3.4'
+gem 'cucumber', '~> 1.0.6'
+# gem 'cucumber-rails', '~> 1.0.6'
+gem "rspec", "2.8.0"
+gem 'rspec-rails'
+gem 'rails', '~> 3.0.7'
+
+if RUBY_VERSION =~ /^1\.9/
+ gem 'ruby-debug19'
+else
+ gem 'ruby-debug', '>= 0.10.3'
+end
+gem 'spork', "~> 1.0.0rc0"
+gem 'spork-rails', :path => "../../../"
View
129 features/gemsets/rails3.0/Gemfile.lock
@@ -0,0 +1,129 @@
+PATH
+ remote: ../../../
+ specs:
+ spork-rails (3.1.0)
+ rails (>= 3.0.0, < 3.3.0)
+ spork (>= 1.0rc0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.11)
+ actionpack (= 3.0.11)
+ mail (~> 2.2.19)
+ actionpack (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.5.0)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.11)
+ activesupport (= 3.0.11)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ arel (~> 2.0.10)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ activesupport (3.0.11)
+ archive-tar-minitar (0.5.2)
+ arel (2.0.10)
+ builder (2.1.2)
+ columnize (0.3.6)
+ cucumber (1.0.6)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.4.18)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ diff-lcs (1.1.3)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ gherkin (2.4.21)
+ json (>= 1.4.6)
+ i18n (0.5.0)
+ json (1.6.5)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.2.19)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ polyglot (0.3.3)
+ rack (1.2.5)
+ rack-mount (0.6.14)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.11)
+ actionmailer (= 3.0.11)
+ actionpack (= 3.0.11)
+ activerecord (= 3.0.11)
+ activeresource (= 3.0.11)
+ activesupport (= 3.0.11)
+ bundler (~> 1.0)
+ railties (= 3.0.11)
+ railties (3.0.11)
+ actionpack (= 3.0.11)
+ activesupport (= 3.0.11)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.4)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ 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.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ spork (1.0.0rc0)
+ sqlite3 (1.3.5)
+ term-ansicolor (1.0.7)
+ thor (0.14.6)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ cucumber (~> 1.0.6)
+ rails (~> 3.0.7)
+ rspec (= 2.8.0)
+ rspec-rails
+ ruby-debug19
+ spork (~> 1.0.0rc0)
+ spork-rails!
+ sqlite3 (~> 1.3.4)
View
15 features/gemsets/rails3.1/Gemfile
@@ -0,0 +1,15 @@
+source :gemcutter
+gem 'sqlite3', '~> 1.3.4'
+gem 'cucumber', '~> 1.0.6'
+# gem 'cucumber-rails', '~> 1.0.6'
+gem "rspec", "2.8.0"
+gem 'rspec-rails'
+gem 'rails', '~> 3.1.0'
+
+if RUBY_VERSION =~ /^1\.9/
+ gem 'ruby-debug19'
+else
+ gem 'ruby-debug', '>= 0.10.3'
+end
+gem 'spork', "~> 1.0.0rc0"
+gem 'spork-rails', :path => "../../../"
View
140 features/gemsets/rails3.1/Gemfile.lock
@@ -0,0 +1,140 @@
+PATH
+ remote: ../../../
+ specs:
+ spork-rails (3.1.0)
+ rails (>= 3.0.0, < 3.3.0)
+ spork (>= 1.0rc0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
+ mail (~> 2.3.0)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ archive-tar-minitar (0.5.2)
+ arel (2.2.1)
+ builder (3.0.0)
+ columnize (0.3.6)
+ cucumber (1.0.6)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.4.18)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ gherkin (2.4.21)
+ json (>= 1.4.6)
+ hike (1.2.1)
+ i18n (0.6.0)
+ json (1.6.5)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.3.6)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
+ bundler (~> 1.0)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ 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.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ spork (1.0.0rc0)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ term-ansicolor (1.0.7)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ cucumber (~> 1.0.6)
+ rails (~> 3.1.0)
+ rspec (= 2.8.0)
+ rspec-rails
+ ruby-debug19
+ spork (~> 1.0.0rc0)
+ spork-rails!
+ sqlite3 (~> 1.3.4)
View
15 features/gemsets/rails3.2/Gemfile
@@ -0,0 +1,15 @@
+source :gemcutter
+gem 'sqlite3', '~> 1.3.4'
+gem 'cucumber', '~> 1.0.6'
+# gem 'cucumber-rails', '~> 1.0.6'
+gem "rspec", "2.8.0"
+gem 'rspec-rails'
+gem 'rails', '~> 3.2.0'
+
+if RUBY_VERSION =~ /^1\.9/
+ gem 'ruby-debug19'
+else
+ gem 'ruby-debug', '>= 0.10.3'
+end
+gem 'spork', "~> 1.0.0rc0"
+gem 'spork-rails', :path => "../../../"
View
138 features/gemsets/rails3.2/Gemfile.lock
@@ -0,0 +1,138 @@
+PATH
+ remote: ../../../
+ specs:
+ spork-rails (3.1.0)
+ rails (>= 3.0.0, < 3.3.0)
+ spork (>= 1.0rc0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.2.0)
+ actionpack (= 3.2.0)
+ mail (~> 2.4.0)
+ actionpack (3.2.0)
+ activemodel (= 3.2.0)
+ activesupport (= 3.2.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.0)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.0)
+ activesupport (= 3.2.0)
+ builder (~> 3.0.0)
+ activerecord (3.2.0)
+ activemodel (= 3.2.0)
+ activesupport (= 3.2.0)
+ arel (~> 3.0.0)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.0)
+ activemodel (= 3.2.0)
+ activesupport (= 3.2.0)
+ activesupport (3.2.0)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ archive-tar-minitar (0.5.2)
+ arel (3.0.0)
+ builder (3.0.0)
+ columnize (0.3.6)
+ cucumber (1.0.6)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.4.18)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ gherkin (2.4.21)
+ json (>= 1.4.6)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.0)
+ json (1.6.5)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.4.1)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.4.0)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.0)
+ actionmailer (= 3.2.0)
+ actionpack (= 3.2.0)
+ activerecord (= 3.2.0)
+ activeresource (= 3.2.0)
+ activesupport (= 3.2.0)
+ bundler (~> 1.0)
+ railties (= 3.2.0)
+ railties (3.2.0)
+ actionpack (= 3.2.0)
+ activesupport (= 3.2.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ 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.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ spork (1.0.0rc0)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ term-ansicolor (1.0.7)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ cucumber (~> 1.0.6)
+ rails (~> 3.2.0)
+ rspec (= 2.8.0)
+ rspec-rails
+ ruby-debug19
+ spork (~> 1.0.0rc0)
+ spork-rails!
+ sqlite3 (~> 1.3.4)
View
177 features/rails_delayed_loading_workarounds.feature
@@ -0,0 +1,177 @@
+Feature: Rails Delayed Work arounds
+ To allow a rails developer to update as many parts of his application as possible without needing to restart Spork
+ Spork automatically tells rails to delay loading certain parts of the application until after the fork occurs
+
+ Background: Rails App with RSpec and Spork
+
+ Given I am in a fresh rails project named "test_rails_project"
+ And a file named "spec/spec_helper.rb" with:
+ """
+ require 'rubygems'
+ require 'spork'
+ require 'spork/ext/ruby-debug'
+
+ Spork.prefork do
+ require File.dirname(__FILE__) + '/../config/environment.rb'
+ require 'rspec'
+ require 'rspec/rails'
+ end
+
+ Spork.each_run do
+ end
+ """
+ And the application has a model, observer, route, and application helper
+
+ Given the following code appears in "config/routes.rb" after /routes\.draw/:
+ """
+ resources :users
+ """
+ Given a file named "app/helpers/application_helper.rb" with:
+ """
+ require 'reverseatron'
+ module ApplicationHelper
+ include Reverseatron
+ end
+ """
+ Given a file named "lib/reverseatron.rb" with:
+ """
+ module Reverseatron
+ def reverse_text(txt)
+ txt.reverse
+ end
+ end
+ """
+ Given a file named "app/controllers/users_controller.rb" with:
+ """
+ class UsersController < ApplicationController
+ $loaded_stuff << 'UsersController'
+ def index
+ @users = []
+ end
+ end
+ """
+ Given a file named "app/helpers/misc_helper.rb" with:
+ """
+ module MiscHelper
+ def misc_helper_method
+ 'hello miscellaneous'
+ end
+ end
+ """
+ Given a file named "app/helpers/users_helper.rb" with:
+ """
+ module UsersHelper
+ end
+ """
+ Given a file named "app/views/users/index.html.erb" with:
+ """
+ Original View
+ """
+ Scenario: respecting custom autoload paths
+ Given the following code appears in "config/application.rb" after /class Application < Rails::Application/:
+ """
+ config.autoload_paths << './app/models/non_standard'
+ """
+
+ And a file named "app/models/non_standard/boogie.rb" with:
+ """
+ class Boogie
+ def boogie
+ 'Boogie Robots!'
+ end
+ end
+ """
+ And a file named "spec/models/non_standard/boogie_spec.rb" with:
+ """
+ describe Boogie do
+ it 'knows how to boogie' do
+ Boogie.new.boogie.should include('Boogie')
+ puts 'BOOGIE!!!'
+ end
+ end
+ """
+ When I fire up a spork instance with "spork rspec"
+ And I run rspec --drb spec/models/non_standard/boogie_spec.rb
+ Then the output should contain "BOOGIE!!!"
+
+ Scenario: within a view rendered by a controller, calling helper methods from an included module in ApplicationHelper
+ Given a file named "spec/controllers/users_controller_spec.rb" with:
+ """
+ require "spec_helper"
+ describe UsersController do
+ render_views
+ it "renders a page, using a method inherited from ApplicationController" do
+ get :index
+ response.body.should_not include('Original View')
+ puts "Views are not being cached when rendering from a controller"
+
+ response.body.should include('listing users')
+ puts "Controller stack is functioning when rendering from a controller"
+
+ response.body.should include('hello miscellaneous')
+ puts "All helper modules were included when rendering from a controller"
+ end
+ end
+ """
+ Given a file named "spec/views/index.html.erb_spec.rb" with:
+ """
+ require "spec_helper"
+ describe "/users/index.html.erb" do
+
+ it "renders the view" do
+ render
+ rendered.should_not include('Original View')
+ puts "Views are not being cached when rendering directly"
+
+ rendered.should include('listing users')
+ puts "Controller stack is functioning when rendering directly"
+
+ rendered.should include('hello miscellaneous')
+ puts "All helper modules were included when rendering directly"
+ end
+ end
+ """
+ When I fire up a spork instance with "spork rspec"
+ And the contents of "app/views/users/index.html.erb" are changed to:
+ """
+ <%= reverse_text('listing users'.reverse) %>
+ <%= misc_helper_method rescue nil %>
+ <p>Here is a list of users</p>
+ """
+
+ And I run rspec --drb spec/controllers/users_controller_spec.rb
+ Then the output should contain "Controller stack is functioning when rendering from a controller"
+ And the output should contain "Views are not being cached when rendering from a controller"
+ And the output should contain "All helper modules were included when rendering from a controller"
+
+ When I run rspec --drb spec/views/index.html.erb_spec.rb
+ Then the output should contain "Controller stack is functioning when rendering directly"
+ And the output should contain "Views are not being cached when rendering directly"
+ And the output should contain "All helper modules were included when rendering directly"
+
+ Given the contents of "app/helpers/application_helper.rb" are changed to:
+ """
+ module ApplicationHelper
+ def make_it_loud(message)
+ message.upcase
+ end
+ end
+ """
+ And the contents of "app/views/users/index.html.erb" are changed to:
+ """
+ <%= make_it_loud('listing users') %>
+ """
+ And the contents of "spec/controllers/users_controller_spec.rb" are changed to:
+ """
+ require "spec_helper"
+ describe UsersController do
+ render_views
+ it "renders a page, using a method inherited from ApplicationController" do
+ get :index
+ response.body.should include('LISTING USERS')
+ puts "Helpers aren't being cached"
+ end
+ end
+ """
+ When I run rspec --drb spec/controllers/users_controller_spec.rb
+ Then the output should contain "Helpers aren't being cached"
View
92 features/rspec_rails_integration.feature
@@ -0,0 +1,92 @@
+Feature: Rails Integration
+ To get a developer up and running quickly
+ Spork automatically integrates with rails
+ Providing default hooks and behaviors
+
+ Background: Rails App with RSpec and Spork
+ Given I am in a fresh rails project named "test_rails_project"
+ And a file named "spec/spec_helper.rb" with:
+ """
+ require 'rubygems'
+ require 'spork'
+
+ Spork.prefork do
+ # Loading more in this block will cause your specs 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.
+ require File.dirname(__FILE__) + '/../config/environment.rb'
+ require 'rspec'
+ require 'rspec/rails'
+
+ #### this is for this test only #######
+ $loaded_stuff << 'prefork block' ######
+ #######################################
+ end
+
+ Spork.each_run do
+ # This code will be run each time you run your specs.
+
+ #### this is for this test only #######
+ $loaded_stuff << 'each_run block' #####
+ #######################################
+ end
+ """
+ And the application has a model, observer, route, and application helper
+ 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 "config/routes.rb"
+
+ Scenario: Running spork with a rails app and observers
+ Given a file named "spec/did_it_work_spec.rb" with:
+ """
+ require 'spec_helper'
+ describe "Did it work?" do
+ it "checks to see if all worked" do
+ Spork.using_spork?.should == true
+ (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('each_run block')
+ $loaded_stuff.should include('prefork block')
+ puts "Specs successfully run within spork, and all initialization files were loaded"
+ end
+ end
+ """
+ When I fire up a spork instance with "spork rspec"
+ And I run rspec --drb spec/did_it_work_spec.rb
+ Then the error output should be empty
+ And the output should contain "Specs successfully run within spork, and all initialization files were loaded"
+ And the file "log/test.log" should include "hey there"
+
+
+ Scenario: Running spork with a rails app and a non-standard port
+ Given a file named "spec/did_it_work_spec.rb" with:
+ """
+ describe "Did it work?" do
+ it "checks to see if all worked" do
+ Spork.using_spork?.should == true
+ (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('each_run block')
+ $loaded_stuff.should include('prefork block')
+ puts "Specs successfully run within spork, and all initialization files were loaded"
+ end
+ end
+ """
+ When I fire up a spork instance with "spork rspec --port 7000"
+ And I run rspec --drb --drb-port 7000 spec/did_it_work_spec.rb
+ Then the error output should be empty
+ And the output should contain "Specs successfully run within spork, and all initialization files were loaded"
+ And the file "log/test.log" should include "hey there"
View
68 features/steps/rails_steps.rb
@@ -0,0 +1,68 @@
+Given /^I am in a fresh rails project named "(.+)"$/ do |folder_name|
+ @current_dir = SporkWorld::SANDBOX_DIR
+ # version_argument = ENV['RAILS_VERSION'] ? "_#{ENV['RAILS_VERSION']}_" : nil
+ # run("#{SporkWorld::RUBY_BINARY} #{%x{which rails}.chomp} #{folder_name}")
+ run(["rails", "new", folder_name].compact * " ")
+
+ if last_exit_status != 0
+ puts "Couldn't generate project. Output:\nSTDERR:\n-------\n#{last_stderr}\n------\n\nSTDOUT:\n-------\n#{last_stdout}\n\n"
+ last_exit_status.should == 0
+ end
+ @current_dir = File.join(File.join(SporkWorld::SANDBOX_DIR, folder_name))
+ in_current_dir do
+ gemfile = ENV["BUNDLE_GEMFILE"]
+ FileUtils.ln_sf(gemfile, "Gemfile")
+ FileUtils.ln_sf("#{gemfile}.lock", "Gemfile.lock")
+ FileUtils.ln_sf("#{File.dirname(gemfile)}/.bundle", ".bundle")
+ end
+end
+
+
+Given "the application has a model, observer, route, and application helper" do
+ Given 'the following code appears in "config/application.rb" after /^end/:',
+ """
+ ActiveRecord::Base.observers = [:user_observer]
+ """
+ Given 'a file named "app/models/user.rb" with:',
+ """
+ class User < ActiveRecord::Base
+ $loaded_stuff << 'User'
+ end
+ """
+ Given 'a file named "app/models/user_observer.rb" with:',
+ """
+ class UserObserver < ActiveRecord::Observer
+ $loaded_stuff << 'UserObserver'
+ end
+ """
+ Given 'a file named "app/helpers/application_helper.rb" with:',
+ """
+ module ApplicationHelper
+ $loaded_stuff << 'ApplicationHelper'
+ end
+ """
+ Given 'the following code appears in "config/environment.rb" after /Rails::Initializer.run/:',
+ """
+ config.active_record.observers = :user_observer
+ """
+ Given 'the following code appears in "config/routes.rb" after /^end/:',
+ """
+ $loaded_stuff << 'config/routes.rb'
+ """
+ Given 'a file named "config/initializers/initialize_loaded_stuff.rb" with:',
+ """
+ $loaded_stuff ||= []
+ """
+ Given 'a file named "config/initializers/log_establish_connection_calls.rb" with:',
+ """
+ class ActiveRecord::Base
+ class << self
+ def establish_connection_with_load_logging(*args)
+ $loaded_stuff << 'ActiveRecord::Base.establish_connection'
+ establish_connection_without_load_logging(*args)
+ end
+ alias_method_chain :establish_connection, :load_logging
+ end
+ end
+ """
+end
View
14 features/support/env.rb
@@ -0,0 +1,14 @@
+require "spork/test/cucumber_helpers.rb"
+
+APP_ROOT = Pathname.new(File.expand_path('../../', File.dirname(__FILE__)))
+SANDBOX_DIR = APP_ROOT + "tmp/sandbox"
+
+BundlerHelpers.set_gemfile(APP_ROOT + "features/gemsets/#{ENV["GEMSET"] || 'rails3.1'}/Gemfile")
+
+World do
+ SporkWorld.new
+end
+
+# FileUtils.rm_rf SporkWorld::SANDBOX_DIR
+Before { reset_sandbox_dir }
+After { terminate_background_jobs }
View
90 lib/spork/app_framework/rails.rb
@@ -0,0 +1,90 @@
+class Spork::AppFramework::Rails < Spork::AppFramework
+
+ def preload(&block)
+ STDERR.puts "Preloading Rails environment"
+ STDERR.flush
+ ENV["RAILS_ENV"] ||= 'test'
+ preload_rails
+ yield
+ end
+
+ def entry_point
+ @entry_point ||= File.expand_path("config/environment.rb", Dir.pwd)
+ end
+
+ alias :environment_file :entry_point
+
+ def boot_file
+ @boot_file ||= File.join(File.dirname(environment_file), 'boot')
+ end
+
+ def application_file
+ @application_file ||= File.join(File.dirname(environment_file), 'application')
+ end
+
+ def environment_contents
+ @environment_contents ||= File.read(environment_file)
+ end
+
+ def vendor
+ @vendor ||= File.expand_path("vendor/rails", Dir.pwd)
+ end
+
+ def deprecated_version
+ @version ||= (
+ if /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/.match(environment_contents)
+ $1
+ else
+ nil
+ end
+ )
+ end
+
+ def preload_rails
+ if deprecated_version && (not /^3/.match(deprecated_version))
+ puts "This version of spork only supports Rails 3.0. To use spork with rails 2.3.x, downgrade to spork 0.8.x."
+ exit 1
+ end
+ require application_file
+ ::Rails.application
+ ::Rails::Engine.class_eval do
+ def eager_load!
+ # turn off eager_loading, all together
+ end
+ end
+ # Spork.trap_method(::AbstractController::Helpers::ClassMethods, :helper)
+ Spork.trap_method(::ActiveModel::Observing::ClassMethods, :instantiate_observers)
+ Spork.each_run { ActiveRecord::Base.establish_connection rescue nil } if Object.const_defined?(:ActiveRecord)
+
+
+ AbstractController::Helpers::ClassMethods.module_eval do
+ def helper(*args, &block)
+ ([args].flatten - [:all]).each do |arg|
+ next unless arg.is_a?(String)
+ filename = arg + "_helper"
+ unless ::ActiveSupport::Dependencies.search_for_file(filename)
+ # this error message must raise in the format such that LoadError#path returns the filename
+ raise LoadError.new("Missing helper file helpers/%s.rb" % filename)
+ end
+ end
+
+ Spork.each_run(false) do
+ modules_for_helpers(args).each do |mod|
+ add_template_helper(mod)
+ end
+
+ _helpers.module_eval(&block) if block_given?
+ end
+ end
+ end
+ end
+
+ def self.present?
+ # TODO - Simplifiy this to only target Rails 3.1
+ File.exist?("config/environment.rb") &&
+ (File.read("config/environment.rb").include?('RAILS_GEM_VERSION') ||
+ (File.exist?("config/application.rb") &&
+ File.read("config/application.rb").include?("Rails::Application")))
+ end
+
+end
View
14 lib/spork/ext/rails-reloader.rb
@@ -0,0 +1,14 @@
+Spork.each_run do
+ ::ActiveSupport.const_defined?(:Dependencies) ?
+ ::ActiveSupport::Dependencies.mechanism = :load :
+ ::Dependencies.mechanism = :load
+
+ require 'action_controller/dispatcher'
+ dispatcher = ::ActionController::Dispatcher.new($stdout)
+
+ if ::ActionController::Dispatcher.respond_to?(:reload_application)
+ ::ActionController::Dispatcher.reload_application
+ else
+ dispatcher.reload_application
+ end
+end if Spork.using_spork?
View
20 spec/spec_helper.rb
@@ -0,0 +1,20 @@
+require 'rspec'
+require 'spork'
+require 'spork/app_framework'
+
+SPEC_TMP_DIR = File.expand_path('tmp', File.dirname(__FILE__))
+
+require "spork/test/test_helpers"
+
+Dir.glob("#{File.dirname(__FILE__)}/support/*.rb").each { |f| require(f) }
+
+RSpec.configure do |config|
+ include(TmpProjectHelpers)
+
+ config.before(:each) do
+ TestIOStreams.set_streams(StringIO.new, StringIO.new)
+
+ @current_dir = nil
+ clear_tmp_dir
+ end
+end
View
22 spec/spork/app_framework/rails_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Spork::AppFramework::Rails do
+ describe ".deprecated_version" do
+ it "detects the current version of rails" do
+ create_file("config/environment.rb", "RAILS_GEM_VERSION = '2.1.0'")
+ in_current_dir do
+ Spork::AppFramework::Rails.new.deprecated_version.should == "2.1.0"
+ end
+
+ create_file("config/environment.rb", 'RAILS_GEM_VERSION = "2.1.0"')
+ in_current_dir do
+ Spork::AppFramework::Rails.new.deprecated_version.should == "2.1.0"
+ end
+
+ create_file("config/environment.rb", 'RAILS_GEM_VERSION = "> 2.1.0"')
+ in_current_dir do
+ Spork::AppFramework::Rails.new.deprecated_version.should == "> 2.1.0"
+ end
+ end
+ end
+end
View
12 spec/spork/app_framework_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe Spork::AppFramework do
+ describe ".detect_framework" do
+ it "detects when rails is installed and available" do
+ create_file("config/environment.rb", "RAILS_GEM_VERSION = '2.1.0'")
+ in_current_dir do
+ Spork::AppFramework.detect_framework.short_name.should == "Rails"
+ end
+ end
+ end
+end
View
1  spec/tmp/config/environment.rb
@@ -0,0 +1 @@
+RAILS_GEM_VERSION = '2.1.0'
View
28 spork-rails.gemspec
@@ -0,0 +1,28 @@
+require 'date'
+
+Gem::Specification.new do |s|
+ s.name = %q{spork-rails}
+ s.version = "3.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Tim Harper"]
+ s.date = Date.today.to_s
+ s.description = %q{Plugin for Spork to support Rails.}
+ s.email = ["timcharper+spork@gmail.com"]
+ s.executables = []
+ s.extra_rdoc_files = [
+ "MIT-LICENSE",
+ "README.rdoc"
+ ]
+ s.files = ["Gemfile", "README.rdoc", "MIT-LICENSE"] + Dir["lib/**/*"] + Dir["features/**/*"] + Dir["spec/**/*"]
+ s.homepage = %q{http://github.com/timcharper/spork-rails}
+ s.rdoc_options = ["--main", "README.rdoc"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{spork}
+ s.rubygems_version = %q{1.3.5}
+ s.summary = %q{spork}
+ s.test_files = Dir["features/**/*"] + Dir["spec/**/*"]
+
+ s.add_dependency "spork", ">= 1.0rc0"
+ s.add_dependency "rails", ">= 3.0.0", "< 3.3.0"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.