ultra_marathon 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ultra_marathon/sub_runner.rb +3 -2
- data/lib/ultra_marathon/version.rb +1 -1
- data/spec/ultra_marathon/sub_runner_spec.rb +25 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb3d6475f8059ad245b2903fe1cd351094518d22
|
4
|
+
data.tar.gz: e691570e98c3c6988dda441d86812e745bca1991
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37279e51d6363da7efe03738001fd322e2ad09fa7d4223ac6326556860ab68d3f30e62a593b55ccf87c16af988b40427d6a31669d36e2265cdbabbc291dda600
|
7
|
+
data.tar.gz: 8a19cdd425fa40c3a579e9bae177d2700728a3a3a3a7ee3837b0fab4cf149de893fb2048c8a0c9f8663b5aa6aeb08c9c9b19dc2f872131ea90a43732e956831b
|
@@ -25,7 +25,7 @@ module UltraMarathon
|
|
25
25
|
def initialize(options, run_block)
|
26
26
|
@name = options[:name]
|
27
27
|
@options = {
|
28
|
-
instrument:
|
28
|
+
instrument: false
|
29
29
|
}.merge(options)
|
30
30
|
@sub_context = SubContext.new(options[:context], run_block)
|
31
31
|
end
|
@@ -48,6 +48,8 @@ module UltraMarathon
|
|
48
48
|
if options[:instrument]
|
49
49
|
run_profile = instrumentations[:run]
|
50
50
|
logger.info """
|
51
|
+
End Time: #{run_profile.formatted_end_time}
|
52
|
+
Start Time: #{run_profile.formatted_start_time}
|
51
53
|
Total Time: #{run_profile.formatted_total_time}
|
52
54
|
"""
|
53
55
|
end
|
@@ -69,7 +71,6 @@ module UltraMarathon
|
|
69
71
|
def run_sub_context
|
70
72
|
invoke_before_run_callbacks
|
71
73
|
sub_context.call
|
72
|
-
invoke_after_run_callbacks
|
73
74
|
end
|
74
75
|
|
75
76
|
def log_header_and_sub_context
|
@@ -52,6 +52,10 @@ describe UltraMarathon::SubRunner do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
describe 'instrumentation' do
|
55
|
+
let(:options) do
|
56
|
+
{ context: context, name: name, instrument: true }
|
57
|
+
end
|
58
|
+
|
55
59
|
it 'should log the total time' do
|
56
60
|
subject
|
57
61
|
test_instance.logger.contents.should include 'Total Time:'
|
@@ -67,5 +71,26 @@ describe UltraMarathon::SubRunner do
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
74
|
+
|
75
|
+
describe 'callbacks' do
|
76
|
+
it 'should invoke before_run callbacks once' do
|
77
|
+
expect(test_instance).to receive(:invoke_before_run_callbacks).once
|
78
|
+
subject
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should invoke after_run callbacks once' do
|
82
|
+
expect(test_instance).to receive(:invoke_after_run_callbacks).once
|
83
|
+
subject
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should invoke before_run callbacks, the subcontext, then after_run callbacks' do
|
87
|
+
sub_context = double(:sub_context)
|
88
|
+
test_instance.stub(:sub_context) { sub_context }
|
89
|
+
expect(test_instance).to receive(:invoke_before_run_callbacks).ordered
|
90
|
+
expect(sub_context).to receive(:call).ordered
|
91
|
+
expect(test_instance).to receive(:invoke_after_run_callbacks).ordered
|
92
|
+
subject
|
93
|
+
end
|
94
|
+
end
|
70
95
|
end
|
71
96
|
end
|