Class: Pact::MockService::AppRegistration

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/pact/mock_service/app_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ AppRegistration

Returns a new instance of AppRegistration.



121
122
123
124
125
126
127
# File 'lib/pact/mock_service/app_manager.rb', line 121

def initialize(opts)
  @max_wait = 10
  @port = opts[:port]
  @host = opts[:host]
  @app = opts[:app]
  @spawned = false
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



119
120
121
# File 'lib/pact/mock_service/app_manager.rb', line 119

def app
  @app
end

#hostObject

Returns the value of attribute host.



119
120
121
# File 'lib/pact/mock_service/app_manager.rb', line 119

def host
  @host
end

#portObject

Returns the value of attribute port.



119
120
121
# File 'lib/pact/mock_service/app_manager.rb', line 119

def port
  @port
end

Instance Method Details

#is_a_mock_service?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/pact/mock_service/app_manager.rb', line 142

def is_a_mock_service?
  app.is_a?(Pact::MockService::App)
end

#killObject



129
130
131
132
# File 'lib/pact/mock_service/app_manager.rb', line 129

def kill
  logger.debug "Supposed to be stopping"
  @spawned = false
end

#not_spawned?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/pact/mock_service/app_manager.rb', line 134

def not_spawned?
  !spawned?
end

#spawnObject



150
151
152
153
154
155
156
# File 'lib/pact/mock_service/app_manager.rb', line 150

def spawn
  logger.info "Starting app #{self}..."
  @server = Pact::Server.new(app, host, port).boot
  @port = @server.port
  @spawned = true
  logger.info "Started on port #{port}"
end

#spawned?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/pact/mock_service/app_manager.rb', line 138

def spawned?
  @spawned
end

#to_sObject



146
147
148
# File 'lib/pact/mock_service/app_manager.rb', line 146

def to_s
  "#{app} on port #{port}"
end