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(line, index) ⇒ Object
Detect index of line with actual result.
-
#detect_er(line, index) ⇒ Object
Detect index of line with expected result.
-
#detect_tc(line, index) ⇒ Object
Detect index of line with test case.
- #eql?(line, text) ⇒ Boolean
- #escape(line) ⇒ Object
-
#initialize(score = 4) ⇒ Testcase
constructor
A new instance of Testcase.
- #passed(issue) ⇒ Object
- #starts?(line, text) ⇒ Boolean
-
#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(line, index) ⇒ Object
Detect index of line with actual result
73 74 75 76 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 73 def detect_ar(line, index) return unless @ar.negative? && index > @tc @ar = index if starts? line, %w[ar: actualresult: ar= [ar]] end |
#detect_er(line, index) ⇒ Object
Detect index of line with expected result
79 80 81 82 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 79 def detect_er(line, index) return unless @er.negative? && index > @tc @er = index if starts? line, %w[er: expectedresult: er= [er]] end |
#detect_tc(line, index) ⇒ Object
Detect index of line with test case
66 67 68 69 70 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 66 def detect_tc(line, index) return unless @tc.negative? @tc = index if eql? line, %w[testcase: tc: teststeps: teststeps steps: tcsteps: tc testcases steps] end |
#eql?(line, text) ⇒ Boolean
88 89 90 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 88 def eql?(line, text) text.any? { |t| t.eql? line } 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?).each_with_index do |l, i| line = escape l.downcase.gsub(/(\s+|\*|\+)/, "") detect_tc line, i detect_ar line, i detect_er line, i break if with_tc_ar_er? end with_tc_ar_er? end |
#starts?(line, text) ⇒ Boolean
84 85 86 |
# File 'lib/lazylead/task/accuracy/testcase.rb', line 84 def starts?(line, text) text.any? { |t| line.start_with? t } 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 |