spork 0.9.0-x86-mingw32 → 1.0.0rc0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -1
- data/README.rdoc +22 -18
- data/features/diagnostic_mode.feature +1 -2
- data/features/support/bundler_helpers.rb +2 -8
- data/features/support/env.rb +7 -94
- data/features/support/spork_world.rb +84 -0
- data/features/unknown_app_framework.feature +5 -7
- data/lib/spork.rb +3 -10
- data/lib/spork/app_framework.rb +16 -30
- data/lib/spork/app_framework/unknown.rb +5 -1
- data/lib/spork/runner.rb +1 -1
- data/lib/spork/test/cucumber_helpers.rb +5 -0
- data/lib/spork/test/test_helpers.rb +2 -0
- data/lib/spork/test_framework.rb +9 -9
- data/spec/spec_helper.rb +7 -88
- data/spec/spork/app_framework_spec.rb +0 -7
- data/spec/spork/diagnoser_spec.rb +0 -1
- data/spec/spork/test_framework_spec.rb +3 -3
- data/spec/support/fake_framework.rb +3 -1
- data/spec/support/should_include_a_string_like.rb +31 -0
- data/spec/support/test_io_streams.rb +17 -0
- data/spec/support/tmp_project_helpers.rb +30 -0
- metadata +26 -37
- data/assets/bootstrap.rb +0 -49
- data/features/cucumber_rails_integration.feature +0 -107
- data/features/gemfiles/rails3.0/Gemfile +0 -14
- data/features/gemfiles/rails3.0/Gemfile.lock +0 -139
- data/features/rails_delayed_loading_workarounds.feature +0 -177
- data/features/rspec_rails_integration.feature +0 -92
- data/features/steps/rails_steps.rb +0 -67
- data/lib/spork/app_framework/padrino.rb +0 -22
- data/lib/spork/app_framework/rails.rb +0 -82
- data/lib/spork/ext/rails-reloader.rb +0 -14
- data/lib/spork/gem_helpers.rb +0 -38
- data/spec/spork/app_framework/rails_spec.rb +0 -22
@@ -1,92 +0,0 @@
|
|
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"
|
@@ -1,67 +0,0 @@
|
|
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
|
-
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
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
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
|
-
Given 'a file named "app/models/user.rb" with:',
|
26
|
-
"""
|
27
|
-
class User < ActiveRecord::Base
|
28
|
-
$loaded_stuff << 'User'
|
29
|
-
end
|
30
|
-
"""
|
31
|
-
Given 'a file named "app/models/user_observer.rb" with:',
|
32
|
-
"""
|
33
|
-
class UserObserver < ActiveRecord::Observer
|
34
|
-
$loaded_stuff << 'UserObserver'
|
35
|
-
end
|
36
|
-
"""
|
37
|
-
Given 'a file named "app/helpers/application_helper.rb" with:',
|
38
|
-
"""
|
39
|
-
module ApplicationHelper
|
40
|
-
$loaded_stuff << 'ApplicationHelper'
|
41
|
-
end
|
42
|
-
"""
|
43
|
-
Given 'the following code appears in "config/environment.rb" after /Rails::Initializer.run/:',
|
44
|
-
"""
|
45
|
-
config.active_record.observers = :user_observer
|
46
|
-
"""
|
47
|
-
Given 'the following code appears in "config/routes.rb" after /^end/:',
|
48
|
-
"""
|
49
|
-
$loaded_stuff << 'config/routes.rb'
|
50
|
-
"""
|
51
|
-
Given 'a file named "config/initializers/initialize_loaded_stuff.rb" with:',
|
52
|
-
"""
|
53
|
-
$loaded_stuff ||= []
|
54
|
-
"""
|
55
|
-
Given 'a file named "config/initializers/log_establish_connection_calls.rb" with:',
|
56
|
-
"""
|
57
|
-
class ActiveRecord::Base
|
58
|
-
class << self
|
59
|
-
def establish_connection_with_load_logging(*args)
|
60
|
-
$loaded_stuff << 'ActiveRecord::Base.establish_connection'
|
61
|
-
establish_connection_without_load_logging(*args)
|
62
|
-
end
|
63
|
-
alias_method_chain :establish_connection, :load_logging
|
64
|
-
end
|
65
|
-
end
|
66
|
-
"""
|
67
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class Spork::AppFramework::Padrino < Spork::AppFramework
|
2
|
-
|
3
|
-
def preload(&block)
|
4
|
-
STDERR.puts "Preloading Padrino environment"
|
5
|
-
STDERR.flush
|
6
|
-
ENV["PADRINO_ENV"] ||= "test"
|
7
|
-
require boot_file
|
8
|
-
# Make it so that we don't have to restart Spork if we change, say, a model or routes
|
9
|
-
Spork.each_run { ::Padrino.reload! }
|
10
|
-
yield
|
11
|
-
end
|
12
|
-
|
13
|
-
def entry_point
|
14
|
-
@entry_point ||= File.expand_path("config/boot.rb", Dir.pwd)
|
15
|
-
end
|
16
|
-
alias :boot_file :entry_point
|
17
|
-
|
18
|
-
def boot_contents
|
19
|
-
@boot_contents ||= File.read(boot_file)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,82 +0,0 @@
|
|
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
|
-
end
|
@@ -1,14 +0,0 @@
|
|
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/lib/spork/gem_helpers.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module Spork::GemHelpers
|
2
|
-
extend self
|
3
|
-
|
4
|
-
class GemPath
|
5
|
-
attr_reader :name, :version, :path, :version_numbers
|
6
|
-
include Comparable
|
7
|
-
def initialize(p)
|
8
|
-
@path = p
|
9
|
-
@name, @version = File.basename(p).scan(/^(.+?)-([^-]+)$/).flatten
|
10
|
-
@version_numbers = @version.split(/[^0-9]+/).map(&:to_i)
|
11
|
-
end
|
12
|
-
|
13
|
-
def <=>(other)
|
14
|
-
raise "Not comparable gem paths ('#{name}' is not '#{other.name}')" unless name == other.name
|
15
|
-
@version_numbers <=> other.version_numbers
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def latest_load_paths
|
20
|
-
case
|
21
|
-
when defined?(Bundler)
|
22
|
-
$LOAD_PATH.map { |p| File.expand_path(p) }.uniq
|
23
|
-
when Gem.respond_to?(:path)
|
24
|
-
Dir["{#{Gem.path.join(',')}}" + "/gems/*"].inject({}) do |h,f|
|
25
|
-
gem_path = GemPath.new(f)
|
26
|
-
if h[gem_path.name]
|
27
|
-
h[gem_path.name] = gem_path if gem_path > h[gem_path.name]
|
28
|
-
else
|
29
|
-
h[gem_path.name] = gem_path
|
30
|
-
end
|
31
|
-
h
|
32
|
-
end.values.map { |gem_path| File.expand_path("lib", gem_path.path) }.sort.uniq
|
33
|
-
else
|
34
|
-
STDERR.puts "No mechanism available to scan for other gems implementing spork hooks. "
|
35
|
-
[]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,22 +0,0 @@
|
|
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
|