Class: Rails::TestTask::TestInfo

Inherits:
Object
  • Object
show all
Defined in:
railties/lib/rails/test_unit/sub_test_task.rb

Overview

This is a utility class used by the TestTask::TestCreator class. This class takes a set of test tasks and checks to see if they correspond to test files (or can be transformed into test files). Calling files provides the set of test files and is used when initializing tests after a call to rake test.

Instance Method Summary collapse

Constructor Details

#initialize(tasks) ⇒ TestInfo


45
46
47
48
# File 'railties/lib/rails/test_unit/sub_test_task.rb', line 45

def initialize(tasks)
  @tasks = tasks
  @files = nil
end

Instance Method Details

#filesObject


50
51
52
53
54
# File 'railties/lib/rails/test_unit/sub_test_task.rb', line 50

def files
  @files ||= @tasks.map { |task|
    [task, translate(task)].find { |file| test_file?(file) }
  }.compact
end

#optsObject


68
69
70
71
72
73
# File 'railties/lib/rails/test_unit/sub_test_task.rb', line 68

def opts
  opts = opt_names
  if opts.any?
    "-n #{opts.join ' '}"
  end
end

#tasksObject


64
65
66
# File 'railties/lib/rails/test_unit/sub_test_task.rb', line 64

def tasks
  @tasks - test_file_tasks - opt_names
end

#translate(file) ⇒ Object


56
57
58
59
60
61
62
# File 'railties/lib/rails/test_unit/sub_test_task.rb', line 56

def translate(file)
  if file =~ /^app\/(.*)$/
    "test/#{$1.sub(/\.rb$/, '')}_test.rb"
  else
    "test/#{file}_test.rb"
  end
end