[英]wrong number of arguments (given 0, expected 1) (ArgumentError) with Expect in Ruby
I'm not getting expect on retrieve method.我对检索方法没有期望。 When I use
expect(@create_user.retrieve.code).to eq (200)
.当我使用
expect(@create_user.retrieve.code).to eq (200)
。 The following error is displayed:显示以下错误:
wrong number of arguments (given 0, expected 1) (ArgumentError) ./features/pages/Empregados.rb:26:in `retrieve'
错误数量的参数(给定 0,预期为 1)(ArgumentError)./features/pages/Empregados.rb:26:in `retrieve'
def retrieve(id)
self.class.get("/employee/#{ id }")
end
$response = @create_user.create
expect(@create_user.create.code).to eq (200)
puts $response.body
@id = JSON.parse($response)['id']
puts @create_user.retrieve(@id)
expect(@create_user.retrieve.code).to eq (200)
][1]
Your retrieve
method takes exactly one param - id
.您的
retrieve
方法只需要一个参数id
。 In在
expect(@create_user.retrieve.code).to eq (200)
you use retrieve
without any params, hence the error.您使用没有任何参数的
retrieve
,因此出现错误。 Add id
to the retrieve
call and it should be OK.将
id
添加到retrieve
调用中,应该没问题。
expect(@create_user.retrieve(@id).code).to eq (200)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.