guard-minitest 2.2.0 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a09241c76a0ba099f355b5e3eaab0f2c19f70f9
4
- data.tar.gz: 7ccf0058158fead7d166775673bb6c195d378ba6
3
+ metadata.gz: c15c836a1882aa9e328cf6d4b692cdfec305fb89
4
+ data.tar.gz: 4f0d052115ce23433e839b46b66c80765bf9970a
5
5
  SHA512:
6
- metadata.gz: 1aab8e10cc6c4e63086298a1ed20e309192ba73121ea0b8b5c9b61869ce6dbfebf10e67a4fd65e6257cc8dd0cbc33ae3822e8d95a6f36c9667495c747644a06c
7
- data.tar.gz: d018ea3126b79602c3931a30a225362da779d3959fa36e5a5a620ba393c54da06228595c83c42a5d3252e31012d84800a43bd20871b3453cd6eab7b5f0aa3865
6
+ metadata.gz: 96bf34afab327f9d62dfc2505ffc62f27dbb4b268b7ec9f83c78c3cdbf96ebb52500484a62f250c23caa7e28e13833e3465fd14dd029c02f89ded61f37bf07eb
7
+ data.tar.gz: 6aa5c35256bada50a4a035b58186a8d27a63778e14f672a527bfa69a43f8ef87e040910b5318e6d7677609a6e02559dfe5940208df835cbba03dab43e4260c3c
data/README.md CHANGED
@@ -102,10 +102,15 @@ zeus: true # enable zeus support; default: false
102
102
  drb: true # enable DRb support, default: false
103
103
  bundler: false # don't use "bundle exec" to run the minitest command, default: true
104
104
  rubygems: true # require rubygems when run the minitest command (only if bundler is disabled), default: false
105
+ env: {} # specify some environment variables to be set when the test command is invoked, default: {}
106
+ all_env: {} # specify additional environment variables to be set when all tests are being run, default: false
107
+ autorun: false # require 'minitest/autorun' automatically, default: true
105
108
  ```
106
109
 
107
110
  ### Options usage examples
108
111
 
112
+ #### `:test_folders` and `:test_file_patterns`
113
+
109
114
  You can change the default location of test files using the `:test_folders` option and pattern of test files using the `:test_file_patterns` option:
110
115
 
111
116
  ```ruby
@@ -114,6 +119,8 @@ guard :minitest, test_folders: 'test/unit', test_file_patterns: '*_test.rb' do
114
119
  end
115
120
  ```
116
121
 
122
+ #### `:cli`
123
+
117
124
  You can pass any of the standard MiniTest CLI options using the `:cli` option:
118
125
 
119
126
  ```ruby
@@ -122,6 +129,8 @@ guard :minitest, cli: '--seed 123456 --verbose' do
122
129
  end
123
130
  ```
124
131
 
132
+ #### `:spring`
133
+
125
134
  [Spring](https://github.com/jonleighton/spring) is supported (Ruby 1.9.X / Rails 3.2+ only), but you must enable it:
126
135
 
127
136
  ```ruby
@@ -130,15 +139,18 @@ guard :minitest, spring: true do
130
139
  end
131
140
  ```
132
141
 
133
- From `spring 0.9.1`, `spring testunit` command has been moved to [spring-commands-testunit](https://github.com/jonleighton/spring-commands-testunit). If you are using
134
- rails >=4.0 and spring >=0.9.1
142
+ Since version 2.3.0, the default Spring command works is `bin/rake test` making the integration with your Rails >= 4.1 app effortless.
143
+
144
+ If you're using an older version of Rails (or no Rails at all), you might want to customize the Spring command, e.g.:
135
145
 
136
146
  ```ruby
137
- guard :minitest, spring: 'rake test' do
147
+ guard :minitest, spring: 'spring rake test' do
138
148
  # ...
139
149
  end
