Why Smartest
Smartest introduces pytest-style fixtures for Ruby.
It is a small Ruby test runner that brings pytest-style fixture injection, explicit fixture dependencies, and fixture teardown to Ruby tests.
It is designed around three ideas:
- Tests should read naturally at the top level.
- Fixture usage should be explicit in the test signature.
- Teardown should be written only for fixtures that actually need it.
# smartest/fixtures/web_fixture.rb
class WebFixture < Smartest::Fixture
fixture :server do
server = TestServer.start
on_teardown { server.stop }
server
end
fixture :client do |server:|
Client.new(base_url: server.url)
end
end
# smartest/test_helper.rb
around_suite do |suite|
use_fixture WebFixture
suite.run
end
# smartest/web_test.rb
test("GET /health") do |client:|
response = client.get("/health")
expect(response.status).to eq(200)
end
What to Read First
- Getting Started shows the smallest runnable test file.
- Writing Tests explains test structure and expectations.
- Skipping Tests covers skipped tests and expected failures.
- Running Tests covers autorun and the CLI.
- Fixtures explains class-based fixtures, dependencies, and teardown.
- Stubs shows method stubs that reset from fixture teardown.
- Helpers explains registering helper modules from
around_test. - Why Smartest browser tests explains why pytest-style fixtures change Ruby browser testing, and walks through the Playwright-powered scaffold.
- Test a Rails app locally shows the generated same-process Rails server fixture.
Current Scope
Smartest currently focuses on a small runner API:
- top-level
test - class-based fixtures
- keyword-argument fixture injection
- fixture dependencies through keyword arguments
- fixture teardown
- suite-scoped fixtures through
suite_fixture - fixture-scoped method stubs and block-scoped constant stubs
- suite hooks through
around_suite - test hooks through
around_test - skipped and pending tests through
skipandpending - expectation matchers through
expect - console reporting
- a CLI runner
Nested describe blocks, watch mode, parallel execution, and file-scoped fixtures are not part of the current MVP.