guard-rspec 2.6.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -7
- data/lib/guard/rspec.rb +6 -6
- data/lib/guard/rspec/inspector.rb +4 -10
- data/lib/guard/rspec/runner.rb +34 -24
- data/lib/guard/rspec/templates/Guardfile +1 -1
- data/lib/guard/rspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb56ed9604ac21d3cae7a6c7beaf37d20c3beab
|
4
|
+
data.tar.gz: 53990653ab1d6803a35b335af297437b40340826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f26e6c5fa2e01614e6020568bd95465422a72ee498435b323fe88e4f4d0c150e661e627936aacea3534f9419dd45357bda79dc6a553a7bb56de34758d9b1b478
|
7
|
+
data.tar.gz: f93d9d5d4edf51fb289c57f56c2d706860b0b107973d95f962a69abc67842713077ccd8cd08f2e6365445b65f5de59af9572ed3b4ba6cf0b4095af9c4abc7a3f
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
RSpec guard allows to automatically & intelligently launch specs when files are modified.
|
4
4
|
|
5
|
-
* Compatible with RSpec >= 2.
|
6
|
-
* Tested against Ruby 1.8.7, 1.9.
|
5
|
+
* Compatible with RSpec >= 2.13 (use guard-rspec 1.2.x for older release, including RSpec 1.x)
|
6
|
+
* Tested against Ruby 1.8.7, 1.9.3, 2.0.0, REE and the latest versions of JRuby & Rubinius.
|
7
7
|
|
8
8
|
## Install
|
9
9
|
|
@@ -40,7 +40,7 @@ RSpec guard can be adapted to all kinds of projects.
|
|
40
40
|
### Standard RubyGem project
|
41
41
|
|
42
42
|
``` ruby
|
43
|
-
guard
|
43
|
+
guard :rspec do
|
44
44
|
watch(%r{^spec/.+_spec\.rb$})
|
45
45
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
46
46
|
watch('spec/spec_helper.rb') { "spec" }
|
@@ -50,7 +50,7 @@ end
|
|
50
50
|
### Typical Rails app
|
51
51
|
|
52
52
|
``` ruby
|
53
|
-
guard
|
53
|
+
guard :rspec do
|
54
54
|
watch('spec/spec_helper.rb') { "spec" }
|
55
55
|
watch('config/routes.rb') { "spec/routing" }
|
56
56
|
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
@@ -113,6 +113,12 @@ guard 'rspec', :parallel => true, :parallel_cli => '-n 2' do
|
|
113
113
|
# ...
|
114
114
|
end
|
115
115
|
```
|
116
|
+
[Foreman](https://github.com/ddollar/foreman) is supported, but you must enable it:
|
117
|
+
``` ruby
|
118
|
+
guard 'rspec', :foreman => true do
|
119
|
+
# ...
|
120
|
+
end
|
121
|
+
```
|
116
122
|
|
117
123
|
Former `:color`, `:drb`, `:fail_fast` and `:formatter` options are deprecated and no longer have effect.
|
118
124
|
|
@@ -124,15 +130,16 @@ Former `:color`, `:drb`, `:fail_fast` and `:formatter` options are deprecated an
|
|
124
130
|
:binstubs => true # use "bin/rspec" to run the RSpec command (takes precedence over :bundle), default: false
|
125
131
|
:rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
|
126
132
|
:notification => false # display Growl (or Libnotify) notification after the specs are done running, default: true
|
127
|
-
:all_after_pass =>
|
128
|
-
:all_on_start =>
|
129
|
-
:keep_failed =>
|
133
|
+
:all_after_pass => true # run all specs after changed specs pass, default: false
|
134
|
+
:all_on_start => true # run all the specs at startup, default: false
|
135
|
+
:keep_failed => true # keep failed specs until they pass, default: false
|
130
136
|
:run_all => { :cli => "-p" } # cli arguments to use when running all specs, default: same as :cli
|
131
137
|
:spec_paths => ["spec"] # specify an array of paths that contain spec files
|
132
138
|
:exclude => "spec/foo/**/*" # exclude files based on glob
|
133
139
|
:spring => true # enable spring support; default: false
|
134
140
|
:turnip => true # enable turnip support; default: false
|
135
141
|
:zeus => true # enable zeus support; default: false
|
142
|
+
:foreman => true # enable foreman support; default: false
|
136
143
|
:focus_on_failed => false # focus on the first 10 failed specs first, rerun till they pass
|
137
144
|
:parallel => true # run all specs in parallel using [ParallelTests](https://github.com/grosser/parallel_tests) gem, default: false
|
138
145
|
:parallel_cli => "-n 2" # pass arbitrary Parallel Tests arguments, default: ""
|
data/lib/guard/rspec.rb
CHANGED
@@ -12,9 +12,9 @@ module Guard
|
|
12
12
|
super
|
13
13
|
@options = {
|
14
14
|
:focus_on_failed => false,
|
15
|
-
:all_after_pass =>
|
16
|
-
:all_on_start =>
|
17
|
-
:keep_failed =>
|
15
|
+
:all_after_pass => false,
|
16
|
+
:all_on_start => false,
|
17
|
+
:keep_failed => false,
|
18
18
|
:spec_paths => ["spec"],
|
19
19
|
:run_all => {}
|
20
20
|
}.merge(options)
|
@@ -61,9 +61,9 @@ module Guard
|
|
61
61
|
if single_spec && @inspector.clean([single_spec]).length == 1
|
62
62
|
failed_specs = failed_specs.select{|p| p.include? single_spec}
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
if failed_specs.any?
|
66
|
-
# some sane limit, stuff will explode if all tests fail
|
66
|
+
# some sane limit, stuff will explode if all tests fail
|
67
67
|
# ... cap at 10
|
68
68
|
|
69
69
|
paths = failed_specs[0..10]
|
@@ -118,7 +118,7 @@ module Guard
|
|
118
118
|
|
119
119
|
def add_failed(paths)
|
120
120
|
if @options[:keep_failed]
|
121
|
-
@failed_paths += paths
|
121
|
+
@failed_paths += paths
|
122
122
|
@failed_paths.uniq!
|
123
123
|
end
|
124
124
|
end
|
@@ -2,23 +2,17 @@ module Guard
|
|
2
2
|
class RSpec
|
3
3
|
class Inspector
|
4
4
|
|
5
|
-
|
6
|
-
self.excluded = options[:exclude]
|
7
|
-
self.spec_paths = options[:spec_paths]
|
8
|
-
end
|
5
|
+
attr_accessor :excluded, :spec_paths
|
9
6
|
|
10
|
-
def
|
11
|
-
|
7
|
+
def initialize(options = {})
|
8
|
+
self.excluded = options.fetch(:exclude, [])
|
9
|
+
self.spec_paths = options.fetch(:spec_paths, [])
|
12
10
|
end
|
13
11
|
|
14
12
|
def excluded=(pattern)
|
15
13
|
@excluded = Dir[pattern.to_s]
|
16
14
|
end
|
17
15
|
|
18
|
-
def spec_paths
|
19
|
-
@spec_paths || []
|
20
|
-
end
|
21
|
-
|
22
16
|
def spec_paths=(paths)
|
23
17
|
@spec_paths = Array(paths)
|
24
18
|
end
|
data/lib/guard/rspec/runner.rb
CHANGED
@@ -19,15 +19,20 @@ module Guard
|
|
19
19
|
:notification => true,
|
20
20
|
:spring => false,
|
21
21
|
:turnip => false,
|
22
|
-
:zeus => false
|
22
|
+
:zeus => false,
|
23
|
+
:foreman => false
|
23
24
|
}.merge(options)
|
24
25
|
|
25
26
|
unless ENV['SPEC_OPTS'].nil?
|
26
27
|
UI.warning "The SPEC_OPTS environment variable is present. This can conflict with guard-rspec, particularly notifications."
|
27
28
|
end
|
28
29
|
|
29
|
-
if
|
30
|
-
|
30
|
+
if options[:bundler] && !options[:binstubs]
|
31
|
+
if options[:zeus]
|
32
|
+
UI.warning "Running Zeus within bundler is waste of time. Bundler option is set to false, when using Zeus."
|
33
|
+
elsif options[:spring]
|
34
|
+
UI.warning "Running Spring within bundler is waste of time. Bundler option is set to false, when using Spring."
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
deprecations_warnings
|
@@ -78,20 +83,20 @@ module Guard
|
|
78
83
|
private
|
79
84
|
|
80
85
|
def environment_variables
|
81
|
-
return if
|
82
|
-
"export " +
|
86
|
+
return if options[:env].nil?
|
87
|
+
"export " + options[:env].map {|key, value| "#{key}=#{value}"}.join(' ') + ';'
|
83
88
|
end
|
84
89
|
|
85
90
|
def rspec_arguments(paths, options)
|
86
91
|
arg_parts = []
|
87
92
|
arg_parts << options[:cli]
|
88
|
-
if
|
93
|
+
if options[:notification]
|
89
94
|
arg_parts << parsed_or_default_formatter unless options[:cli] =~ formatter_regex
|
90
95
|
arg_parts << "-r #{File.dirname(__FILE__)}/formatter.rb"
|
91
96
|
arg_parts << "-f Guard::RSpec::Formatter"
|
92
97
|
end
|
93
98
|
arg_parts << "--failure-exit-code #{FAILURE_EXIT_CODE}" if failure_exit_code_supported?
|
94
|
-
arg_parts << "-r turnip/rspec" if
|
99
|
+
arg_parts << "-r turnip/rspec" if options[:turnip]
|
95
100
|
arg_parts << paths.join(' ')
|
96
101
|
|
97
102
|
arg_parts.compact.join(' ')
|
@@ -109,7 +114,8 @@ module Guard
|
|
109
114
|
def rspec_command(paths, options)
|
110
115
|
cmd_parts = []
|
111
116
|
cmd_parts << environment_variables
|
112
|
-
cmd_parts << "rvm #{
|
117
|
+
cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].respond_to?(:join)
|
118
|
+
cmd_parts << bin_command('foreman run') if foreman?
|
113
119
|
cmd_parts << "bundle exec" if bundle_exec?
|
114
120
|
cmd_parts << executable_prefix if executable_prefix?
|
115
121
|
cmd_parts << rspec_executable
|
@@ -121,7 +127,7 @@ module Guard
|
|
121
127
|
def run_via_shell(paths, options)
|
122
128
|
success = system(rspec_command(paths, options))
|
123
129
|
|
124
|
-
if
|
130
|
+
if options[:notification] && !drb_used? && !success && rspec_command_exited_with_an_exception?
|
125
131
|
Notifier.notify("Failed", :title => "RSpec results", :image => :failed, :priority => 2)
|
126
132
|
end
|
127
133
|
|
@@ -152,7 +158,7 @@ module Guard
|
|
152
158
|
end
|
153
159
|
|
154
160
|
def drb_used?
|
155
|
-
@drb_used ||=
|
161
|
+
@drb_used ||= options[:cli] && options[:cli].include?('--drb')
|
156
162
|
end
|
157
163
|
|
158
164
|
# W we can avoid loading a large chunk of rspec
|
@@ -180,7 +186,7 @@ module Guard
|
|
180
186
|
end
|
181
187
|
|
182
188
|
def bundler_allowed?
|
183
|
-
@bundler_allowed ||= File.exist?("#{Dir.pwd}/Gemfile")
|
189
|
+
@bundler_allowed ||= (File.exist?("#{Dir.pwd}/Gemfile") && !zeus? && !spring?)
|
184
190
|
end
|
185
191
|
|
186
192
|
def bundler?
|
@@ -192,35 +198,39 @@ module Guard
|
|
192
198
|
end
|
193
199
|
|
194
200
|
def executable_prefix?
|
195
|
-
zeus? || spring?
|
201
|
+
zeus? || spring? || foreman?
|
196
202
|
end
|
197
203
|
|
198
204
|
def executable_prefix
|
199
|
-
prefix = binstubs? ? "#{binstubs}/" : ''
|
200
205
|
if zeus?
|
201
|
-
|
206
|
+
bin_command('zeus')
|
202
207
|
elsif spring? && !parallel?
|
203
|
-
|
204
|
-
else
|
205
|
-
prefix = nil
|
208
|
+
bin_command('spring')
|
206
209
|
end
|
207
|
-
return prefix
|
208
210
|
end
|
209
211
|
|
210
212
|
def zeus?
|
211
|
-
|
213
|
+
options.fetch(:zeus, false)
|
212
214
|
end
|
213
215
|
|
214
216
|
def parallel?
|
215
|
-
|
217
|
+
options.fetch(:parallel, false)
|
216
218
|
end
|
217
219
|
|
218
220
|
def spring?
|
219
|
-
|
221
|
+
options.fetch(:spring, false)
|
222
|
+
end
|
223
|
+
|
224
|
+
def foreman?
|
225
|
+
options.fetch(:foreman, false)
|
220
226
|
end
|
221
227
|
|
222
228
|
def binstubs
|
223
|
-
|
229
|
+
options[:binstubs] == true ? "bin" : options[:binstubs]
|
230
|
+
end
|
231
|
+
|
232
|
+
def bin_command(command)
|
233
|
+
binstubs? ? "#{binstubs}/#{command}" : command
|
224
234
|
end
|
225
235
|
|
226
236
|
def bundle_exec?
|
@@ -230,12 +240,12 @@ module Guard
|
|
230
240
|
def deprecations_warnings
|
231
241
|
[:color, :drb, [:fail_fast, "fail-fast"], [:formatter, "format"]].each do |option|
|
232
242
|
key, value = option.is_a?(Array) ? option : [option, option.to_s]
|
233
|
-
if
|
243
|
+
if options.key?(key)
|
234
244
|
@options.delete(key)
|
235
245
|
UI.info %{DEPRECATION WARNING: The :#{key} option is deprecated. Pass standard command line argument "--#{value}" to RSpec with the :cli option.}
|
236
246
|
end
|
237
247
|
end
|
238
|
-
if
|
248
|
+
if options.key?(:version)
|
239
249
|
@options.delete(:version)
|
240
250
|
UI.info %{DEPRECATION WARNING: The :version option is deprecated. Only RSpec 2 is now supported.}
|
241
251
|
end
|
data/lib/guard/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibaud Guillaume-Gentil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|