140
150
  ```
141
151
 
152
+ #### `:zeus`
153
+
142
154
  [Zeus](https://github.com/burke/zeus) is supported, but you must enable it.
143
155
  Please note that notifications support is very basic when using Zeus. The zeus client exit status is evaluated, and
144
156
  a Guard `:success` or `:failed` notification is triggered. It does not include the test results though.
@@ -158,6 +170,8 @@ guard :minitest, zeus: true do
158
170
  end
159
171
  ```
160
172
 
173
+ #### `:drb`
174
+
161
175
  [Spork / spork-testunit](https://github.com/sporkrb/spork-testunit) is supported, but you must enable it:
162
176
 
163
177
  ```ruby
@@ -183,6 +197,8 @@ For questions please join us in our [Google group](http://groups.google.com/grou
183
197
 
184
198
  ## Maintainer
185
199
 
200
+ **I'm currently looking for new maintainers, don't hesitate!**
201
+
186
202
  [Rémy Coutable](https://github.com/rymai)
187
203
 
188
204
  ## Author
@@ -32,11 +32,11 @@ module Guard
32
32
  end
33
33
 
34
34
  def run_all
35
- runner.run_all
35
+ throw_on_failed_tests { runner.run_all }
36
36
  end
37
37
 
38
38
  def run_on_modifications(paths = [])
39
- runner.run_on_modifications(paths)
39
+ throw_on_failed_tests { runner.run_on_modifications(paths) }
40
40
  end
41
41
 
42
42
  def run_on_additions(paths)
@@ -47,5 +47,11 @@ module Guard
47
47
  runner.run_on_removals(paths)
48
48
  end
49
49
 
50
+ private
51
+
52
+ def throw_on_failed_tests
53
+ throw :task_has_failed unless yield
54
+ end
55
+
50
56
  end
51
57
  end
@@ -18,7 +18,7 @@ module Guard
18
18
 
19
19
  # failed | pending (skip) | success
20
20
  def self.guard_image(failure_count, skip_count)
21
- icon = if failure_count > 0
21
+ if failure_count > 0
22
22
  :failed
23
23
  elsif skip_count > 0
24
24
  :pending
@@ -13,10 +13,13 @@ module Guard
13
13
  drb: false,
14
14
  zeus: false,
15
15
  spring: false,
16
+ all_env: {},
17
+ env: {},
16
18
  include: [],
17
19
  test_folders: %w[test spec],
18
20
  test_file_patterns: %w[*_test.rb test_*.rb *_spec.rb],
19
- cli: nil
21
+ cli: nil,
22
+ autorun: true
20
23
  }.merge(options)
21
24
 
22
25
  parse_deprecated_options
@@ -32,17 +35,7 @@ module Guard
32
35
  message = "Running: #{options[:all] ? 'all tests' : paths.join(' ')}"
33
36
  UI.info message, reset: true
34
37
 
35
- status = if bundler?
36
- system(minitest_command(paths))
37
- else
38
- if defined?(::Bundler)
39
- ::Bundler.with_clean_env do
40
- system(minitest_command(paths))
41
- end
42
- else
43
- system(minitest_command(paths))
44
- end
45
- end
38
+ status = _run_command(paths, options[:all])
46
39
 
47
40
  # When using zeus or spring, the Guard::Minitest::Reporter can't be used because the minitests run in another
48
41
  # process, but we can use the exit status of the client process to distinguish between :success and :failed.
@@ -76,6 +69,8 @@ module Guard
76
69
  inspector.clear_memoized_test_files
77
70
  end
78
71
 
72
+ private
73
+
79
74
  def cli_options
80
75
  @cli_options ||= Array(@options[:cli])
81
76
  end
@@ -116,13 +111,26 @@ module Guard
116
111
  @options[:test_file_patterns]
117
112
  end
118
113
 
119
- private
114
+ def autorun?
115
+ @options[:autorun]
116
+ end
120
117
 
121
- def minitest_command(paths)
122
- cmd_parts = []
118
+ def _run_command(paths, all)
119
+ if bundler?
120
+ system(*minitest_command(paths, all))
121
+ else
122
+ if defined?(::Bundler)
123
+ ::Bundler.with_clean_env do
124
+ system(*minitest_command(paths, all))
125
+ end
126
+ else
127
+ system(*minitest_command(paths, all))
128
+ end
129
+ end
130
+ end
123
131
 
124
- cmd_parts << 'bundle exec' if bundler?
125
- cmd_parts << if drb?
132
+ def _commander(paths)
133
+ if drb?
126
134
  drb_command(paths)
127
135
  elsif zeus?
128
136
  zeus_command(paths)
@@ -131,8 +139,18 @@ module Guard
131
139
  else
132
140
  ruby_command(paths)
133
141
  end
142
+ end
134
143
 
135
- cmd_parts.compact.join(' ')
144
+ def minitest_command(paths, all)
145
+ cmd_parts = []
146
+
147
+ cmd_parts << 'bundle exec' if bundler?
148
+ cmd_parts << _commander(paths)
149
+
150
+ [cmd_parts.compact.join(' ')].tap do |args|
151
+ env = generate_env(all)
152
+ args.unshift(env) if env.length > 0
153
+ end
136
154
  end
137
155
 
138
156
  def drb_command(paths)
@@ -145,9 +163,9 @@ module Guard
145
163
  end
146
164
 
147
165
  def spring_command(paths)
148
- command = @options[:spring].is_a?(String) ? @options[:spring] : 'testunit'
149
- cmd_parts = ['spring', command]
150
- cmd_parts << File.expand_path('../runners/old_runner.rb', __FILE__) unless (Utils.minitest_version_gte_5? || command != 'testunit')
166
+ command = @options[:spring].is_a?(String) ? @options[:spring] : 'bin/rake test'
167
+ cmd_parts = [command]
168
+ cmd_parts << File.expand_path('../runners/old_runner.rb', __FILE__) unless (Utils.minitest_version_gte_5? || command != 'spring testunit')
151
169
  if cli_options.length > 0
152
170
  cmd_parts + paths + ['--'] + cli_options
153
171
  else
@@ -160,7 +178,7 @@ module Guard
160
178
  cmd_parts.concat(generate_includes)
161
179
  cmd_parts << '-r rubygems' if rubygems?
162
180
  cmd_parts << '-r bundler/setup' if bundler?
163
- cmd_parts << '-r minitest/autorun'
181
+ cmd_parts << '-r minitest/autorun' if autorun?
164
182
  cmd_parts.concat(paths.map { |path| "-r ./#{path}" })
165
183
 
166
184
  unless Utils.minitest_version_gte_5?
@@ -181,6 +199,22 @@ module Guard
181
199
  (test_folders + include_folders).map {|f| %[-I"#{f}"] }
182
200
  end
183
201
 
202
+ def generate_env(all=false)
203
+ base_env.merge(all ? all_env : {})
204
+ end
205
+
206
+ def base_env
207
+ Hash[(@options[:env] || {}).map{|key, value| [key.to_s, value.to_s]}]
208
+ end
209
+
210
+ def all_env
211
+ if @options[:all_env].kind_of? Hash
212
+ Hash[@options[:all_env].map{|key, value| [key.to_s, value.to_s]}]
213
+ else
214
+ {@options[:all_env].to_s => "true"}
215
+ end
216
+ end
217
+
184
218
  def relative_paths(paths)
185
219
  paths.map { |p| "./#{p}" }
186
220
  end
@@ -1,7 +1,7 @@
1
1
  module Guard
2
2
  class MinitestVersion
3
3
 
4
- VERSION = '2.2.0'
4
+ VERSION = '2.3.0'
5
5
 
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Lugrin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-15 00:00:00.000000000 Z
12
+ date: 2014-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.2.0
98
+ rubygems_version: 2.2.2
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Guard plugin for the Minitest framework