test-prof 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/test_prof.rb +12 -1
- data/lib/test_prof/factory_doctor.rb +2 -2
- data/lib/test_prof/rspec_stamp.rb +5 -1
- data/lib/test_prof/rspec_stamp/parser.rb +5 -0
- data/lib/test_prof/tag_prof/rspec.rb +2 -2
- data/lib/test_prof/version.rb +1 -1
- metadata +2 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e482ddcaca18180a0606f53fd51871ba132e4a5
|
4
|
+
data.tar.gz: cb321462168846d649df3237117451926a18398a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d9c32fb4241f02f5d6fa3234543fca96abffbc5f968a7e67f9e23da8f41dea1990992e82c8e54cc46feb2af2c0ceac1d1a2ef7055a6784359bef67d97c485d
|
7
|
+
data.tar.gz: ad8a9004ee118da1fc8c9d2d32b290e8632ce0db0ac26803d2372fddf9efc898b28dd432f77ba89043a335724f2cddc9598742bca228486eb85e8ccea835437e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.2.2
|
6
|
+
|
7
|
+
- Fix time calculation when Time class is monkey-patched. ([@palkan][])
|
8
|
+
|
9
|
+
Add `TestProf.now` method which is just a copy of original `Time.now` and
|
10
|
+
use it everywhere.
|
11
|
+
|
12
|
+
Fixes [#10](https://github.com/palkan/test-prof/issues/10).
|
13
|
+
|
5
14
|
## 0.2.1
|
6
15
|
|
7
16
|
- Detect `RSpec` by checking the presence of `RSpec::Core`. ([@palkan][])
|
data/lib/test_prof.rb
CHANGED
@@ -33,6 +33,17 @@ module TestProf
|
|
33
33
|
yield config
|
34
34
|
end
|
35
35
|
|
36
|
+
# Avoid issues with wrong time due to monkey-patches (e.g. timecop)
|
37
|
+
# See https://github.com/rspec/rspec-core/blob/v3.6.0/lib/rspec/core.rb#L147
|
38
|
+
#
|
39
|
+
# We also want to handle Timecop specificaly
|
40
|
+
# See https://github.com/travisjeffery/timecop/blob/master/lib/timecop/time_extensions.rb#L11
|
41
|
+
if Time.respond_to?(:now_without_mock_time)
|
42
|
+
define_method(:now, &::Time.method(:now_without_mock_time))
|
43
|
+
else
|
44
|
+
define_method(:now, &::Time.method(:now))
|
45
|
+
end
|
46
|
+
|
36
47
|
# Require gem and shows a custom
|
37
48
|
# message if it fails to load
|
38
49
|
def require(gem_name, msg)
|
@@ -79,7 +90,7 @@ module TestProf
|
|
79
90
|
|
80
91
|
def with_timestamps(path)
|
81
92
|
return path unless config.timestamps?
|
82
|
-
timestamps = "-#{
|
93
|
+
timestamps = "-#{now.to_i}"
|
83
94
|
"#{path.sub(/\.\w+$/, '')}#{timestamps}#{::File.extname(path)}"
|
84
95
|
end
|
85
96
|
end
|
@@ -82,14 +82,14 @@ module TestProf
|
|
82
82
|
return yield if ignore? || !running? || (strategy != :create)
|
83
83
|
|
84
84
|
begin
|
85
|
-
ts =
|
85
|
+
ts = TestProf.now if @depth.zero?
|
86
86
|
@depth += 1
|
87
87
|
@count += 1
|
88
88
|
yield
|
89
89
|
ensure
|
90
90
|
@depth -= 1
|
91
91
|
|
92
|
-
@time += (
|
92
|
+
@time += (TestProf.now - ts) if @depth.zero?
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -88,8 +88,12 @@ module TestProf
|
|
88
88
|
|
89
89
|
tags.each do |t|
|
90
90
|
if t.is_a?(Hash)
|
91
|
-
t.keys.each
|
91
|
+
t.keys.each do |k|
|
92
|
+
parsed.remove_tag(k)
|
93
|
+
parsed.add_htag(k, t[k])
|
94
|
+
end
|
92
95
|
else
|
96
|
+
parsed.remove_tag(t)
|
93
97
|
parsed.add_tag(t)
|
94
98
|
end
|
95
99
|
end
|
@@ -21,7 +21,7 @@ module TestProf
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def example_started(_notification)
|
24
|
-
@ts =
|
24
|
+
@ts = TestProf.now
|
25
25
|
end
|
26
26
|
|
27
27
|
def example_finished(notification)
|
@@ -30,7 +30,7 @@ module TestProf
|
|
30
30
|
tag = notification.example.metadata.fetch(@tag, :__unknown__)
|
31
31
|
|
32
32
|
@tags[tag][:count] += 1
|
33
|
-
@tags[tag][:time] += (
|
33
|
+
@tags[tag][:time] += (TestProf.now - @ts)
|
34
34
|
end
|
35
35
|
|
36
36
|
def print
|
data/lib/test_prof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,34 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.9'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: activerecord
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '5.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '5.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: factory_girl
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 4.8.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 4.8.0
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: rubocop
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,34 +94,6 @@ dependencies:
|
|
122
94
|
- - ">="
|
123
95
|
- !ruby/object:Gem::Version
|
124
96
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: sqlite3
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: sidekiq
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '4.0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '4.0'
|
153
97
|
description: "\n Ruby applications tests profiling tools.\n\n Contains tools
|
154
98
|
to anylyze factories usage, integrate with Ruby profilers,\n profile your examples
|
155
99
|
using ActiveSupport notifications (if any) and\n statically analyze your code
|