Class: Cuke4Nuke::Main

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

Instance Method Summary collapse

Instance Method Details

#kill_cuke4nuke_processObject



40
41
42
# File 'lib/cuke4nuke/main.rb', line 40

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

#launch_cucumber(args) ⇒ Object



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

def launch_cucumber(args)
  command = "cucumber #{args.join(' ')} 2>&1"
  system(command)
  $?
end

#launch_cuke4nuke_process(step_definitions_dll_path) ⇒ Object



33
34
35
36
37
38
# File 'lib/cuke4nuke/main.rb', line 33

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}"}
  process = IO.popen(command, 'r')
  @cuke4nuke_server_pid = process.pid
end

#run(args) ⇒ Object



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

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



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

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