smartest 0.3.1 → 0.3.3.alpha1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 262d446f5f8c460bf71fcd4c0d4a7b59d964905926327d8a2612a08befe68d8f
4
- data.tar.gz: 250eb3bf7bca45dc67dbe8ad77a16306274976db7b555c0951060fc6d1950875
3
+ metadata.gz: 8e7e25cbb3432e62d6264a3308b1b8f01406ed44362f742356b31aa31629926a
4
+ data.tar.gz: cbb07c4ae5e9532836d505543f1af85ea222fd013d65b3fa79d0de0228fac1e6
5
5
  SHA512:
6
- metadata.gz: 16aaa0eb4e01fdc26f0f9d9baa49510096bd4d1f131a975951f717da1c3f81c4d847c3d85ee7912ca0811fdb5348ad933cd4483ecf29772c953e356104bcf08b
7
- data.tar.gz: 7a827e6bb95e8a7263806884bcb9150e1f8eaee02b066e702333ea141ed2e1a345d081d94250785e4d2100b444a078d2d5d35caf0ab514913d04e5f43a16fe2b
6
+ metadata.gz: 5d8cc3fde5695e83649858389212a849ded911ff350689747a62a53ae4c0ce7da5c800e8d6866fb46b04756d0f890efaa3107e9e0bed642092cf2f42aa01bb63
7
+ data.tar.gz: dbd5c2b3fab3d0ab182c78d2ee8f60dbb71efe61e0779646bea2194d1e2710bc3baf6c307b046500dcb293446bcd49a1a1c119c09df22703a9805f83992b7780
data/README.md CHANGED
@@ -1,20 +1,31 @@
1
- # Smartest
1
+ # Smartest introduces Pytest-style fixtures for Ruby
2
2
 
3
- Smartest is a small Ruby test runner with a keyword-fixture-first design.
3
+ Smartest is a small Ruby test runner that brings pytest-style fixture
4
+ injection, explicit fixture dependencies, and fixture cleanup to Ruby tests.
4
5
 
5
- It lets you write tests like this:
6
+ Tests request fixtures with Ruby keyword arguments. Fixtures define their own
7
+ dependencies the same way:
6
8
 
7
9
  ```ruby
8
- test("factorial") do
9
- expect(1 * 2 * 3).to eq(6)
10
+ class WebFixture < Smartest::Fixture
11
+ fixture :server do
12
+ server = TestServer.start
13
+ cleanup { server.stop }
14
+ server
15
+ end
16
+
17
+ fixture :client do |server:|
18
+ Client.new(base_url: server.url)
19
+ end
10
20
  end
11
- ```
12
21
 
13
- and fixture-driven tests like this:
22
+ around_suite do |suite|
23
+ use_fixture WebFixture
24
+ suite.run
25
+ end
14
26
 
15
- ```ruby
16
- test("GET /me") do |logged_in_client:|
17
- response = logged_in_client.get("/me")
27
+ test("GET /health") do |client:|
28
+ response = client.get("/health")
18
29
 
19
30
  expect(response.status).to eq(200)
20
31
  end
@@ -26,8 +37,36 @@ Smartest is designed around three ideas:
26
37
  2. Fixture dependencies should be explicit.
27
38
  3. Teardown should be written only when it is needed.
28
39
 
40
+ ## Why Smartest?
41
+
42
+ Ruby already has excellent testing tools, but Smartest focuses on a specific
43
+ idea: tests should explicitly declare their dependencies.
44
+
45
+ RSpec `let` is useful when examples need lazy helper methods. Minitest `setup`
46
+ is simple for xUnit-style setup. Rails fixtures and FactoryBot are great for
47
+ test data. Smartest is aimed at tests where setup resources, dependency graphs,
48
+ and cleanup should be visible in the test signature and fixture definitions.
49
+
50
+ ```ruby
51
+ test("GET /me") do |logged_in_client:|
52
+ response = logged_in_client.get("/me")
53
+
54
+ expect(response.status).to eq(200)
55
+ end
56
+ ```
57
+
58
+ | Tool | Style | Difference from Smartest |
59
+ | --- | --- | --- |
60
+ | RSpec `let` | Lazy helper method | Tests pull dependencies from inside the example. |
61
+ | Minitest `setup` | xUnit setup method | Dependencies often become implicit instance state. |
62
+ | Rails fixtures | Database records | Not resource setup or fixture dependency injection. |
63
+ | FactoryBot | Test data factories | Not fixture lifecycle management. |
64
+ | Smartest | Keyword fixture injection | Tests declare dependencies explicitly. |
65
+
29
66
  ## Installation
30
67
 
68
+ Smartest requires Ruby 2.7 or newer.
69
+
31
70
  Add this line to your application's Gemfile:
32
71
 
33
72
  ```ruby
