test-prof 0.3.0.beta2 → 0.3.0.beta3

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: 6af9c62cf692b558711fe96e40cff6e82fb49b99
4
- data.tar.gz: e308236c1ed5c5c9abc81e6a7a672adfcbc49dbf
3
+ metadata.gz: 6f2516ff090c97feae6be50fe1edc765aa495337
4
+ data.tar.gz: d6c4aba8cd0ace60d4c80898a8cfc1b22015a32c
5
5
  SHA512:
6
- metadata.gz: 493dfc669dec10234282bc6c24c22a4da701537f30f920f295a98993fd029abd47f5fd419e27779711d2f9266c4011778bf61fafb9da8894bfb20b3d18e728d9
7
- data.tar.gz: 57f0c57b1320e4f2fa50249e0f88da00fb6091b32faef4f16ef57c65deb784ba203b9bab10d54e5ebc0c279a79de02539f69ea3af2bc429b492060c29ad2d253
6
+ metadata.gz: ddf6a60d44432bc56b253b7c667f40efedee36f7f37a4710c826ef5625dcb5c6768416e2c8fea681843894dfd8e39d78ba53ea48fb7ff6ee382eb24b807e8afa
7
+ data.tar.gz: 5fadec4649c715e2fcd93ab5ec6fc4b3e55c6b2cfeba877659431cb6894d3dcc9ed9a5b6bef5b46b36f28cfd34d928a2618b89f195808cc4ef95d9b0f6935f50
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  Features:
6
6
 
7
+ - Combine RSpecStamp with FactoryDoctor. ([@palkan][])
8
+
9
+ Automatically mark _bad_ examples with custom tags.
10
+
7
11
  - [#17](https://github.com/palkan/test-prof/pull/17) Combine RSpecStamp with EventProf and RSpecDissect. ([@palkan][])
8
12
 
9
13
  It is possible now to automatically mark _slow_ examples and groups with custom tags. For example:
@@ -62,3 +62,13 @@ To activate FactoryDoctor use `FDOC` environment variable:
62
62
  ```sh
63
63
  FDOC=1 rspec ...
64
64
  ```
65
+
66
+ ## Using with RSpecStamp
67
+
68
+ FactoryDoctor can be used with [RSpec Stamp](https://github.com/palkan/test-prof/tree/master/guides/rspec_stamp.md) to automatically mark _bad_ examples with custom tags. For example:
69
+
70
+ ```sh
71
+ FDOC=1 FDOC_STAMP="fdoc:consider" rspec ...
72
+ ```
73
+
74
+ After running the command above all _potentially_ bad examples would be marked with the `fdoc: :consider` tag.
@@ -54,6 +54,14 @@ module TestProf
54
54
  defined?(::FactoryGirl)
55
55
 
56
56
  subscribe!
57
+
58
+ @stamp = ENV['FDOC_STAMP']
59
+
60
+ RSpecStamp.config.tags = @stamp if stamp?
61
+ end
62
+
63
+ def stamp?
64
+ !@stamp.nil?
57
65
  end
58
66
 
59
67
  def start
@@ -70,6 +70,40 @@ module TestProf
70
70
  end
71
71
 
72
72
  log :info, msgs.join
73
+
74
+ stamp! if FactoryDoctor.stamp?
75
+ end
76
+
77
+ def stamp!
78
+ stamper = RSpecStamp::Stamper.new
79
+
80
+ examples = Hash.new { |h, k| h[k] = [] }
81
+
82
+ @example_groups.each do |_group, bad_examples|
83
+ bad_examples.each do |example|
84
+ file, line = example.metadata[:location].split(":")
85
+ examples[file] << line.to_i
86
+ end
87
+ end
88
+
89
+ examples.each do |file, lines|
90
+ stamper.stamp_file(file, lines.uniq)
91
+ end
92
+
93
+ msgs = []
94
+
95
+ msgs <<
96
+ <<-MSG.strip_heredoc
97
+ RSpec Stamp results
98
+
99
+ Total patches: #{stamper.total}
100
+ Total files: #{examples.keys.size}
101
+
102
+ Failed patches: #{stamper.failed}
103
+ Ignored files: #{stamper.ignored}
104
+ MSG
105
+
106
+ log :info, msgs.join
73
107
  end
74
108
 
75
109
  private
@@ -144,9 +144,9 @@ module TestProf
144
144
  need_parens = block == "{"
145
145
 
146
146
  tags_str = parsed.tags.map { |t| t.is_a?(Symbol) ? ":#{t}" : t }.join(", ") unless
147
- parsed.tags.nil?
147
+ parsed.tags.nil? || parsed.tags.empty?
148
148
 
149
- unless parsed.htags.nil?
149
+ unless parsed.htags.nil? || parsed.htags.empty?
150
150
  htags_str = parsed.htags.map do |(k, v)|
151
151
  vstr = v.is_a?(Symbol) ? ":#{v}" : quote(v)
152
152
 
@@ -169,6 +169,7 @@ module TestProf
169
169
  # rubocop: enable Metrics/PerceivedComplexity
170
170
 
171
171
  def quote(str)
172
+ return str unless str.is_a?(String)
172
173
  if str.include?("'")
173
174
  "\"#{str}\""
174
175
  else
@@ -100,7 +100,24 @@ module TestProf
100
100
 
101
101
  def parse_hash(res, hash_arg)
102
102
  hash_arg.each do |(_, label, val)|
103
- res.add_htag label[1][0..-2].to_sym, parse_literal(val)
103
+ res.add_htag label[1][0..-2].to_sym, parse_value(val)
104
+ end
105
+ end
106
+
107
+ # Expr of the form:
108
+ # bool - [:var_ref, [:@kw, "true", [1, 24]]]
109
+ # string - [:string_literal, [:string_content, [...]]]
110
+ # int - [:@int, "3", [1, 52]]]]
111
+ def parse_value(expr)
112
+ case expr.first
113
+ when :var_ref
114
+ expr[1][1] == "true"
115
+ when :@int
116
+ expr[1].to_i
117
+ when :@float
118
+ expr[1].to_f
119
+ else
120
+ parse_literal(expr)
104
121
  end
105
122
  end
106
123
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.3.0.beta2".freeze
4
+ VERSION = "0.3.0.beta3".freeze
5
5
  end
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.3.0.beta2
4
+ version: 0.3.0.beta3
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-31 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: 1.3.1
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.13
187
+ rubygems_version: 2.6.11
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Ruby applications tests profiling tools