Class: Redcar::RunnableTestRunner

Inherits:
Object
  • Object
show all
Defined in:
plugins/test_runner/lib/test_runner/runnable_test_runner.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RunnableTestRunner) initialize(config)

A new instance of RunnableTestRunner



6
7
8
9
10
11
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 6

def initialize(config)
  @single_test_patterns = config["single_test_patterns"]
  @single_test_runner = config["single_test_runner"]
  @file_runner = config["file_runner"]
  @other_notebook = config["other_notebook"]
end

Instance Attribute Details

- (Object) file_runner

Returns the value of attribute file_runner



4
5
6
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 4

def file_runner
  @file_runner
end

- (Object) other_notebook

Returns the value of attribute other_notebook



4
5
6
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 4

def other_notebook
  @other_notebook
end

- (Object) single_test_patterns

Returns the value of attribute single_test_patterns



4
5
6
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 4

def single_test_patterns
  @single_test_patterns
end

- (Object) single_test_runner

Returns the value of attribute single_test_runner



4
5
6
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 4

def single_test_runner
  @single_test_runner
end

Instance Method Details

- (Object) run_process(command, title)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 25

def run_process(command, title)
  p [:command, command]
  current_tab = Redcar.app.focussed_window.focussed_notebook_tab
  Redcar::Runnables.run_process Project::Manager.focussed_project.path, command, title
  if other_notebook
    window = Redcar.app.focussed_window
    tab = Redcar.app.all_tabs.detect {|tab| tab.title == title }
    if current_tab.notebook == tab.notebook
      i = window.notebooks.index(tab.notebook)
      target_notebook = window.notebooks[ (i + 1) % window.notebooks.length ]
      target_notebook.grab_tab_from(tab.notebook, tab)
    end
    current_tab.focus
  end
end

- (Object) run_test(path, current_line)



13
14
15
16
17
18
19
20
21
22
23
# File 'plugins/test_runner/lib/test_runner/runnable_test_runner.rb', line 13

def run_test(path, current_line)
  single_test_patterns.each do |pattern|
    if current_line =~ pattern
      test_name = $1
      command = single_test_runner.gsub("__TEST_NAME__", test_name)
      run_process command, "Running test: #{test_name}"
      return
    end
  end
  run_process file_runner.dup, "Running test: #{File.basename(path)}"
end