test-prof 0.7.4 → 0.7.5

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: 42dd5bfd5d77f676d37c3cf9ff88d366cf19b459da3736d891d974f31dcaef97
4
- data.tar.gz: 7b99baeb4d93f86b11bb34c3a43fe2bb2f2b75487cd66190fcd2decc3d8ed532
3
+ metadata.gz: d382abde5291f54f1168e9403e3151aaafbe6e6e7409de394169169a0eca19fe
4
+ data.tar.gz: 68037c8c7d819c6e68d7e8d4a4291471101539a6239f452e630de5ea0a4648d6
5
5
  SHA512:
6
- metadata.gz: 12a11804603dc80ef72ecfae63ec6f33f172c63bd447a9032df131cf33265c02926871d55eaabb08fc74d61de211d6bd78727b44802d6a488b20c9a1fee854cc
7
- data.tar.gz: a826158093a4f66433c3b521311f2f3028f526d1864f2106c2294eb97e22b996da3328bebaed0d247b51baf9905fa117a8b75472b81119ffda2c6ebb660566a2
6
+ metadata.gz: fe73709e9e6d6e609f4a0f705d2de0dbab37daecffeb1bac91a4b1a7585a9f81bc656489e9b84d43ad5a9dd04be93a5b9b1020eecd370cbbfee2d2c2fbc862ce
7
+ data.tar.gz: 91ff9f2c02b86260c9d0d88b834775528007b05eefa3fb00ba28ce9464dbfc615ae7ddde33f2d7544bfc048602687da078b6d01bd38038609b1ca33bb83500fe
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.7.5 (2019-02-22)
6
+
7
+ - Make `let_it_be` and `before_all` work with `include_context`. ([@palkan][])
8
+
9
+ Fixes [#117](https://github.com/palkan/test-prof/issues/117)
10
+
5
11
  ## 0.7.4 (2019-02-16)
6
12
 
7
13
  - Add JSON report support for StackProf. ([@palkan][])
data/lib/test_prof.rb CHANGED
@@ -34,6 +34,16 @@ module TestProf
34
34
  yield config
35
35
  end
36
36
 
37
+ # Returns true if we're inside RSpec
38
+ def rspec?
39
+ defined?(RSpec::Core)
40
+ end
41
+
42
+ # Returns true if we're inside Minitest
43
+ def minitest?
44
+ defined?(Minitest)
45
+ end
46
+
37
47
  # Avoid issues with wrong time due to monkey-patches (e.g. timecop)
38
48
  # See https://github.com/rspec/rspec-core/blob/v3.6.0/lib/rspec/core.rb#L147
39
49
  #
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
3
4
  require "test_prof/rspec_stamp"
4
5
  require "test_prof/event_prof/profiler"
5
6
  require "test_prof/event_prof/instrumentations/active_support"
@@ -103,5 +104,5 @@ module TestProf
103
104
  end
104
105
 
105
106
  require "test_prof/event_prof/custom_events"
106
- require "test_prof/event_prof/rspec" if defined?(RSpec::Core)
107
- require "test_prof/event_prof/minitest" if defined?(Minitest)
107
+ require "test_prof/event_prof/rspec" if TestProf.rspec?
108
+ require "test_prof/event_prof/minitest" if TestProf.minitest?
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
3
4
  require "test_prof/factory_bot"
4
5
  require "test_prof/factory_doctor/factory_bot_patch"
5
6
 
@@ -139,5 +140,5 @@ module TestProf
139
140
  end
140
141
  end
141
142
 
142
- require "test_prof/factory_doctor/rspec" if defined?(RSpec::Core)
143
- require "test_prof/factory_doctor/minitest" if defined?(Minitest)
143
+ require "test_prof/factory_doctor/rspec" if TestProf.rspec?
144
+ require "test_prof/factory_doctor/minitest" if TestProf.minitest?
@@ -9,6 +9,24 @@ module TestProf
9
9
  # implementation of #patch and #track methods
10
10
  # to provide unified interface for all factory-building gems
11
11
  class FactoryBot
12
+ # FactoryBot 5.0 uses strategy classes for associations,
13
+ # older versions and top-level invocations use Symbols
14
+ using(Module.new do
15
+ refine Symbol do
16
+ def create?
17
+ self == :create
18
+ end
19
+ end
20
+
21
+ if defined?(::FactoryBot::Strategy::Create)
22
+ refine Class do
23
+ def create?
24
+ self <= ::FactoryBot::Strategy::Create
25
+ end
26
+ end
27
+ end
28
+ end)
29
+
12
30
  # Monkey-patch FactoryBot / FactoryGirl
13
31
  def self.patch
14
32
  TestProf::FactoryBot::FactoryRunner.prepend(FactoryBotPatch) if
@@ -16,7 +34,7 @@ module TestProf
16
34
  end
17
35
 
18
36
  def self.track(strategy, factory, &block)
19
- return yield unless strategy == :create
37
+ return yield unless strategy.create?
20
38
  FactoryProf.track(factory, &block)
21
39
  end
22
40
  end
@@ -6,7 +6,7 @@ module TestProf
6
6
  COLORS = {
7
7
  info: "\e[34m", # blue
8
8
  warn: "\e[33m", # yellow
9
- error: "\e[31m", # red
9
+ error: "\e[31m" # red
10
10
  }.freeze
11
11
 
12
12
  def log(level, msg)
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if defined?(RSpec)
3
+ require "test_prof"
4
+
5
+ if TestProf.rspec?
4
6
  RSpec.shared_context "logging:verbose", log: true do
5
7
  around(:each) do |ex|
6
8
  *loggers = ActiveSupport::LogSubscriber.logger,
@@ -30,6 +30,4 @@ module TestProf
30
30
  end
31
31
  end
32
32
 
33
- RSpec.configure do |config|
34
- config.extend TestProf::BeforeAll::RSpec
35
- end
33
+ RSpec::Core::ExampleGroup.extend TestProf::BeforeAll::RSpec
@@ -86,6 +86,4 @@ module TestProf
86
86
  end
87
87
  end
88
88
 
89
- RSpec.configure do |config|
90
- config.extend TestProf::LetItBe
91
- end
89
+ RSpec::Core::ExampleGroup.extend TestProf::LetItBe
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
3
4
  require "test_prof/rspec_stamp"
4
5
  require "test_prof/logging"
5
6
 
@@ -145,7 +146,7 @@ end
145
146
 
146
147
  require "test_prof/rspec_dissect/collectors/let"
147
148
  require "test_prof/rspec_dissect/collectors/before"
148
- require "test_prof/rspec_dissect/rspec" if defined?(RSpec::Core)
149
+ require "test_prof/rspec_dissect/rspec" if TestProf.rspec?
149
150
 
150
151
  TestProf.activate('RD_PROF') do
151
152
  TestProf::RSpecDissect.init
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
3
4
  require "test_prof/logging"
4
5
  require "test_prof/rspec_stamp/parser"
5
6
 
@@ -181,4 +182,4 @@ module TestProf
181
182
  end
182
183
  end
183
184
 
184
- require "test_prof/rspec_stamp/rspec" if defined?(RSpec::Core)
185
+ require "test_prof/rspec_stamp/rspec" if TestProf.rspec?
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
4
+
3
5
  module TestProf
4
6
  # RubyProf wrapper.
5
7
  #
@@ -223,7 +225,7 @@ module TestProf
223
225
  end
224
226
 
225
227
  def exclude_rspec_methods(profiler)
226
- return unless defined?(RSpec::Core)
228
+ return unless TestProf.rspec?
227
229
 
228
230
  RSpecExclusions.generate.each do |klass, mids|
229
231
  profiler.exclude_methods!(klass, *mids)
@@ -251,7 +253,7 @@ module TestProf
251
253
  end
252
254
  end
253
255
 
254
- if defined?(RSpec::Core)
256
+ if TestProf.rspec?
255
257
  require "test_prof/ruby_prof/rspec"
256
258
  require "test_prof/ruby_prof/rspec_exclusions"
257
259
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
4
+
3
5
  module TestProf
4
6
  # StackProf wrapper.
5
7
  #
@@ -169,7 +171,7 @@ module TestProf
169
171
  end
170
172
  end
171
173
 
172
- require "test_prof/stack_prof/rspec" if defined?(RSpec::Core)
174
+ require "test_prof/stack_prof/rspec" if TestProf.rspec?
173
175
 
174
176
  # Hook to run StackProf globally
175
177
  TestProf.activate('TEST_STACK_PROF') do
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "test_prof"
4
+
3
5
  require "test_prof/tag_prof/result"
4
6
  require "test_prof/tag_prof/printers/simple"
5
7
  require "test_prof/tag_prof/printers/html"
@@ -9,4 +11,4 @@ module TestProf
9
11
  end
10
12
  end
11
13
 
12
- require "test_prof/tag_prof/rspec" if defined?(RSpec::Core)
14
+ require "test_prof/tag_prof/rspec" if TestProf.rspec?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.7.4"
4
+ VERSION = "0.7.5"
5
5
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-16 00:00:00.000000000 Z
11
+ date: 2019-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.60.0
75
+ version: 0.65.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.60.0
82
+ version: 0.65.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop-md
85
85
  requirement: !ruby/object:Gem::Requirement