spork 0.9.0.rc2 → 0.9.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -8,18 +8,10 @@
8
8
 
9
9
  == SYNOPSIS:
10
10
 
11
- Spork is Tim Harper's implementation of test server (similar to the script/spec_server provided by rspec-rails), except rather than using the Rails constant unloading to reload your files, it forks a copy of the server each time you run your tests. The result? Spork runs more solid: it doesn't get corrupted over time, and it properly handles modules and any voo-doo meta programming you may have put in your app.
11
+ Spork is Tim Harper's implementation of test server (similar to the script/spec_server that used to be provided by rspec-rails), except rather than using the Rails constant unloading to reload your files, it forks a copy of the server each time you run your tests. The result? Spork runs more solid: it doesn't get corrupted over time, and it properly handles modules and any voodoo meta programming you may have put in your app.
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
data/assets/bootstrap.rb CHANGED
@@ -2,27 +2,45 @@ require 'rubygems'
2
2
  require 'spork'
3
3
 
4
4
  Spork.prefork do
5
- # Loading more in this block will cause your tests to run faster. However,
5
+ # Loading more in this block will cause your tests to run faster. However,
6
6
  # if you change any configuration or code from libraries loaded here, you'll
7
7
  # need to restart spork for it take effect.
8
-
8
+
9
9
  end
10
10
 
11
11
  Spork.each_run do
12
12
  # This code will be run each time you run your specs.
13
-
13
+
14
14
  end
15
15
 
16
16
  # --- Instructions ---
17
- # - Sort through your spec_helper file. Place as much environment loading
18
- # code that you don't normally modify during development in the
19
- # Spork.prefork block.
20
- # - Place the rest under Spork.each_run block
21
- # - Any code that is left outside of the blocks will be ran during preforking
22
- # and during each_run!
23
- # - These instructions should self-destruct in 10 seconds. If they don't,
24
- # feel free to delete them.
17
+ # Sort the contents of this file into a Spork.prefork and a Spork.each_run
18
+ # block.
19
+ #
20
+ # The Spork.prefork block is run only once when the spork server is started.
21
+ # You typically want to place most of your (slow) initializer code in here, in
22
+ # particular, require'ing any 3rd-party gems that you don't normally modify
23
+ # during development.
24
+ #
25
+ # The Spork.each_run block is run each time you run your specs. In case you
26
+ # need to load files that tend to change during development, require them here.
27
+ # With Rails, your application modules are loaded automatically, so sometimes
28
+ # this block can remain empty.
29
+ #
30
+ # Note: You can modify files loaded *from* the Spork.each_run block without
31
+ # restarting the spork server. However, this file itself will not be reloaded,
32
+ # so if you change any of the code inside the each_run block, you still need to
33
+ # restart the server. In general, if you have non-trivial code in this file,
34
+ # it's advisable to move it into a separate file so you can easily edit it
35
+ # without restarting spork. (For example, with RSpec, you could move
36
+ # non-trivial code into a file spec/support/my_helper.rb, making sure that the
37
+ # spec/support/* files are require'd from inside the each_run block.)
38
+ #
39
+ # Any code that is left outside the two blocks will be run during preforking
40
+ # *and* during each_run -- that's probably not what you want.
25
41
  #
42
+ # These instructions should self-destruct in 10 seconds. If they don't, feel
43
+ # free to delete them.
26
44
 
27
45
 
28
46
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/timcharper/projects/spork
3
3
  specs:
