Skip to content

Clarify seeded state setup in specs#104

Merged
bartul merged 4 commits into
masterfrom
clarify-spec-given-state
Mar 28, 2026
Merged

Clarify seeded state setup in specs#104
bartul merged 4 commits into
masterfrom
clarify-spec-given-state

Conversation

@bartul
Copy link
Copy Markdown
Owner

@bartul bartul commented Mar 28, 2026

Summary

  • rename the internal specification seed field from State to GivenState and rename the helper from withState to withGivenState
  • keep the state computation-expression step unchanged while making the internal naming line up with GivenActions
  • apply small Rondel spec cleanups: use Id.newId () consistently for test ids, keep the local newBillingId helper, remove an unused System open, and fix a small tuple/formatting inconsistency

Why

  • GivenState is a better name for scenario seed data than the more ambiguous State
  • the renamed helper makes the API around seeded test setup more explicit and internally consistent
  • the Rondel test cleanups remove small inconsistencies without changing behavior

Impact

  • no production code changes
  • no DSL call-site change for state in specs
  • only test infrastructure and test readability are affected

Validation

  • dotnet fantomas .
  • dotnet build Imperium.slnx
  • dotnet test
  • dotnet run --no-build --project tests/Imperium.UnitTests/Imperium.UnitTests.fsproj -- --render-spec-markdown

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Clarify seeded state setup in specs' accurately reflects the main changes—renaming the internal specification seed field from 'State' to 'GivenState' and updating related helpers to improve clarity around state setup in test specifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch clarify-spec-given-state

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bartul bartul marked this pull request as ready for review March 28, 2026 19:52
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/Imperium.UnitTests/Rondel.fs`:
- Line 193: The line containing "state (RondelState.create gameId nations)" has
trailing whitespace causing Fantomas to fail; remove the trailing whitespace on
that line and reformat the file (or project) with Fantomas (e.g., run "dotnet
fantomas .") so the file passes the fs/fsi formatting rules; ensure the change
touches the RondelState.create usage only to remove the extra spaces and commit
the formatted file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c66e4d8-55b0-44d0-a655-fda670a08b67

📥 Commits

Reviewing files that changed from the base of the PR and between cbd8682 and b1eff64.

📒 Files selected for processing (2)
  • tests/Imperium.UnitTests/Rondel.fs
  • tests/Imperium.UnitTests/Spec.fs

Comment thread tests/Imperium.UnitTests/Rondel.fs Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/Imperium.UnitTests/Rondel.fs (1)

333-333: Consider using Id.newId () consistently for billing IDs.

Most billing IDs use Guid.NewGuid() |> Id |> RondelBillingId.ofId, while invoicePaymentFailedTwiceBillingId (lines 491-492) uses the more concise Id.newId () |> RondelBillingId.ofId. Since Id.newId () is just Guid.NewGuid() |> Id, consider using the shorter form everywhere for consistency.

♻️ Proposed refactor for consistency
-      let previousBillingId = Guid.NewGuid() |> Id |> RondelBillingId.ofId
+      let previousBillingId = Id.newId () |> RondelBillingId.ofId

Apply similarly to other billing ID definitions.

Also applies to: 363-363, 388-388, 432-432, 461-461, 521-521, 551-551

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Imperium.UnitTests/Rondel.fs` at line 333, Replace occurrences that
create billing IDs using the longer pattern "Guid.NewGuid() |> Id |>
RondelBillingId.ofId" with the concise helper "Id.newId () |>
RondelBillingId.ofId" for consistency; update definitions such as
previousBillingId and the other billing id bindings (e.g.,
invoicePaymentFailedTwiceBillingId and the instances flagged in the review) to
use Id.newId () before RondelBillingId.ofId so all billing ID constructors use
the same concise form.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/Imperium.UnitTests/Rondel.fs`:
- Line 193: Remove the trailing whitespace after the closing parenthesis on the
line that calls RondelState.create (the expression "state (RondelState.create
gameId nations)"); open the Rondel.fs file, edit the line to eliminate the extra
space immediately following the ")" so it ends cleanly, then run `dotnet
fantomas .` to reformat and verify the Fantomas check passes.

---

Nitpick comments:
In `@tests/Imperium.UnitTests/Rondel.fs`:
- Line 333: Replace occurrences that create billing IDs using the longer pattern
"Guid.NewGuid() |> Id |> RondelBillingId.ofId" with the concise helper "Id.newId
() |> RondelBillingId.ofId" for consistency; update definitions such as
previousBillingId and the other billing id bindings (e.g.,
invoicePaymentFailedTwiceBillingId and the instances flagged in the review) to
use Id.newId () before RondelBillingId.ofId so all billing ID constructors use
the same concise form.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8d9f50a8-a25e-4200-b05b-976c244a3247

📥 Commits

Reviewing files that changed from the base of the PR and between cbd8682 and b1eff64.

📒 Files selected for processing (2)
  • tests/Imperium.UnitTests/Rondel.fs
  • tests/Imperium.UnitTests/Spec.fs

Comment thread tests/Imperium.UnitTests/Rondel.fs Outdated
@bartul bartul merged commit 8c22d68 into master Mar 28, 2026
2 checks passed
@bartul bartul deleted the clarify-spec-given-state branch March 28, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant