Class: RestAssured::Server

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rest-assured/api/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



9
10
11
# File 'lib/rest-assured/api/server.rb', line 9

def address
  @address
end

Class Method Details

.method_missing(*args) ⇒ Object



47
48
49
# File 'lib/rest-assured/api/server.rb', line 47

def self.method_missing(*args)
  instance.send(*args)
end

Instance Method Details

#start(*args) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rest-assured/api/server.rb', line 27

def start(*args)
  start!(*args)

  while not up?
    sleep 0.5
  end
end

#start!(opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/rest-assured/api/server.rb', line 17

def start!(opts = {})
  stop if up?

  Config.build(opts)

  self.address = "http#{AppConfig.ssl ? 's' : ''}://127.0.0.1:#{AppConfig.port}"

  @session = AppSession.new
end

#stopObject



39
40
41
# File 'lib/rest-assured/api/server.rb', line 39

def stop
  @session.try :stop
end

#up?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rest-assured/api/server.rb', line 43

def up?
  !!@session && @session.alive? && !Utils::PortExplorer.port_free?(AppConfig.port)
end