@spree/docs 0.1.118 → 0.1.119

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.
@@ -264,6 +264,19 @@ spree routes -c Spree::Api::V3::Store::ProductsController # Filter by controll
264
264
  spree routes --expanded
265
265
  ```
266
266
 
267
+ ### `spree rspec`
268
+
269
+ Run the RSpec test suite inside the web container with `RAILS_ENV=test`, so tests hit the `spree_test` database — never your development data. Everything after `rspec` passes through, so file paths, line numbers, and flags work as usual.
270
+
271
+ ```bash
272
+ spree rspec # full suite
273
+ spree rspec spec/models/spree/brand_spec.rb # one file
274
+ spree rspec spec/models/spree/brand_spec.rb:15 # one example
275
+ spree rspec --format documentation
276
+ ```
277
+
278
+ Before the first run, create the test database with `spree rails db:test:prepare`. See the [Testing tutorial](../tutorial/testing.md) for writing specs.
279
+
267
280
  ## Running things inside the container
268
281
 
269
282
  These are passthrough commands — anything after the subcommand reaches the inner Rails/Bundle/Rake invocation as-is. Useful for ad-hoc commands that don't have a dedicated wrapper.
@@ -587,24 +587,33 @@ expect(page).to have_content('Success!')
587
587
 
588
588
  ## Running Tests
589
589
 
590
- In the Docker flow the container's `DATABASE_URL` points at the development database, so tests need two overrides: a dedicated test database, and DatabaseCleaner's opt-in for non-localhost database hosts (its safeguard against cleaning a database it doesn't own). One-time test database setup:
590
+ ### Prepare the test database
591
591
 
592
- ```bash Spree CLI (Docker) one-time setup
593
- spree exec env RAILS_ENV=test DATABASE_URL=postgres://postgres@postgres:5432/spree_test bin/rails db:prepare
592
+ Tests run against a dedicated `spree_test` database, so your development data is never touched. Create it and load the schema once:
593
+
594
+
595
+ ```bash Spree CLI (Docker)
596
+ spree rails db:test:prepare
597
+ ```
598
+
599
+ ```bash Without Spree CLI
600
+ bin/rails db:test:prepare
594
601
  ```
595
602
 
596
- Then run tests:
603
+
604
+ You rarely need to run this again — `rails_helper.rb` re-syncs the test schema automatically when you add migrations. It's the command to reach for when the test database gets into a broken or out-of-sync state.
605
+
606
+ ### Run the suite
607
+
608
+ `spree rspec` runs `bundle exec rspec` inside the web container with `RAILS_ENV=test`. Everything after `rspec` is passed through, so file paths, line numbers, and flags work as usual:
597
609
 
598
610
 
599
611
  ```bash Spree CLI (Docker)
600
- # Define once per shell (or add as an alias):
601
- alias spree-rspec='spree exec env RAILS_ENV=test DATABASE_URL=postgres://postgres@postgres:5432/spree_test DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true bundle exec rspec'
602
-
603
- spree-rspec # all tests
604
- spree-rspec spec/models/spree/brand_spec.rb # specific file
605
- spree-rspec spec/models/spree/brand_spec.rb:15 # specific test
606
- spree-rspec --format documentation # documentation format
607
- spree-rspec spec/features/ # only feature tests
612
+ spree rspec # all tests
613
+ spree rspec spec/models/spree/brand_spec.rb # specific file
614
+ spree rspec spec/models/spree/brand_spec.rb:15 # specific test
615
+ spree rspec --format documentation # documentation format
616
+ spree rspec spec/features/ # only feature tests
608
617
  ```
609
618
 
610
619
  ```bash Without Spree CLI
@@ -616,6 +625,29 @@ bundle exec rspec spec/features/ # only feature tests
616
625
  ```
617
626
 
618
627
 
628
+ <details>
629
+ <summary>Troubleshooting: DatabaseCleaner refuses a remote database URL, or tests hit the development database</summary>
630
+
631
+ Projects scaffolded before July 2026 set `DATABASE_URL` in `docker-compose.dev.yml`. A URL overrides `config/database.yml` for **every** Rails environment, so in-container tests pointed at the development database and tripped DatabaseCleaner's remote-URL safeguard. Two small changes bring an older project up to date:
632
+
633
+ 1. In `docker-compose.dev.yml`, replace the `DATABASE_URL` entry under `environment:` with host/username parts, so each Rails environment resolves its own database from `database.yml`:
634
+
635
+ ```yaml
636
+ DATABASE_HOST: postgres
637
+ DATABASE_USERNAME: postgres
638
+ ```
639
+
640
+ 2. In `spec/rails_helper.rb`, force the test environment — the dev container bakes in `RAILS_ENV=development`:
641
+
642
+ ```ruby
643
+ ENV['RAILS_ENV'] = 'test'
644
+ ```
645
+
646
+ Then restart the stack (`Ctrl+C` and `spree dev`) so the container picks up the new environment.
647
+
648
+ </details>
649
+
650
+
619
651
  ## Best Practices
620
652
 
621
653
 
@@ -677,6 +709,7 @@ spec/
677
709
  * [Admin Tutorial](admin.md) - Building the admin interface
678
710
  * [Extending Core Models](extending-models.md) - Connecting Brands to Products
679
711
  * [API Tutorial](api.md) - Creating Brand API endpoints
712
+ * [Spree CLI](../cli/quickstart.md) - `spree rspec` and the other dev workflow commands
680
713
  * [RSpec Documentation](https://rspec.info/documentation/) - Official RSpec docs
681
714
  * [Factory Bot Documentation](https://github.com/thoughtbot/factory_bot/blob/main/GETTING_STARTED.md) - Factory Bot guide
682
715
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.118",
3
+ "version": "0.1.119",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",