Class: RubyTestHook
- Inherits:
-
Mumukit::Templates::FileHook
- Object
- Mumukit::Templates::FileHook
- RubyTestHook
- Defined in:
- lib/test_hook.rb
Instance Method Summary collapse
- #command_line(filename) ⇒ Object
- #parse_out(exception) ⇒ Object
- #post_process_unstructured_result(file, result, status) ⇒ Object
- #tempfile_extension ⇒ Object
- #to_structured_result(result) ⇒ Object
- #transform(examples) ⇒ Object
Instance Method Details
#command_line(filename) ⇒ Object
25 26 27 |
# File 'lib/test_hook.rb', line 25 def command_line(filename) "rspec #{filename} -f json" end |
#parse_out(exception) ⇒ Object
53 54 55 |
# File 'lib/test_hook.rb', line 53 def parse_out(exception) exception ? exception['message'] : '' end |
#post_process_unstructured_result(file, result, status) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/test_hook.rb', line 29 def post_process_unstructured_result(file, result, status) if status.errored? [ result .gsub(/^.*(#{masked_tempfile_path}:\d+:)/) { $1 } .lines .reject { |it| it.start_with? " from /usr/local" } .take(3) .join + "\n", status ] else super end end |
#tempfile_extension ⇒ Object
21 22 23 |
# File 'lib/test_hook.rb', line 21 def tempfile_extension '.rb' end |
#to_structured_result(result) ⇒ Object
45 46 47 |
# File 'lib/test_hook.rb', line 45 def to_structured_result(result) transform(super['examples']) end |
#transform(examples) ⇒ Object
49 50 51 |
# File 'lib/test_hook.rb', line 49 def transform(examples) examples.map { |e| [e['full_description'].strip, e['status'].to_sym, parse_out(e['exception'])] } end |