Sha256: 47ee4def91d64de4096b783589d2100a17683ccdeaa136bfa95c26af99e3c22a

Contents?: true

Size: 453 Bytes

Versions: 13

Compression:

Stored size: 453 Bytes

Contents

class StubServer
  module Server
    attr_accessor :response, :delay
    def receive_data(data)
      EM.add_timer(@delay) {
        send_data @response
        close_connection_after_writing
      }
    end
  end

  def initialize(response, delay = 0, port=8081)
    @sig = EventMachine::start_server("127.0.0.1", port, Server) { |s|
      s.response = response
      s.delay = delay
    }
  end

  def stop
    EventMachine.stop_server @sig
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
em-synchrony-1.0.6 spec/helper/stub-http-server.rb
em-synchrony-1.0.5 spec/helper/stub-http-server.rb
em-synchrony-1.0.4 spec/helper/stub-http-server.rb
em-synchrony-1.0.3 spec/helper/stub-http-server.rb
em-synchrony-1.0.2 spec/helper/stub-http-server.rb
em-synchrony-1.0.1 spec/helper/stub-http-server.rb
em-synchrony-1.0.0 spec/helper/stub-http-server.rb
em-synchrony-0.3.0.beta.1 spec/helper/stub-http-server.rb
em-synchrony-0.2.0 spec/helper/stub-http-server.rb
em-synchrony-0.1.5 spec/helper/stub-http-server.rb
em-synchrony-0.1.4 spec/helper/stub-http-server.rb
em-synchrony-0.1.2 spec/helper/stub-http-server.rb
em-synchrony-0.1.1 spec/helper/stub-http-server.rb