class NEC::MockServerStarter
Constants
- RUN_SCRIPT_NAME
Public Class Methods
new(sub_app_dir_path, opts = {})
click to toggle source
Create new instance of SubAppUnitTestHelper
@param [String] sub_app_dir_path @param [Hash] opts @option opts [String] :run_scrip_name Default is #RUN_SCRIPT_NAME @option opts [Fixnum] :port
# File lib/nec_mock_server/mock_server_starter.rb, line 13 def initialize(sub_app_dir_path, opts = {}) @path = File.expand_path(sub_app_dir_path, File.dirname(__FILE__)) @run_scrip_name = opts.fetch(:run_scrip_name) {RUN_SCRIPT_NAME} @port = opts[:port] end
Public Instance Methods
run!()
click to toggle source
The method start another sub application by defined path Sub app will be started in new command line with irb
# File lib/nec_mock_server/mock_server_starter.rb, line 22 def run! return if @port && already_run? create_threat end
Private Instance Methods
already_run?()
click to toggle source
# File lib/nec_mock_server/mock_server_starter.rb, line 30 def already_run? begin Net::HTTP.get(URI("http://localhost:#{@port}")) return true rescue Errno::ECONNREFUSED return false end end
create_threat()
click to toggle source
The method create new thread for sub app and start it in new cmd window.
# File lib/nec_mock_server/mock_server_starter.rb, line 41 def create_threat @thread = Thread.new { system("cd #{@path} && start irb -I . -r #{@run_scrip_name}") } end