Skip to content

Provide Hanami::Action::TestHelper class#524

Open
radar wants to merge 1 commit into
mainfrom
test-helper
Open

Provide Hanami::Action::TestHelper class#524
radar wants to merge 1 commit into
mainfrom
test-helper

Conversation

@radar

@radar radar commented Jul 4, 2026

Copy link
Copy Markdown

This allows for a cleaner syntax for passing through params + session data in a test:

Before:

params = {
  book_permalink: "book-permalink",
  chapter_permalink: "chapter-permalink",
  note_id: 1,
  text: "Updated note text",
  "rack.session" => { user_id: 1 },
}
action.call(params)

After:

params = {
  book_permalink: "book-permalink",
  chapter_permalink: "chapter-permalink",
  note_id: 1,
  text: "Updated note text",
}
session = { user_id: 1 }
action.call(params:, session:)

You can opt in to this via:

described_class.include Hanami::Action::TestHelper

Or via similar "global" before syntax with RSpec.

Helper is opt-in, and should only be used in test environments. It is not intended for use in production code.

This allows for a cleaner syntax for passing through params + session data in a test:

Before ()

```
params = {
  book_permalink: "book-permalink",
  chapter_permalink: "chapter-permalink",
  note_id: 1,
  text: "Updated note text",
  "rack.session" => { user_id: 1 },
}
action.call(params)
```

After:

```
params = {
  book_permalink: "book-permalink",
  chapter_permalink: "chapter-permalink",
  note_id: 1,
  text: "Updated note text",
}
session = { user_id: 1 }
action.call(params: params, session: session)
```

Helper is opt-in, and should only be used in test environments. It is not intended for use in production code.
@parndt parndt changed the title Provide Hanami::Action::TestHelper class Provide Hanami::Action::TestHelper class Jul 5, 2026
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