test-prof 0.11.3 → 1.0.0.rc2

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +122 -447
  3. data/LICENSE.txt +1 -1
  4. data/README.md +9 -13
  5. data/config/default.yml +0 -15
  6. data/config/rubocop-rspec.yml +6 -0
  7. data/lib/minitest/test_prof_plugin.rb +3 -0
  8. data/lib/test_prof/any_fixture.rb +116 -7
  9. data/lib/test_prof/any_fixture/dump.rb +207 -0
  10. data/lib/test_prof/any_fixture/dump/base_adapter.rb +43 -0
  11. data/lib/test_prof/any_fixture/dump/digest.rb +29 -0
  12. data/lib/test_prof/any_fixture/dump/postgresql.rb +91 -0
  13. data/lib/test_prof/any_fixture/dump/sqlite.rb +42 -0
  14. data/lib/test_prof/before_all.rb +9 -4
  15. data/lib/test_prof/before_all/adapters/active_record.rb +14 -5
  16. data/lib/test_prof/cops/rspec/aggregate_examples.rb +2 -2
  17. data/lib/test_prof/cops/rspec/aggregate_examples/its.rb +1 -1
  18. data/lib/test_prof/cops/rspec/aggregate_examples/line_range_helpers.rb +1 -1
  19. data/lib/test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects.rb +1 -1
  20. data/lib/test_prof/cops/rspec/aggregate_examples/metadata_helpers.rb +1 -1
  21. data/lib/test_prof/cops/rspec/aggregate_examples/node_matchers.rb +1 -1
  22. data/lib/test_prof/event_prof/instrumentations/active_support.rb +22 -4
  23. data/lib/test_prof/recipes/minitest/before_all.rb +48 -23
  24. data/lib/test_prof/recipes/minitest/sample.rb +6 -10
  25. data/lib/test_prof/recipes/rspec/before_all.rb +10 -10
  26. data/lib/test_prof/recipes/rspec/let_it_be.rb +111 -13
  27. data/lib/test_prof/recipes/rspec/sample.rb +4 -2
  28. data/lib/test_prof/rubocop.rb +0 -1
  29. data/lib/test_prof/stack_prof.rb +3 -0
  30. data/lib/test_prof/version.rb +1 -1
  31. metadata +23 -21
  32. data/lib/test_prof/cops/rspec/aggregate_failures.rb +0 -26
  33. data/lib/test_prof/ext/active_record_3.rb +0 -27
  34. data/lib/test_prof/recipes/active_record_one_love.rb +0 -6
  35. data/lib/test_prof/recipes/active_record_shared_connection.rb +0 -77
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- class AggregateExamples
7
- def self.registry
8
- RuboCop::Cop::Cop.registry
9
- end
10
- end
11
-
12
- class AggregateFailures < AggregateExamples
13
- def initialize(*)
14
- super
15
- self.class.just_once { warn "`AggregateFailures` cop has been renamed to `AggregateExamples`." }
16
- end
17
-
18
- def self.just_once
19
- return if @already_done
20
- yield
21
- @already_done = true
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TestProf
4
- # Add missing `begin_transaction` and `rollback_transaction` methods
5
- module ActiveRecord3Transactions
6
- refine ::ActiveRecord::ConnectionAdapters::AbstractAdapter do
7
- def begin_transaction(joinable: true)
8
- increment_open_transactions
9
- if open_transactions > 0
10
- create_savepoint
11
- else
12
- begin_db_transaction
13
- end
14
- self.transaction_joinable = joinable
15
- end
16
-
17
- def rollback_transaction(*)
18
- if open_transactions > 1
19
- rollback_to_savepoint
20
- else
21
- rollback_db_transaction
22
- end
23
- decrement_open_transactions
24
- end
25
- end
26
- end
27
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "./active_record_shared_connection"
4
-
5
- # One ❤️
6
- TestProf::ActiveRecordOneLove = TestProf::ActiveRecordSharedConnection
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TestProf
4
- # Forces ActiveRecord to use the same connection between threads
5
- module ActiveRecordSharedConnection # :nodoc: all
6
- class << self
7
- attr_reader :connection
8
-
9
- def enable!
10
- self.connection = ActiveRecord::Base.connection
11
- end
12
-
13
- def disable!
14
- self.connection = nil
15
- end
16
-
17
- def ignore(&block)
18
- raise ArgumentError, "Block is required" unless block_given?
19
-
20
- @ignores ||= []
21
-
22
- ignores << block
23
- end
24
-
25
- def ignored?(config)
26
- !ignores.nil? && ignores.any? { |clbk| clbk.call(config) }
27
- end
28
-
29
- private
30
-
31
- attr_reader :ignores
32
-
33
- def connection=(conn)
34
- @connection = conn
35
- connection.singleton_class.prepend Connection
36
- connection
37
- end
38
- end
39
-
40
- module Connection
41
- def shared_lock
42
- @shared_lock ||= Mutex.new
43
- end
44
-
45
- def exec_cache(*)
46
- shared_lock.synchronize { super }
47
- end
48
-
49
- def exec_no_cache(*)
50
- shared_lock.synchronize { super }
51
- end
52
-
53
- def execute(*)
54
- shared_lock.synchronize { super }
55
- end
56
- end
57
-
58
- module Ext
59
- def connection
60
- return super if ActiveRecordSharedConnection.ignored?(connection_config)
61
- ActiveRecordSharedConnection.connection || super
62
- end
63
- end
64
- end
65
- end
66
-
67
- ActiveSupport.on_load(:active_record) do
68
- if ::ActiveRecord::Base.connection.pool.respond_to?(:lock_thread=)
69
- TestProf.log :warn, "You activated ActiveRecordSharedConnection patch for the Rails version,\n" \
70
- "which has a built-in support for the same functionality.\n" \
71
- "Consider removing it, 'cause this could result in unexpected behaviour.\n\n" \
72
- "Read more in the docs: https://test-prof.evilmartians.io/#/active_record_shared_connection"
73
- end
74
-
75
- TestProf::ActiveRecordSharedConnection.enable!
76
- ActiveRecord::Base.singleton_class.prepend TestProf::ActiveRecordSharedConnection::Ext
77
- end