@@ -776,22 +815,24 @@ end
776
815
 
777
816
  The dependency declaration and usage are in one place.
778
817
 
779
- ## Status
818
+ ## Current scope
780
819
 
781
- Smartest is currently a design-stage test runner.
782
-
783
- The intended MVP includes:
820
+ Smartest currently focuses on a small runner API:
784
821
 
785
822
  - top-level `test`
786
823
  - class-based fixtures
787
824
  - keyword-argument fixture injection
788
825
  - fixture dependencies through keyword arguments
789
826
  - fixture cleanup
827
+ - suite-scoped fixtures through `suite_fixture`
790
828
  - suite hooks with `around_suite`
791
829
  - test hooks with `around_test`
792
830
  - skipped and pending tests through `skip` and `pending`
793
- - `expect(...).to eq(...)`
831
+ - expectation matchers through `expect`
794
832
  - console reporter
795
833
  - CLI runner
796
834
  - circular fixture dependency detection
797
835
  - duplicate fixture detection
836
+
837
+ Nested `describe` blocks, watch mode, parallel execution, and file-scoped
838
+ fixtures are not part of the current MVP.
data/exe/smartest CHANGED
@@ -43,7 +43,7 @@ begin
43
43
  end
44
44
 
45
45
  Smartest.disable_autorun!
46
- Kernel.prepend Smartest::DSL
46
+ Smartest.install_dsl!
47
47
  test_load_path = File.expand_path("smartest", Dir.pwd)
48
48
  $LOAD_PATH.unshift(test_load_path) if Dir.exist?(test_load_path) && !$LOAD_PATH.include?(test_load_path)
49
49
 
@@ -3,6 +3,6 @@
3
3
  require "English"
4
4
  require_relative "../smartest"
5
5
 
6
- Kernel.prepend Smartest::DSL
6
+ Smartest.install_dsl!
7
7
 
8
8
  Smartest.register_autorun!
@@ -70,7 +70,7 @@ module Smartest
70
70
 
71
71
  page.locator("a[href='/gems/smartest']").click
72
72
  expect(page).to have_url("https://rubygems.org/gems/smartest")
73
- expect(page.locator(".versions")).to have_text("0.3.0.alpha1")
73
+ expect(page.locator("h1")).to have_text("smartest")
74
74
  end
75
75
  RUBY
76
76
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartest
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.3.alpha1"
5
5
  end
data/lib/smartest.rb CHANGED
@@ -57,11 +57,26 @@ module Smartest
57
57
  end
58
58
  end
59
59
 
60
+ def install_dsl!
61
+ if kernel_prepend_effective?
62
+ Kernel.prepend DSL
63
+ else
64
+ Object.include DSL
65
+ end
66
+ end
67
+
60
68
  def fatal_exception?(error)
61
69
  error.is_a?(SystemExit) ||
62
70
  error.is_a?(Interrupt) ||
63
71
  error.is_a?(SignalException) ||
64
72
  error.is_a?(NoMemoryError)
65
73
  end
74
+
75
+ private
76
+
77
+ def kernel_prepend_effective?
78
+ # Ruby 2.7 does not support Kernel.prepend for defining top-level method.
79
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0")
80
+ end
66
81
  end
67
82
  end
