guard-rspec 4.5.2 → 4.6.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/.travis.yml +2 -5
- data/Gemfile +6 -1
- data/README.md +20 -0
- data/gemfiles/{Gemfile.rspec-3.0 → Gemfile.rspec-3.3} +1 -1
- data/lib/guard/rspec/rspec_process.rb +66 -0
- data/lib/guard/rspec/runner.rb +33 -51
- data/lib/guard/rspec/version.rb +1 -1
- data/lib/guard/rspec_formatter.rb +9 -5
- data/spec/lib/guard/rspec/command_spec.rb +7 -0
- data/spec/lib/guard/rspec/rspec_process_spec.rb +78 -0
- data/spec/lib/guard/rspec/runner_spec.rb +68 -20
- data/spec/lib/guard/rspec_formatter_spec.rb +39 -7
- data/spec/spec_helper.rb +23 -1
- metadata +7 -5
- data/gemfiles/Gemfile.rspec-3.2 +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da3d682ea54facc503739cd4d094710f204117da
|
4
|
+
data.tar.gz: 7222b1f22d4650eeb50b510e6ddd0b653d72c145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 069b0a96a591b25139fff82402d4a48dff213ac9b4412ed570aad6ac92bae197808217786552b1b91785f91c0bb16e33c21bda3f7dacdfa33cd52439e3f3855f
|
7
|
+
data.tar.gz: d6d147aca928c4c5bc7c68f7b2cf40ee0eeeb8ff72ef63a5d1bb544b23ce401d6615f6ac039b51dfbd30840fc3c07c78f2eb54f818ae99e66f2f4fa5ebcec5ac
|
data/.travis.yml
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
bundler_args: --without tool
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.1.5
|
6
|
-
- 2.2.0
|
4
|
+
- 2.2.2
|
7
5
|
- jruby-19mode
|
8
6
|
- rbx
|
9
7
|
gemfile:
|
10
8
|
- gemfiles/Gemfile.rspec-2.14
|
11
9
|
- gemfiles/Gemfile.rspec-2.99
|
12
|
-
- gemfiles/Gemfile.rspec-3.
|
13
|
-
- gemfiles/Gemfile.rspec-3.2
|
10
|
+
- gemfiles/Gemfile.rspec-3.3
|
14
11
|
matrix:
|
15
12
|
allow_failures:
|
16
13
|
- rvm: jruby-19mode
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -95,6 +95,7 @@ notification: false # Display notification after the specs are done running,
|
|
95
95
|
run_all: { cmd: 'custom rspec command', message: 'custom message' } # Custom options to use when running all specs
|
96
96
|
title: 'My project' # Display a custom title for the notification, default: 'RSpec results'
|
97
97
|
chdir: 'directory' # run rspec from within a given subdirectory (useful if project has separate specs for submodules)
|
98
|
+
results_file: 'some/path' # use the given file for storing results (instead of default relative path)
|
98
99
|
```
|
99
100
|
|
100
101
|
### Using Launchy to view rspec results
|
@@ -108,6 +109,25 @@ guard :rspec, cmd: 'rspec -f html -o ./tmp/spec_results.html', launchy: './tmp/s
|
|
108
109
|
end
|
109
110
|
```
|
110
111
|
|
112
|
+
### Using parallel_tests
|
113
|
+
|
114
|
+
parallel_tests has a `-o` option for passing RSpec options, and here's a trick to make it work with Guard::RSpec:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
rspec_options = {
|
118
|
+
cmd: "bundle exec rspec",
|
119
|
+
run_all: {
|
120
|
+
cmd: "bundle exec parallel_rspec -o '",
|
121
|
+
cmd_additional_args: "'"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
guard :rspec, rspec_options do
|
125
|
+
# (...)
|
126
|
+
```
|
127
|
+
|
128
|
+
(Notice where the `'` characters are placed)
|
129
|
+
|
130
|
+
|
111
131
|
## Development
|
112
132
|
|
113
133
|
* Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-rspec/master/frames).
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "guard/rspec/command"
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
class RSpec < Plugin
|
5
|
+
class RSpecProcess
|
6
|
+
class Failure < RuntimeError
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :results
|
10
|
+
|
11
|
+
def initialize(command, formatter_tmp_file)
|
12
|
+
@command = command
|
13
|
+
@formatter_tmp_file = formatter_tmp_file
|
14
|
+
@results = nil
|
15
|
+
|
16
|
+
@exit_code = _run
|
17
|
+
@results = _read_results
|
18
|
+
end
|
19
|
+
|
20
|
+
def all_green?
|
21
|
+
exit_code.zero?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def _run
|
27
|
+
_without_bundler_env do
|
28
|
+
exit_code = _really_run
|
29
|
+
unless [0, Command::FAILURE_EXIT_CODE].include?(exit_code)
|
30
|
+
fail Failure, "Failed: #{command.inspect} (exit code: #{exit_code})"
|
31
|
+
end
|
32
|
+
exit_code
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def _really_run
|
37
|
+
env = { "GUARD_RSPEC_RESULTS_FILE" => formatter_tmp_file }
|
38
|
+
pid = Kernel.spawn(env, command) # use spawn to stub in JRuby
|
39
|
+
result = Process.wait2(pid)
|
40
|
+
result.last.exitstatus
|
41
|
+
rescue Errno::ENOENT => ex
|
42
|
+
fail Failure, "Failed: #{command.inspect} (#{ex})"
|
43
|
+
end
|
44
|
+
|
45
|
+
def _read_results
|
46
|
+
Results.new(formatter_tmp_file)
|
47
|
+
ensure
|
48
|
+
File.delete(formatter_tmp_file) if File.exist?(formatter_tmp_file)
|
49
|
+
end
|
50
|
+
|
51
|
+
def _without_bundler_env
|
52
|
+
if defined?(::Bundler)
|
53
|
+
::Bundler.with_clean_env { yield }
|
54
|
+
else
|
55
|
+
yield
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
attr_reader :command
|
62
|
+
attr_reader :exit_code
|
63
|
+
attr_reader :formatter_tmp_file
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/guard/rspec/runner.rb
CHANGED
@@ -2,11 +2,18 @@ require "guard/rspec/inspectors/factory"
|
|
2
2
|
require "guard/rspec/command"
|
3
3
|
require "guard/rspec/notifier"
|
4
4
|
require "guard/rspec/results"
|
5
|
+
require "guard/rspec/rspec_process"
|
5
6
|
|
6
7
|
module Guard
|
7
8
|
class RSpec < Plugin
|
8
9
|
class Runner
|
9
|
-
|
10
|
+
class NoCmdOptionError < RuntimeError
|
11
|
+
def initialize
|
12
|
+
super "No cmd option specified, unable to run specs!"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# NOTE: must match with const in RSpecFormatter!
|
10
17
|
TEMPORARY_FILE_PATH ||= "tmp/rspec_guard_result"
|
11
18
|
|
12
19
|
attr_accessor :options, :inspector, :notifier
|
@@ -22,14 +29,16 @@ module Guard
|
|
22
29
|
options = @options.merge(@options[:run_all])
|
23
30
|
return true if paths.empty?
|
24
31
|
Compat::UI.info(options[:message], reset: true)
|
25
|
-
_run(
|
32
|
+
_run(paths, options)
|
26
33
|
end
|
27
34
|
|
28
35
|
def run(paths)
|
29
36
|
paths = inspector.paths(paths)
|
30
37
|
return true if paths.empty?
|
31
38
|
Compat::UI.info("Running: #{paths.join(' ')}", reset: true)
|
32
|
-
_run(
|
39
|
+
_run(paths, options) do |all_green|
|
40
|
+
run_all if options[:all_after_pass] && all_green
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
def reload
|
@@ -38,44 +47,29 @@ module Guard
|
|
38
47
|
|
39
48
|
private
|
40
49
|
|
41
|
-
def _run(
|
42
|
-
|
50
|
+
def _run(paths, options, &block)
|
51
|
+
fail NoCmdOptionError unless options[:cmd]
|
43
52
|
command = Command.new(paths, options)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
else
|
49
|
-
notifier.notify_failure
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def _without_bundler_env
|
55
|
-
if defined?(::Bundler)
|
56
|
-
::Bundler.with_clean_env { yield }
|
57
|
-
else
|
58
|
-
yield
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def _cmd_option_present(options)
|
63
|
-
return true if options[:cmd]
|
64
|
-
Compat::UI.error("No cmd option specified, unable to run specs!")
|
53
|
+
_really_run(command, options, &block)
|
54
|
+
true
|
55
|
+
rescue RSpecProcess::Failure, NoCmdOptionError => ex
|
56
|
+
Compat::UI.error(ex.to_s)
|
65
57
|
notifier.notify_failure
|
66
58
|
false
|
67
59
|
end
|
68
60
|
|
69
|
-
def
|
70
|
-
|
71
|
-
[
|
72
|
-
|
61
|
+
def _really_run(cmd, options)
|
62
|
+
# TODO: add option to specify the file
|
63
|
+
file = _results_file(options[:results_file], options[:chdir])
|
64
|
+
|
65
|
+
process = RSpecProcess.new(cmd, file)
|
66
|
+
results = process.results
|
73
67
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
68
|
+
inspector.failed(results.failed_paths)
|
69
|
+
notifier.notify(results.summary)
|
70
|
+
_open_launchy
|
71
|
+
|
72
|
+
yield process.all_green? if block_given?
|
79
73
|
end
|
80
74
|
|
81
75
|
def _open_launchy
|
@@ -85,22 +79,10 @@ module Guard
|
|
85
79
|
::Launchy.open(options[:launchy]) if pn.exist?
|
86
80
|
end
|
87
81
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
def _process_run_result(result, all)
|
94
|
-
results = _command_output
|
95
|
-
inspector.failed(results.failed_paths)
|
96
|
-
notifier.notify(results.summary)
|
97
|
-
_open_launchy
|
98
|
-
|
99
|
-
_run_all_after_pass if !all && result
|
100
|
-
end
|
101
|
-
|
102
|
-
def _tmp_file(chdir)
|
103
|
-
chdir ? File.join(chdir, TEMPORARY_FILE_PATH) : TEMPORARY_FILE_PATH
|
82
|
+
def _results_file(results_file, chdir)
|
83
|
+
results_file ||= TEMPORARY_FILE_PATH
|
84
|
+
return results_file unless Pathname(results_file).relative?
|
85
|
+
chdir ? File.join(chdir, results_file) : results_file
|
104
86
|
end
|
105
87
|
end
|
106
88
|
end
|
data/lib/guard/rspec/version.rb
CHANGED
@@ -9,8 +9,6 @@ require "rspec/core/formatters/base_formatter"
|
|
9
9
|
|
10
10
|
module Guard
|
11
11
|
class RSpecFormatter < ::RSpec::Core::Formatters::BaseFormatter
|
12
|
-
TEMPORARY_FILE_PATH ||= "tmp/rspec_guard_result"
|
13
|
-
|
14
12
|
def self.rspec_3?
|
15
13
|
::RSpec::Core::Version::STRING.split(".").first == "3"
|
16
14
|
end
|
@@ -33,10 +31,10 @@ module Guard
|
|
33
31
|
location = metadata[:location]
|
34
32
|
|
35
33
|
until spec_path?(location)
|
36
|
-
metadata = metadata[:example_group]
|
34
|
+
metadata = metadata[:parent_example_group] || metadata[:example_group]
|
37
35
|
|
38
36
|
unless metadata
|
39
|
-
STDERR.puts "no spec file
|
37
|
+
STDERR.puts "no spec file location in #{root_metadata.inspect}"
|
40
38
|
return root_metadata[:location]
|
41
39
|
end
|
42
40
|
|
@@ -82,7 +80,7 @@ module Guard
|
|
82
80
|
end
|
83
81
|
|
84
82
|
def _write(&block)
|
85
|
-
file =
|
83
|
+
file = _results_file
|
86
84
|
FileUtils.mkdir_p(File.dirname(file))
|
87
85
|
File.open(file, "w", &block)
|
88
86
|
end
|
@@ -109,5 +107,11 @@ module Guard
|
|
109
107
|
example.execution_result[:status].to_s == "failed"
|
110
108
|
end
|
111
109
|
end
|
110
|
+
|
111
|
+
def _results_file
|
112
|
+
path = ENV["GUARD_RSPEC_RESULTS_FILE"]
|
113
|
+
fail "Fatal: No output file given for Guard::RSpec formatter!" unless path
|
114
|
+
File.expand_path(path)
|
115
|
+
end
|
112
116
|
end
|
113
117
|
end
|
@@ -46,6 +46,13 @@ RSpec.describe Guard::RSpec::Command do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with no RSpec defined formatter" do
|
49
|
+
before do
|
50
|
+
allow(RSpec::Core::ConfigurationOptions).to receive(:new) do
|
51
|
+
instance_double(RSpec::Core::ConfigurationOptions,
|
52
|
+
options: { formatters: nil })
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
49
56
|
it "sets default progress formatter" do
|
50
57
|
expect(command).to match %r{-f progress}
|
51
58
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "guard/compat/test/helper"
|
2
|
+
|
3
|
+
require "guard/rspec/rspec_process"
|
4
|
+
|
5
|
+
RSpec.describe Guard::RSpec::RSpecProcess do
|
6
|
+
before do
|
7
|
+
allow(Kernel).to receive(:spawn) do |*args|
|
8
|
+
fail "Not stubbed: Kernel.spawn(#{args.map(&:inspect) * ','})"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:results) { instance_double(Guard::RSpec::Results) }
|
13
|
+
|
14
|
+
let(:cmd) { "foo" }
|
15
|
+
let(:file) { "foobar.txt" }
|
16
|
+
let(:pid) { 1234 }
|
17
|
+
let(:exit_code) { 0 }
|
18
|
+
let(:status) { instance_double(Process::Status, exitstatus: exit_code) }
|
19
|
+
let(:wait_result) { [pid, status] }
|
20
|
+
|
21
|
+
subject do
|
22
|
+
described_class.new(cmd, file)
|
23
|
+
end
|
24
|
+
|
25
|
+
before do
|
26
|
+
allow(Kernel).to receive(:spawn).
|
27
|
+
with({ "GUARD_RSPEC_RESULTS_FILE" => file }, cmd).and_return(pid)
|
28
|
+
|
29
|
+
allow(Guard::RSpec::Results).to receive(:new).
|
30
|
+
with(file).and_return(results)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with an non-existing command" do
|
34
|
+
before do
|
35
|
+
allow(Kernel).to receive(:spawn).
|
36
|
+
and_raise(Errno::ENOENT, "No such file or directory - foo")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "fails" do
|
40
|
+
expect { subject }.
|
41
|
+
to raise_error(Guard::RSpec::RSpecProcess::Failure, /Failed: /)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with an existing command" do
|
46
|
+
before do
|
47
|
+
allow(Process).to receive(:wait2).with(pid).and_return(wait_result)
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with an unknown failure" do
|
51
|
+
let(:exit_code) { 100 }
|
52
|
+
|
53
|
+
it "fails" do
|
54
|
+
expect { subject }.
|
55
|
+
to raise_error(Guard::RSpec::RSpecProcess::Failure, /Failed: /)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "with the failure code for normal test failures" do
|
60
|
+
let(:exit_code) { Guard::RSpec::Command::FAILURE_EXIT_CODE }
|
61
|
+
|
62
|
+
it "fails" do
|
63
|
+
expect { subject }.to_not raise_error
|
64
|
+
end
|
65
|
+
|
66
|
+
it { is_expected.to_not be_all_green }
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with no failures" do
|
70
|
+
it "waits for process to end" do
|
71
|
+
expect(Process).to receive(:wait2).with(pid).and_return(wait_result)
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
|
75
|
+
it { is_expected.to be_all_green }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -10,22 +10,23 @@ RSpec.describe Guard::RSpec::Runner do
|
|
10
10
|
let(:inspector) { instance_double(Guard::RSpec::Inspectors::SimpleInspector) }
|
11
11
|
let(:notifier) { instance_double(Guard::RSpec::Notifier) }
|
12
12
|
let(:results) { instance_double(Guard::RSpec::Results) }
|
13
|
+
let(:process) { instance_double(Guard::RSpec::RSpecProcess) }
|
13
14
|
|
14
15
|
before do
|
15
16
|
allow(Guard::Compat::UI).to receive(:info)
|
16
|
-
allow(
|
17
|
+
allow(Guard::Compat::UI).to receive(:error)
|
17
18
|
allow(Guard::RSpec::Inspectors::Factory).to receive(:create) { inspector }
|
18
19
|
allow(Guard::RSpec::Notifier).to receive(:new) { notifier }
|
19
20
|
allow(Guard::RSpec::Command).to receive(:new) { "rspec" }
|
20
21
|
allow(notifier).to receive(:notify)
|
21
22
|
allow(notifier).to receive(:notify_failure)
|
22
23
|
|
23
|
-
allow(Guard::RSpec::Results).to receive(:new).
|
24
|
-
with("tmp/rspec_guard_result").and_return(results)
|
25
24
|
allow(results).to receive(:summary).and_return("Summary")
|
26
25
|
allow(results).to receive(:failed_paths).and_return([])
|
27
26
|
|
28
|
-
|
27
|
+
allow(Guard::RSpec::RSpecProcess).to receive(:new).and_return(process)
|
28
|
+
allow(process).to receive(:all_green?).and_return(true)
|
29
|
+
allow(process).to receive(:results).and_return(results)
|
29
30
|
end
|
30
31
|
|
31
32
|
describe ".initialize" do
|
@@ -190,6 +191,66 @@ RSpec.describe Guard::RSpec::Runner do
|
|
190
191
|
end
|
191
192
|
end
|
192
193
|
|
194
|
+
context "with a custom results file" do
|
195
|
+
let(:options) do
|
196
|
+
{ cmd: "rspec", results_file: results_file }.merge(chdir_options)
|
197
|
+
end
|
198
|
+
|
199
|
+
context "with no chdir option" do
|
200
|
+
let(:chdir_options) { {} }
|
201
|
+
|
202
|
+
context "when the path is relative" do
|
203
|
+
let(:results_file) { "foobar.txt" }
|
204
|
+
it "uses the given file" do
|
205
|
+
expect(Guard::RSpec::RSpecProcess).to receive(:new).
|
206
|
+
with(anything, results_file).and_return(process)
|
207
|
+
runner.run(paths)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "when the path is absolute" do
|
212
|
+
let(:results_file) { "/foo/foobar.txt" }
|
213
|
+
it "uses the given path" do
|
214
|
+
expect(Guard::RSpec::RSpecProcess).to receive(:new).
|
215
|
+
with(anything, results_file).and_return(process)
|
216
|
+
runner.run(paths)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
context "with chdir option" do
|
222
|
+
let(:chdir_options) { { chdir: "moduleA" } }
|
223
|
+
|
224
|
+
context "when the path is relative" do
|
225
|
+
let(:results_file) { "foobar.txt" }
|
226
|
+
|
227
|
+
it "uses a path relative to chdir" do
|
228
|
+
expect(Guard::RSpec::RSpecProcess).to receive(:new).
|
229
|
+
with(anything, "moduleA/foobar.txt").and_return(process)
|
230
|
+
runner.run(paths)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context "when the path is absolute" do
|
235
|
+
let(:results_file) { "/foo/foobar.txt" }
|
236
|
+
it "uses the full given path anyway" do
|
237
|
+
expect(Guard::RSpec::RSpecProcess).to receive(:new).
|
238
|
+
with(anything, results_file).and_return(process)
|
239
|
+
runner.run(paths)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
context "with no custom results file" do
|
246
|
+
let(:options) { { cmd: "rspec" } }
|
247
|
+
it "uses the default" do
|
248
|
+
expect(Guard::RSpec::RSpecProcess).to receive(:new).
|
249
|
+
with(anything, "tmp/rspec_guard_result").and_return(process)
|
250
|
+
runner.run(paths)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
193
254
|
it "notifies inspector about failed paths" do
|
194
255
|
expect(inspector).to receive(:failed).with([])
|
195
256
|
runner.run(paths)
|
@@ -217,24 +278,11 @@ RSpec.describe Guard::RSpec::Runner do
|
|
217
278
|
end
|
218
279
|
|
219
280
|
it "notifies failure" do
|
220
|
-
allow(
|
281
|
+
allow(process).to receive(:all_green?).
|
282
|
+
and_raise(Guard::RSpec::RSpecProcess::Failure, /Failed: /)
|
283
|
+
|
221
284
|
expect(notifier).to receive(:notify_failure)
|
222
285
|
runner.run(paths)
|
223
286
|
end
|
224
287
|
end
|
225
|
-
|
226
|
-
# TODO: remove / cleanup
|
227
|
-
describe "_tmp_file" do
|
228
|
-
subject { described_class.new.send(:_tmp_file, chdir) }
|
229
|
-
|
230
|
-
context "with no chdir option" do
|
231
|
-
let(:chdir) { nil }
|
232
|
-
it { is_expected.to eq("tmp/rspec_guard_result") }
|
233
|
-
end
|
234
|
-
|
235
|
-
context "chdir option" do
|
236
|
-
let(:chdir) { "moduleA" }
|
237
|
-
it { is_expected.to eq("moduleA/tmp/rspec_guard_result") }
|
238
|
-
end
|
239
|
-
end
|
240
288
|
end
|
@@ -1,11 +1,6 @@
|
|
1
1
|
require "guard/rspec_formatter"
|
2
2
|
|
3
3
|
RSpec.describe Guard::RSpecFormatter do
|
4
|
-
describe "::TEMPORARY_FILE_PATH" do
|
5
|
-
subject { Pathname.new(described_class::TEMPORARY_FILE_PATH) }
|
6
|
-
it { is_expected.to be_relative }
|
7
|
-
end
|
8
|
-
|
9
4
|
describe "#dump_summary" do
|
10
5
|
def rspec_summary_args(*args)
|
11
6
|
return args unless ::RSpec::Core::Version::STRING.start_with?("3.")
|
@@ -53,8 +48,15 @@ RSpec.describe Guard::RSpecFormatter do
|
|
53
48
|
context "without stubbed IO" do
|
54
49
|
let(:stub_formatter) { false }
|
55
50
|
|
51
|
+
around do |example|
|
52
|
+
env_var = "GUARD_RSPEC_RESULTS_FILE"
|
53
|
+
old, ENV[env_var] = ENV[env_var], "foobar.txt"
|
54
|
+
example.run
|
55
|
+
ENV[env_var] = old
|
56
|
+
end
|
57
|
+
|
56
58
|
it "creates temporary file and and writes to it" do
|
57
|
-
file = File.expand_path(
|
59
|
+
file = File.expand_path("foobar.txt")
|
58
60
|
|
59
61
|
expect(FileUtils).to receive(:mkdir_p).
|
60
62
|
with(File.dirname(file)) {}
|
@@ -145,13 +147,43 @@ RSpec.describe Guard::RSpecFormatter do
|
|
145
147
|
}
|
146
148
|
|
147
149
|
expect(STDERR).to receive(:puts).
|
148
|
-
with("no spec file
|
150
|
+
with("no spec file location in #{metadata.inspect}")
|
149
151
|
|
150
152
|
expect(described_class.extract_spec_location(metadata)).
|
151
153
|
to eq metadata[:location]
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
157
|
+
context "when a shared examples are nested" do
|
158
|
+
it "should return location of the root spec" do
|
159
|
+
metadata = {
|
160
|
+
location: "./spec/support/breadcrumbs.rb:75",
|
161
|
+
example_group: {
|
162
|
+
example_group: {
|
163
|
+
location: "./spec/requests/breadcrumbs_spec.rb:218"
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
expect(described_class.extract_spec_location(metadata)).
|
169
|
+
to eq "./spec/requests/breadcrumbs_spec.rb"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context "when RSpec 3.0 metadata is present" do
|
174
|
+
it "should return location of the root spec" do
|
175
|
+
metadata = {
|
176
|
+
location: "./spec/support/breadcrumbs.rb:75",
|
177
|
+
parent_example_group: {
|
178
|
+
location: "./spec/requests/breadcrumbs_spec.rb:218"
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
expect(described_class.extract_spec_location(metadata)).
|
183
|
+
to eq "./spec/requests/breadcrumbs_spec.rb"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
155
187
|
context "with only success" do
|
156
188
|
it "notifies success" do
|
157
189
|
formatter.dump_summary(*summary_with_no_failures)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
require "rspec"
|
2
2
|
|
3
|
+
# To help produce better bug reports in Rubinius
|
4
|
+
if RUBY_ENGINE == "rbx"
|
5
|
+
$DEBUG = true # would be nice if this didn't fail ... :(
|
6
|
+
require "rspec/matchers"
|
7
|
+
require "rspec/matchers/built_in/be"
|
8
|
+
end
|
9
|
+
|
3
10
|
if ENV["CI"]
|
4
11
|
require "coveralls"
|
5
12
|
Coveralls.wear!
|
@@ -107,7 +114,16 @@ RSpec.configure do |config|
|
|
107
114
|
abort "stub me: Dir[#{args.first}]!"
|
108
115
|
end
|
109
116
|
|
110
|
-
|
117
|
+
unless RUBY_ENGINE == "rbx"
|
118
|
+
# RBX uses cache in ~/.rbx
|
119
|
+
%w(directory?).each do |meth|
|
120
|
+
allow(File).to receive(meth.to_sym) do |*args|
|
121
|
+
abort "stub me: File.#{meth}(#{args.map(&:inspect) * ','})!"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
%w(delete readlines).each do |meth|
|
111
127
|
allow(File).to receive(meth.to_sym) do |*args|
|
112
128
|
abort "stub me: File.#{meth}(#{args.map(&:inspect) * ','})!"
|
113
129
|
end
|
@@ -118,5 +134,11 @@ RSpec.configure do |config|
|
|
118
134
|
abort "stub me: FileUtils.#{meth}(#{args.map(&:inspect) * ','})!"
|
119
135
|
end
|
120
136
|
end
|
137
|
+
|
138
|
+
%w(spawn system).each do |meth|
|
139
|
+
allow(File).to receive(meth.to_sym) do |*args|
|
140
|
+
abort "stub me: Kernel.#{meth}(#{args.map(&:inspect) * ','})!"
|
141
|
+
end
|
142
|
+
end
|
121
143
|
end
|
122
144
|
end
|
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.
|
4
|
+
version: 4.6.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: 2015-06-
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -126,8 +126,7 @@ files:
|
|
126
126
|
- Rakefile
|
127
127
|
- gemfiles/Gemfile.rspec-2.14
|
128
128
|
- gemfiles/Gemfile.rspec-2.99
|
129
|
-
- gemfiles/Gemfile.rspec-3.
|
130
|
-
- gemfiles/Gemfile.rspec-3.2
|
129
|
+
- gemfiles/Gemfile.rspec-3.3
|
131
130
|
- guard-rspec.gemspec
|
132
131
|
- lib/guard/rspec.rb
|
133
132
|
- lib/guard/rspec/command.rb
|
@@ -141,6 +140,7 @@ files:
|
|
141
140
|
- lib/guard/rspec/notifier.rb
|
142
141
|
- lib/guard/rspec/options.rb
|
143
142
|
- lib/guard/rspec/results.rb
|
143
|
+
- lib/guard/rspec/rspec_process.rb
|
144
144
|
- lib/guard/rspec/runner.rb
|
145
145
|
- lib/guard/rspec/templates/Guardfile
|
146
146
|
- lib/guard/rspec/version.rb
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb
|
156
156
|
- spec/lib/guard/rspec/notifier_spec.rb
|
157
157
|
- spec/lib/guard/rspec/results_spec.rb
|
158
|
+
- spec/lib/guard/rspec/rspec_process_spec.rb
|
158
159
|
- spec/lib/guard/rspec/runner_spec.rb
|
159
160
|
- spec/lib/guard/rspec/template_spec.rb
|
160
161
|
- spec/lib/guard/rspec_formatter_spec.rb
|
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
requirements: []
|
182
183
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.4.
|
184
|
+
rubygems_version: 2.4.7
|
184
185
|
signing_key:
|
185
186
|
specification_version: 4
|
186
187
|
summary: Guard gem for RSpec
|
@@ -195,6 +196,7 @@ test_files:
|
|
195
196
|
- spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb
|
196
197
|
- spec/lib/guard/rspec/notifier_spec.rb
|
197
198
|
- spec/lib/guard/rspec/results_spec.rb
|
199
|
+
- spec/lib/guard/rspec/rspec_process_spec.rb
|
198
200
|
- spec/lib/guard/rspec/runner_spec.rb
|
199
201
|
- spec/lib/guard/rspec/template_spec.rb
|
200
202
|
- spec/lib/guard/rspec_formatter_spec.rb
|
data/gemfiles/Gemfile.rspec-3.2
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec path: '../'
|
4
|
-
|
5
|
-
gem 'rspec', '~> 3.2.0'
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'coveralls', require: false
|
9
|
-
gem "guard-compat", ">= 0.0.2", require: false
|
10
|
-
end
|
11
|
-
|
12
|
-
group :tool do
|
13
|
-
gem 'ruby_gntp', require: false
|
14
|
-
end
|