Рассмотрим следующий ответ json:
{
"data": {
"someFunction": null
},
"errors": [
{
"message": "Email was already confirmed, please try signing in",
"locations": [
{
"line": 9,
"column": 2
}
],
"path": [
"someFunction"
],
"extensions": {
"code": "USER_ERROR"
}
}
]
}
Сейчас в тесте я ожидаю, что следующий ответ будет правильным:
expect(json_response[:errors]).to contain_exactly(
hash_including(
message: "Email was already confirmed, please try signing in.",
extensions: { code: 'USER_ERROR' }
)
)
Приведенный выше ответ должен быть действительным, кромечто мои тесты говорят, что это не так:
expected collection contained: [hash_including(:message=>"Email was already confirmed, please try signing in.", :extensions=>{:code=>"USER_ERROR"})]
actual collection contained: [{:extensions=>{:code=>"USER_ERROR"}, :locations=>[{:column=>9, :line=>2}], :message=>"Email was already confirmed, please try signing in", :path=>["someFunction"]}]
the missing elements were: [hash_including(:message=>"Email was already confirmed, please try signing in.", :extensions=>{:code=>"USER_ERROR"})]
the extra elements were: [{:extensions=>{:code=>"USER_ERROR"}, :locations=>[{:column=>9, :line=>2}], :message=>"Email was already confirmed, please try signing in", :path=>["someFunction"]}]
Что я здесь не так делаю?