Class: Polyspec::TestSetupRunner
- Inherits:
-
Object
- Object
- Polyspec::TestSetupRunner
- Defined in:
- lib/polyspec/test_setup_runner.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_WAIT_TRIES =
3- DEFAULT_WAIT_CHECK =
->(port, check_url) { begin HTTParty.get("http://localhost:#{port}#{check_url}") rescue end }
Instance Attribute Summary collapse
-
#build_command ⇒ Object
Returns the value of attribute build_command.
-
#check_url ⇒ Object
Returns the value of attribute check_url.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#port ⇒ Object
Returns the value of attribute port.
-
#start_command ⇒ Object
Returns the value of attribute start_command.
-
#stop_command ⇒ Object
Returns the value of attribute stop_command.
-
#wait_check ⇒ Object
Returns the value of attribute wait_check.
-
#wait_tries ⇒ Object
Returns the value of attribute wait_tries.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#build_command ⇒ Object
Returns the value of attribute build_command.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def build_command @build_command end |
#check_url ⇒ Object
Returns the value of attribute check_url.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def check_url @check_url end |
#pid ⇒ Object
Returns the value of attribute pid.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def pid @pid end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def port @port end |
#start_command ⇒ Object
Returns the value of attribute start_command.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def start_command @start_command end |
#stop_command ⇒ Object
Returns the value of attribute stop_command.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def stop_command @stop_command end |
#wait_check ⇒ Object
Returns the value of attribute wait_check.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def wait_check @wait_check end |
#wait_tries ⇒ Object
Returns the value of attribute wait_tries.
5 6 7 |
# File 'lib/polyspec/test_setup_runner.rb', line 5 def wait_tries @wait_tries end |
Class Method Details
.from_args(args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/polyspec/test_setup_runner.rb', line 14 def self.from_args(args) runner = new runner.build_command = [:build_command] runner.start_command = [:start_command] runner.stop_command = [:stop_command] runner.wait_tries = [:wait_tries] runner.port = [:port] runner.check_url = [:check_url] runner end |
Instance Method Details
#build ⇒ Object
26 27 28 |
# File 'lib/polyspec/test_setup_runner.rb', line 26 def build `#{build_command}` end |
#cleanup ⇒ Object
44 45 46 |
# File 'lib/polyspec/test_setup_runner.rb', line 44 def cleanup # NOOP end |
#start ⇒ Object
30 31 32 33 34 |
# File 'lib/polyspec/test_setup_runner.rb', line 30 def start self.pid = Process.spawn(start_command, pgroup: true) wait_for_app_to_boot pid end |
#stop ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/polyspec/test_setup_runner.rb', line 36 def stop if stop_command `#{stop_command}` else Process.kill(-9, pid) end end |