Sha256: b0d33db9c71302d612ef328077b2f51be52c4cc596dbfac518769529c80507e4

Contents?: true

Size: 468 Bytes

Versions: 20

Compression:

Stored size: 468 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, host = "127.0.0.1")
    @sig = EventMachine::start_server(host, port, Server) { |s|
      s.response = response
      s.delay = delay
    }
  end

  def stop
    EventMachine.stop_server @sig
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
big_brother-0.8.8.1 spec/support/stub_server.rb
big_brother-0.8.8 spec/support/stub_server.rb
big_brother-0.8.7 spec/support/stub_server.rb
big_brother-0.6.8 spec/support/stub_server.rb
big_brother-0.6.7 spec/support/stub_server.rb
big_brother-0.6.6 spec/support/stub_server.rb
big_brother-0.6.5 spec/support/stub_server.rb
big_brother-0.6.4 spec/support/stub_server.rb
big_brother-0.6.3 spec/support/stub_server.rb
big_brother-0.6.2 spec/support/stub_server.rb
big_brother-0.6.1 spec/support/stub_server.rb
big_brother-0.6.0 spec/support/stub_server.rb
big_brother-0.5.0 spec/support/stub_server.rb
big_brother-0.4.1 spec/support/stub_server.rb
big_brother-0.4.0 spec/support/stub_server.rb
big_brother-0.3.1 spec/support/stub_server.rb
big_brother-0.3.0 spec/support/stub_server.rb
big_brother-0.2.1 spec/support/stub_server.rb
big_brother-0.2.0 spec/support/stub_server.rb
big_brother-0.1.0 spec/support/stub_server.rb