Sha256: ae5c87ab7e85f551dbcab6e85b8e69082f767c26e007981f3c934d6ec6547c68

Contents?: true

Size: 565 Bytes

Versions: 6

Compression:

Stored size: 565 Bytes

Contents

class FakeClient
  def initialize
    @data = {}
    @uploaded = {}
    @uploads = 0
    @downloads = 0
  end

  attr_reader :uploaded, :uploads, :downloads
  attr_accessor :delay

  def []=(key, value)
    @data[key] = value
  end

  def download
    wait_for_delay
    @downloads += 1
    yield @data.dup
    nil
  end

  def upload(data)
    wait_for_delay
    @uploaded.update(data)
    @uploads += 1
  end

  def uploaded?
    @uploads > 0
  end

  def downloaded?
    @downloads > 0
  end

  private

  def wait_for_delay
    sleep(delay) if delay
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
copycopter_client-1.0.2 spec/support/fake_client.rb
copycopter_client-1.0.1 spec/support/fake_client.rb
copycopter_client-1.0.0 spec/support/fake_client.rb
copycopter_client-1.0.0.beta11 spec/support/fake_client.rb
copycopter_client-1.0.0.beta10 spec/support/fake_client.rb
copycopter_client-1.0.0.beta9 spec/support/fake_client.rb