knapsack_pro 2.13.0 → 2.14.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb896076bc1dc61363682126869b0add7f9ca6a9a8dfde47c8b7472d3ebb2cb
|
4
|
+
data.tar.gz: 86ee89293cbc0425c1d2c521c98983d4dd4d41954e614661979ca69e7d300c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8caa055376e60414a8596a941782fa99d24f92bc6c7bb6fa4aa26937d645d7b217b4fcc091a6d277edfbad29caccc08c09ce2c07db03fa375f0891dc69d4c5b0
|
7
|
+
data.tar.gz: d7f922e9a271d761f038eec7d1df91a86e51d54ad9e77dd304bba2507540ccae097269919861c8e1204e71f39f6c604fbd6d6555c097a3375a72bdfea5556451
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 2.14.0
|
4
|
+
|
5
|
+
* Track time spend in RSpec context hook
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/143
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.13.0...v2.14.0
|
10
|
+
|
3
11
|
### 2.13.0
|
4
12
|
|
5
13
|
* Update FAQ links in `knapsack_pro` warnings and remove FAQ from readme
|
@@ -21,6 +21,10 @@ module KnapsackPro
|
|
21
21
|
|
22
22
|
def bind_time_tracker
|
23
23
|
::RSpec.configure do |config|
|
24
|
+
config.prepend_before(:context) do
|
25
|
+
KnapsackPro.tracker.start_timer
|
26
|
+
end
|
27
|
+
|
24
28
|
config.around(:each) do |example|
|
25
29
|
current_example_group =
|
26
30
|
if ::RSpec.respond_to?(:current_example)
|
@@ -38,10 +42,10 @@ module KnapsackPro
|
|
38
42
|
current_test_path
|
39
43
|
end
|
40
44
|
|
41
|
-
KnapsackPro.tracker.start_timer
|
42
|
-
|
43
45
|
example.run
|
46
|
+
end
|
44
47
|
|
48
|
+
config.append_after(:context) do
|
45
49
|
KnapsackPro.tracker.stop_timer
|
46
50
|
end
|
47
51
|
|
data/lib/knapsack_pro/tracker.rb
CHANGED
@@ -24,14 +24,18 @@ module KnapsackPro
|
|
24
24
|
|
25
25
|
def stop_timer
|
26
26
|
execution_time = @start_time ? now_without_mock_time.to_f - @start_time : 0.0
|
27
|
-
|
28
|
-
|
27
|
+
|
28
|
+
if current_test_path
|
29
|
+
update_global_time(execution_time)
|
30
|
+
update_test_file_time(execution_time)
|
31
|
+
@current_test_path = nil
|
32
|
+
end
|
33
|
+
|
29
34
|
execution_time
|
30
35
|
end
|
31
36
|
|
32
37
|
def current_test_path
|
33
|
-
|
34
|
-
KnapsackPro::TestFileCleaner.clean(@current_test_path)
|
38
|
+
KnapsackPro::TestFileCleaner.clean(@current_test_path) if @current_test_path
|
35
39
|
end
|
36
40
|
|
37
41
|
def set_prerun_tests(test_file_paths)
|
@@ -63,7 +67,7 @@ module KnapsackPro
|
|
63
67
|
def set_defaults
|
64
68
|
@global_time = 0
|
65
69
|
@test_files_with_time = {}
|
66
|
-
@
|
70
|
+
@current_test_path = nil
|
67
71
|
end
|
68
72
|
|
69
73
|
def update_global_time(execution_time)
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -86,7 +86,9 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'records time for current test path' do
|
89
|
+
expect(config).to receive(:prepend_before).with(:context).and_yield
|
89
90
|
expect(config).to receive(:around).with(:each).and_yield(example)
|
91
|
+
expect(config).to receive(:append_after).with(:context).and_yield
|
90
92
|
expect(config).to receive(:after).with(:suite).and_yield
|
91
93
|
expect(::RSpec).to receive(:configure).and_yield(config)
|
92
94
|
|
@@ -94,12 +96,12 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
94
96
|
expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
|
95
97
|
|
96
98
|
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
97
|
-
expect(tracker).to receive(:
|
98
|
-
expect(tracker).to receive(:
|
99
|
+
expect(tracker).to receive(:start_timer).ordered
|
100
|
+
expect(tracker).to receive(:current_test_path=).with(test_path).ordered
|
99
101
|
|
100
102
|
expect(example).to receive(:run)
|
101
103
|
|
102
|
-
expect(tracker).to receive(:stop_timer)
|
104
|
+
expect(tracker).to receive(:stop_timer).ordered
|
103
105
|
|
104
106
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
105
107
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
@@ -124,7 +126,9 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
124
126
|
it 'records time for example.id' do
|
125
127
|
expect(example).to receive(:id).and_return(test_example_path)
|
126
128
|
|
129
|
+
expect(config).to receive(:prepend_before).with(:context).and_yield
|
127
130
|
expect(config).to receive(:around).with(:each).and_yield(example)
|
131
|
+
expect(config).to receive(:append_after).with(:context).and_yield
|
128
132
|
expect(config).to receive(:after).with(:suite).and_yield
|
129
133
|
expect(::RSpec).to receive(:configure).and_yield(config)
|
130
134
|
|
@@ -132,12 +136,12 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
132
136
|
expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
|
133
137
|
|
134
138
|
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
135
|
-
expect(tracker).to receive(:
|
136
|
-
expect(tracker).to receive(:
|
139
|
+
expect(tracker).to receive(:start_timer).ordered
|
140
|
+
expect(tracker).to receive(:current_test_path=).with(test_example_path).ordered
|
137
141
|
|
138
142
|
expect(example).to receive(:run)
|
139
143
|
|
140
|
-
expect(tracker).to receive(:stop_timer)
|
144
|
+
expect(tracker).to receive(:stop_timer).ordered
|
141
145
|
|
142
146
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
143
147
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
@@ -153,7 +157,9 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
153
157
|
end
|
154
158
|
|
155
159
|
it 'records time for current test path' do
|
160
|
+
expect(config).to receive(:prepend_before).with(:context).and_yield
|
156
161
|
expect(config).to receive(:around).with(:each).and_yield(example)
|
162
|
+
expect(config).to receive(:append_after).with(:context).and_yield
|
157
163
|
expect(config).to receive(:after).with(:suite).and_yield
|
158
164
|
expect(::RSpec).to receive(:configure).and_yield(config)
|
159
165
|
|
@@ -161,12 +167,12 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
161
167
|
expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
|
162
168
|
|
163
169
|
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
164
|
-
expect(tracker).to receive(:
|
165
|
-
expect(tracker).to receive(:
|
170
|
+
expect(tracker).to receive(:start_timer).ordered
|
171
|
+
expect(tracker).to receive(:current_test_path=).with(test_path).ordered
|
166
172
|
|
167
173
|
expect(example).to receive(:run)
|
168
174
|
|
169
|
-
expect(tracker).to receive(:stop_timer)
|
175
|
+
expect(tracker).to receive(:stop_timer).ordered
|
170
176
|
|
171
177
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
172
178
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
@@ -12,9 +12,7 @@ describe KnapsackPro::Tracker do
|
|
12
12
|
subject { tracker.current_test_path }
|
13
13
|
|
14
14
|
context 'when current_test_path not set' do
|
15
|
-
it
|
16
|
-
expect { subject }.to raise_error("current_test_path needs to be set by Knapsack Pro Adapter's bind method")
|
17
|
-
end
|
15
|
+
it { expect(subject).to be_nil }
|
18
16
|
end
|
19
17
|
|
20
18
|
context 'when current_test_path set' do
|
@@ -58,6 +56,9 @@ describe KnapsackPro::Tracker do
|
|
58
56
|
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
|
59
57
|
it { expect(tracker.test_files_with_time['a_spec.rb'][:time_execution]).to be_within(delta).of(0.1) }
|
60
58
|
it { expect(tracker.test_files_with_time['b_spec.rb'][:time_execution]).to be_within(delta).of(0.2) }
|
59
|
+
it 'resets current_test_path after time is measured' do
|
60
|
+
expect(tracker.current_test_path).to be_nil
|
61
|
+
end
|
61
62
|
it_behaves_like '#to_a'
|
62
63
|
end
|
63
64
|
|
@@ -83,6 +84,9 @@ describe KnapsackPro::Tracker do
|
|
83
84
|
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
|
84
85
|
it { expect(tracker.test_files_with_time['a_spec.rb'][:time_execution]).to be_within(delta).of(0) }
|
85
86
|
it { expect(tracker.test_files_with_time['b_spec.rb'][:time_execution]).to be_within(delta).of(0) }
|
87
|
+
it 'resets current_test_path after time is measured' do
|
88
|
+
expect(tracker.current_test_path).to be_nil
|
89
|
+
end
|
86
90
|
it_behaves_like '#to_a'
|
87
91
|
end
|
88
92
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|