I'm starting a cucumber automation and I'm struggling to validate a simple string, cucumber is telling me the following:
expected: "[The value '123456789' is not valid.]"
got: ["The value '123456789' is not valid."]
the code I wrote for that validation: expect(@response['errors']['id']).to eql "[The value '123456789' is not valid.]"
how can I make such validation? Thanks everyone.
CodePudding user response:
Maybe there is a mistake in your assertion :
Just move double quote inside your array
eql "[The value '123456789' is not valid.]"
to
eql ["The value '123456789' is not valid."]
CodePudding user response:
AhmeDEV49's answer is already good, I just want to suggest using another matcher, include instead of eql, like this:
expect(@response['errors']['id']).to include "The value '123456789' is not valid."
Then you do not have to care about the array brackets at all.
CodePudding user response:
The response was a array of strings, so the following worked:
expect(@response['errors']['id']).to eql ["The value '123456789' is not valid."]
