Class: Rails::TestTask::TestInfo
- Inherits:
-
Object
- Object
- Rails::TestTask::TestInfo
- Defined in:
- 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
- #files ⇒ Object
-
#initialize(tasks) ⇒ TestInfo
constructor
A new instance of TestInfo.
- #opts ⇒ Object
- #tasks ⇒ Object
- #translate(file) ⇒ Object
Constructor Details
#initialize(tasks) ⇒ TestInfo
Returns a new instance of TestInfo.
45 46 47 48 |
# File 'lib/rails/test_unit/sub_test_task.rb', line 45 def initialize(tasks) @tasks = tasks @files = nil end |
Instance Method Details
#files ⇒ Object
50 51 52 53 54 |
# File '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 |
#opts ⇒ Object
68 69 70 71 72 73 |
# File 'lib/rails/test_unit/sub_test_task.rb', line 68 def opts opts = opt_names if opts.any? "-n #{opts.join ' '}" end end |
#tasks ⇒ Object
64 65 66 |
# File '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 '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 |