Class: Rails::TestTask::TestInfo

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

Instance Method Summary collapse

Constructor Details

#initialize(tasks) ⇒ TestInfo

Returns a new instance of TestInfo.



6
7
8
# File 'lib/rails/test_unit/sub_test_task.rb', line 6

def initialize(tasks)
  @tasks = tasks
end

Instance Method Details

#filesObject



10
11
12
13
14
# File 'lib/rails/test_unit/sub_test_task.rb', line 10

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

#optsObject



28
29
30
31
32
33
# File 'lib/rails/test_unit/sub_test_task.rb', line 28

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

#tasksObject



24
25
26
# File 'lib/rails/test_unit/sub_test_task.rb', line 24

def tasks
  @tasks - test_file_tasks - opt_names
end

#translate(file) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rails/test_unit/sub_test_task.rb', line 16

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