@@ -55,6 +55,7 @@ def initialize(image, name: nil, command: nil, entrypoint: nil, exposed_ports: n
5555 add_labels ( labels ) if labels
5656 @working_dir = working_dir
5757 @healthcheck = add_healthcheck ( healthcheck ) if healthcheck
58+ @wait_for_user_defined = false
5859 @wait_for = add_wait_for ( wait_for )
5960 @logger = logger
6061 @_container = nil
@@ -263,16 +264,19 @@ def add_wait_for(method = nil, *args, **kwargs, &block)
263264 if block
264265 if block . arity == 1
265266 @wait_for = block
267+ @wait_for_user_defined = true
266268 else
267269 raise ArgumentError , "Invalid wait_for block: #{ block } "
268270 end
269271 elsif @exposed_ports && !@exposed_ports . empty?
270272 port = @exposed_ports . keys . first . split ( "/" ) . first
271273 @wait_for = -> ( container ) { container . wait_for_tcp_port ( port ) }
274+ @wait_for_user_defined ||= false
272275 end
273276 elsif method . is_a? ( Proc )
274277 if method . arity == 1
275278 @wait_for = method
279+ @wait_for_user_defined = true
276280 else
277281 raise ArgumentError , "Invalid wait_for method: #{ method } "
278282 end
@@ -282,20 +286,26 @@ def add_wait_for(method = nil, *args, **kwargs, &block)
282286 kwargs = method [ 2 ] || { }
283287 if respond_to? ( method_name )
284288 @wait_for = -> ( container ) { container . send ( method_name , *args , **kwargs ) }
289+ @wait_for_user_defined = true
285290 else
286291 raise ArgumentError , "Invalid wait_for method: #{ method_name } "
287292 end
288293 else
289294 method_name = :"wait_for_#{ method } "
290295 if respond_to? ( method_name )
291296 @wait_for = -> ( container ) { container . send ( method_name , *args , **kwargs ) }
297+ @wait_for_user_defined = true
292298 else
293299 raise ArgumentError , "Invalid wait_for method: #{ method_name } "
294300 end
295301 end
296302 @wait_for
297303 end
298304
305+ def wait_for_user_defined?
306+ @wait_for_user_defined
307+ end
308+
299309 # Set options for the container configuration using "with_" methods.
300310 #
301311 # @param options [Hash] A hash of options where keys correspond to "with_" methods and values are the arguments for those methods.
0 commit comments