smartest 0.6.2 → 0.7.0
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 +8 -0
- data/README.md +10 -4
- data/lib/smartest/init_rails_generator.rb +2 -2
- data/lib/smartest/{rails.rb → rack.rb} +4 -4
- data/lib/smartest/version.rb +1 -1
- data/smartest/smartest_test.rb +11 -11
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6ad960075fac5ace157331444bdc448d1325cbf1fa19d7ecc17b67586011e97
|
|
4
|
+
data.tar.gz: 7ba158adac3211340a492432208ea9c57315be6946b28acd8e9c4a423de67a28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3926a55fa11cfbd6bae599318cb94aa5e7f32840d853f5c25244aaf0cac827df7f6bfe2de1f849e73a009d02ff599f4f52a1041d0b6a0680369945503c859100
|
|
7
|
+
data.tar.gz: 1eb3e75230cf1aa0b278c0486d1986f509f9eee6fcb1fe3e43f28cea9f74f3eef9490032228cea6eae515c318c2a70ad3573c5118d6277ea095dfc402c370a58
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- Rename the Rails test server to a Rack test server. Replace
|
|
8
|
+
`require "smartest/rails"` with `require "smartest/rack"` and
|
|
9
|
+
`Smartest::Rails::TestServer` with `Smartest::Rack::TestServer`.
|
|
10
|
+
|
|
3
11
|
## 0.6.1
|
|
4
12
|
|
|
5
13
|
### Bug Fixes
|
data/README.md
CHANGED
|
@@ -259,15 +259,17 @@ smartest/matchers/playwright_matcher.rb
|
|
|
259
259
|
smartest/example_rails_system_test.rb
|
|
260
260
|
```
|
|
261
261
|
|
|
262
|
-
The generated fixture requires `smartest/
|
|
262
|
+
The generated fixture requires `smartest/rack`, loads `config/environment`
|
|
263
263
|
when `test_helper` requires the fixture file, and starts
|
|
264
|
-
`Smartest::
|
|
264
|
+
`Smartest::Rack::TestServer` against `Rails.application` in the same Ruby
|
|
265
265
|
process as the test runner. Loading Rails during helper setup makes app
|
|
266
266
|
constants such as ActiveRecord models available inside test files and
|
|
267
267
|
`around_test` hooks before per-test fixtures are resolved. The generated
|
|
268
268
|
fixture forces `RAILS_ENV` and `RACK_ENV` to `test` before Rails boots.
|
|
269
|
-
`Smartest::
|
|
270
|
-
`smartest/
|
|
269
|
+
`Smartest::Rack::TestServer` is only loaded by explicitly requiring
|
|
270
|
+
`smartest/rack`; plain `require "smartest"` does not load Puma.
|
|
271
|
+
Despite being used by the Rails scaffold, it accepts any Rack app via `app:`,
|
|
272
|
+
including Sinatra, Hanami, and other Rack-compatible apps.
|
|
271
273
|
|
|
272
274
|
This is aimed at local Rails system tests that combine Rails test data, stubs,
|
|
273
275
|
and Playwright browser assertions. It is not a Capybara compatibility layer or
|
|
@@ -292,6 +294,10 @@ At runtime, set `PLAYWRIGHT_WS_ENDPOINT`,
|
|
|
292
294
|
sidecar and gives the browser a Docker-network URL for Rails. These are usually
|
|
293
295
|
stable Docker topology settings, so put them in `compose.yml` instead of
|
|
294
296
|
repeating them on every `docker compose run` command.
|
|
297
|
+
Because this path connects to Playwright over WebSocket, `websocket-driver` is
|
|
298
|
+
**REQUIRED only when** using `PLAYWRIGHT_WS_ENDPOINT` or
|
|
299
|
+
`Playwright.connect_to_browser_server`; local Rails browser tests that launch
|
|
300
|
+
Playwright locally do not need it.
|
|
295
301
|
For a Rails Compose service named `web`, use
|
|
296
302
|
`SMARTEST_RAILS_BASE_URL=http://web:4001`; replace `web` with your service name.
|
|
297
303
|
The generated Rails fixture sets `RAILS_ENV` and `RACK_ENV` to `test`, even if
|
|
@@ -7,7 +7,7 @@ module Smartest
|
|
|
7
7
|
RAILS_SYSTEM_FIXTURE = <<~RUBY
|
|
8
8
|
# frozen_string_literal: true
|
|
9
9
|
|
|
10
|
-
require 'smartest/
|
|
10
|
+
require 'smartest/rack'
|
|
11
11
|
require "playwright"
|
|
12
12
|
|
|
13
13
|
# Force the test environment and load Rails while test_helper is required
|
|
@@ -18,7 +18,7 @@ module Smartest
|
|
|
18
18
|
|
|
19
19
|
class RailsSystemTestFixture < Smartest::Fixture
|
|
20
20
|
suite_fixture :rails_server do
|
|
21
|
-
server = Smartest::
|
|
21
|
+
server = Smartest::Rack::TestServer.new(
|
|
22
22
|
app: Rails.application,
|
|
23
23
|
host: ENV["SMARTEST_RAILS_TEST_SERVER_HOST"],
|
|
24
24
|
port: ENV["SMARTEST_RAILS_TEST_SERVER_PORT"],
|
|
@@ -7,7 +7,7 @@ require "timeout"
|
|
|
7
7
|
require_relative "../smartest"
|
|
8
8
|
|
|
9
9
|
module Smartest
|
|
10
|
-
module
|
|
10
|
+
module Rack
|
|
11
11
|
class TestServer
|
|
12
12
|
DEFAULT_READY_TIMEOUT = 10
|
|
13
13
|
|
|
@@ -35,14 +35,14 @@ module Smartest
|
|
|
35
35
|
sleep 0.05 until responsive?
|
|
36
36
|
end
|
|
37
37
|
rescue Timeout::Error
|
|
38
|
-
raise "
|
|
38
|
+
raise "Rack test server did not become ready at #{base_url} within #{timeout} seconds"
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def wait_for_stopped(timeout: DEFAULT_READY_TIMEOUT)
|
|
42
42
|
return unless @thread
|
|
43
43
|
return if @thread.join(timeout)
|
|
44
44
|
|
|
45
|
-
raise "
|
|
45
|
+
raise "Rack test server did not stop within #{timeout} seconds"
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def base_url
|
|
@@ -57,7 +57,7 @@ module Smartest
|
|
|
57
57
|
|
|
58
58
|
return bound_port if bound_port && bound_port.positive?
|
|
59
59
|
|
|
60
|
-
raise "
|
|
60
|
+
raise "Rack test server could not determine bound port"
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def responsive?
|
data/lib/smartest/version.rb
CHANGED
data/smartest/smartest_test.rb
CHANGED
|
@@ -2290,13 +2290,13 @@ test("cli browser init generator skips npm init when package.json already exists
|
|
|
2290
2290
|
end
|
|
2291
2291
|
end
|
|
2292
2292
|
|
|
2293
|
-
test("smartest
|
|
2293
|
+
test("smartest rack helper is loaded only by explicit require") do
|
|
2294
2294
|
lib_path = File.expand_path("../lib", __dir__)
|
|
2295
2295
|
stdout, stderr, status = Open3.capture3(
|
|
2296
2296
|
{ "RUBYLIB" => lib_path },
|
|
2297
2297
|
"ruby",
|
|
2298
2298
|
"-e",
|
|
2299
|
-
'require "smartest"; puts Smartest.const_defined?(:
|
|
2299
|
+
'require "smartest"; puts Smartest.const_defined?(:Rack, false)'
|
|
2300
2300
|
)
|
|
2301
2301
|
|
|
2302
2302
|
expect(status.success?).to eq(true)
|
|
@@ -2310,7 +2310,7 @@ test("smartest rails helper is loaded only by explicit require") do
|
|
|
2310
2310
|
{ "RUBYLIB" => "#{dir}:#{lib_path}" },
|
|
2311
2311
|
"ruby",
|
|
2312
2312
|
"-e",
|
|
2313
|
-
'require "smartest/
|
|
2313
|
+
'require "smartest/rack"; puts Smartest::Rack.const_defined?(:TestServer, false)'
|
|
2314
2314
|
)
|
|
2315
2315
|
|
|
2316
2316
|
expect(status.success?).to eq(true)
|
|
@@ -2319,7 +2319,7 @@ test("smartest rails helper is loaded only by explicit require") do
|
|
|
2319
2319
|
end
|
|
2320
2320
|
end
|
|
2321
2321
|
|
|
2322
|
-
test("smartest
|
|
2322
|
+
test("smartest rack test server wraps puma with explicit arguments and lifecycle") do
|
|
2323
2323
|
lib_path = File.expand_path("../lib", __dir__)
|
|
2324
2324
|
|
|
2325
2325
|
Dir.mktmpdir do |dir|
|
|
@@ -2367,10 +2367,10 @@ test("smartest rails test server wraps puma with explicit arguments and lifecycl
|
|
|
2367
2367
|
"ruby",
|
|
2368
2368
|
"-e",
|
|
2369
2369
|
<<~'RUBY'
|
|
2370
|
-
require "smartest/
|
|
2370
|
+
require "smartest/rack"
|
|
2371
2371
|
|
|
2372
|
-
server = Smartest::
|
|
2373
|
-
default_port_server = Smartest::
|
|
2372
|
+
server = Smartest::Rack::TestServer.new(app: Object.new, port: "4567")
|
|
2373
|
+
default_port_server = Smartest::Rack::TestServer.new(app: Object.new)
|
|
2374
2374
|
thread = server.start
|
|
2375
2375
|
server.stop
|
|
2376
2376
|
server.wait_for_stopped
|
|
@@ -2411,7 +2411,7 @@ test("cli rails init generator creates Rails browser scaffold and installation c
|
|
|
2411
2411
|
|
|
2412
2412
|
expect(status).to eq(0)
|
|
2413
2413
|
rails_fixture = File.read(File.join(dir, "smartest/fixtures/rails_system_fixture.rb"))
|
|
2414
|
-
expect(rails_fixture).to include("require 'smartest/
|
|
2414
|
+
expect(rails_fixture).to include("require 'smartest/rack'")
|
|
2415
2415
|
expect(rails_fixture).to include("class RailsSystemTestFixture < Smartest::Fixture")
|
|
2416
2416
|
expect(rails_fixture).to include("suite_fixture :rails_server")
|
|
2417
2417
|
expect(rails_fixture).to include('ENV["RAILS_ENV"] = "test"')
|
|
@@ -2420,7 +2420,7 @@ test("cli rails init generator creates Rails browser scaffold and installation c
|
|
|
2420
2420
|
expect(rails_fixture).to include("constants are available before per-test fixtures are resolved")
|
|
2421
2421
|
expect(rails_fixture).to include('require_relative "../../config/environment"')
|
|
2422
2422
|
expect(rails_fixture.index('require_relative "../../config/environment"') < rails_fixture.index("class RailsSystemTestFixture")).to eq(true)
|
|
2423
|
-
expect(rails_fixture).to include("Smartest::
|
|
2423
|
+
expect(rails_fixture).to include("Smartest::Rack::TestServer.new(")
|
|
2424
2424
|
expect(rails_fixture).to include('host: ENV["SMARTEST_RAILS_TEST_SERVER_HOST"]')
|
|
2425
2425
|
expect(rails_fixture).not_to include("bind_host:")
|
|
2426
2426
|
expect(rails_fixture).to include('port: ENV["SMARTEST_RAILS_TEST_SERVER_PORT"]')
|
|
@@ -2497,7 +2497,7 @@ test("cli rails init generator forces Rails test environment when the generated
|
|
|
2497
2497
|
|
|
2498
2498
|
stub_dir = File.join(dir, "stub_load_path")
|
|
2499
2499
|
FileUtils.mkdir_p(File.join(stub_dir, "smartest"))
|
|
2500
|
-
File.write(File.join(stub_dir, "smartest/
|
|
2500
|
+
File.write(File.join(stub_dir, "smartest/rack.rb"), <<~RUBY)
|
|
2501
2501
|
module Smartest
|
|
2502
2502
|
class Fixture
|
|
2503
2503
|
def self.suite_fixture(*)
|
|
@@ -2507,7 +2507,7 @@ test("cli rails init generator forces Rails test environment when the generated
|
|
|
2507
2507
|
end
|
|
2508
2508
|
end
|
|
2509
2509
|
|
|
2510
|
-
module
|
|
2510
|
+
module Rack
|
|
2511
2511
|
end
|
|
2512
2512
|
end
|
|
2513
2513
|
RUBY
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smartest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yusuke Iwaki
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -66,7 +66,7 @@ files:
|
|
|
66
66
|
- lib/smartest/matcher_registry.rb
|
|
67
67
|
- lib/smartest/matchers.rb
|
|
68
68
|
- lib/smartest/parameter_extractor.rb
|
|
69
|
-
- lib/smartest/
|
|
69
|
+
- lib/smartest/rack.rb
|
|
70
70
|
- lib/smartest/reporter.rb
|
|
71
71
|
- lib/smartest/runner.rb
|
|
72
72
|
- lib/smartest/simple_stub.rb
|