Class: Buildr::TestFramework::TestResult::YamlFormatter
- Defined in:
- lib/buildr/java/test_result.rb
Overview
An Rspec formatter used by buildr
Instance Attribute Summary collapse
-
#example_group ⇒ Object
Returns the value of attribute example_group.
-
#options ⇒ Object
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#where ⇒ Object
Returns the value of attribute where.
Instance Method Summary collapse
- #add_example_group(example_group) ⇒ Object
- #close ⇒ Object
- #example_failed(example, counter, failure) ⇒ Object
- #example_passed(example) ⇒ Object
- #example_pending(example, counter, failure) ⇒ Object
-
#initialize(options, where) ⇒ YamlFormatter
constructor
A new instance of YamlFormatter.
- #path_from_bt(ary) ⇒ Object
- #start(example_count) ⇒ Object
Constructor Details
#initialize(options, where) ⇒ YamlFormatter
Returns a new instance of YamlFormatter.
59 60 61 62 63 64 65 |
# File 'lib/buildr/java/test_result.rb', line 59 def initialize(, where) @options = @where = where @result = Hash.new @result[:succeeded] = [] @result[:failed] = [] end |
Instance Attribute Details
#example_group ⇒ Object
Returns the value of attribute example_group.
57 58 59 |
# File 'lib/buildr/java/test_result.rb', line 57 def example_group @example_group end |
#options ⇒ Object
Returns the value of attribute options.
57 58 59 |
# File 'lib/buildr/java/test_result.rb', line 57 def @options end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
55 56 57 |
# File 'lib/buildr/java/test_result.rb', line 55 def result @result end |
#where ⇒ Object
Returns the value of attribute where.
57 58 59 |
# File 'lib/buildr/java/test_result.rb', line 57 def where @where end |
Instance Method Details
#add_example_group(example_group) ⇒ Object
72 73 74 |
# File 'lib/buildr/java/test_result.rb', line 72 def add_example_group(example_group) @example_group = example_group end |
#close ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/buildr/java/test_result.rb', line 105 def close files = .files result.succeeded = files - result.failed FileUtils.mkdir_p(File.dirname(where)) File.open(where, 'w') { |f| f.puts YAML.dump(result) } end |
#example_failed(example, counter, failure) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/buildr/java/test_result.rb', line 82 def example_failed(example, counter, failure) if example_group.respond_to?(:spec_path) result.failed << example_group.spec_path.gsub(/:\d+$/, '') else path = path_from_bt(failure.exception.backtrace) result.failed << path if path end end |
#example_passed(example) ⇒ Object
76 77 |
# File 'lib/buildr/java/test_result.rb', line 76 def example_passed(example) end |
#example_pending(example, counter, failure) ⇒ Object
79 80 |
# File 'lib/buildr/java/test_result.rb', line 79 def example_pending(example, counter, failure) end |
#path_from_bt(ary) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/buildr/java/test_result.rb', line 95 def path_from_bt(ary) files = .files test = nil ary.find do |bt| bt = bt.split(':').first.strip test = bt if files.include?(bt) end test end |
#start(example_count) ⇒ Object
91 92 93 |
# File 'lib/buildr/java/test_result.rb', line 91 def start(example_count) @result = TestResult.new end |