当我运行btn.setFocusTraversable(false);
时,显示以下错误:
参数数量错误(给定0,预期为1)(ArgumentError)
这里有人试图帮助我,但我觉得我的问题很不方便,因为我真的无法解决。 我只需要这个就可以解决这个问题。
retrieve
我正在尝试在规格中使用它
class Crud
include HTTParty
base_uri 'http://dummy.restapiexample.com/api/v1'
def create
nome = Faker::Name.first_name
salario = Faker::Number.decimal(l_digits: 4, r_digits: 2)
idade = Faker::Number.number(digits: 2)
#note, you should pass body as JSON string
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 }")
end
end
答案 0 :(得分:3)
问题是多次调用create
,您需要将结果存储在变量中。另外,您还需要在创建后立即检索实例-规格顺序可能会发生变化,并且在创建之前尝试检索时会遇到麻烦
Some spanish? text goes here do
created = manter_user.create
expect(created.code).to eq (200)
puts created.body
id = JSON.parse(created)['id']
retrieved = manter_user.retrieve(id)
expect(retrieved.code).to eq (200)
puts retrieved.body
end