kapnismology 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51c9bd5b25a2eff1be770baeb7ca2046f757e589
4
- data.tar.gz: 8d7d741333c07ec96c7dee8b88ccede3ce5c10f5
3
+ metadata.gz: 9cdd88164310160ef407d2e58091fa887e8b06cd
4
+ data.tar.gz: a98c0e7f701a41b1ed83a5298f250150f655b86c
5
5
  SHA512:
6
- metadata.gz: 6fa2922b7ec761a04001292743ce4695a8cba5d504c55936a4c28a026fe7ebddd12cbfe8b4fe3f15bb27c5cec8336058a0d9f54431b7afcf6669bb378d8d2a51
7
- data.tar.gz: 5ee7a610033ee55a7a3d025331baeba88bb93fbb059d03ed01c0e59b44ff7853087ccb236a03a2f3abdbac23b7349087be0bccc66ff9fbbba036c268129e90db
6
+ metadata.gz: aa5eb88c8dd3926e736a46104181d8476e77e0a70696675ae89e031566f00e7be9961a41c3b41b4c5587ca39cf0f13fe1ce2155c7ceb6841d5516322172f3d4f
7
+ data.tar.gz: a1defdc78278c650b7e7a36610b1fe82011e192fc77b7748fe6cc072c6401ff7ecbf0fe2ee7b67cc18f1e6ae7b3aaf4e7416bc9bce93dd895e4ea944f24c0473
@@ -22,5 +22,9 @@ module Kapnismology
22
22
  @result.to_s(@name)
23
23
  end
24
24
 
25
+ def duration
26
+ @result.duration
27
+ end
28
+
25
29
  end
26
30
  end
@@ -23,6 +23,10 @@ module Kapnismology
23
23
  evaluations.map(&:to_hash)
24
24
  end
25
25
 
26
+ def total_duration
27
+ evaluations.inject(0) { |total, member| total += member.duration.to_i }
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def evaluations
@@ -3,15 +3,15 @@ module Kapnismology
3
3
  # It is useful to be able to test if the object is of a correct result type.
4
4
  # It also have methods to add information and serialize it.
5
5
  class BaseResult
6
- attr_reader :data, :message, :debug_messages
6
+ attr_reader :data, :message, :debug_messages, :duration
7
7
  def to_hash
8
- { passed: passed?, data: @data, message: @message, debug_messages: @debug_messages }
8
+ { passed: passed?, data: @data, message: @message, debug_messages: @debug_messages, duration: @duration }
9
9
  end
10
10
 
11
11
  def to_s(name)
12
12
  <<-eos
13
13
  #{format_passed(passed?)}: #{name}
14
- #{format_debug_messages(@debug_messages)}#{Terminal.bold(@message)}
14
+ #{format_duration(@duration)}#{format_debug_messages(@debug_messages)}#{Terminal.bold(@message)}
15
15
  #{@data}
16
16
  eos
17
17
  end
@@ -25,6 +25,10 @@ eos
25
25
  !!@passed
26
26
  end
27
27
 
28
+ def record_duration(start_time)
29
+ @duration = ((Time.now - start_time) * 1000).floor
30
+ end
31
+
28
32
  private
29
33
 
30
34
  def format_debug_messages(debug_messages)
@@ -38,6 +42,10 @@ eos
38
42
  def format_passed(passed)
39
43
  passed ? Terminal.green('passed') : Terminal.red('failed')
40
44
  end
45
+
46
+ def format_duration(duration)
47
+ "duration: #{Terminal.bold(duration)} ms\n"
48
+ end
41
49
  end
42
50
 
43
51
  # This is the result of each smoke test.
@@ -54,6 +62,7 @@ eos
54
62
  @data = data
55
63
  @message = message
56
64
  @debug_messages = []
65
+ @duration = 0
57
66
  end
58
67
  end
59
68
 
@@ -64,6 +73,7 @@ eos
64
73
  @data = data
65
74
  @message = message
66
75
  @debug_messages = []
76
+ @duration = 0
67
77
  end
68
78
 
69
79
  def to_s(name)
@@ -97,6 +107,7 @@ eos
97
107
  @data = data
98
108
  @message = message
99
109
  @debug_messages = []
110
+ @duration = 0
100
111
  end
101
112
  end
102
113
  end
@@ -17,6 +17,7 @@ module Kapnismology
17
17
 
18
18
  # Internally Kapnismology is calling this method. We are handling exceptions under the hood here
19
19
  def __result__
20
+ start_time = Time.now
20
21
  execution = Timeout::timeout(self.class.timeout) { result }
21
22
  result_object = execution || Result.new(false, {}, 'This test has not returned any result')
22
23
  unless result_object.class.ancestors.include?(BaseResult)
@@ -33,6 +34,7 @@ module Kapnismology
33
34
  result_object = Result.new(false, { exception: e.class, message: e.message }, message)
34
35
  ensure
35
36
  @all_result_messages ||= []
37
+ result_object.record_duration(start_time)
36
38
  return result_object.add_debug_messages(@all_result_messages)
37
39
  end
38
40
 
@@ -23,6 +23,7 @@ module Kapnismology
23
23
  count: items.size,
24
24
  trace_id: ApplicationInformation.new.trace_id,
25
25
  codebase_revision: ApplicationInformation.new.codebase_revision,
26
+ duration: @evaluations.total_duration,
26
27
  items: items
27
28
  }.to_json
28
29
  end
@@ -1,3 +1,3 @@
1
1
  module Kapnismology
2
- VERSION = '2.2.1'.freeze
2
+ VERSION = '2.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapnismology
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordi Polo Carres
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-21 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: timecop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.7'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.7'
153
167
  description: Engine for smoke tests and base classes
154
168
  email:
155
169
  - mumismo@gmail.com