devloop 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/bin/devloop +4 -2
- data/lib/devloop/diff_parser.rb +9 -3
- data/lib/devloop/version.rb +1 -1
- data/spec/diff_parser_spec.rb +27 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df5e69165e639a7c989ba94a3e645beb934ee3d265906dfcb327def357867a09
|
4
|
+
data.tar.gz: 2351433c44454695d6f6ea2bcdd26f574dd79c5939b2fbc2eacd2d9d908f987c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c4744c85d13176a521691e28232d9db7ef14eacb00cd374fc533ac2d7641dfcf23edf228c30bf3cec02cee7e31e596f986da89e1214a25b6df27a4f48b4e376
|
7
|
+
data.tar.gz: fbbfc4813cc205ed367529ae84ca758a5915dbba407e052042ff74f9934b71c5e74d56dba3d708e02e2e590e3a5309815aff51422c029d84bc7ed8905136710b
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Devloop is an automated Rspec runner for Rails apps inspired by [TLDR](https://github.com/tendersearls/tldr). The purpose of this tool is to provide continuous and instant feedback when working on the Rails app. It runs only specs from _lines_ modified in the recent git commits. Even if you have a large `spec/user_spec.rb` file, you'll receive specs feedback in ~second on each file save.
|
4
4
|
|
5
|
+
Optionally, you can edit first line of any spec file (i.e. add `#`) to run all the tests from it.
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
It uses [fswatch](https://github.com/emcrisostomo/fswatch) so make sure to install it first:
|
@@ -22,7 +24,16 @@ Now you can run:
|
|
22
24
|
bundle exec devloop
|
23
25
|
```
|
24
26
|
|
25
|
-
|
27
|
+
You can also use it without adding to the `Gemfile`:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
gem install devloop
|
31
|
+
devloop
|
32
|
+
```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
While `devloop` command is running it will automatically execute tests related to the recently modified lines of code from `spec/` folder.
|
26
37
|
|
27
38
|
Devloop will automatically detect if [Spring](https://github.com/rails/spring) is enabled for your Rails app. I've observed it reduces time needed to run specs by ~4x.
|
28
39
|
|
data/bin/devloop
CHANGED
@@ -6,9 +6,11 @@ require "devloop"
|
|
6
6
|
|
7
7
|
begin
|
8
8
|
system("bundle exec spring > /dev/null 2>&1")
|
9
|
-
|
9
|
+
is_bundled = `bundle list`.include?("devloop")
|
10
|
+
run_command = is_bundled ? "bundle exec devloop_run" : "devloop_run"
|
11
|
+
system(run_command)
|
10
12
|
puts "Devloop: watching for changes in spec directory..."
|
11
|
-
system("fswatch -e '.*' -i '\.rb$' #{Dir.pwd} | xargs -n1 -I{}
|
13
|
+
system("fswatch -e '.*' -i '\.rb$' #{Dir.pwd} | xargs -n1 -I{} #{run_command}")
|
12
14
|
rescue Interrupt # user pressed CTRL+C
|
13
15
|
STDERR.puts "\nDevloop: exiting due to user request"
|
14
16
|
exit 130
|
data/lib/devloop/diff_parser.rb
CHANGED
@@ -10,12 +10,18 @@ module Devloop
|
|
10
10
|
[line[6..-1], results]
|
11
11
|
elsif line.start_with?("@@ -")
|
12
12
|
line_number = line.match(/@@ -(\d+)/)[1]
|
13
|
-
|
13
|
+
if line_number == "1"
|
14
|
+
[file, results << "#{relative_path(file)}"]
|
15
|
+
else
|
16
|
+
[file, results << "#{relative_path(file)}:#{line_number}"]
|
17
|
+
end
|
14
18
|
else
|
15
19
|
[file, results]
|
16
20
|
end
|
17
|
-
end
|
18
|
-
|
21
|
+
end.uniq
|
22
|
+
|
23
|
+
# Remove filenames with line number if filename without line number is present
|
24
|
+
results.reject { |result| results.include?(result.split(":").first) && result.include?(":") }
|
19
25
|
end
|
20
26
|
|
21
27
|
private
|
data/lib/devloop/version.rb
CHANGED
data/spec/diff_parser_spec.rb
CHANGED
@@ -4,7 +4,30 @@ require "spec_helper"
|
|
4
4
|
require "devloop/diff_parser"
|
5
5
|
|
6
6
|
describe Devloop::DiffParser do
|
7
|
-
context "
|
7
|
+
context "first line of a file was edited" do
|
8
|
+
let(:diff) do
|
9
|
+
<<~DIFF
|
10
|
+
diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
|
11
|
+
index 19772f2a..9f614e20 100644
|
12
|
+
--- a/spec/models/team_spec.rb
|
13
|
+
+++ b/spec/models/team_spec.rb
|
14
|
+
@@ -1 +1,3 @@ describe Team do
|
15
|
+
- it "has_many emojis" do
|
16
|
+
+ it "has_many eojis" do
|
17
|
+
@@ -24,2 +24,2 @@ describe Team do
|
18
|
+
- describe "normalize attributes" do
|
19
|
+
- it "does not allow empty string values" do
|
20
|
+
+ describe "normalize attrbtes" do
|
21
|
+
+ it "does not allw empty string values" do
|
22
|
+
DIFF
|
23
|
+
end
|
24
|
+
|
25
|
+
it "will run the whole file" do
|
26
|
+
expect(Devloop::DiffParser.call(diff)).to eq(["spec/models/team_spec.rb"])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "the project root is the same as git root" do
|
8
31
|
let(:diff1) do
|
9
32
|
<<~DIFF
|
10
33
|
diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
|
@@ -39,7 +62,7 @@ describe Devloop::DiffParser do
|
|
39
62
|
- describe "normalize attributes" do
|
40
63
|
- it "does not allow empty string values" do
|
41
64
|
+ describe "normalize attrbtes" do
|
42
|
-
+ it "does not allw empty
|
65
|
+
+ it "does not allw empty string values" do
|
43
66
|
DIFF
|
44
67
|
end
|
45
68
|
|
@@ -49,7 +72,7 @@ describe Devloop::DiffParser do
|
|
49
72
|
end
|
50
73
|
end
|
51
74
|
|
52
|
-
context "
|
75
|
+
context "the project root is different from the git root" do
|
53
76
|
let(:diff) do
|
54
77
|
<<~DIFF
|
55
78
|
diff --git a/src/spec/models/team_spec.rb b/src/spec/models/team_spec.rb
|
@@ -63,7 +86,7 @@ describe Devloop::DiffParser do
|
|
63
86
|
- describe "normalize attributes" do
|
64
87
|
- it "does not allow empty string values" do
|
65
88
|
+ describe "normalize attrbtes" do
|
66
|
-
+ it "does not allw empty
|
89
|
+
+ it "does not allw empty string values" do
|
67
90
|
DIFF
|
68
91
|
end
|
69
92
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devloop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|