Class: Cuke4Nuke::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/cuke4nuke/main.rb

Instance Method Summary collapse

Instance Method Details

#kill_cuke4nuke_processObject



45
46
47
# File 'lib/cuke4nuke/main.rb', line 45

def kill_cuke4nuke_process
  Process.kill(9, @cuke4nuke_server_pid)
end

#launch_cucumber(args) ⇒ Object



49
50
51
52
53
54
# File 'lib/cuke4nuke/main.rb', line 49

def launch_cucumber(args)
  command = "cucumber #{args.join(' ')} 2>&1"
  status, stdout, stderr = systemu(command)
  puts stdout
  status
end

#launch_cuke4nuke_process(step_definitions_dll_path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/cuke4nuke/main.rb', line 34

def launch_cuke4nuke_process(step_definitions_dll_path)
  cuke4nuke_server_exe = File.expand_path(File.join(File.dirname(__FILE__), '../../dotnet/Cuke4Nuke.Server.exe'))
  command = %{"#{cuke4nuke_server_exe}" -a "#{step_definitions_dll_path}"  }
	  config_file_path ="#{step_definitions_dll_path}.config"
	  if File.exist?(config_file_path)
		command += %{ -c "#{step_definitions_dll_path}.config"}
	  end
  process = IO.popen(command, 'r')
  @cuke4nuke_server_pid = process.pid
end

#run(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cuke4nuke/main.rb', line 9

def run(args)
  if args.empty? || ['-h', '-?', '/?', '--help'].include?(args[0])
    show_usage
  else
    step_definitions_dll_path = File.expand_path(args.shift)

    if !File.file?(step_definitions_dll_path)
      puts %{"#{step_definitions_dll_path}" is not a valid file path.\n\n}
      show_usage
      exit 1
    end

    launch_cuke4nuke_process(step_definitions_dll_path)

    @exit_status = 1
    begin
      cucumber_status = launch_cucumber(args)
      @exit_status = cucumber_status.exitstatus
    ensure
      kill_cuke4nuke_process
    end
    exit @exit_status
  end
end

#show_usageObject



56
57
58
59
60
61
# File 'lib/cuke4nuke/main.rb', line 56

def show_usage
  puts "Usage: cuke4nuke STEP_DEFINITION_DLL_PATH [CUCUMBER_ARGUMENTS]\n\n"
  puts "The following is Cucumber's help. Anything after the cucumber command can be"
  puts "passed in the CUCUMBER_ARGUMENTS argument for cuke4nuke:\n\n"
  launch_cucumber(['--help'])
end