last_response
ruuts opened this issue · comments
When sending 2 requests in one scenario like:
When I send and accept JSON
And I send a POST request to "/nl/parks/1/categories/1/reservations.json?api_key=123_abc" with the following:
"""
{
"reservation": {
"start_date": "2011-10-10",
"end_date": "2011-10-17",
"number_of_people": 4,
"email": "example@example.com",
"phone": "0612345678",
"initials": "J.",
"last_name": "Doe",
"address": "Street",
"number": "1",
"postalcode": "1234AB",
"city": "Enschede",
"country": "Nederland",
"extras": {
"1": 1
}
}
}
"""
Then the JSON response should have "$..email" with the text "example@example.com"
And the JSON response should have "$..arrival_date" with the text "2011-10-10"
And the JSON response should have "$..checkout_date" with the text "2011-10-17"
And the JSON response should have "$..number_of_people" with the text "4"
And the JSON response should have "$..confirmed" with the text "false"
When I send a PUT request to the last reservation api confirm url
Then the JSON response should have "$..confirmed" with the text "true"
The last JSON response should... refers to the first response
I identified this by calling:
Show me the page
And outputting the send parameters for the action.
I also double checked the fact that it calls 2 separate actions.
Bottom line:
api_steps.rb#78:
json = JSON.parse(last_response.body)
Returns the wrong body
Could you try to check response using Then show me the response step?
show me the page step invokes save_and_open_page method of capybara API.
cucumber-api-steps uses rack_test methods. Capybara and rack_test have different sessions.
Then it comes back with a
can't convert Rack::MockResponse into String (TypeError)
It's solved for now with a separate scenario. Which is basically better.