guard-spork 0.1.11 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  = Guard::Spork
2
2
  http://travis-ci.org/guard/guard-spork.png
3
3
 
4
- Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber {Spork}[https://github.com/timcharper/spork] server(s).
4
+ Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber/Test::Unit {Spork}[https://github.com/timcharper/spork] server(s).
5
5
 
6
6
  - Compatible with Spork 0.8.4 & 0.9.0.rcXX.
7
- - Tested on Ruby 1.8.6, 1.8.7, REE, 1.9.2, JRuby & Rubinius.
7
+ - Tested on Ruby 1.8.7, REE, 1.9.2, JRuby & Rubinius.
8
8
 
9
9
  == Install
10
10
 
@@ -30,7 +30,7 @@ Please read {Guard usage doc}[https://github.com/guard/guard#readme].
30
30
 
31
31
  Please read {Guard doc}[https://github.com/guard/guard#readme] for more info about the Guardfile DSL.
32
32
 
33
- <b>IMPORTANT: place Spork guard before RSpec/Cucumber guards!</b>
33
+ <b>IMPORTANT: place Spork guard before RSpec/Cucumber/Test::Unit guards!</b>
34
34
 
35
35
  === Rails app
36
36
 
@@ -56,28 +56,31 @@ Pass the <tt>:cli => "--drb"</tt> option to {Guard::RSpec}[https://github.com/gu
56
56
 
57
57
  == Options
58
58
 
59
- Guard::Spork automatically detect RSpec/Cucumber/Bundler presence but you can disable any of them with the corresponding options:
59
+ Guard::Spork automatically detect RSpec/Cucumber/Test::Unit/Bundler presence but you can disable any of them with the corresponding options:
60
60
 
61
61
  guard 'spork', :cucumber => false, :bundler => false do
62
62
  ...
63
63
  end
64
64
 
65
- You can provide additional environment variables for RSpec and Cucumber with the <tt>:rspec_env</tt> and <tt>:cucumber_env</tt> options:
65
+ You can provide additional environment variables for RSpec, Cucumber, and Test::Unit with the <tt>:rspec_env</tt>, <tt>:cucumber_env</tt>, and <tt>:test_unit_env</tt> options:
66
66
 
67
- guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
67
+ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit_env => { 'RAILS_ENV' => 'test' } do
68
68
  ...
69
69
  end
70
70
 
71
71
  Available options:
72
72
 
73
- :wait => 30 # Seconds to wait for the server to starts, default: 20
73
+ :wait => 30 # Seconds to wait for the server to starts, default: 20
74
74
  :cucumber => false
75
75
  :rspec => false
76
- :bundler => false # Don't use "bundle exec"
77
- :rspec_port => 1234 # Default: 8989
78
- :cucumber_port => 4321 # Default: 8990
79
- :rspec_env => { 'RAILS_ENV' => 'foo' } # Default: nil
80
- :cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil
76
+ :test_unit => false
77
+ :bundler => false # Don't use "bundle exec"
78
+ :test_unit_port => 1233 # Default: 8988
79
+ :rspec_port => 1234 # Default: 8989
80
+ :cucumber_port => 4321 # Default: 8990
81
+ :test_unit_env => { 'RAILS_ENV' => 'baz' } # Default: nil
82
+ :rspec_env => { 'RAILS_ENV' => 'foo' } # Default: nil
83
+ :cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil
81
84
 
82
85
  == Common troubleshooting
83
86
 
@@ -6,11 +6,13 @@ module Guard
6
6
  attr_accessor :options
7
7
 
8
8
  def initialize(options={})
9
- options[:wait] ||= 20 # seconds
10
- options[:rspec_port] ||= 8989
11
- options[:cucumber_port] ||= 8990
12
- options[:rspec_env] ||= {}
13
- options[:cucumber_env] ||= {}
9
+ options[:wait] ||= 20 # seconds
10
+ options[:test_unit_port] ||= 8988
11
+ options[:rspec_port] ||= 8989
12
+ options[:cucumber_port] ||= 8990
13
+ options[:test_unit_env] ||= {}
14
+ options[:rspec_env] ||= {}
15
+ options[:cucumber_env] ||= {}
14
16
  @options = options
15
17
  @children = {}
16
18
 
@@ -19,6 +21,7 @@ module Guard
19
21
 
20
22
  def launch_sporks(action)
21
23
  UI.info "#{action.capitalize}ing Spork for #{sporked_gems} ", :reset => true
24
+ spawn_child(options[:test_unit_env], spork_command("test_unit")) if test_unit?
22
25
  spawn_child(options[:rspec_env], spork_command("rspec")) if rspec?
23
26
  spawn_child(options[:cucumber_env], spork_command("cucumber")) if cucumber?
24
27
  verify_launches(action)
@@ -98,6 +101,8 @@ module Guard
98
101
  cmd_parts << "spork"
99
102
 
100
103
  case type
104
+ when "test_unit"
105
+ cmd_parts << "testunit -p #{options[:test_unit_port]}"
101
106
  when "rspec"
102
107
  cmd_parts << "-p #{options[:rspec_port]}"
103
108
  when "cucumber"
@@ -111,6 +116,7 @@ module Guard
111
116
  options[:wait].times do
112
117
  sleep 1
113
118
  begin
119
+ TCPSocket.new('localhost', options[:test_unit_port]).close if test_unit?
114
120
  TCPSocket.new('localhost', options[:rspec_port]).close if rspec?
115
121
  TCPSocket.new('localhost', options[:cucumber_port]).close if cucumber?
116
122
  rescue Errno::ECONNREFUSED
@@ -131,6 +137,7 @@ module Guard
131
137
 
132
138
  def sporked_gems
133
139
  gems = []
140
+ gems << "Test::Unit" if test_unit?
134
141
  gems << "RSpec" if rspec?
135
142
  gems << "Cucumber" if cucumber?
136
143
  gems.join(' & ')
@@ -140,6 +147,10 @@ module Guard
140
147
  @bundler ||= File.exist?("#{Dir.pwd}/Gemfile") && options[:bundler] != false
141
148
  end
142
149
 
150
+ def test_unit?
151
+ @test_unit ||= File.exist?("#{Dir.pwd}/test/test_helper.rb") && options[:test_unit] != false
152
+ end
153
+
143
154
  def rspec?
144
155
  @rspec ||= File.exist?("#{Dir.pwd}/spec") && options[:rspec] != false
145
156
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module SporkVersion
3
- VERSION = "0.1.11"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: guard-spork
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.11
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thibaud Guillaume-Gentil
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-02 00:00:00 Z
13
+ date: 2011-06-05 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: guard
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: "2.5"
56
+ version: "2.6"
57
57
  type: :development
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: "0.2"
67
+ version: "0.4"
68
68
  type: :development
69
69
  version_requirements: *id005
70
70
  description: Guard::Spork automatically manage Spork DRb servers.