def expect_json( ok = true, http = 200 ) expect(last_response.header['Content-Type']).to eq('application/json') if (ok == true) then expect(JSON.parse(last_response.body)['ok']).to eq(true) else expect(JSON.parse(last_response.body)['ok']).to eq(false) end expect(last_response.status).to eq(http) end