Search code examples
rubycucumberhttparty

Cucumber rescue Exception (Ruby/HTTParty)


I'm just get a Exception while running a Cucumber test and I tried to find what I can do for it, but no luck about that.

When I made a post in the last step:

When('accept terms of use') do
  until @o == 200
  @o = CadastroApp.sign_term1.code
  sleep 1
  end
end

class CadastroApp
  include HTTParty
   def self.sign_term1
   post("#{$uat_uri}agree/multipleterms",
     body: {
       'ContractsId': $contract1,
       'deviceType': 'Smartphone',
       'Platform': 'ios',
       'Model': 'Iphone XS max',
     }.to_json,
     headers: {
       'Authorization': "Bearer #{$auth_token}",
       'Content-Type': 'application/json'
     })
   end
  end

I got the error:

52: def self.cucumber_run_with_backtrace_filtering(pseudo_method)
53:   begin
54:     yield
55:   rescue Exception => e
56:     instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
57:     replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
58:     raise e
59:   end
60: end

I don't know if it is a problem, but I was using a lot of "until @variable == 200" to loop the api until I got response code 200.


Solution

  • This isn't a error. This is a response send by Ruby when I get a failure in the step.