It is a very newbie question: I am developing a REST API using Rails and I'd like to use json_spec to handle JSON in RSpec and Cucumber.
I created my feature test (from here):
Feature: User API
Scenario: User list
Given I post to "/users.json" with:
"""
{
"first_name": "Steve",
"last_name": "Richert"
}
"""
And I keep the JSON response at "id" as "USER_ID"
When I get "/users.json"
Then the JSON response should have 1 user
And the JSON response at "0" should be:
"""
{
"id": %{USER_ID},
"first_name": "Steve",
"last_name": "Richert"
}
"""
But I got this error:
Given(/^I post to "(.*?)" with:$/) do |arg1, string|
pending # express the regexp above with the code you wish you had
end
When(/^I get "(.*?)"$/) do |arg1|
pending # express the regexp above with the code you wish you had
end
I think methods get and post are provided by capybara, but I cannot make the system recognize them.
I also read that I’ll need to define a last_json method but I don't know where I should add it.
Thanks!