This was running without problems, now I'm getting the following error when I use the same ID that I registered in the query:
no implicit conversion of HTTParty::Response into String (TypeError)
Code:
include HTTParty
base_uri 'http://dummy.restapiexample.com/api/v1'
def create
nome = Faker::UniqueGenerator.clear
nome = Faker::Name.unique.first_name
salario = Faker::Number.number(digits: 2)
idade = Faker::Number.number(digits: 2)
$body = {name: nome, salary: salario, age: idade }.to_json
$headers = {
'Accept' => 'application/vnd.tasksmanager.v2',
'Content-Type' => 'application/json'
}
self.class.post('/create', body: $body, headers: $headers)
end
def retrieve(id)
self.class.get("/employee/#{ id }")
When("the request to change the employee is sent") do
$response = @manter_user.create
expect(@manter_user.create.code).to eq (200)
puts $response.body
{"status":"success","data":{"name":"Patrice","salary":59,"age":39,"id":364},"message":"Successfully! Record has been added."}
@id = JSON.parse($response)['id'] #### error
puts @manter_user.retrieve(@id)
no implicit conversion of HTTParty::Response into String (TypeError)
expect(@manter_user.retrieve(@id).code).to eq (200)
end