4
- spork (0.9.0.rc)
4
+ spork (0.9.0.rc2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/spork.rb CHANGED
@@ -131,7 +131,11 @@ module Spork
131
131
  def expanded_caller(caller_line)
132
132
  file, line = caller_line.split(/:(\d+)/)
133
133
  line.gsub(/:.+/, '')
134
- File.expand_path(file, Dir.pwd) + ":" + line
134
+ expanded = File.expand_path(file, Dir.pwd) + ":" + line
135
+ if ENV['OS'] == 'Windows_NT' # windows
136
+ expanded = expanded[2..-1]
137
+ end
138
+ expanded
135
139
  end
136
140
 
137
141
  def already_ran?(caller_script_and_line)
@@ -28,7 +28,7 @@ class Spork::RunStrategy
28
28
 
29
29
  protected
30
30
  def self.factory(test_framework)
31
- if RUBY_PLATFORM =~ /mswin|mingw/
31
+ if RUBY_PLATFORM =~ /mswin|mingw|java/
32
32
  Spork::RunStrategy::Magazine.new(test_framework)
33
33
  else
34
34
  Spork::RunStrategy::Forking.new(test_framework)
@@ -4,11 +4,11 @@
4
4
  require 'drb'
5
5
  require 'rinda/ring'
6
6
  require 'win32/process' if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1'
7
+ require 'rubygems' # used for Gem.ruby
7
8
 
8
9
  $:.unshift(File.dirname(__FILE__))
9
10
  require 'magazine/magazine_slave'
10
11
 
11
-
12
12
  class Spork::RunStrategy::Magazine < Spork::RunStrategy
13
13
 
14
14
  Slave_Id_Range = 1..2 # Ringserver uses id: 0. Slave use: 1..MAX_SLAVES
@@ -33,8 +33,8 @@ class Spork::RunStrategy::Magazine < Spork::RunStrategy
33
33
  end
34
34
 
35
35
  def start_Rinda_ringserver
36
- app_name = 'ruby ring_server.rb'
37
- spawn_process(app_name)
36
+ app_name = "#{Gem.ruby} ring_server.rb"
37
+ spawn_process(app_name)
38
38
  end
39
39
 
40
40
  def fill_slave_pool
@@ -49,11 +49,21 @@ class Spork::RunStrategy::Magazine < Spork::RunStrategy
49
49
 
50
50
  def start_slave(id)
51
51
  app_pwd = Dir.pwd # path running app in
52
- app = "ruby magazine_slave_provider.rb #{id} '#{app_pwd}' #{@test_framework.short_name}"
52
+ app = "#{Gem.ruby} magazine_slave_provider.rb #{id} '#{app_pwd}' #{@test_framework.short_name}"
53
53
  @pids[id] = spawn_process(app)
54
54
  end
55
55
 
56
56
  def spawn_process(app)
57
+
58
+ if RUBY_PLATFORM =~ /java/
59
+ # jruby 1.8 has no easy way to just spawn, so use a thread
60
+ Dir.chdir(@path) do
61
+ io = IO.popen app
62
+ Thread.new { puts io.read }
63
+ return io.pid
64
+ end
65
+ end
66
+
57
67
  if RUBY_VERSION < '1.9.1'
58
68
  Process.create( :app_name => app, :cwd => @path ).process_id
59
69
  else
@@ -92,9 +102,19 @@ class Spork::RunStrategy::Magazine < Spork::RunStrategy
92
102
  start_slave(id)
93
103
  end
94
104
 
105
+ def windows?
106
+ ENV['OS'] == 'Windows_NT'
107
+ end
108
+
95
109
  def kill_all_processes
96
110
 
97
- @pids.each {|pid| Process.kill(9, pid)}
111
+ @pids.each {|pid|
112
+ if windows?
113
+ system("taskkill /f /pid #{pid}")
114
+ else
115
+ Process.kill(9, pid)
116
+ end
117
+ }
98
118
  puts "\nKilling processes."; $stdout.flush
99
119
  end
100
120
 
data/lib/spork/server.rb CHANGED
@@ -44,7 +44,9 @@ class Spork::Server
44
44
  #
45
45
  # When implementing a test server, don't override this method: override run_tests instead.
46
46
  def run(argv, stderr, stdout)
47
+ puts "Running tests with args #{argv.inspect}..."
47
48
  run_strategy.run(argv, stderr, stdout)
49
+ puts "Done.\n\n"
48
50
  end
49
51
 
50
52
  def abort
@@ -9,7 +9,7 @@ class Spork::TestFramework
9
9
 
10
10
  class NoFrameworksAvailable < FactoryException
11
11
  def message
12
- "I can't find any testing frameworks to use. Are you running me from a project directory?"
12
+ "I can\'t find any testing frameworks to use. Are you running me from a project directory?"
13
13
  end
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ class Spork::TestFramework
19
19
  end
20
20
 
21
21
  def message
22
- "I can't find the file #{@framework.helper_file} for the #{@framework.short_name} testing framework.\nAre you running me from the project directory?"
22
+ "I can\'t find the file #{@framework.helper_file} for the #{@framework.short_name} testing framework.\nAre you running me from the project directory?"
23
23
  end
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ class Spork::TestFramework
29
29
  end
30
30
 
31
31
  def message
32
- "Couldn't find a supported test framework that begins with '#{@beginning_with}'"
32
+ "Couldn\'t find a supported test framework that begins with '#{@beginning_with}'"
33
33
  end
34
34
  end
35
35
 
@@ -123,7 +123,7 @@ class Spork::TestFramework
123
123
  stderr.flush
124
124
 
125
125
  if framework.bootstrap_required?
126
- stderr.puts "I can't do anything for you by default for the framework your using: #{framework.short_name}.\nYou must bootstrap #{helper_file} to continue."
126
+ stderr.puts "I can't do anything for you by default for the framework you're using: #{framework.short_name}.\nYou must bootstrap #{helper_file} to continue."
127
127
  stderr.flush
128
128
  return false
129
129
  else
data/spec/spec_helper.rb CHANGED
@@ -46,6 +46,10 @@ unless $spec_helper_loaded
46
46
  def change_current_dir(sub_path)
47
47
  @current_dir = File.expand_path(sub_path, SPEC_TMP_DIR)
48
48
  end
49
+
50
+ def windows?
51
+ ENV['OS'] == 'Windows_NT'
52
+ end
49
53
  end
50
54
 
51
55
 
@@ -41,4 +41,4 @@ describe Spork::Forker do
41
41
  forker.running?.should == false
42
42
  end
43
43
  end
44
- end
44
+ end unless windows?
@@ -35,4 +35,4 @@ describe Spork::RunStrategy::Forking do
35
35
 
36
36
  (Time.now - started_at).should < @fake_framework.wait_time
37
37
  end
38
- end
38
+ end unless windows?
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spork
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940487
5
- prerelease: true
4
+ hash: 15424131
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 0
10
- - rc2
11
- version: 0.9.0.rc2
10
+ - rc
11
+ - 3
12
+ version: 0.9.0.rc3
12
13
  platform: ruby
13
14
  authors:
14
15
  - Tim Harper
@@ -17,7 +18,7 @@ autorequire:
17
18
  bindir: bin
18
19
  cert_chain: []
19
20
 
20
- date: 2010-09-13 00:00:00 -06:00
21
+ date: 2011-02-06 00:00:00 -07:00
21
22
  default_executable: spork
22
23
  dependencies: []
23
24
 
@@ -37,9 +38,6 @@ files:
37
38
  - MIT-LICENSE
38
39
  - lib/spork/app_framework/padrino.rb
39
40
  - lib/spork/app_framework/rails.rb
40
- - lib/spork/app_framework/rails_stub_files/application.rb
41
- - lib/spork/app_framework/rails_stub_files/application_controller.rb
42
- - lib/spork/app_framework/rails_stub_files/application_helper.rb
43
41
  - lib/spork/app_framework/unknown.rb
44
42
  - lib/spork/app_framework.rb
45
43
  - lib/spork/custom_io_streams.rb
@@ -124,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
122
  requirements: []
125
123
 
126
124
  rubyforge_project: spork
127
- rubygems_version: 1.3.7
125
+ rubygems_version: 1.5.0
128
126
  signing_key:
129
127
  specification_version: 3
130
128
  summary: spork
@@ -1 +0,0 @@
1
- load(File.dirname(__FILE__) + "/application_controller.rb")
@@ -1,22 +0,0 @@
1
- # This is a stub used to help Spork delay the loading of the real ApplicationController
2
- class ::ApplicationController < ActionController::Base
3
- @@preloading = true
4
- class << self
5
- def inherited(klass)
6
- (@_descendants ||= []) << klass if @@preloading
7
- super
8
- end
9
-
10
- def reapply_inheritance!
11
- @@preloading = false
12
- Array(@_descendants).each do |descendant|
13
- descendant.master_helper_module.send(:include, master_helper_module)
14
- descendant.send(:default_helper_module!)
15
-
16
- descendant.respond_to?(:reapply_inheritance!) && descendant.reapply_inheritance!
17
- end
18
- end
19
- end
20
- end
21
-
22
- Spork.each_run { ApplicationController.reapply_inheritance! }
@@ -1,3 +0,0 @@
1
- # This is a stub used to help Spork delay the loading of the real ApplicationHelper
2
- module ::ApplicationHelper
3
- end