bblimke / webmock

Library for stubbing and setting expectations on HTTP requests in Ruby.
MIT License
3.98k stars 557 forks source link

random failure of spec/acceptance/httpclient/httpclient_spec.rb[1:5:1:4:4] #711

Open lnussbaum opened 7 years ago

lnussbaum commented 7 years ago

Hi,

spec/acceptance/httpclient/httpclient_spec.rb[1:5:1:4:4] fails randomly with the following error:

  1) HTTPClient when using async requests with WebMock when request stub declares that request should raise exception should raise exception after returning declared successful response first
     Failure/Error: raise @exception if @exception

     MyException:
       Exception from WebMock
     Shared Example Group: "declared responses" called from ./spec/acceptance/webmock_shared.rb:29
     Shared Example Group: "with WebMock" called from ./spec/acceptance/httpclient/httpclient_spec.rb:46
     # ./lib/webmock/response.rb:66:in `raise_error_if_any'
     # ./lib/webmock/http_lib_adapters/httpclient_adapter.rb:118:in `build_httpclient_response'
     # ./lib/webmock/http_lib_adapters/httpclient_adapter.rb:61:in `do_get'
     # ./lib/webmock/http_lib_adapters/httpclient_adapter.rb:51:in `do_get_stream'

Finished in 7.31 seconds (files took 0.83351 seconds to load)
627 examples, 1 failure

Failed examples:

rspec ./spec/acceptance/httpclient/httpclient_spec.rb[1:5:1:4:4] # HTTPClient when using async requests with WebMock when request stub declares that request should raise exception should raise exception after returning declared successful response first

To reproduce:

while rspec ./spec/acceptance/httpclient/httpclient_spec.rb ; do :; done
lnussbaum commented 7 years ago

It also fails differently sometimes:

  1) HTTPClient when using async requests with WebMock when request stub declares that request should return a response when responses are declared to return more than once should repeat sequence of response declared number of times
     Failure/Error: expect(http_request(:get, "http://www.example.com/").body).to eq("2")

       expected: "2"
            got: "1"

       (compared using ==)
     Shared Example Group: "declared responses" called from ./spec/acceptance/webmock_shared.rb:29
     Shared Example Group: "with WebMock" called from ./spec/acceptance/httpclient/httpclient_spec.rb:46
     # ./spec/acceptance/shared/returning_declared_responses.rb:331:in `block (4 levels) in <top (required)>'

Finished in 7.41 seconds (files took 0.81591 seconds to load)
627 examples, 1 failure

Failed examples:

rspec ./spec/acceptance/httpclient/httpclient_spec.rb[1:5:1:6:16:2] # HTTPClient when using async requests with WebMock when request stub declares that request should return a response when responses are declared to return more than once should repeat sequence of response declared number of times
lnussbaum commented 7 years ago

or:

  1) HTTPClient when using async requests with WebMock when requests are stubbed when stubbing request with a global hook should call the block only once per request
     Failure/Error: expect(call_count).to eq(1)

       expected: 1
            got: 2

       (compared using ==)
     Shared Example Group: "stubbing requests" called from ./spec/acceptance/webmock_shared.rb:27
     Shared Example Group: "with WebMock" called from ./spec/acceptance/httpclient/httpclient_spec.rb:46
     # ./spec/acceptance/shared/stubbing_requests.rb:499:in `block (4 levels) in <top (required)>'

Finished in 7.6 seconds (files took 0.81887 seconds to load)
627 examples, 1 failure

Failed examples:

rspec ./spec/acceptance/httpclient/httpclient_spec.rb[1:5:1:2:8:5] # HTTPClient when using async requests with WebMock when requests are stubbed when stubbing request with a global hook should call the block only once per request
lnussbaum commented 7 years ago

another one:

  1) HTTPClient when using async requests with WebMock when request stub declares that request should return a response when sequences of responses are declared should return responses one by one if declared with several to_return invokations
     Failure/Error: expect(http_request(:get, "http://www.example.com/").body).to eq("2")

       expected: "2"
            got: "3"

       (compared using ==)
     Shared Example Group: "declared responses" called from ./spec/acceptance/webmock_shared.rb:29
     Shared Example Group: "with WebMock" called from ./spec/acceptance/httpclient/httpclient_spec.rb:46
     # ./spec/acceptance/shared/returning_declared_responses.rb:301:in `block (4 levels) in <top (required)>'

Finished in 9.09 seconds (files took 0.6657 seconds to load)
627 examples, 1 failure

Failed examples:

rspec ./spec/acceptance/httpclient/httpclient_spec.rb[1:5:1:6:15:4] # HTTPClient when using async requests with WebMock when request stub declares that request should return a response when sequences of responses are declared should return responses one by one if declared with several to_return invokations
bblimke commented 7 years ago

@lnussbaum thanks. it's a known problem. Have you investigated why this happens?

lnussbaum commented 7 years ago

I tried but couldn't find anything, sorry