I use the Cucumber + Capybara + Ruby framework and I'm not able to make an assertion using the "expect" method.
I need to, for example, validate four messages returned in the body, but displays error:
Expected: "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
Obtained: "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