antonmi / espec

Elixir Behaviour Driven Development
Other
808 stars 62 forks source link

Feature: Add a diff for the `have` spec when it looks for a key-value tuple #263

Closed sascha-wolf closed 6 years ago

sascha-wolf commented 6 years ago

As the title suggests. The error message for the enum_string/have.ex assertions has been extended.

It now actually talks about keys and values. It also returns a diff_fn for a positive match with the expected and actual data.

Before

Expected `[a: 1]` to have `{:a, 2}`, but it has not.

After

Expected `[a: 1]` to have `2` for key `:a`, but it has not.
  expected: 1
  actual:   2

In addition it extends the CheckErrorSharedSpec to allow checking for an extra in the raised error. This is used to test the inclusion of the diff in the have assertion and also for eq whose spec has been extended.

sascha-wolf commented 6 years ago

The test fail seems to be a flaky finally test. I don't think it's related to the changes in the PR.

https://github.com/antonmi/espec/blob/69cffae1df4dbb13ed15eb25dc63364126f6ea30/test/configuration/config_finally_error_test.exs#L52-L56

antonmi commented 6 years ago

Yeap! Thanks, @Zeeker !