devloop 0.0.6 → 0.0.8
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/README.md +2 -0
- data/lib/devloop/diff_parser.rb +27 -8
- data/lib/devloop/version.rb +1 -1
- data/spec/diff_parser_spec.rb +87 -37
- 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: c6e087fe2cd945782777fe0a1a87fd21b3022f0348a38b1c789f8ba6c7817f49
|
4
|
+
data.tar.gz: 1718ef614659f6ba55a3a7ca1d60d2d7b676a70919d1a93e7bd4f0c5ff1a46ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0948c9527bc7bed104aa6cac0a65bf6c67618e5d3afa31d2245d90565ca32546cb4bdc8c084ef2103c0919c648f4a315c923aed8ca1b1ec7b636fa394b83fa
|
7
|
+
data.tar.gz: 59775a6c5a08119a319cd541bd8e45a7bc1432fb57b498a0e788eb22018f7ef864f316fd412c788a8574359144607ca695bb75b7e38bbe132e51ae68b712ecde
|
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:
|
data/lib/devloop/diff_parser.rb
CHANGED
@@ -5,18 +5,37 @@ module Devloop
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(diff)
|
8
|
-
|
9
|
-
results = []
|
10
|
-
file = ""
|
11
|
-
lines.each_with_index do |line, index|
|
8
|
+
_, results = diff.split("\n").reduce(["", []]) do |(file, results), line|
|
12
9
|
if line.start_with?("+++ b/")
|
13
|
-
|
10
|
+
[line[6..-1], results]
|
14
11
|
elsif line.start_with?("@@ -")
|
15
12
|
line_number = line.match(/@@ -(\d+)/)[1]
|
16
|
-
|
13
|
+
if line_number == "1"
|
14
|
+
[file, results << "#{relative_path(file)}"]
|
15
|
+
else
|
16
|
+
[file, results << "#{relative_path(file)}:#{line_number}"]
|
17
|
+
end
|
18
|
+
else
|
19
|
+
[file, results]
|
17
20
|
end
|
18
|
-
end
|
19
|
-
|
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?(":") }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def relative_path(path)
|
30
|
+
path.gsub(project_path, "")
|
31
|
+
end
|
32
|
+
|
33
|
+
def project_path
|
34
|
+
@project_path ||= Dir.pwd.gsub("#{git_root_path}/", "") + "/"
|
35
|
+
end
|
36
|
+
|
37
|
+
def git_root_path
|
38
|
+
@git_root_path ||= `git rev-parse --show-toplevel`.strip
|
20
39
|
end
|
21
40
|
end
|
22
41
|
end
|
data/lib/devloop/version.rb
CHANGED
data/spec/diff_parser_spec.rb
CHANGED
@@ -4,46 +4,96 @@ require "spec_helper"
|
|
4
4
|
require "devloop/diff_parser"
|
5
5
|
|
6
6
|
describe Devloop::DiffParser do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
30
|
+
context "the project root is the same as git root" do
|
31
|
+
let(:diff1) do
|
32
|
+
<<~DIFF
|
33
|
+
diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
|
34
|
+
index 19772f2a..a32824f9 100644
|
35
|
+
--- a/spec/models/team_spec.rb
|
36
|
+
+++ b/spec/models/team_spec.rb
|
37
|
+
@@ -10,2 +10,2 @@ describe Team do
|
38
|
+
- it "has a valid factory" do
|
39
|
+
- expect(team).to be_valid
|
40
|
+
+ it "has valid factory" do
|
41
|
+
+ expect(team).not_to be_valid
|
42
|
+
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
|
43
|
+
index 410ffa8c..610d9e19 100644
|
44
|
+
--- a/spec/models/user_spec.rb
|
45
|
+
+++ b/spec/models/user_spec.rb
|
46
|
+
@@ -167 +167 @@ describe User do
|
47
|
+
- web_auth_token_generated_at: 50.minutes.ago,
|
48
|
+
+ web_auth_token_generated_at: 10.minutes.ago,
|
49
|
+
DIFF
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:diff2) do
|
53
|
+
<<~DIFF
|
54
|
+
diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
|
55
|
+
index 19772f2a..9f614e20 100644
|
56
|
+
--- a/spec/models/team_spec.rb
|
57
|
+
+++ b/spec/models/team_spec.rb
|
58
|
+
@@ -19 +19 @@ describe Team do
|
59
|
+
- it "has_many emojis" do
|
60
|
+
+ it "has_many eojis" do
|
61
|
+
@@ -24,2 +24,2 @@ describe Team do
|
62
|
+
- describe "normalize attributes" do
|
63
|
+
- it "does not allow empty string values" do
|
64
|
+
+ describe "normalize attrbtes" do
|
65
|
+
+ it "does not allw empty string values" do
|
66
|
+
DIFF
|
67
|
+
end
|
68
|
+
|
69
|
+
it "parses the diff correctly" do
|
70
|
+
expect(Devloop::DiffParser.call(diff1)).to eq(["spec/models/team_spec.rb:10", "spec/models/user_spec.rb:167"])
|
71
|
+
expect(Devloop::DiffParser.call(diff2)).to eq(["spec/models/team_spec.rb:19", "spec/models/team_spec.rb:24"])
|
72
|
+
end
|
43
73
|
end
|
44
74
|
|
45
|
-
|
46
|
-
|
47
|
-
|
75
|
+
context "the project root is different from the git root" do
|
76
|
+
let(:diff) do
|
77
|
+
<<~DIFF
|
78
|
+
diff --git a/src/spec/models/team_spec.rb b/src/spec/models/team_spec.rb
|
79
|
+
index 19772f2a..9f614e20 100644
|
80
|
+
--- a/src/spec/models/team_spec.rb
|
81
|
+
+++ b/src/spec/models/team_spec.rb
|
82
|
+
@@ -19 +19 @@ describe Team do
|
83
|
+
- it "has_many emojis" do
|
84
|
+
+ it "has_many eojis" do
|
85
|
+
@@ -24,2 +24,2 @@ describe Team do
|
86
|
+
- describe "normalize attributes" do
|
87
|
+
- it "does not allow empty string values" do
|
88
|
+
+ describe "normalize attrbtes" do
|
89
|
+
+ it "does not allw empty string values" do
|
90
|
+
DIFF
|
91
|
+
end
|
92
|
+
|
93
|
+
it "parses the diff correctly" do
|
94
|
+
allow_any_instance_of(Devloop::DiffParser).to receive(:git_root_path).and_return("/Users/username/projects/")
|
95
|
+
allow_any_instance_of(Devloop::DiffParser).to receive(:project_path).and_return("src/")
|
96
|
+
expect(Devloop::DiffParser.call(diff)).to eq(["spec/models/team_spec.rb:19", "spec/models/team_spec.rb:24"])
|
97
|
+
end
|
48
98
|
end
|
49
99
|
end
|
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.8
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|