Summary
Add RSpec-style shared examples for reusable test patterns across types.
Motivation
- DRY: Eliminate duplicate tests for similar behaviors
- Consistency: Same tests applied to multiple implementations
- RSpec parity: Well-known pattern
Acceptance Criteria
Example Usage
shared_examples("CRUD operations", (createFn) => {
it("creates", () => {
var item = createFn();
expect(item).toNotBeNull();
expect(item.Id).toBeGreaterThan(0);
});
it("reads", () => {
var item = createFn();
var loaded = service.Get(item.Id);
expect(loaded).toBeEquivalentTo(item);
});
});
describe("UserService", () => {
include_examples("CRUD operations", () => service.Create(new User("Alice")));
});
describe("TodoService", () => {
include_examples("CRUD operations", () => service.Create(new Todo("Task")));
});
Implementation Notes
- Store shared examples in registry by name
- Clone context when including
- Handle parameter binding
Summary
Add RSpec-style shared examples for reusable test patterns across types.
Motivation
Acceptance Criteria
Example Usage
Implementation Notes