luckyframework / luckyframework/lucky

Add some sort of `with_keys` option to `send_json`

Open
#1,846 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

hacktoberfest
Dominant language
Crystal
Stars
2.7k
Forks
172
PR merge metrics
No merged PRs in 30d

Description

I don't know exactly what this looks like yet, but I have a ton of really large custom JSON output in my actions that are too complex to say response.should send_json(200, messages: [{.......}]). Really I don't care that the value looks exactly a specific way, I just want to ensure that there is a value from that key. So really I want something kind of like..

response.should send_json(200, with_keys: [:messages, ....])

or maybe comparing a type somehow?

response.should send_json(200, with: {messages: Array(MessageSerializer)})

definitely a half-baked idea 😂

https://github.com/luckyframework/lucky/blob/8eef897212ebbcbb6f0735ae3d8c3381f44b2449/src/lucky/request_expectations.cr#L12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/lucky/request_expectations.cr around line 12 and review the existing send_json expectation behavior. Define the supported key- or type-matching API before implementation, then add coverage showing the chosen form accepts large JSON responses without requiring exact values.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.