Class: OnlyofficeTcmHelper::TcmHelper
- Inherits:
-
Object
- Object
- OnlyofficeTcmHelper::TcmHelper
- Includes:
- PendingHelper, RspecHelper, TimeHelper
- Defined in:
- lib/onlyoffice_tcm_helper.rb
Overview
Class for generate data for result by RSpec::Core::Example
Instance Attribute Summary collapse
-
#case_name ⇒ String
readonly
Name of case(or name of result_set).
-
#comment ⇒ String
readonly
Is a comment for result, like a error, link to bug, etc.
-
#example ⇒ RSpec::Core::Example
readonly
Example - is a returned object in “after” block.
-
#last_case ⇒ String
readonly
Is a name last case, who result has generated.
-
#plan_name ⇒ String
readonly
Is a name of plan.
-
#product_name ⇒ String
readonly
Is a name of product.
-
#result_message ⇒ Hash
Is a result message.
-
#status ⇒ Symbol
One of status: passed, passed_2, failed, aborted, pending, service_unavailable, lpv.
-
#suite_name ⇒ String
readonly
Is a name of suite(ore run).
Instance Method Summary collapse
-
#get_message_and_custom_fields(example) ⇒ String
Get message and custom fields from example.
-
#get_status_and_comment(example) ⇒ Symbol
Is a symbolic name of test status.
-
#initialize(params = {}) ⇒ TcmHelper
constructor
A new instance of TcmHelper.
-
#parse(example) ⇒ TcmHelper
Is object.
- #result_is_failed?(example) ⇒ Boolean
- #result_is_lpv?(example) ⇒ Boolean
- #result_is_passed2?(example) ⇒ Boolean
- #result_is_passed?(example) ⇒ Boolean
- #result_is_service_unavailable?(example) ⇒ Boolean
Methods included from RspecHelper
find_dirty_line, find_failed_line
Methods included from TimeHelper
Methods included from PendingHelper
#handle_pending, #passed_pending_message, #pending_passed?, #pending_status
Constructor Details
#initialize(params = {}) ⇒ TcmHelper
Returns a new instance of TcmHelper.
37 38 39 40 41 |
# File 'lib/onlyoffice_tcm_helper.rb', line 37 def initialize(params = {}) @product_name = params[:product_name] @plan_name = params[:plan_name] @suite_name = params[:suite_name] end |
Instance Attribute Details
#case_name ⇒ String (readonly)
Returns name of case(or name of result_set).
21 22 23 |
# File 'lib/onlyoffice_tcm_helper.rb', line 21 def case_name @case_name end |
#comment ⇒ String (readonly)
Returns is a comment for result, like a error, link to bug, etc.
25 26 27 |
# File 'lib/onlyoffice_tcm_helper.rb', line 25 def comment @comment end |
#example ⇒ RSpec::Core::Example (readonly)
Returns example - is a returned object in “after” block.
23 24 25 |
# File 'lib/onlyoffice_tcm_helper.rb', line 23 def example @example end |
#last_case ⇒ String (readonly)
Returns is a name last case, who result has generated.
33 34 35 |
# File 'lib/onlyoffice_tcm_helper.rb', line 33 def last_case @last_case end |
#plan_name ⇒ String (readonly)
Returns is a name of plan.
29 30 31 |
# File 'lib/onlyoffice_tcm_helper.rb', line 29 def plan_name @plan_name end |
#product_name ⇒ String (readonly)
Returns is a name of product.
27 28 29 |
# File 'lib/onlyoffice_tcm_helper.rb', line 27 def product_name @product_name end |
#result_message ⇒ Hash
Returns is a result message.
35 36 37 |
# File 'lib/onlyoffice_tcm_helper.rb', line 35 def @result_message end |
#status ⇒ Symbol
Returns one of status: passed, passed_2, failed, aborted, pending, service_unavailable, lpv.
19 20 21 |
# File 'lib/onlyoffice_tcm_helper.rb', line 19 def status @status end |
#suite_name ⇒ String (readonly)
Returns is a name of suite(ore run).
31 32 33 |
# File 'lib/onlyoffice_tcm_helper.rb', line 31 def suite_name @suite_name end |
Instance Method Details
#get_message_and_custom_fields(example) ⇒ String
Get message and custom fields from example
55 56 57 58 59 60 61 62 63 |
# File 'lib/onlyoffice_tcm_helper.rb', line 55 def (example) custom_fields = {} custom_fields[:subdescriber] = [ { title: 'elapsed', value: example_time_in_seconds(example) }, { title: 'custom_host', value: Socket.gethostname } ] custom_fields[:describer] = [{ title: 'comment', value: @comment }] custom_fields.to_json end |
#get_status_and_comment(example) ⇒ Symbol
Returns is a symbolic name of test status.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/onlyoffice_tcm_helper.rb', line 67 def get_status_and_comment(example) @status = if result_is_failed?(example) @comment = form_failed_comment(example) :failed elsif example.pending? handle_pending(example) elsif result_is_passed?(example) @comment = "\nOk" :passed elsif result_is_passed2?(example) @comment = "\nPassed 2" :passed_2 else handle_other_status(example) end @last_case = @case_name end |
#parse(example) ⇒ TcmHelper
Returns is object.
45 46 47 48 49 50 |
# File 'lib/onlyoffice_tcm_helper.rb', line 45 def parse(example) @case_name = example.[:description] get_status_and_comment(example) @result_message = (example) self end |
#result_is_failed?(example) ⇒ Boolean
93 94 95 96 97 98 99 |
# File 'lib/onlyoffice_tcm_helper.rb', line 93 def result_is_failed?(example) # return true if example.metadata[:execution_result].pending_fixed ['got:', 'expected:', 'to return'].map do |current_error| return true if example.exception.to_s.include?(current_error) end false end |
#result_is_lpv?(example) ⇒ Boolean
105 106 107 |
# File 'lib/onlyoffice_tcm_helper.rb', line 105 def result_is_lpv?(example) example.exception.to_s.include?('Limited program version') end |
#result_is_passed2?(example) ⇒ Boolean
89 90 91 |
# File 'lib/onlyoffice_tcm_helper.rb', line 89 def result_is_passed2?(example) example.exception.nil? && @last_case == example.description end |
#result_is_passed?(example) ⇒ Boolean
85 86 87 |
# File 'lib/onlyoffice_tcm_helper.rb', line 85 def result_is_passed?(example) example.exception.nil? && @last_case != example.description end |
#result_is_service_unavailable?(example) ⇒ Boolean
101 102 103 |
# File 'lib/onlyoffice_tcm_helper.rb', line 101 def result_is_service_unavailable?(example) example.exception.to_s.include?('Service Unavailable') end |