rspec-daemon 0.1.5 → 1.0.1
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/CHANGELOG.md +10 -1
- data/README.md +70 -0
- data/exe/rspec-daemon +1 -1
- data/exe/rspeccc +4 -0
- data/lib/rspec/daemon/cli.rb +36 -2
- data/lib/rspec/daemon/client_cli.rb +52 -0
- data/lib/rspec/daemon/version.rb +1 -1
- data/lib/rspec/daemon.rb +6 -10
- data/rspec-daemon.gemspec +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89e342dbe33448b2a4321d6425f22924ef2e2ffca0da9c62b9b9dfe85b30df24
|
4
|
+
data.tar.gz: c73ef7dc9be41b613ab443f9c3bde415afe4689bf4114bbb98fc137429b7128c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40f70439941100811fbcf34906e077be7d8172399ecd5a046b0815dbc3ec786a87b280a6332a97dced543d4a65e13ad924b93f902ed524f9eb700ff5bea2c1a
|
7
|
+
data.tar.gz: 5951972b8a86979b652a757a0ca36f41daee408728e512125230c02ee90a73088f1dd2fb064f89540fe8724ff3754ef04ce416e47b8cc7a1b3730c3525e22f6b
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
## [
|
1
|
+
## [1.0.1] - 2023-12-16
|
2
|
+
|
3
|
+
- Fix the method to start the test #9 @ta1kt0me
|
4
|
+
|
5
|
+
## [1.0.0] - 2023-12-15
|
6
|
+
|
7
|
+
- Make bind address and port configurable #7 @osyoyu
|
8
|
+
- Remove pry dependency #6 @osyoyu
|
9
|
+
- rspeccc, a client tool for rspec-daemon #5 @osyoyu
|
10
|
+
- allow configuration of port via env #4 @felixRun
|
2
11
|
|
3
12
|
## [0.1.0] - 2023-04-11
|
4
13
|
|
data/README.md
CHANGED
@@ -15,15 +15,85 @@ gem 'rspec-daemon', require: false
|
|
15
15
|
|
16
16
|
## Usage
|
17
17
|
|
18
|
+
Start the daemon process by running `rspec-daemon` in the directory where you would run `rspec`.
|
19
|
+
|
18
20
|
```
|
19
21
|
$ cd YOUR_PROJECT
|
20
22
|
$ bundle ex rspec-daemon
|
23
|
+
Listening on tcp://0.0.0.0:3002
|
24
|
+
```
|
25
|
+
|
26
|
+
To run specs, use the `rspeccc` client tool.
|
27
|
+
|
28
|
+
```
|
29
|
+
$ bundle ex rspeccc spec/models/user_spec.rb # arguments are passed to rspec
|
30
|
+
|
31
|
+
User
|
32
|
+
is healthy
|
33
|
+
|
34
|
+
Finished in 0.00136 seconds (files took 36.25 seconds to load)
|
35
|
+
1 example, 0 failures
|
21
36
|
```
|
22
37
|
|
38
|
+
Alternatively, standard utilites such as `nc` may be used.
|
39
|
+
|
23
40
|
```
|
24
41
|
$ echo 'spec/models/user_spec.rb' | nc -v 0.0.0.0 3002
|
25
42
|
```
|
26
43
|
|
44
|
+
By default, `rspec-daemon` will run on port `3002`. You can adjust the port by passing `--port` to `rspec-daemon` or setting the `RSPEC_DAEMON_PORT` environment variable.
|
45
|
+
|
46
|
+
## Editor integration
|
47
|
+
|
48
|
+
### Vim/Neovim
|
49
|
+
|
50
|
+
Add a key binding of your preference to your `.vimrc` or `init.vim`.
|
51
|
+
|
52
|
+
```vim
|
53
|
+
" Run specs under the current cursor line
|
54
|
+
nnoremap <Leader>h :execute '!bundle exec rspeccc ' . expand('%:p') . ':' . line('.')<CR>
|
55
|
+
```
|
56
|
+
|
57
|
+
If you are using [rspec.vim](https://github.com/thoughtbot/vim-rspec), you may want to configure `g:rspec_command`.
|
58
|
+
|
59
|
+
```vim
|
60
|
+
" For rspec.vim users
|
61
|
+
let g:rspec_command = "!bundle exec rspeccc {spec}"
|
62
|
+
```
|
63
|
+
|
64
|
+
### Visual Studio Code
|
65
|
+
|
66
|
+
Tasks are a nice way to launch `rspeccc`.
|
67
|
+
Here is an example `tasks.json` configuration which runs specs under the current cursor location:
|
68
|
+
|
69
|
+
```json
|
70
|
+
{
|
71
|
+
"version": "2.0.0",
|
72
|
+
"tasks": [
|
73
|
+
{
|
74
|
+
"label": "rspec-remote: Cursor context",
|
75
|
+
"group": "test",
|
76
|
+
"type": "shell",
|
77
|
+
"command": "bundle exec rspeccc ${relativeFile}:${lineNumber}"
|
78
|
+
}
|
79
|
+
]
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
Adding a keybindings.json entry for your Task is also recommendable.
|
84
|
+
|
85
|
+
```json
|
86
|
+
[
|
87
|
+
{
|
88
|
+
"key": "cmd+h",
|
89
|
+
"command": "workbench.action.tasks.runTask",
|
90
|
+
"args": "rspec-remote: Cursor context"
|
91
|
+
}
|
92
|
+
]
|
93
|
+
```
|
94
|
+
|
95
|
+
Refer to Visual Studio Code's documentation ([Integrate with External Tools via Tasks](https://go.microsoft.com/fwlink/?LinkId=733558)) for further customization.
|
96
|
+
|
27
97
|
## Development
|
28
98
|
|
29
99
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/rspec-daemon
CHANGED
data/exe/rspeccc
ADDED
data/lib/rspec/daemon/cli.rb
CHANGED
@@ -3,8 +3,42 @@ require_relative '../daemon'
|
|
3
3
|
module RSpec
|
4
4
|
class Daemon
|
5
5
|
class Cli
|
6
|
-
|
7
|
-
|
6
|
+
DEFAULT_OPTIONS = {
|
7
|
+
bind_address: "0.0.0.0",
|
8
|
+
port: 3002,
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.start(...)
|
12
|
+
new.start(...)
|
13
|
+
end
|
14
|
+
|
15
|
+
def start(argv)
|
16
|
+
options = DEFAULT_OPTIONS.dup
|
17
|
+
if ENV['RSPEC_DAEMON_BIND_ADDRESS']
|
18
|
+
options[:bind_address] = ENV['RSPEC_DAEMON_BIND_ADDRESS']
|
19
|
+
end
|
20
|
+
if ENV['RSPEC_DAEMON_PORT']
|
21
|
+
options[:port] = ENV['RSPEC_DAEMON_PORT'].to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
option_parser = OptionParser.new do |opts|
|
25
|
+
opts.on('-v', '--version', 'Prints version') do
|
26
|
+
puts RSpec::Daemon::VERSION
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('-b', '--bind ADDRESS', 'address to bind (default: 0.0.0.0)') do |address|
|
31
|
+
options[:bind_address] = address
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('-p', '--port PORT', 'port to listen on (default: 3002)') do |port|
|
35
|
+
options[:port] = port
|
36
|
+
end
|
37
|
+
end
|
38
|
+
option_parser.parse!(argv)
|
39
|
+
|
40
|
+
RSpec::Daemon.new(options[:bind_address], options[:port]).start
|
41
|
+
0
|
8
42
|
end
|
9
43
|
end
|
10
44
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../daemon'
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
class Daemon
|
5
|
+
class ClientCli
|
6
|
+
DEFAULT_OPTIONS = {
|
7
|
+
host: "localhost",
|
8
|
+
port: 3002,
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.start(...)
|
12
|
+
new.start(...)
|
13
|
+
end
|
14
|
+
|
15
|
+
def start(argv)
|
16
|
+
options = DEFAULT_OPTIONS.dup
|
17
|
+
option_parser = OptionParser.new do |opts|
|
18
|
+
opts.on('-v', '--version', 'Prints version') do
|
19
|
+
puts RSpec::Daemon::VERSION
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on('-h', '--host HOST', 'rspec-daemon host (default: localhost)') do |host|
|
24
|
+
options[:host] = host
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on('-p', '--port PORT', 'rspec-daemon port (default: 3002)') do |port|
|
28
|
+
options[:port] = port
|
29
|
+
end
|
30
|
+
end
|
31
|
+
option_parser.parse!(argv)
|
32
|
+
# Send all other arguments to rspec via the daemon
|
33
|
+
command = argv.join(' ') + "\n"
|
34
|
+
|
35
|
+
begin
|
36
|
+
# Open connection to rspec-daemon
|
37
|
+
socket = TCPSocket.open(options[:host], options[:port])
|
38
|
+
socket.write(command)
|
39
|
+
while line = socket.gets # rubocop:disable Lint/AssignmentInCondition
|
40
|
+
print line
|
41
|
+
end
|
42
|
+
socket.close
|
43
|
+
rescue Errno::ECONNREFUSED => e
|
44
|
+
STDERR.puts "Failed to connect to #{options[:host]}:#{options[:port]} (#{e})"
|
45
|
+
return 1
|
46
|
+
end
|
47
|
+
|
48
|
+
0
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/rspec/daemon/version.rb
CHANGED
data/lib/rspec/daemon.rb
CHANGED
@@ -6,7 +6,6 @@ require_relative "daemon/configuration"
|
|
6
6
|
require "socket"
|
7
7
|
require "stringio"
|
8
8
|
require "rspec"
|
9
|
-
require "pry"
|
10
9
|
|
11
10
|
module RSpec
|
12
11
|
class Daemon
|
@@ -14,20 +13,17 @@ module RSpec
|
|
14
13
|
|
15
14
|
class Error < StandardError; end
|
16
15
|
|
17
|
-
def
|
18
|
-
|
16
|
+
def initialize(bind_address, port)
|
17
|
+
@bind_address = bind_address
|
18
|
+
@port = port
|
19
19
|
end
|
20
20
|
|
21
21
|
def start
|
22
|
-
entry_point
|
23
|
-
end
|
24
|
-
|
25
|
-
def entry_point
|
26
22
|
$LOAD_PATH << "./spec"
|
27
23
|
|
28
24
|
RSpec::Core::Runner.disable_autorun!
|
29
|
-
server = TCPServer.open(
|
30
|
-
puts "
|
25
|
+
server = TCPServer.open(@bind_address, @port)
|
26
|
+
puts "Listening on tcp://#{server.addr[2]}:#{server.addr[1]}"
|
31
27
|
|
32
28
|
loop do
|
33
29
|
handle_request(server.accept)
|
@@ -39,7 +35,7 @@ module RSpec
|
|
39
35
|
end
|
40
36
|
|
41
37
|
def handle_request(socket)
|
42
|
-
status, out = run(socket.
|
38
|
+
status, out = run(socket.gets)
|
43
39
|
|
44
40
|
socket.puts(status)
|
45
41
|
socket.puts(out)
|
data/rspec-daemon.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
33
|
spec.add_dependency "rspec"
|
34
|
-
spec.
|
34
|
+
spec.add_development_dependency "pry"
|
35
35
|
|
36
36
|
# For more information and examples about making a new gem, check out our
|
37
37
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-daemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya Fujiwara
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -43,6 +43,7 @@ email:
|
|
43
43
|
- asonas@cookpad.com
|
44
44
|
executables:
|
45
45
|
- rspec-daemon
|
46
|
+
- rspeccc
|
46
47
|
extensions: []
|
47
48
|
extra_rdoc_files: []
|
48
49
|
files:
|
@@ -58,8 +59,10 @@ files:
|
|
58
59
|
- example/Gemfile.lock
|
59
60
|
- example/user_spec.rb
|
60
61
|
- exe/rspec-daemon
|
62
|
+
- exe/rspeccc
|
61
63
|
- lib/rspec/daemon.rb
|
62
64
|
- lib/rspec/daemon/cli.rb
|
65
|
+
- lib/rspec/daemon/client_cli.rb
|
63
66
|
- lib/rspec/daemon/configuration.rb
|
64
67
|
- lib/rspec/daemon/version.rb
|
65
68
|
- rspec-daemon.gemspec
|
@@ -71,7 +74,7 @@ metadata:
|
|
71
74
|
homepage_uri: https://github.com/asonas/rspec-daemon
|
72
75
|
source_code_uri: https://github.com/asonas/rspec-daemon
|
73
76
|
changelog_uri: https://github.com/asonas/rspec-daemon/blob/master/CHANGELOG.md
|
74
|
-
post_install_message:
|
77
|
+
post_install_message:
|
75
78
|
rdoc_options: []
|
76
79
|
require_paths:
|
77
80
|
- lib
|
@@ -86,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
89
|
- !ruby/object:Gem::Version
|
87
90
|
version: '0'
|
88
91
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
90
|
-
signing_key:
|
92
|
+
rubygems_version: 3.4.10
|
93
|
+
signing_key:
|
91
94
|
specification_version: 4
|
92
95
|
summary: rspec-daemon is a mechanism to run tests at super faster speed
|
93
96
|
test_files: []
|