rspec-doom 0.1.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 +7 -0
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +80 -0
- data/LICENSE +21 -0
- data/README.md +76 -0
- data/Rakefile +8 -0
- data/bin/rspec-doom +6 -0
- data/lib/rspec/doom/assets/images/doom1.png +0 -0
- data/lib/rspec/doom/assets/images/doom2.png +0 -0
- data/lib/rspec/doom/assets/images/doom3.png +0 -0
- data/lib/rspec/doom/assets/images/doom4.png +0 -0
- data/lib/rspec/doom/assets/images/doom5.png +0 -0
- data/lib/rspec/doom/cli.rb +53 -0
- data/lib/rspec/doom/notifier.rb +79 -0
- data/lib/rspec/doom/runner.rb +69 -0
- data/lib/rspec/doom/version.rb +5 -0
- data/lib/rspec/doom/watcher.rb +103 -0
- data/lib/rspec/doom.rb +7 -0
- data/lib/rspec-doom.rb +3 -0
- data/rspec-doom.gemspec +32 -0
- metadata +136 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d7786f1ff6b902d89bda213599275fa63eb396d3f310ebb6654d46a0ffe197ee
|
|
4
|
+
data.tar.gz: 8c970f53eb0d8091d8533ccb54970c4c9a89a421dbb1ead9dde9b012b11f4358
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ed87672a16d727a78baf33d43b1b25e258f537227566d5871e93edb3e0f9c7cbaf83d3879f68238a811cca63889b728db8f4cefb42c47141783be75eaa72383f
|
|
7
|
+
data.tar.gz: 926c19d4b9783be514aa3af0769d4bd3d813899f952f0ff615eac7ed58ab11513ae71d28921b8d51ad957c9b0d3e34eeee446ed0cb803e541f02529955e50c78
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
rspec-doom (0.1.0)
|
|
5
|
+
cruise
|
|
6
|
+
logger
|
|
7
|
+
notiffany
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
cruise (0.3.0)
|
|
13
|
+
cruise (0.3.0-aarch64-linux-gnu)
|
|
14
|
+
cruise (0.3.0-aarch64-linux-musl)
|
|
15
|
+
cruise (0.3.0-arm-linux-gnu)
|
|
16
|
+
cruise (0.3.0-arm64-darwin)
|
|
17
|
+
cruise (0.3.0-x86_64-darwin)
|
|
18
|
+
cruise (0.3.0-x86_64-linux-gnu)
|
|
19
|
+
cruise (0.3.0-x86_64-linux-musl)
|
|
20
|
+
diff-lcs (1.6.2)
|
|
21
|
+
logger (1.7.0)
|
|
22
|
+
nenv (0.3.0)
|
|
23
|
+
notiffany (0.1.3)
|
|
24
|
+
nenv (~> 0.1)
|
|
25
|
+
shellany (~> 0.0)
|
|
26
|
+
rake (13.4.2)
|
|
27
|
+
rspec (3.13.2)
|
|
28
|
+
rspec-core (~> 3.13.0)
|
|
29
|
+
rspec-expectations (~> 3.13.0)
|
|
30
|
+
rspec-mocks (~> 3.13.0)
|
|
31
|
+
rspec-core (3.13.6)
|
|
32
|
+
rspec-support (~> 3.13.0)
|
|
33
|
+
rspec-expectations (3.13.5)
|
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
35
|
+
rspec-support (~> 3.13.0)
|
|
36
|
+
rspec-mocks (3.13.8)
|
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
+
rspec-support (~> 3.13.0)
|
|
39
|
+
rspec-support (3.13.7)
|
|
40
|
+
shellany (0.0.1)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
aarch64-linux-gnu
|
|
44
|
+
aarch64-linux-musl
|
|
45
|
+
arm-linux-gnu
|
|
46
|
+
arm64-darwin
|
|
47
|
+
ruby
|
|
48
|
+
x86_64-darwin
|
|
49
|
+
x86_64-linux-gnu
|
|
50
|
+
x86_64-linux-musl
|
|
51
|
+
|
|
52
|
+
DEPENDENCIES
|
|
53
|
+
rake (~> 13.0)
|
|
54
|
+
rspec (~> 3.0)
|
|
55
|
+
rspec-doom!
|
|
56
|
+
|
|
57
|
+
CHECKSUMS
|
|
58
|
+
cruise (0.3.0) sha256=db75b7c589d1746965708bb82433591647ee32d77690fe7c42582352e0851e43
|
|
59
|
+
cruise (0.3.0-aarch64-linux-gnu) sha256=99c96550a7d2e740212978770d3867837371de335cd866e4755abd34b8428838
|
|
60
|
+
cruise (0.3.0-aarch64-linux-musl) sha256=a23e5c415f491a3480eff71f1a07692d7fc1bac39a316c04fb3726faec620d87
|
|
61
|
+
cruise (0.3.0-arm-linux-gnu) sha256=c266461d7ab6422afd8f3504d9b67ebc0db2c2116750d2b4eb32c7103bf42d3e
|
|
62
|
+
cruise (0.3.0-arm64-darwin) sha256=6bb8bbef2ab7b4103849e1809435aa1922d07ec5e2c766a525626c41682ab5ff
|
|
63
|
+
cruise (0.3.0-x86_64-darwin) sha256=5dcf048c20cfcaf208cdcdd6ddfd4410acb431ff18a84bd7441bba0c8b8d6b83
|
|
64
|
+
cruise (0.3.0-x86_64-linux-gnu) sha256=a7bdd7c72307a450a9d37f3c7a90c118230ea6122663b32b8c8e52cad32adfa8
|
|
65
|
+
cruise (0.3.0-x86_64-linux-musl) sha256=54ed6809f1d476bf99a3043bc256cca0efed8bbc9df93a55f4e49eac2bbcb7f4
|
|
66
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
67
|
+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
68
|
+
nenv (0.3.0) sha256=d9de6d8fb7072228463bf61843159419c969edb34b3cef51832b516ae7972765
|
|
69
|
+
notiffany (0.1.3) sha256=d37669605b7f8dcb04e004e6373e2a780b98c776f8eb503ac9578557d7808738
|
|
70
|
+
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
|
71
|
+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
72
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
73
|
+
rspec-doom (0.1.0)
|
|
74
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
75
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
76
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
77
|
+
shellany (0.0.1) sha256=0e127a9132698766d7e752e82cdac8250b6adbd09e6c0a7fbbb6f61964fedee7
|
|
78
|
+
|
|
79
|
+
BUNDLED WITH
|
|
80
|
+
4.0.16
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amalrik Maia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# rspec-doom
|
|
2
|
+
|
|
3
|
+
A standalone RSpec file watcher with Doom-themed notifications. Runs tests
|
|
4
|
+
automatically and shows Doom Guy images based on test results.
|
|
5
|
+
|
|
6
|
+
Built on [Cruise](https://github.com/marcoroth/cruise), a fast OS-native file
|
|
7
|
+
watcher — no Guard required.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add to your Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'rspec-doom'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bundle install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Requires Ruby 3.2+ and macOS or Linux (precompiled native gems).
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
From the root of your project:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bundle exec rspec-doom
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Watches `app/` and `spec/` by default. When a spec changes it runs that spec;
|
|
34
|
+
when a source file changes it runs the matching spec (or the whole suite if
|
|
35
|
+
no matching spec exists).
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
bundle exec rspec-doom lib spec # watch extra directories
|
|
41
|
+
bundle exec rspec-doom --cmd 'rspec' # custom RSpec command
|
|
42
|
+
bundle exec rspec-doom --debounce 0.5 # debounce in seconds
|
|
43
|
+
bundle exec rspec-doom --notify-file n # write notifications to a file (headless/CI)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Press Ctrl-C to stop.
|
|
47
|
+
|
|
48
|
+
## Doom Images
|
|
49
|
+
|
|
50
|
+
The gem includes 5 Doom-themed images (via Notiffany desktop notifications):
|
|
51
|
+
|
|
52
|
+
- `doom1.png` — All tests passing
|
|
53
|
+
- `doom2.png` — 1-2 failures
|
|
54
|
+
- `doom3.png` — 3-5 failures
|
|
55
|
+
- `doom4.png` — 6-10 failures
|
|
56
|
+
- `doom5.png` — 11+ failures
|
|
57
|
+
|
|
58
|
+
The images are Doom HUD sprites from id Software, included here as a fan and
|
|
59
|
+
educational homage to the classic *autotest + growl + Doomguy* setup. DOOM and
|
|
60
|
+
its sprites are trademarks of id Software or their respective owners; this
|
|
61
|
+
project is not affiliated with or endorsed by id Software.
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bundle install
|
|
67
|
+
bundle exec rspec
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Contributing
|
|
71
|
+
|
|
72
|
+
Bug reports and pull requests are welcome on GitHub.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
The gem is available as open source under the terms of the MIT License.
|
data/Rakefile
ADDED
data/bin/rspec-doom
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
|
|
5
|
+
module RSpecDoom
|
|
6
|
+
class CLI
|
|
7
|
+
def self.start(argv)
|
|
8
|
+
new(argv).run
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def initialize(argv)
|
|
12
|
+
@argv = argv
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
options = parse_options
|
|
17
|
+
Watcher.new(options).run
|
|
18
|
+
0
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def parse_options
|
|
24
|
+
options = { directories: [] }
|
|
25
|
+
|
|
26
|
+
parser = OptionParser.new do |opts|
|
|
27
|
+
opts.banner = 'Usage: rspec-doom [options] [dir …]'
|
|
28
|
+
|
|
29
|
+
opts.on('-c', '--cmd CMD', 'Command to run RSpec (default: bundle exec rspec)') do |cmd|
|
|
30
|
+
options[:cmd] = cmd
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
opts.on('-d', '--debounce SECONDS', Float, 'Debounce interval in seconds (default: 0.1)') do |sec|
|
|
34
|
+
options[:debounce] = sec
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
opts.on('--notify-file PATH', 'Write notifications to a file (useful for headless/CI)') do |path|
|
|
38
|
+
options[:notifiers] = [[:file, { path: path, format: "%s|%s|%s\n" }]]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
opts.on('-h', '--help', 'Show this help') do
|
|
42
|
+
puts opts
|
|
43
|
+
exit
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
parser.parse!(@argv)
|
|
48
|
+
options[:directories] = @argv
|
|
49
|
+
|
|
50
|
+
options
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'notiffany'
|
|
4
|
+
|
|
5
|
+
module RSpecDoom
|
|
6
|
+
class Notifier
|
|
7
|
+
MESSAGES = {
|
|
8
|
+
1 => 'Minor casualties...',
|
|
9
|
+
2 => 'Taking damage!',
|
|
10
|
+
3 => 'It\'ll be fine... probably',
|
|
11
|
+
4 => 'REQUIRED: MORE DAKKA!',
|
|
12
|
+
5 => 'IMPS EVERYWHERE!'
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
def initialize(options = {})
|
|
16
|
+
@options = options
|
|
17
|
+
@notifier = nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def connect
|
|
21
|
+
@notifier = Notiffany.connect({ title: 'RSpec Doom' }.merge(@options))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def disconnect
|
|
25
|
+
@notifier&.disconnect
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def notify(result)
|
|
29
|
+
return if result[:error]
|
|
30
|
+
|
|
31
|
+
level = determine_level(result[:failures])
|
|
32
|
+
image_path = image_for(level)
|
|
33
|
+
|
|
34
|
+
message = build_message(result, level)
|
|
35
|
+
|
|
36
|
+
notifier.notify(
|
|
37
|
+
message,
|
|
38
|
+
title: 'RSpec Doom',
|
|
39
|
+
image: image_path
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
attr_reader :notifier
|
|
46
|
+
|
|
47
|
+
def determine_level(failures)
|
|
48
|
+
case failures
|
|
49
|
+
when 0 then 1
|
|
50
|
+
when 1..2 then 2
|
|
51
|
+
when 3..5 then 3
|
|
52
|
+
when 6..10 then 4
|
|
53
|
+
else 5
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def images_path
|
|
58
|
+
File.join(__dir__, 'assets', 'images')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def image_for(level)
|
|
62
|
+
path = File.join(images_path, "doom#{level}.png")
|
|
63
|
+
return path if File.exist?(path)
|
|
64
|
+
|
|
65
|
+
nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def build_message(result, level)
|
|
69
|
+
examples = result[:examples]
|
|
70
|
+
failures = result[:failures]
|
|
71
|
+
|
|
72
|
+
if result[:success]
|
|
73
|
+
"#{examples} tests - ALL CLEAR!"
|
|
74
|
+
else
|
|
75
|
+
"#{MESSAGES[level]} (#{failures} failures)"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
require 'shellwords'
|
|
5
|
+
|
|
6
|
+
module RSpecDoom
|
|
7
|
+
class Runner
|
|
8
|
+
RSPEC_ARGS = %w[--no-color --format=progress].freeze
|
|
9
|
+
|
|
10
|
+
attr_reader :options
|
|
11
|
+
|
|
12
|
+
def initialize(options = {})
|
|
13
|
+
@options = options || {}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run(paths = [])
|
|
17
|
+
cmd = [options[:cmd] || 'bundle exec rspec', *RSPEC_ARGS].join(' ')
|
|
18
|
+
cmd += " #{paths.flatten.compact.map { |p| Shellwords.escape(p.to_s) }.join(' ')}" if paths.any?
|
|
19
|
+
|
|
20
|
+
stdout, stderr, status = Open3.capture3(cmd)
|
|
21
|
+
|
|
22
|
+
parse_result([stdout, stderr].join("\n"), status.exitstatus)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def parse_result(output, exit_code)
|
|
28
|
+
failures = parse_failures(output)
|
|
29
|
+
examples = parse_examples(output)
|
|
30
|
+
|
|
31
|
+
if summary_missing?(output, examples)
|
|
32
|
+
{
|
|
33
|
+
success: false,
|
|
34
|
+
examples: examples,
|
|
35
|
+
failures: failures,
|
|
36
|
+
output: output,
|
|
37
|
+
error: no_summary_reason(output)
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
{
|
|
41
|
+
success: exit_code.zero? && failures.zero?,
|
|
42
|
+
examples: examples,
|
|
43
|
+
failures: failures,
|
|
44
|
+
output: output
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def parse_failures(output)
|
|
50
|
+
output.scan(/(\d+) failures?/).first&.[](0)&.to_i || 0
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def parse_examples(output)
|
|
54
|
+
output.scan(/(\d+) examples?/).first&.[](0)&.to_i || 0
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def summary_missing?(output, examples)
|
|
58
|
+
examples.zero? && !output.include?('0 examples')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def no_summary_reason(output)
|
|
62
|
+
if output.include?('No examples found.')
|
|
63
|
+
'No examples found'
|
|
64
|
+
else
|
|
65
|
+
'RSpec failed to boot or produced no summary'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cruise'
|
|
4
|
+
|
|
5
|
+
module RSpecDoom
|
|
6
|
+
class Watcher
|
|
7
|
+
EVENTS_INTERESTED_IN = %i[modified created renamed changed].freeze
|
|
8
|
+
DEFAULT_DEBOUNCE = 0.1
|
|
9
|
+
|
|
10
|
+
attr_reader :options
|
|
11
|
+
|
|
12
|
+
def initialize(options = {})
|
|
13
|
+
@options = options
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Watches the configured directories and runs RSpec whenever a spec or a
|
|
17
|
+
# source file changes. Blocks until interrupted.
|
|
18
|
+
def run
|
|
19
|
+
notifier.connect
|
|
20
|
+
watch_loop
|
|
21
|
+
rescue Interrupt
|
|
22
|
+
nil
|
|
23
|
+
ensure
|
|
24
|
+
notifier.disconnect
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The directories to watch, defaulting to 'app' and 'spec'.
|
|
28
|
+
def directories
|
|
29
|
+
dirs = options[:directories]
|
|
30
|
+
dirs.nil? || dirs.empty? ? %w[app spec] : dirs
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def debounce
|
|
34
|
+
options[:debounce] || DEFAULT_DEBOUNCE
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def cmd
|
|
38
|
+
options[:cmd] || 'bundle exec rspec'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The list of spec files to run for a changed path.
|
|
42
|
+
#
|
|
43
|
+
# spec/foo_spec.rb -> ['spec/foo_spec.rb']
|
|
44
|
+
# app/models/foo.rb (exists) -> ['spec/models/foo_spec.rb'] (if exists)
|
|
45
|
+
# app/models/foo.rb (no spec) -> [] (run whole suite)
|
|
46
|
+
def paths_for(event_path)
|
|
47
|
+
relative = relative_path(event_path)
|
|
48
|
+
|
|
49
|
+
if spec_file?(relative)
|
|
50
|
+
[relative]
|
|
51
|
+
elsif source_file?(relative)
|
|
52
|
+
spec_for_source(relative)
|
|
53
|
+
else
|
|
54
|
+
[]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def watch_loop
|
|
61
|
+
Cruise.watch(
|
|
62
|
+
*directories,
|
|
63
|
+
debounce: debounce,
|
|
64
|
+
only: EVENTS_INTERESTED_IN
|
|
65
|
+
) do |event|
|
|
66
|
+
run_rspec(paths_for(event.path))
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def run_rspec(paths)
|
|
71
|
+
notifier.notify(runner.run(paths))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def notifier
|
|
75
|
+
@notifier ||= Notifier.new(options)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def runner
|
|
79
|
+
@runner ||= Runner.new(options)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def relative_path(event_path)
|
|
83
|
+
return event_path unless event_path.start_with?(Dir.pwd)
|
|
84
|
+
|
|
85
|
+
event_path.sub("#{Dir.pwd}/", '')
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def spec_file?(relative_path)
|
|
89
|
+
relative_path.start_with?('spec/') && relative_path.end_with?('_spec.rb')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def source_file?(relative_path)
|
|
93
|
+
directories.any? { |dir| relative_path.start_with?("#{dir}/") } &&
|
|
94
|
+
relative_path.end_with?('.rb')
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def spec_for_source(relative_path)
|
|
98
|
+
candidate = relative_path.sub(%r{\A(app|lib)/}, 'spec/')
|
|
99
|
+
.sub(/\.rb\z/, '_spec.rb')
|
|
100
|
+
File.file?(candidate) ? [candidate] : []
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
data/lib/rspec/doom.rb
ADDED
data/lib/rspec-doom.rb
ADDED
data/rspec-doom.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = 'rspec-doom'
|
|
5
|
+
spec.version = '0.1.0'
|
|
6
|
+
spec.authors = ['Amalrik Maia']
|
|
7
|
+
spec.email = ['amalrik.maia@gmail.com']
|
|
8
|
+
spec.summary = 'RSpec file watcher with Doom-themed notifications'
|
|
9
|
+
spec.description = 'Watches source and spec files with Cruise and runs RSpec, showing Doom guy notifications based on test results.'
|
|
10
|
+
spec.homepage = 'https://github.com/amalrik/rspec-doom'
|
|
11
|
+
spec.license = 'MIT'
|
|
12
|
+
spec.files = Dir.chdir(__dir__) do
|
|
13
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|\.github|\.ruby-lsp)/}) }
|
|
14
|
+
end
|
|
15
|
+
spec.bindir = 'bin'
|
|
16
|
+
spec.executables = ['rspec-doom']
|
|
17
|
+
spec.require_paths = ['lib']
|
|
18
|
+
spec.required_ruby_version = '>= 3.2'
|
|
19
|
+
|
|
20
|
+
spec.metadata = {
|
|
21
|
+
'homepage_uri' => spec.homepage,
|
|
22
|
+
'source_code_uri' => spec.homepage,
|
|
23
|
+
'rubygems_mfa_required' => 'true'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
spec.add_dependency 'cruise'
|
|
27
|
+
spec.add_dependency 'notiffany'
|
|
28
|
+
spec.add_dependency 'logger'
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rspec-doom
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Amalrik Maia
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: cruise
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: notiffany
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: logger
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rake
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '13.0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '13.0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rspec
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '3.0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '3.0'
|
|
82
|
+
description: Watches source and spec files with Cruise and runs RSpec, showing Doom
|
|
83
|
+
guy notifications based on test results.
|
|
84
|
+
email:
|
|
85
|
+
- amalrik.maia@gmail.com
|
|
86
|
+
executables:
|
|
87
|
+
- rspec-doom
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".rspec"
|
|
93
|
+
- Gemfile
|
|
94
|
+
- Gemfile.lock
|
|
95
|
+
- LICENSE
|
|
96
|
+
- README.md
|
|
97
|
+
- Rakefile
|
|
98
|
+
- bin/rspec-doom
|
|
99
|
+
- lib/rspec-doom.rb
|
|
100
|
+
- lib/rspec/doom.rb
|
|
101
|
+
- lib/rspec/doom/assets/images/doom1.png
|
|
102
|
+
- lib/rspec/doom/assets/images/doom2.png
|
|
103
|
+
- lib/rspec/doom/assets/images/doom3.png
|
|
104
|
+
- lib/rspec/doom/assets/images/doom4.png
|
|
105
|
+
- lib/rspec/doom/assets/images/doom5.png
|
|
106
|
+
- lib/rspec/doom/cli.rb
|
|
107
|
+
- lib/rspec/doom/notifier.rb
|
|
108
|
+
- lib/rspec/doom/runner.rb
|
|
109
|
+
- lib/rspec/doom/version.rb
|
|
110
|
+
- lib/rspec/doom/watcher.rb
|
|
111
|
+
- rspec-doom.gemspec
|
|
112
|
+
homepage: https://github.com/amalrik/rspec-doom
|
|
113
|
+
licenses:
|
|
114
|
+
- MIT
|
|
115
|
+
metadata:
|
|
116
|
+
homepage_uri: https://github.com/amalrik/rspec-doom
|
|
117
|
+
source_code_uri: https://github.com/amalrik/rspec-doom
|
|
118
|
+
rubygems_mfa_required: 'true'
|
|
119
|
+
rdoc_options: []
|
|
120
|
+
require_paths:
|
|
121
|
+
- lib
|
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: '3.2'
|
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
requirements: []
|
|
133
|
+
rubygems_version: 4.0.16
|
|
134
|
+
specification_version: 4
|
|
135
|
+
summary: RSpec file watcher with Doom-themed notifications
|
|
136
|
+
test_files: []
|