guard-rspec 4.0.4 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +5 -1
- data/README.md +12 -9
- data/lib/guard/rspec.rb +3 -6
- data/lib/guard/rspec/command.rb +6 -19
- data/lib/guard/rspec/deprecator.rb +13 -1
- data/lib/guard/rspec/formatter.rb +36 -0
- data/lib/guard/rspec/inspectors/base_inspector.rb +52 -0
- data/lib/guard/rspec/inspectors/factory.rb +24 -0
- data/lib/guard/rspec/inspectors/focused_inspector.rb +39 -0
- data/lib/guard/rspec/inspectors/keeping_inspector.rb +96 -0
- data/lib/guard/rspec/inspectors/simple_inspector.rb +21 -0
- data/lib/guard/rspec/notifier.rb +52 -0
- data/lib/guard/rspec/options.rb +34 -0
- data/lib/guard/rspec/runner.rb +40 -31
- data/lib/guard/rspec/version.rb +1 -1
- data/spec/lib/guard/rspec/command_spec.rb +2 -6
- data/spec/lib/guard/rspec/deprecator_spec.rb +21 -2
- data/spec/lib/guard/rspec/formatter_spec.rb +42 -0
- data/spec/lib/guard/rspec/inspectors/base_inspector_spec.rb +34 -0
- data/spec/lib/guard/rspec/inspectors/factory_spec.rb +40 -0
- data/spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb +74 -0
- data/spec/lib/guard/rspec/inspectors/keeping_inspector_spec.rb +122 -0
- data/spec/lib/guard/rspec/inspectors/shared_examples.rb +59 -0
- data/spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb +23 -0
- data/spec/lib/guard/rspec/notifier_spec.rb +69 -0
- data/spec/lib/guard/rspec/runner_spec.rb +75 -66
- data/spec/lib/guard/rspec_spec.rb +8 -3
- metadata +25 -12
- data/lib/guard/rspec/formatters/focuser.rb +0 -29
- data/lib/guard/rspec/formatters/notifier.rb +0 -48
- data/lib/guard/rspec/inspector.rb +0 -78
- data/spec/lib/guard/rspec/formatters/focuser_spec.rb +0 -25
- data/spec/lib/guard/rspec/formatters/notifier_spec.rb +0 -44
- data/spec/lib/guard/rspec/inspector_spec.rb +0 -107
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Guard::RSpec do
|
4
|
-
let(:default_options) {
|
5
|
-
let(:options) { {
|
4
|
+
let(:default_options) { Guard::RSpec::Options::DEFAULTS }
|
5
|
+
let(:options) { {} }
|
6
6
|
let(:plugin) { Guard::RSpec.new(options) }
|
7
7
|
let(:runner) { double(Guard::RSpec::Runner) }
|
8
8
|
before {
|
@@ -12,7 +12,12 @@ describe Guard::RSpec do
|
|
12
12
|
}
|
13
13
|
|
14
14
|
describe '.initialize' do
|
15
|
-
it 'instanciates
|
15
|
+
it 'instanciates with default and custom options' do
|
16
|
+
guard_rspec = Guard::RSpec.new(foo: :bar)
|
17
|
+
expect(guard_rspec.options).to eq(default_options.merge(foo: :bar))
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'instanciates Runner with all default and custom options' do
|
16
21
|
expect(Guard::RSpec::Runner).to receive(:new).with(default_options.merge(foo: :bar))
|
17
22
|
Guard::RSpec.new(foo: :bar)
|
18
23
|
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.0
|
4
|
+
version: 4.1.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-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -112,18 +112,27 @@ files:
|
|
112
112
|
- lib/guard/rspec.rb
|
113
113
|
- lib/guard/rspec/command.rb
|
114
114
|
- lib/guard/rspec/deprecator.rb
|
115
|
-
- lib/guard/rspec/
|
116
|
-
- lib/guard/rspec/
|
117
|
-
- lib/guard/rspec/
|
115
|
+
- lib/guard/rspec/formatter.rb
|
116
|
+
- lib/guard/rspec/inspectors/base_inspector.rb
|
117
|
+
- lib/guard/rspec/inspectors/factory.rb
|
118
|
+
- lib/guard/rspec/inspectors/focused_inspector.rb
|
119
|
+
- lib/guard/rspec/inspectors/keeping_inspector.rb
|
120
|
+
- lib/guard/rspec/inspectors/simple_inspector.rb
|
121
|
+
- lib/guard/rspec/notifier.rb
|
122
|
+
- lib/guard/rspec/options.rb
|
118
123
|
- lib/guard/rspec/runner.rb
|
119
124
|
- lib/guard/rspec/templates/Guardfile
|
120
125
|
- lib/guard/rspec/version.rb
|
121
126
|
- spec/lib/guard/rspec/command_spec.rb
|
122
127
|
- spec/lib/guard/rspec/deprecator_spec.rb
|
123
128
|
- spec/lib/guard/rspec/formatter_spec.rb
|
124
|
-
- spec/lib/guard/rspec/
|
125
|
-
- spec/lib/guard/rspec/
|
126
|
-
- spec/lib/guard/rspec/
|
129
|
+
- spec/lib/guard/rspec/inspectors/base_inspector_spec.rb
|
130
|
+
- spec/lib/guard/rspec/inspectors/factory_spec.rb
|
131
|
+
- spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb
|
132
|
+
- spec/lib/guard/rspec/inspectors/keeping_inspector_spec.rb
|
133
|
+
- spec/lib/guard/rspec/inspectors/shared_examples.rb
|
134
|
+
- spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb
|
135
|
+
- spec/lib/guard/rspec/notifier_spec.rb
|
127
136
|
- spec/lib/guard/rspec/runner_spec.rb
|
128
137
|
- spec/lib/guard/rspec_spec.rb
|
129
138
|
- spec/spec_helper.rb
|
@@ -147,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
156
|
version: '0'
|
148
157
|
requirements: []
|
149
158
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.0.14
|
151
160
|
signing_key:
|
152
161
|
specification_version: 4
|
153
162
|
summary: Guard gem for RSpec
|
@@ -155,9 +164,13 @@ test_files:
|
|
155
164
|
- spec/lib/guard/rspec/command_spec.rb
|
156
165
|
- spec/lib/guard/rspec/deprecator_spec.rb
|
157
166
|
- spec/lib/guard/rspec/formatter_spec.rb
|
158
|
-
- spec/lib/guard/rspec/
|
159
|
-
- spec/lib/guard/rspec/
|
160
|
-
- spec/lib/guard/rspec/
|
167
|
+
- spec/lib/guard/rspec/inspectors/base_inspector_spec.rb
|
168
|
+
- spec/lib/guard/rspec/inspectors/factory_spec.rb
|
169
|
+
- spec/lib/guard/rspec/inspectors/focused_inspector_spec.rb
|
170
|
+
- spec/lib/guard/rspec/inspectors/keeping_inspector_spec.rb
|
171
|
+
- spec/lib/guard/rspec/inspectors/shared_examples.rb
|
172
|
+
- spec/lib/guard/rspec/inspectors/simple_inspector_spec.rb
|
173
|
+
- spec/lib/guard/rspec/notifier_spec.rb
|
161
174
|
- spec/lib/guard/rspec/runner_spec.rb
|
162
175
|
- spec/lib/guard/rspec_spec.rb
|
163
176
|
- spec/spec_helper.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'guard/rspec'
|
2
|
-
require 'rspec/core/formatters/base_formatter'
|
3
|
-
|
4
|
-
module Guard::RSpec::Formatters
|
5
|
-
class Focuser < ::RSpec::Core::Formatters::BaseFormatter
|
6
|
-
|
7
|
-
def dump_summary(duration, total, failures, pending)
|
8
|
-
_write_failed_paths_in_tmp if failures > 0
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
# Used for focus_on_failed options
|
14
|
-
def _write_failed_paths_in_tmp
|
15
|
-
FileUtils.mkdir_p('tmp')
|
16
|
-
File.open('./tmp/rspec_guard_result','w') do |f|
|
17
|
-
f.puts _failed_paths.join("\n")
|
18
|
-
end
|
19
|
-
rescue
|
20
|
-
# nothing really we can do, at least don't kill the test runner
|
21
|
-
end
|
22
|
-
|
23
|
-
def _failed_paths
|
24
|
-
failed = examples.select { |e| e.execution_result[:status] == 'failed' }
|
25
|
-
failed.map { |e| e.metadata[:location] }
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'guard/rspec'
|
2
|
-
require 'guard/notifier'
|
3
|
-
require 'rspec/core/formatters/base_formatter'
|
4
|
-
|
5
|
-
module Guard::RSpec::Formatters
|
6
|
-
class Notifier < ::RSpec::Core::Formatters::BaseFormatter
|
7
|
-
|
8
|
-
def dump_summary(duration, total, failures, pending)
|
9
|
-
message = _message(total, failures, pending, duration)
|
10
|
-
status = _status(failures, pending)
|
11
|
-
_notify(message, status)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def _message(example_count, failure_count, pending_count, duration)
|
17
|
-
message = "#{example_count} examples, #{failure_count} failures"
|
18
|
-
if pending_count > 0
|
19
|
-
message << " (#{pending_count} pending)"
|
20
|
-
end
|
21
|
-
message << "\nin #{duration.round(4)} seconds"
|
22
|
-
message
|
23
|
-
end
|
24
|
-
|
25
|
-
def _status(failure_count, pending_count)
|
26
|
-
if failure_count > 0
|
27
|
-
:failed
|
28
|
-
elsif pending_count > 0
|
29
|
-
:pending
|
30
|
-
else
|
31
|
-
:success
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def _notify(message, status)
|
36
|
-
::Guard::Notifier.turn_on(silent: true)
|
37
|
-
::Guard::Notifier.notify(message, title: 'RSpec results', image: status, priority: _priority(status))
|
38
|
-
end
|
39
|
-
|
40
|
-
def _priority(status)
|
41
|
-
{ failed: 2,
|
42
|
-
pending: -1,
|
43
|
-
success: -2
|
44
|
-
}[status]
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module Guard
|
2
|
-
class RSpec
|
3
|
-
class Inspector
|
4
|
-
FOCUSED_FILE_PATH = './tmp/rspec_guard_result'
|
5
|
-
|
6
|
-
attr_accessor :options, :failed_paths, :spec_paths
|
7
|
-
|
8
|
-
def initialize(options = {})
|
9
|
-
@options = {
|
10
|
-
focus_on_failed: true,
|
11
|
-
keep_failed: false,
|
12
|
-
spec_paths: %w[spec]
|
13
|
-
}.merge(options)
|
14
|
-
|
15
|
-
@failed_paths = []
|
16
|
-
@spec_paths = @options[:spec_paths]
|
17
|
-
end
|
18
|
-
|
19
|
-
def paths(paths = nil)
|
20
|
-
if paths
|
21
|
-
_paths(paths)
|
22
|
-
else
|
23
|
-
spec_paths
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def clear_paths(paths = nil)
|
28
|
-
if paths
|
29
|
-
@failed_paths -= paths
|
30
|
-
else
|
31
|
-
@failed_paths.clear
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def _paths(paths)
|
38
|
-
_focused_paths || if options[:keep_failed]
|
39
|
-
@failed_paths += _clean(paths)
|
40
|
-
else
|
41
|
-
_clean(paths)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def _focused_paths
|
46
|
-
return nil unless options[:focus_on_failed]
|
47
|
-
File.open(FOCUSED_FILE_PATH) { |f| f.read.split("\n")[0..10] }
|
48
|
-
rescue
|
49
|
-
nil
|
50
|
-
ensure
|
51
|
-
File.exist?(FOCUSED_FILE_PATH) && File.delete(FOCUSED_FILE_PATH)
|
52
|
-
end
|
53
|
-
|
54
|
-
def _clean(paths)
|
55
|
-
paths.uniq!
|
56
|
-
paths.compact!
|
57
|
-
|
58
|
-
spec_dirs = _select_only_spec_dirs(paths)
|
59
|
-
spec_files = _select_only_spec_files(paths)
|
60
|
-
paths = spec_dirs + spec_files
|
61
|
-
|
62
|
-
paths
|
63
|
-
end
|
64
|
-
|
65
|
-
def _select_only_spec_dirs(paths)
|
66
|
-
paths.select { |p| File.directory?(p) || spec_paths.include?(p) }
|
67
|
-
end
|
68
|
-
|
69
|
-
def _select_only_spec_files(paths)
|
70
|
-
spec_files = spec_paths.collect { |path| Dir[File.join(path, "**{,/*/**}", "*[_.]spec.rb")] }
|
71
|
-
feature_files = spec_paths.collect { |path| Dir[File.join(path, "**{,/*/**}", "*.feature")] }
|
72
|
-
files = (spec_files + feature_files).flatten
|
73
|
-
paths.select { |p| files.include?(p) }
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
require 'guard/rspec/formatters/focuser'
|
4
|
-
|
5
|
-
describe Guard::RSpec::Formatters::Focuser do
|
6
|
-
let(:formatter) { Guard::RSpec::Formatters::Focuser.new(StringIO.new) }
|
7
|
-
|
8
|
-
describe "#dump_summary" do
|
9
|
-
context "with failures" do
|
10
|
-
let(:example) { double(
|
11
|
-
execution_result: { status: 'failed' },
|
12
|
-
metadata: { location: 'failed_location' }
|
13
|
-
) }
|
14
|
-
after { File.delete('./tmp/rspec_guard_result') }
|
15
|
-
|
16
|
-
it "writes failed location in tmp dir" do
|
17
|
-
formatter.stub(:examples) { [example] }
|
18
|
-
formatter.dump_summary(123, 3, 1, 0)
|
19
|
-
result = File.open('./tmp/rspec_guard_result').read
|
20
|
-
expect(result).to eq "failed_location\n"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
require 'guard/rspec/formatters/notifier'
|
4
|
-
|
5
|
-
describe Guard::RSpec::Formatters::Notifier do
|
6
|
-
let(:formatter) { Guard::RSpec::Formatters::Notifier.new(StringIO.new) }
|
7
|
-
|
8
|
-
describe "#dump_summary" do
|
9
|
-
before {
|
10
|
-
Guard::Notifier.stub(:turn_on)
|
11
|
-
Guard::Notifier.stub(:notify)
|
12
|
-
}
|
13
|
-
|
14
|
-
it "turns on Notifier" do
|
15
|
-
expect(Guard::Notifier).to receive(:turn_on).with(silent: true)
|
16
|
-
formatter.dump_summary(123, 3, 0, 0)
|
17
|
-
end
|
18
|
-
|
19
|
-
context "with only success" do
|
20
|
-
it "notifies success" do
|
21
|
-
expect(Guard::Notifier).to receive(:notify).with(
|
22
|
-
"3 examples, 0 failures\nin 123.0 seconds", title: "RSpec results", image: :success, priority:-2)
|
23
|
-
formatter.dump_summary(123, 3, 0, 0)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "with pending" do
|
28
|
-
it "notifies pending too" do
|
29
|
-
expect(Guard::Notifier).to receive(:notify).with(
|
30
|
-
"3 examples, 0 failures (1 pending)\nin 123.0 seconds", title: "RSpec results", image: :pending, priority:-1)
|
31
|
-
formatter.dump_summary(123, 3, 0, 1)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "with failures" do
|
36
|
-
it "notifies failures too" do
|
37
|
-
expect(Guard::Notifier).to receive(:notify).with(
|
38
|
-
"3 examples, 1 failures\nin 123.0 seconds", title: "RSpec results", image: :failed, priority:2)
|
39
|
-
formatter.dump_summary(123, 3, 1, 0)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Guard::RSpec::Inspector do
|
4
|
-
let(:options) { { } }
|
5
|
-
let(:inspector) { Guard::RSpec::Inspector.new(options) }
|
6
|
-
before { Guard::UI.stub(:warning) }
|
7
|
-
|
8
|
-
describe '.initialize' do
|
9
|
-
it "sets empty failed paths" do
|
10
|
-
expect(inspector.failed_paths).to be_empty
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#paths" do
|
15
|
-
let(:paths) { %w[spec/lib/guard/rspec/inspector_spec.rb] }
|
16
|
-
|
17
|
-
it "returns spec paths if no args" do
|
18
|
-
expect(inspector.paths).to eq %w[spec]
|
19
|
-
end
|
20
|
-
|
21
|
-
context "with custom spec_paths" do
|
22
|
-
let(:options) { { spec_paths: %w[custom_spec] } }
|
23
|
-
|
24
|
-
it "returns custom spec paths if no args" do
|
25
|
-
expect(inspector.paths).to eq %w[custom_spec]
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns spec path if given as argument" do
|
29
|
-
expect(inspector.paths(%w[custom_spec])).to eq %w[custom_spec]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns new paths" do
|
34
|
-
expect(inspector.paths(paths)).to eq paths
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns uniq new paths" do
|
38
|
-
expect(inspector.paths(paths + paths)).to eq paths
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns compact new paths" do
|
42
|
-
expect(inspector.paths(paths + [nil])).to eq paths
|
43
|
-
end
|
44
|
-
|
45
|
-
it "returns only rspec file" do
|
46
|
-
expect(inspector.paths(paths + %w[foo])).to eq paths
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns only rspec directory" do
|
50
|
-
File.stub(:directory?) { true }
|
51
|
-
expect(inspector.paths(%w[spec/foo])).to eq %w[spec/foo]
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns spec path if given as argument" do
|
55
|
-
expect(inspector.paths(%w[spec])).to eq %w[spec]
|
56
|
-
end
|
57
|
-
|
58
|
-
context "with focused paths" do
|
59
|
-
before {
|
60
|
-
FileUtils.mkdir_p('tmp')
|
61
|
-
File.open(Guard::RSpec::Inspector::FOCUSED_FILE_PATH,'w') { |f|
|
62
|
-
f.puts 'spec/lib/guard/rspec/command_spec.rb'
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
it "returns them" do
|
67
|
-
expect(inspector.paths(paths)).to eq %w[spec/lib/guard/rspec/command_spec.rb]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "without focused paths" do
|
72
|
-
it "returns new paths" do
|
73
|
-
expect(inspector.paths(paths)).to eq paths
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "with keep_failed options and failed_paths" do
|
78
|
-
let(:options) { { keep_failed: true } }
|
79
|
-
let(:failed_paths) { %w[spec/lib/guard/rspec/command_spec.rb] }
|
80
|
-
before { inspector.failed_paths = failed_paths }
|
81
|
-
|
82
|
-
it "returns failed paths alongs new paths" do
|
83
|
-
expect(inspector.paths(paths)).to eq failed_paths + paths
|
84
|
-
end
|
85
|
-
|
86
|
-
it "adds new paths to failed_paths" do
|
87
|
-
inspector.paths(paths)
|
88
|
-
expect(inspector.failed_paths).to eq failed_paths + paths
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#clear_paths" do
|
94
|
-
before { inspector.failed_paths = %w[failed_path1 failed_path2] }
|
95
|
-
|
96
|
-
it "clears all failed_paths if no args" do
|
97
|
-
inspector.clear_paths
|
98
|
-
expect(inspector.failed_paths).to be_empty
|
99
|
-
end
|
100
|
-
|
101
|
-
it "clears given failed_path" do
|
102
|
-
inspector.clear_paths(%w[failed_path1 failed_path3])
|
103
|
-
expect(inspector.failed_paths).to eq %w[failed_path2]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|