devloop 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c58cf90575fbc861048dba5e43e4b2498248c2a955931f0336e161168759512
4
- data.tar.gz: d86a34e42e0f9851c79acaced99f54f1ad0468f1b0d301aa92394420fa238344
3
+ metadata.gz: bd315f90c485333f7c0f4386b15c08920865b3e42906c8cc60bd081c7c466299
4
+ data.tar.gz: 8561edca5696f4b1cccb46353717987b093b0820780e801be773196f39f4c0a6
5
5
  SHA512:
6
- metadata.gz: 3cc7f78b87bf3dadf84392a795feecb8aade84578e784e8a4b5e330a4bad9d043383882a17173c64453298c7e2e376d2875804fa8b39e1fa903ba9f4553e645d
7
- data.tar.gz: 3b6e4772b2f595bb78824dcbc6008d09f87eee2198e1b38f95ef66abd51cb8e8e2d31f1adf4bfa37b09d7d9a253cd659ae39dd749de53e0b5deb106203f487b3
6
+ metadata.gz: c6ff478bdb188648ee16f025aada1d5381a373b9ab7095456fea0d2c66d14f53f617581017ba58504607c584b706ee74e68a7c61bfe2bf368e885c8ec27696b1
7
+ data.tar.gz: 8bde33a6fa0a8b140441f4c5a839948e89d708163ffb30e755cd97f15f4a1252de8cedee8948e6f3cf2c5bf7d3eca6d989eb950918061747976961a6f428f2d8
data/README.md CHANGED
@@ -1 +1,27 @@
1
- # Devloop [WIP]
1
+ # Devloop
2
+
3
+ Devloop is an automated Rspec runner for Rails app inspired by [TLDR](https://github.com/tendersearls/tldr). The purpose of this tool is to provide continous and instant feedback when working on Rails app. It run only specs from _lines_ modified in the recent git commits. It means that even if you have a large `spec/user_spec.rb` file, you'll receive specs feedback in fraction on a second on every file save.
4
+
5
+ ## Installation
6
+
7
+ It uses [fswatch](https://github.com/emcrisostomo/fswatch) so make sure to install it first:
8
+
9
+ ```bash
10
+ brew install fswatch
11
+ ```
12
+
13
+ In your `Gemfile`:
14
+
15
+ ```ruby
16
+ gem "devloop", group: :development
17
+ ```
18
+
19
+ Now you can run:
20
+
21
+ ```bash
22
+ bundle exec devloop
23
+ ```
24
+
25
+ While this command it running it will automatically execute tests related to the recenly modified lines of code from `specs/` folder.
26
+
27
+ This is in a very early stage of development so feedback is welcome.
data/bin/devloop ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib") unless $LOAD_PATH.include?(File.dirname(__FILE__) + "/../lib")
5
+
6
+ require "devloop"
7
+
8
+ begin
9
+ puts "Devloop: watching for changes in spec directory..."
10
+ system("fswatch -e '.*' -i '\.rb$' #{Dir.pwd}/spec | xargs -n1 -I{} bundle exec devloop_run")
11
+ rescue Interrupt # user pressed CTRL+C
12
+ STDERR.puts "\nDevloop: exiting due to user request"
13
+ exit 130
14
+ end
data/bin/devloop_run ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib") unless $LOAD_PATH.include?(File.dirname(__FILE__) + "/../lib")
3
+
4
+ require "devloop"
5
+ begin
6
+ require "spring/env"
7
+ rescue LoadError
8
+ # Spring not available
9
+ end
10
+
11
+ begin
12
+ diff = `git diff -U0 spec/`
13
+ if diff == ""
14
+ diff = `git diff HEAD~1 -U0 spec/`
15
+ end
16
+
17
+ tests = Devloop::DiffParser.call(diff)
18
+ puts "Devloop running tests:"
19
+ if tests.length == 0
20
+ puts "No tests to run"
21
+ return
22
+ end
23
+ puts tests
24
+ command = if defined?(Spring) && Spring::Env.new.server_running?
25
+ "spring rspec"
26
+ else
27
+ "rspec"
28
+ end
29
+ system("bundle exec #{command} #{tests.join(" ")}")
30
+ rescue Interrupt # user pressed CTRL+C
31
+ STDERR.puts "\nDevloop: exiting due to user request"
32
+ exit 130
33
+ end
data/devloop.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = s.files.grep(%r{^(spec)/})
16
16
  s.require_paths = ["lib"]
17
+ s.executables = ["devloop", "devloop_run"]
17
18
  s.license = "MIT"
18
19
  s.add_development_dependency "rake"
19
20
  s.add_development_dependency "rspec"
@@ -0,0 +1,22 @@
1
+ module Devloop
2
+ class DiffParser
3
+ def self.call(diff)
4
+ new.call(diff)
5
+ end
6
+
7
+ def call(diff)
8
+ lines = diff.split("\n")
9
+ results = []
10
+ file = ""
11
+ lines.each_with_index do |line, index|
12
+ if line.start_with?("+++ b/")
13
+ file = line[6..-1]
14
+ elsif line.start_with?("@@ -")
15
+ line_number = line.match(/@@ -(\d+)/)[1]
16
+ results << "#{file}:#{line_number}"
17
+ end
18
+ end
19
+ results
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devloop
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.3"
5
5
  end
data/lib/devloop.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "devloop/diff_parser"
4
+
3
5
  module Devloop
4
6
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "devloop/diff_parser"
5
+
6
+ describe Devloop::DiffParser do
7
+ let(:diff1) do
8
+ <<~DIFF
9
+ diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
10
+ index 19772f2a..a32824f9 100644
11
+ --- a/spec/models/team_spec.rb
12
+ +++ b/spec/models/team_spec.rb
13
+ @@ -10,2 +10,2 @@ describe Team do
14
+ - it "has a valid factory" do
15
+ - expect(team).to be_valid
16
+ + it "has valid factory" do
17
+ + expect(team).not_to be_valid
18
+ diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
19
+ index 410ffa8c..610d9e19 100644
20
+ --- a/spec/models/user_spec.rb
21
+ +++ b/spec/models/user_spec.rb
22
+ @@ -167 +167 @@ describe User do
23
+ - web_auth_token_generated_at: 50.minutes.ago,
24
+ + web_auth_token_generated_at: 10.minutes.ago,
25
+ DIFF
26
+ end
27
+
28
+ let(:diff2) do
29
+ <<~DIFF
30
+ diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
31
+ index 19772f2a..9f614e20 100644
32
+ --- a/spec/models/team_spec.rb
33
+ +++ b/spec/models/team_spec.rb
34
+ @@ -19 +19 @@ describe Team do
35
+ - it "has_many emojis" do
36
+ + it "has_many eojis" do
37
+ @@ -24,2 +24,2 @@ describe Team do
38
+ - describe "normalize attributes" do
39
+ - it "does not allow empty string values" do
40
+ + describe "normalize attrbtes" do
41
+ + it "does not allw empty sting values" do
42
+ DIFF
43
+ end
44
+
45
+ it "parses the diff correctly" do
46
+ expect(Devloop::DiffParser.call(diff1)).to eq(["spec/models/team_spec.rb:10", "spec/models/user_spec.rb:167"])
47
+ expect(Devloop::DiffParser.call(diff2)).to eq(["spec/models/team_spec.rb:19", "spec/models/team_spec.rb:24"])
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
@@ -56,7 +56,9 @@ description: " This simple tool allows to run apps tests based on current git di
56
56
  output. "
57
57
  email:
58
58
  - contact@pawelurbanek.com
59
- executables: []
59
+ executables:
60
+ - devloop
61
+ - devloop_run
60
62
  extensions: []
61
63
  extra_rdoc_files: []
62
64
  files:
@@ -65,10 +67,13 @@ files:
65
67
  - LICENSE.txt
66
68
  - README.md
67
69
  - Rakefile
70
+ - bin/devloop
71
+ - bin/devloop_run
68
72
  - devloop.gemspec
69
73
  - lib/devloop.rb
74
+ - lib/devloop/diff_parser.rb
70
75
  - lib/devloop/version.rb
71
- - spec/smoke_spec.rb
76
+ - spec/diff_parser_spec.rb
72
77
  - spec/spec_helper.rb
73
78
  homepage: https://github.com/pawurb/devloop
74
79
  licenses:
@@ -95,5 +100,5 @@ signing_key:
95
100
  specification_version: 4
96
101
  summary: Ruby test runner
97
102
  test_files:
98
- - spec/smoke_spec.rb
103
+ - spec/diff_parser_spec.rb
99
104
  - spec/spec_helper.rb
data/spec/smoke_spec.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe Devloop do
6
- end