Eu uso o framework Cucumber + Capybara + Ruby e não estou conseguindo realizar uma asserção usando o método “expect”.
Preciso por exemplo validar quatro mensagens retornadas no body, porem exibe erro:
Esperado: "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
Obtido: "qui est esse"
#encoding: utf-8
Given(/^I send a get to see four titles$/) do
@api = HTTParty.get("https://jsonplcaholder.typicode.com/posts")
end
Then(/^Returned status code "(.*?)"$/) do |statuscode|
expect(@api.code.to_s).to eq statuscode
end
Then(^Returnered message "(.*?)"$/) do |message|
expect(@api[0]["title"]).to eq message
expect(@api[1]["title"]).to eq message
expect(@api[2]["title"]).to eq message
expect(@api[3]["title"]).to eq message
end
Feature: message body
@titles
Scenario: Display of title all films
Given I send a get to see four titles
Then Returned status code "200"
Then Returned message "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
Then Returned message "qui est esse"
Then Returned message "ea molestias quasi exercitationem repellat qui ipsa sit aut"
Then Returned message "eum et est occaecati"
compared using ==
RSpec::Expectations::ExpectationNotMetError