Class: AppCommand::Test

Inherits:
Convoy::ActionCommand::Base
  • Object
show all
Defined in:
lib/routes/test.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
# File 'lib/routes/test.rb', line 5

def execute

    @opts = command_options
    @args = arguments
    opts_validate
    opts_routing

end

#opts_routingObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/routes/test.rb', line 32

def opts_routing

    if @opts[:cucumber]
        run_cucumber
    elsif @opts[:fitnesse]
        run_fitnesse
    elsif @opts[:php] || @opts[:php_local]
        run_php
    elsif @opts[:ruby]
        run_ruby
    end

end

#opts_validateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/routes/test.rb', line 14

def opts_validate

    opts_set = 0
    opts_set = opts_set + 1 if @opts[:cucumber]
    opts_set = opts_set + 1 if @opts[:fitnesse]
    opts_set = opts_set + 1 if @opts[:php]
    opts_set = opts_set + 1 if @opts[:php_local]
    opts_set = opts_set + 1 if @opts[:ruby]

    if opts_set >= 2
        puts "You can only run one set of tests at a time. Please set only 1 one of the following flags: \x1B[90m-c, -f, -p, -P, -r\x1B[0m"
        exit
    elsif opts_set == 0
        @opts[:php] = true
    end

end

#run_cucumberObject



46
47
48
# File 'lib/routes/test.rb', line 46

def run_cucumber

end

#run_fitnesseObject



50
51
52
# File 'lib/routes/test.rb', line 50

def run_fitnesse

end

#run_phpObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/routes/test.rb', line 54

def run_php

    if @opts[:php]

        App::Terminal::info('Running PHPUnit tests on VM')

        commands = [
            "sshpass -p#{App::Config.param(App::Config::VM_USER_PASSWORD)} ssh #{App::Config.param(App::Config::VM_USER)}@#{App::Config.param(App::Config::VM_IP)} 'cd /brightpearl-source/brightpearl-code/brightpearl/private/tests/ && ./phpunit.sh #{@args.join(' ')}'"
        ]
        App::Terminal::command(commands, nil, false)

    elsif @opts[:php_local]

        App::Terminal::warning('Running PHPUnit tests on Workstation', "This isn't fully functioning yet.")

        commands = [
            "phpunit --bootstrap #{App::Enum::get_base_path}/assets/phpunit/bootstrap.php"
        ]
        App::Terminal::command(commands, "#{App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE)}/brightpearl/private/tests", false)

    end

end

#run_rubyObject



78
79
80
# File 'lib/routes/test.rb', line 78

def run_ruby

end