Class: Iudex::HTTP::Test::BrokenServer

Inherits:
Object
  • Object
show all
Defined in:
lib/iudex-http-test/broken_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBrokenServer

Returns a new instance of BrokenServer.



26
27
28
29
30
# File 'lib/iudex-http-test/broken_server.rb', line 26

def initialize
  @port = 19293
  @server = nil
  @log = RJack::SLF4J[ self.class ]
end

Instance Attribute Details

#portObject

Returns the value of attribute port.



24
25
26
# File 'lib/iudex-http-test/broken_server.rb', line 24

def port
  @port
end

Instance Method Details

#acceptObject



36
37
38
39
40
41
# File 'lib/iudex-http-test/broken_server.rb', line 36

def accept
  sock = @server.accept
  yield sock if block_given?
rescue Errno::EPIPE => x
  @log.warn( "In accept:", x )
end

#startObject



32
33
34
# File 'lib/iudex-http-test/broken_server.rb', line 32

def start
  @server = TCPServer.new( @port )
end

#stopObject



43
44
45
46
47
48
49
# File 'lib/iudex-http-test/broken_server.rb', line 43

def stop
  if @server
    @server.close
    @server = nil
    true
  end
end