Class: KnapsackPro::Adapters::TestUnitAdapter
Defined Under Namespace
Modules: BindTimeTrackerTestUnitPlugin
Constant Summary
collapse
- TEST_DIR_PATTERN =
'test/**{,/*/**}/*_test.rb'
- @@parent_of_test_dir =
nil
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseAdapter
adapter_bind_method_called_file, bind, #bind, #bind_before_queue_hook, #bind_queue_mode, slow_test_file?, verify_bind_method_called
Class Method Details
.test_path(obj) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/knapsack_pro/adapters/test_unit_adapter.rb', line 7
def self.test_path(obj)
full_test_path = nil
found_valid_test_file_path = false
obj.tests.each do |test_obj|
method = test_obj.method_name
full_test_path = test_obj.method(method).source_location.first
if full_test_path.include?(@@parent_of_test_dir)
found_valid_test_file_path = true
break
end
end
unless found_valid_test_file_path
KnapsackPro.logger.warn('cannot detect a valid test file path. Probably the test file contains only shared examples. Please add test cases to your test file. Read more at https://github.com/KnapsackPro/knapsack_pro-ruby/pull/123')
KnapsackPro.logger.warn("See test file for #{obj.inspect}")
end
parent_of_test_dir_regexp = Regexp.new("^#{@@parent_of_test_dir}")
test_path = full_test_path.gsub(parent_of_test_dir_regexp, '.')
test_path
end
|
Instance Method Details
#bind_save_report ⇒ Object
72
73
74
75
76
|
# File 'lib/knapsack_pro/adapters/test_unit_adapter.rb', line 72
def bind_save_report
add_post_run_callback do
KnapsackPro::Report.save
end
end
|
#bind_time_tracker ⇒ Object
#set_test_helper_path(file_path) ⇒ Object
78
79
80
81
|
# File 'lib/knapsack_pro/adapters/test_unit_adapter.rb', line 78
def set_test_helper_path(file_path)
test_dir_path = File.dirname(file_path)
@@parent_of_test_dir = File.expand_path('../', test_dir_path)
end
|