Open damaon opened 7 years ago
I think there should be 3 colors: Red - incorrect things Yellow - missing things Green - OK
But this can be easily expressed with text interface:
Expected: StrictHash[{ user: StrictHash[{ name: String , id: Num }] }]
Actual: { user: { name: INCORRECT<{ foo: "bar" }>, id: 123, REDUNDANT<last_name: "foo"> }
Hi Machiaweliczny! I like this idea. The change would have to be made here: https://github.com/egonSchiele/contracts.ruby/blob/master/lib/contracts.rb#L129
Also keep in mind, sometimes it is not appropriate to color. For example, if the output is being written to a file, then the coloring would just add nonsense characters to the output. So you should check if the output is tty before coloring.
@egonSchiele is this still relevant? Was looking over issues in the repo to see if there was another ticket about errors.
Dunno about coloring in OP, would just love for the error message to tell me 'this key in the hash did not match the contract'.
Have never contributed but would love to take a stab at this one as it would save me a lot of time debugging.
First thanks for developing great library, but I would like to propose enhancement.
When testing this gem for complex params hashes I found that
ParamContractError
is almost unreadable. I mean structure of error is neat, but what is displayed inExpected:
is hardly readable IMO. AlsoActual:
would be nice with some coloring or addingErrors:
as I propose below.1)
Expected:
shows inspected ruby structures instead of how I wrote assertion. Totaly unreadable - I just need to check where type was defined and read it in editor to compare.2) I propose also adding output coloring for
Actual:
- so coloring Red, or at least writing "INCORRECT" where you make mistake in recursive type.Example:
I would appreciate feedback about my proposal and tips how this could be implemented.