Class: ProbeDockRSpec::TestResult
- Inherits:
-
Object
- Object
- ProbeDockRSpec::TestResult
- Defined in:
- lib/probe_dock_rspec/test_result.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tickets ⇒ Object
readonly
Returns the value of attribute tickets.
Class Method Summary collapse
- .extract_grouped(example, groups = []) ⇒ Object
- .extract_key(example, groups = []) ⇒ Object
- .meta(holder) ⇒ Object
Instance Method Summary collapse
- #grouped? ⇒ Boolean
-
#initialize(project, example, groups = [], options = {}) ⇒ TestResult
constructor
A new instance of TestResult.
- #passed? ⇒ Boolean
- #to_h(options = {}) ⇒ Object
- #update(options = {}) ⇒ Object
Constructor Details
#initialize(project, example, groups = [], options = {}) ⇒ TestResult
Returns a new instance of TestResult.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/probe_dock_rspec/test_result.rb', line 7 def initialize project, example, groups = [], = {} @category = project.category @tags = project. @tickets = project.tickets @grouped = extract_grouped example, groups [ :key, :name, :category, :tags, :tickets, :data ].each do |attr| instance_variable_set "@#{attr}".to_sym, send("extract_#{attr}".to_sym, example, groups) end @passed = !![:passed] @duration = [:duration] @message = [:message] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def category @category end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def data @data end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def duration @duration end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def key @key end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def name @name end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def @tags end |
#tickets ⇒ Object (readonly)
Returns the value of attribute tickets.
5 6 7 |
# File 'lib/probe_dock_rspec/test_result.rb', line 5 def tickets @tickets end |
Class Method Details
.extract_grouped(example, groups = []) ⇒ Object
58 59 60 |
# File 'lib/probe_dock_rspec/test_result.rb', line 58 def self.extract_grouped example, groups = [] !!groups.collect{ |g| (g)[:grouped] }.compact.last end |
.extract_key(example, groups = []) ⇒ Object
62 63 64 |
# File 'lib/probe_dock_rspec/test_result.rb', line 62 def self.extract_key example, groups = [] (groups.collect{ |g| (g)[:key] } << (example)[:key]).compact.reject{ |k| k.strip.empty? }.last end |
.meta(holder) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/probe_dock_rspec/test_result.rb', line 66 def self. holder = holder.[:probe_dock] || {} if .kind_of? String { key: } elsif .kind_of? Hash else {} end end |
Instance Method Details
#grouped? ⇒ Boolean
28 29 30 |
# File 'lib/probe_dock_rspec/test_result.rb', line 28 def grouped? @grouped end |
#passed? ⇒ Boolean
24 25 26 |
# File 'lib/probe_dock_rspec/test_result.rb', line 24 def passed? @passed end |
#to_h(options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/probe_dock_rspec/test_result.rb', line 38 def to_h = {} { 'p' => @passed, 'd' => @duration }.tap do |h| h['k'] = @key if @key h['m'] = @message if @message cache = [:cache] first = !cache || !cache.known?(self) stale = !first && cache.stale?(self) h['n'] = @name if stale or first h['c'] = @category if stale or (first and @category) h['g'] = @tags if stale or (first and !@tags.empty?) h['t'] = @tickets if stale or (first and !@tickets.empty?) h['a'] = @data if @data # FIXME: cache custom data end end |
#update(options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/probe_dock_rspec/test_result.rb', line 32 def update = {} @passed &&= [:passed] @duration += [:duration] @message = [ @message, [:message] ].select{ |m| m }.join("\n\n") if [:message] end |