Rebeka Montana
Rebeka Montana

Reputation: 47

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). The following error is displayed:

wrong number of arguments (given 0, expected 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]

Upvotes: 2

Views: 574

Answers (1)

mrzasa
mrzasa

Reputation: 23327

Your retrieve method takes exactly one param - id. In

expect(@create_user.retrieve.code).to eq (200)

you use retrieve without any params, hence the error. Add id to the retrieve call and it should be OK.

expect(@create_user.retrieve(@id).code).to eq (200)

Upvotes: 1

Related Questions