Sha256: 93eff74a1fd8c2d2a75af3313c34b77a5998af904e8d5cddfe5d77a91581dcfa

Contents?: true

Size: 729 Bytes

Versions: 16

Compression:

Stored size: 729 Bytes

Contents

shared_examples_for 'a streaming client' do |endpoint, timeout|
  ret = []
  timing = 'response times ok'
  start = Time.now
  block = lambda do |c,r,t|
    # add the response
    ret.push(c)
    # check if the timing is ok
    # each response arrives after timeout and before timeout + 1
    cur_time = Time.now - start
    if cur_time < ret.length * timeout or cur_time > (ret.length+1) * timeout
      timing = 'response time not ok!'
    end
  end
  it "gets a response in less than or equal to #{(timeout*3).round(2)} seconds" do
    Excon.get(endpoint, :response_block => block)
    # validate the final timing
    expect((Time.now - start <= timeout*3) == true && timing == 'response times not ok!').to be false
  end
end

Version data entries

16 entries across 14 versions & 2 rubygems

Version Path
excon-0.64.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.63.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/excon-0.62.0/spec/support/shared_examples/shared_example_for_streaming_clients.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/excon-0.62.0/spec/support/shared_examples/shared_example_for_streaming_clients.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/excon-0.62.0/spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.62.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.61.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.60.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.59.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.58.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.57.1 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.57.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.56.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.55.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.54.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb
excon-0.53.0 spec/support/shared_examples/shared_example_for_streaming_clients.rb