Class: E2E::Server
- Inherits:
-
Object
- Object
- E2E::Server
- Defined in:
- lib/e2e/server.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#initialize(app, port: nil) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(app, port: nil) ⇒ Server
Returns a new instance of Server.
12 13 14 15 16 |
# File 'lib/e2e/server.rb', line 12 def initialize(app, port: nil) @app = app @host = "127.0.0.1" @port = port || find_available_port end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'lib/e2e/server.rb', line 10 def app @app end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/e2e/server.rb', line 10 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/e2e/server.rb', line 10 def port @port end |
Instance Method Details
#base_url ⇒ Object
32 33 34 |
# File 'lib/e2e/server.rb', line 32 def base_url "http://#{@host}:#{@port}" end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/e2e/server.rb', line 18 def start @thread = Thread.new do # Use Rackup handler for Rack 3 compatibility Rackup::Handler::WEBrick.run( @app, Host: @host, Port: @port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) # Silence logs ) end wait_for_boot end |