capybara-thruster 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +18 -3
- data/lib/capybara/dependency_checker.rb +30 -0
- data/lib/capybara/thruster/version.rb +1 -1
- data/lib/capybara/thruster.rb +6 -2
- metadata +49 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb193e41ea232704ba2ae902a1dcb1ce3986503d1cbe4a0032bc0749af052ca0
|
4
|
+
data.tar.gz: d42cad741af90cc72b10c2cad6e715b1494edb52ea533ae2f6b66bbbc1f9b99e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 931611098086ebf60db3ac10085e2b0af922af17b8513c5a0a2c431f176e585588f94a76b32830b523940b6f9fa707aa2a7f7a89f3871db3625e1825328cf28e
|
7
|
+
data.tar.gz: 3d6edd5a360dbfcbc3652b4deb18f79cb90b3e1f9c4fbd7f71ccc0a80eec6da274921296ddf4e459a2abf1e95e03959b53e9225c3c8d43b2117239536af46bfd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
3
|
## master
|
4
|
+
|
5
|
+
## 0.1.1
|
6
|
+
|
7
|
+
- Show a warning if no Thruster gem installed. ([@prog-supdex][])
|
8
|
+
|
9
|
+
## 0.1.0
|
10
|
+
|
11
|
+
- Initial release ([@palkan][])
|
12
|
+
|
13
|
+
[@palkan]: https://github.com/palkan
|
14
|
+
[@prog-supdex]: https://github.com/prog-supdex
|
data/README.md
CHANGED
@@ -5,11 +5,23 @@
|
|
5
5
|
|
6
6
|
This gem makes it possible to use [Thruster][] as a Capybara server. Run your browser test with HTTP/2 enabled and static assets served via Thruster for faster load times!
|
7
7
|
|
8
|
-
> [TIP
|
8
|
+
> [!TIP]
|
9
9
|
> Using AnyCable? This gem works with [AnyCable-d Thruster][anycable-thruster], so you can run your system tests against a real AnyCable server with all its features!
|
10
10
|
|
11
11
|
## Getting started
|
12
12
|
|
13
|
+
### Prerequisites
|
14
|
+
|
15
|
+
Before adding the gem to your project, ensure you have either `thruster` or `anycable-thruster` installed. You can add one of these gems to your `Gemfile`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
# For thruster
|
19
|
+
gem "thruster"
|
20
|
+
|
21
|
+
# or for anycable-thruster
|
22
|
+
gem "anycable-thruster"
|
23
|
+
```
|
24
|
+
|
13
25
|
Adding the gem to your project:
|
14
26
|
|
15
27
|
```ruby
|
@@ -25,12 +37,15 @@ Capybara.server = :thruster
|
|
25
37
|
# You can also specify some options.
|
26
38
|
|
27
39
|
# For example, if you want to see the server output,
|
28
|
-
# pass the `debug: true` option
|
40
|
+
# pass the `debug: true` option:
|
29
41
|
Capybara.server = :thruster, {debug: true}
|
30
42
|
|
31
43
|
# To customize the server settings, you can pass arbitrary environment
|
32
|
-
# variables via the `env` option
|
44
|
+
# variables via the `env` option:
|
33
45
|
Capybara.server = :thruster, {env: {"DEBUG" => "true"}}
|
46
|
+
|
47
|
+
# To specify Puma server options, use the `puma_options` option:
|
48
|
+
Capybara.server = :thruster, {puma_options: {Silent: false}}
|
34
49
|
```
|
35
50
|
|
36
51
|
## Contributing
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Capybara
|
4
|
+
module Thruster
|
5
|
+
class DependencyChecker
|
6
|
+
def self.call
|
7
|
+
new.call
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
unless thruster_installed?
|
12
|
+
warn "*********************************************************"
|
13
|
+
warn "Warning: capybara-thruster requires either 'thruster' or 'anycable-thruster' gem."
|
14
|
+
warn "Please install one of them to ensure proper functionality."
|
15
|
+
warn "*********************************************************"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def thruster_installed?
|
22
|
+
gem_installed?("thruster") || gem_installed?("anycable-thruster")
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem_installed?(name)
|
26
|
+
Gem::Specification.find_all_by_name(name).any?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/capybara/thruster.rb
CHANGED
@@ -2,13 +2,16 @@
|
|
2
2
|
|
3
3
|
require "childprocess"
|
4
4
|
require "capybara"
|
5
|
+
require "capybara/dependency_checker"
|
6
|
+
require "rack/handler"
|
7
|
+
|
8
|
+
Capybara::Thruster::DependencyChecker.call
|
5
9
|
|
6
10
|
# Replaces the default Puma server on CAPYBARA_SERVER_PORT port with Thruster server.
|
7
11
|
# Requests are proxied to the Puma server running on the internal port (CAPYBARA_SERVER_PORT + 1).
|
8
12
|
Capybara.register_server :thruster do |app, port, host, **options|
|
9
13
|
puma_port = port + 1
|
10
14
|
|
11
|
-
# TODO: Figure out how to avoid sleep here
|
12
15
|
process = ChildProcess.build("bundle", "exec", "thrust", "ruby", "-e", "sleep")
|
13
16
|
process.environment["TARGET_PORT"] = puma_port.to_s
|
14
17
|
process.environment["HTTP_PORT"] = port.to_s
|
@@ -21,5 +24,6 @@ Capybara.register_server :thruster do |app, port, host, **options|
|
|
21
24
|
|
22
25
|
at_exit { process.stop }
|
23
26
|
|
24
|
-
|
27
|
+
puma_options = options.fetch(:puma_options, {Silent: true})
|
28
|
+
Capybara.servers[:puma].call(app, puma_port, host, **puma_options)
|
25
29
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-thruster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: childprocess
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,20 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '1.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rackup
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rake
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +108,20 @@ dependencies:
|
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '5.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: thruster
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
83
125
|
description: Example description
|
84
126
|
email:
|
85
127
|
- Vladimir Dementyev
|
@@ -91,6 +133,7 @@ files:
|
|
91
133
|
- LICENSE.txt
|
92
134
|
- README.md
|
93
135
|
- lib/capybara-thruster.rb
|
136
|
+
- lib/capybara/dependency_checker.rb
|
94
137
|
- lib/capybara/thruster.rb
|
95
138
|
- lib/capybara/thruster/version.rb
|
96
139
|
homepage: https://github.com/evilmartians/capybara-thruster
|
@@ -102,7 +145,7 @@ metadata:
|
|
102
145
|
documentation_uri: https://github.com/evilmartians/capybara-thruster
|
103
146
|
homepage_uri: https://github.com/evilmartians/capybara-thruster
|
104
147
|
source_code_uri: https://github.com/evilmartians/capybara-thruster
|
105
|
-
post_install_message:
|
148
|
+
post_install_message:
|
106
149
|
rdoc_options: []
|
107
150
|
require_paths:
|
108
151
|
- lib
|
@@ -117,8 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
160
|
- !ruby/object:Gem::Version
|
118
161
|
version: '0'
|
119
162
|
requirements: []
|
120
|
-
rubygems_version: 3.4.
|
121
|
-
signing_key:
|
163
|
+
rubygems_version: 3.4.19
|
164
|
+
signing_key:
|
122
165
|
specification_version: 4
|
123
166
|
summary: Example description
|
124
167
|
test_files: []
|