rmiller/behat-spec
Behat extension that integrates with PhpSpec to prevent fatal errors on missing classes or methods. Automatically generates specs and examples when Behat encounters undefined domain objects, then can run phpspec to create the code.
User, Order, Product) where specs are critical.PaymentService, InventoryManager) if PhpSpec’s mocking aligns with testing needs.make:test or custom Behat contexts may suffice.*"This tool eliminates a major bottleneck in our BDD workflow. Today, when a business analyst defines a new domain rule in Gherkin (e.g., ‘a discounted product’), developers spend 2–3 hours manually creating specs and classes—time that could be spent delivering value. This package automates that process, letting us ship domain logic 30% faster while keeping specs aligned with business requirements.
Why it matters:
- Faster feature delivery: Reduces manual work by 70%+ for domain modeling.
- Better alignment: Ensures business rules are immediately testable as code.
- Low risk: Open-source (MIT license), minimal setup, and no ongoing costs.
Tradeoff: The package is no longer actively maintained, but it’s stable for our current stack (Behat 3.x + PhpSpec 3.x). If we later adopt modern tools like PestPHP, we can phase this out."*
Key Outcomes:
*"Problem: Behat’s domain modeling workflow breaks when classes/methods are missing—we either get fatal errors or waste time manually writing specs. Solution:
rmiller/behat-specseamlessly integrates Behat and PhpSpec to:
- Auto-generate specs for missing classes (e.g.,
Product) when running features.- Add method examples (e.g.,
applyDiscount()) on-the-fly.- Optionally create the class stub with
phpspec run.Why adopt now?
- Saves 2–3 hours per feature in manual spec creation.
- Drop-in integration with our existing Behat/PhpSpec setup.
- MIT-licensed and stable (last release 2015, but core functionality works).
Risks:
- No PHP 8.x support (may need forking).
- Interactive prompts could break CI/CD (need
--non-interactiveflags or scripts).- Not Laravel-optimized (e.g., no Eloquent model support).
Alternatives:
- Build a custom solution (e.g., Laravel Artisan commands + Behat hooks).
- Switch to PestPHP (if adopting Laravel’s native testing tools).
Recommendation: Pilot for core domain entities (e.g.,
User,Order) and monitor integration with Laravel’s ecosystem. If we later adopt Pest, we can deprecate this package."*
Implementation Notes:
composer.json (--dev), configure behat.yml/phpspec.yml (~15 mins).--non-interactive flags or script around prompts (e.g., yes | vendor/bin/behat).How can I help you explore Laravel packages today?