Class: Lazylead::Testcase
- Inherits:
-
Requirement
- Object
- Requirement
- Lazylead::Testcase
- Defined in:
- lib/lazylead/task/accuracy/testcase.rb
Overview
Check the ‘Description’ field that ticket has mandatory details like
- test case (TC)
- actual result (AR)
- expected result (ER)
Instance Attribute Summary
Attributes inherited from Requirement
Instance Method Summary collapse
-
#detect_ar(index, src, strip) ⇒ Object
Detect index of line with actual result.
-
#detect_er(index, src, strip) ⇒ Object
Detect index of line with expected result.
-
#detect_tc(index, src, strip) ⇒ Object
Detect index of line with test case.
- #escape(line) ⇒ Object
-
#initialize(score = 4) ⇒ Testcase
constructor
A new instance of Testcase.
- #passed(issue) ⇒ Object
-
#with_tc_ar_er? ⇒ Boolean
True if description has test case, AR and ER.
Methods inherited from Requirement
Constructor Details
#initialize(score = 4) ⇒ Testcase
Returns a new instance of Testcase.
33 34 35 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 33 def initialize(score = 4) super "Test case with AR/ER", score, "Description" end |
Instance Method Details
#detect_ar(index, src, strip) ⇒ Object
Detect index of line with actual result
81 82 83 84 85 86 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 81 def detect_ar(index, src, strip) return unless @ar.negative? && index > @tc keywords = %w[ar: actualresult: ar= [ar] actualresult] @ar = index if keywords.any? { |k| strip.start_with? k } @ar = index if keywords.any? { |k| src.include? k } end |
#detect_er(index, src, strip) ⇒ Object
Detect index of line with expected result
92 93 94 95 96 97 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 92 def detect_er(index, src, strip) return unless @er.negative? && index > @tc keywords = %w[er: expectedresult: er= [er] expectedresult] @er = index if keywords.any? { |k| strip.start_with? k } @er = index if keywords.any? { |k| src.include? k } end |
#detect_tc(index, src, strip) ⇒ Object
Detect index of line with test case
69 70 71 72 73 74 75 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 69 def detect_tc(index, src, strip) return unless @tc.negative? keywords = %w[testcase: tc: teststeps: teststeps steps: tcsteps: tc testcases steps usecase pre-requisitesandsteps:] @tc = index if keywords.any? { |k| strip.eql? k } @tc = index if keywords.any? { |k| src.include? k } end |
#escape(line) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 50 def escape(line) if line.include?("{color") line.gsub( /({color:(#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|[A-Za-z]+)})|{color}/, "" ) else line.gsub(/[^a-zA-Z(:|=)]/, "") end end |
#passed(issue) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 37 def passed(issue) return false if issue.description.nil? @tc = @ar = @er = -1 issue.description.split("\n").reject(&:blank?).map(&:downcase).each_with_index do |l, i| line = escape l.gsub(/(\s+|\*|\+)/, "") detect_tc i, l, line detect_ar i, l, line detect_er i, l, line break if with_tc_ar_er? end with_tc_ar_er? end |
#with_tc_ar_er? ⇒ Boolean
Returns true if description has test case, AR and ER.
61 62 63 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 61 def with_tc_ar_er? (@tc.zero? || @tc.positive?) && @ar.positive? && @er.positive? end |