@@ -2024,8 +2024,11 @@ test("cli browser init generator creates Playwright scaffold and installation co
2024
2024
  status = generator.run
2025
2025
 
2026
2026
  expect(status).to eq(0)
2027
- expect(File.read(File.join(dir, "smartest/example_browser_test.rb"))).to include("finds the smartest gem on RubyGems")
2028
- expect(File.read(File.join(dir, "smartest/example_browser_test.rb"))).to include('expect(page).to have_url("https://rubygems.org/gems/smartest")')
2027
+ example_browser_test = File.read(File.join(dir, "smartest/example_browser_test.rb"))
2028
+ expect(example_browser_test).to include("finds the smartest gem on RubyGems")
2029
+ expect(example_browser_test).to include('expect(page).to have_url("https://rubygems.org/gems/smartest")')
2030
+ expect(example_browser_test).to include('expect(page.locator("h1")).to have_text("smartest")')
2031
+ expect(example_browser_test).not_to include("0.3.0.alpha1")
2029
2032
  expect(File.read(File.join(dir, "smartest/fixtures/playwright_fixture.rb"))).to include("class PlaywrightFixture < Smartest::Fixture")
2030
2033
  expect(File.read(File.join(dir, "smartest/fixtures/playwright_fixture.rb"))).to include('require "playwright"')
2031
2034
  expect(File.read(File.join(dir, "smartest/fixtures/playwright_fixture.rb"))).to include('playwright_cli_executable_path: "./node_modules/.bin/playwright"')
data/smartest.gemspec CHANGED
@@ -7,19 +7,20 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Smartest::VERSION
8
8
  spec.authors = ["Yusuke Iwaki"]
9
9
 
10
- spec.summary = "A small Ruby test runner with keyword-first fixtures."
11
- spec.description = "Smartest is a small Ruby test runner focused on readable top-level tests, explicit keyword-argument fixture dependencies, and optional fixture cleanup."
12
- spec.homepage = "https://github.com/YusukeIwaki/smartest"
10
+ spec.summary = "Pytest-style fixtures for Ruby."
11
+ spec.description = "Smartest is a Ruby test runner with pytest-style fixture injection. Tests request fixtures using keyword arguments, fixtures can depend on other fixtures, and cleanup is registered only when needed."
12
+ spec.homepage = "https://smartest-rb.vercel.app"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.1"
14
+ spec.required_ruby_version = ">= 2.7"
15
15
 
16
16
  spec.metadata = {
17
17
  "allowed_push_host" => "https://rubygems.org",
18
18
  "bug_tracker_uri" => "https://github.com/YusukeIwaki/smartest/issues",
19
- "documentation_uri" => "https://smartest-rb.vercel.app/",
19
+ "changelog_uri" => "https://github.com/YusukeIwaki/smartest/blob/main/CHANGELOG.md",
20
+ "documentation_uri" => "https://smartest-rb.vercel.app/docs/fixtures",
20
21
  "homepage_uri" => spec.homepage,
21
22
  "rubygems_mfa_required" => "true",
22
- "source_code_uri" => "https://github.com/YusukeIwaki/smartest/tree/main"
23
+ "source_code_uri" => "https://github.com/YusukeIwaki/smartest"
23
24
  }
24
25
 
25
26
  spec.files = Dir.chdir(__dir__) do
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.3.1
4
+ version: 0.3.3.alpha1
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-04-29 00:00:00.000000000 Z
11
+ date: 2026-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,8 +24,9 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '13.0'
27
- description: Smartest is a small Ruby test runner focused on readable top-level tests,
28
- explicit keyword-argument fixture dependencies, and optional fixture cleanup.
27
+ description: Smartest is a Ruby test runner with pytest-style fixture injection. Tests
28
+ request fixtures using keyword arguments, fixtures can depend on other fixtures,
29
+ and cleanup is registered only when needed.
29
30
  email:
30
31
  executables:
31
32
  - smartest
@@ -71,16 +72,17 @@ files:
71
72
  - lib/smartest/version.rb
72
73
  - smartest.gemspec
73
74
  - smartest/smartest_test.rb
74
- homepage: https://github.com/YusukeIwaki/smartest
75
+ homepage: https://smartest-rb.vercel.app
75
76
  licenses:
76
77
  - MIT
77
78
  metadata:
78
79
  allowed_push_host: https://rubygems.org
79
80
  bug_tracker_uri: https://github.com/YusukeIwaki/smartest/issues
80
- documentation_uri: https://smartest-rb.vercel.app/
81
- homepage_uri: https://github.com/YusukeIwaki/smartest
81
+ changelog_uri: https://github.com/YusukeIwaki/smartest/blob/main/CHANGELOG.md
82
+ documentation_uri: https://smartest-rb.vercel.app/docs/fixtures
83
+ homepage_uri: https://smartest-rb.vercel.app
82
84
  rubygems_mfa_required: 'true'
83
- source_code_uri: https://github.com/YusukeIwaki/smartest/tree/main
85
+ source_code_uri: https://github.com/YusukeIwaki/smartest
84
86
  post_install_message:
85
87
  rdoc_options: []
86
88
  require_paths:
@@ -89,15 +91,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
91
  requirements:
90
92
  - - ">="
91
93
  - !ruby/object:Gem::Version
92
- version: '3.1'
94
+ version: '2.7'
93
95
  required_rubygems_version: !ruby/object:Gem::Requirement
94
96
  requirements:
95
- - - ">="
97
+ - - ">"
96
98
  - !ruby/object:Gem::Version
97
- version: '0'
99
+ version: 1.3.1
98
100
  requirements: []
99
101
  rubygems_version: 3.4.19
100
102
  signing_key:
101
103
  specification_version: 4
102
- summary: A small Ruby test runner with keyword-first fixtures.
104
+ summary: Pytest-style fixtures for Ruby.
103
105
  test_files: []