rspec-watcher 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -24
- data/lib/rspec-watcher.rb +1 -0
- data/lib/rspec_watcher/tasks/watch.rake +6 -6
- data/lib/rspec_watcher/version.rb +1 -1
- metadata +3 -4
- data/rspec_watcher.gemspec +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 298785cbb1ce4aa2e1bbd5cf68e6b2e00537cb4395b738f6d10823703de22ed5
|
4
|
+
data.tar.gz: 770ed8be7ea9c8ec239147669b6b4751d436467f30c2f15a825db8c777bee822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10868133ea19816f38a8688f35cdf2e586e6ff9cd1a456777f603ba33a5fd575e737f74ada3461a6b266ec1bbe5c9933bbb2719b3eac62d7d496c7fb99e15b49
|
7
|
+
data.tar.gz: dfc02f84e633cd55fd4131b2459f5749235b4189caf01769d0e3c6fc63b67c2db83c0939c601aee0adebf35c7ac27bea34b07774253fa1b9962fe41c8c40a2aa
|
data/README.md
CHANGED
@@ -1,49 +1,67 @@
|
|
1
|
-
#
|
1
|
+
# RSpecWatcher
|
2
2
|
|
3
|
-
Automatically runs specs in reaction to changes in files.
|
3
|
+
Provides an instant feedback loop for TDD with RSpec. Automatically runs specs in reaction to changes in files. Inspired by [Guard](https://github.com/guard/guard), but unlike Guard, the watcher does not start a new process every time. It only loads the project once and uses code reloading to get changes. Needs to be restarted after changes to files that do not get reloaded (just like you would restart a Rails development server).
|
4
4
|
|
5
|
-
|
5
|
+
Specs that fail are remembered and will be rerun until they pass again. This enables a nearly instant TDD feedbeck loop, because every spec we add will be automatically picked up and run until we add the implementation.
|
6
6
|
|
7
|
-
|
7
|
+
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
Add `rspec-watcher` to the Gemfile, only needs to exist in the `test` group.
|
10
10
|
|
11
|
-
|
11
|
+
```ruby
|
12
|
+
group :test do
|
13
|
+
gem 'rspec-watcher'
|
14
|
+
end
|
15
|
+
```
|
12
16
|
|
13
|
-
|
17
|
+
Then run `bundle install`
|
14
18
|
|
15
19
|
## Usage
|
16
20
|
|
17
|
-
|
21
|
+
### Configuration
|
18
22
|
|
19
|
-
|
23
|
+
Disable caching classes in `config/environments/test.rb` when the watcher is running:
|
20
24
|
|
21
|
-
|
25
|
+
```ruby
|
26
|
+
config.cache_classes = ENV['RSPEC_WATCHER'].nil?
|
27
|
+
```
|
28
|
+
|
29
|
+
Rules for the watcher and other options can be customized, for example in a Rails initializer. Not passing a block to a `watch` rule will run all specs. The configuration shown here is used by default:
|
22
30
|
|
23
31
|
```ruby
|
24
|
-
|
25
|
-
watch 'spec', only: /_spec\.rb\z/ do |modified, added, _removed|
|
26
|
-
modified + added
|
27
|
-
end
|
32
|
+
# config/initializers/rspec_watcher.rb
|
28
33
|
|
29
|
-
|
34
|
+
if ENV['RSPEC_WATCHER']
|
35
|
+
RSpecWatcher.configure do
|
36
|
+
watch 'spec', only: /_spec\.rb\z/ do |modified, added, _removed|
|
37
|
+
modified + added
|
38
|
+
end
|
39
|
+
|
40
|
+
watch 'spec', ignore: /_spec\.rb\z/
|
30
41
|
|
31
|
-
|
32
|
-
|
33
|
-
|
42
|
+
watch 'app', only: /\.rb\z/, ignore: %r{controllers/} do |modified, added, removed|
|
43
|
+
(modified + added + removed).map do |path|
|
44
|
+
path.sub('app/', 'spec/').sub('.rb', '_spec.rb')
|
45
|
+
end
|
34
46
|
end
|
35
|
-
end
|
36
47
|
|
37
|
-
|
38
|
-
|
39
|
-
|
48
|
+
watch 'app/controllers', only: /\.rb\z/ do |modified, added, removed|
|
49
|
+
(modified + added + removed).map do |path|
|
50
|
+
path.sub('app/', 'spec/').sub('controllers/', 'requests/').sub('_controller.rb', '_spec.rb')
|
51
|
+
end
|
40
52
|
end
|
41
|
-
end
|
42
53
|
|
43
|
-
|
54
|
+
watch 'config', only: /routes\.rb\z/
|
55
|
+
end
|
44
56
|
end
|
45
57
|
```
|
46
58
|
|
59
|
+
### Running the watcher
|
60
|
+
|
61
|
+
Start the watcher with `RAILS_ENV=test bundle exec rake rspec_watcher:watch`
|
62
|
+
|
63
|
+
In order to use the watcher without Rails, `path_inferrer` and `reloader` need to be configured. Check `lib/rspec-watcher.rb`.
|
64
|
+
|
47
65
|
## Development
|
48
66
|
|
49
67
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/rspec-watcher.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
namespace :rspec_watcher do
|
4
|
-
desc 'Start the watcher
|
4
|
+
desc 'Start the watcher'
|
5
5
|
task :watch do
|
6
|
-
abort('Not running in test environment')
|
6
|
+
abort('Not running in test environment') if defined?(Rails) && !Rails.env.test?
|
7
7
|
|
8
8
|
require 'rspec/core'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
else
|
10
|
+
ENV['RSPEC_WATCHER'] = 'true'
|
11
|
+
|
12
|
+
if RSpecWatcher.rules.empty?
|
14
13
|
require_relative '../default_configuration'
|
14
|
+
puts 'Using default configuration'
|
15
15
|
end
|
16
16
|
|
17
17
|
RSpecWatcher.start
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-watcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matous Vokal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
14
|
+
name: rspec-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- lib/rspec_watcher/railtie.rb
|
43
43
|
- lib/rspec_watcher/tasks/watch.rake
|
44
44
|
- lib/rspec_watcher/version.rb
|
45
|
-
- rspec_watcher.gemspec
|
46
45
|
homepage: https://github.com/Sorc96/rspec-watcher
|
47
46
|
licenses:
|
48
47
|
- MIT
|
data/rspec_watcher.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/rspec_watcher/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "rspec-watcher"
|
7
|
-
spec.version = RSpecWatcher::VERSION
|
8
|
-
spec.authors = ["Matous Vokal"]
|
9
|
-
spec.email = ["matous.vokal@gmail.com"]
|
10
|
-
|
11
|
-
spec.summary = "Instant feedback for awesome TDD experience with RSpec."
|
12
|
-
spec.description = "Automatically runs specs in reaction to changes in files. Loads the project once and uses code reloading to get changes instead of starting a new process for every test run."
|
13
|
-
spec.homepage = "https://github.com/Sorc96/rspec-watcher"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.6.0"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/Sorc96/rspec-watcher"
|
19
|
-
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files = Dir.chdir(__dir__) do
|
23
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
-
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
spec.require_paths = ["lib"]
|
28
|
-
|
29
|
-
spec.add_dependency "rspec", "~> 3.0"
|
30
|
-
end
|