wt_activerecord_index_spy 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 139af66e444d627962e5c1012c22bb950aaf2e4f5ca4626068174beb75664bb6
4
- data.tar.gz: 5f0d2385cf19cee78366660c2d647dbe468a86f189589a4c745c91df18d84bf9
3
+ metadata.gz: 80c60b9f84a74e7e6a712ab694cde7d9df2d7bd7b5f02c19e0203c0c3f6a337d
4
+ data.tar.gz: c0997eb1f14fbf0a5a136cf977dd2778f02ef09f1951aa28fbdd933e6d47854e
5
5
  SHA512:
6
- metadata.gz: 0f211a9e65df94123ce1404e35a13c615eafe0a9fe5189ccf0397d64fc357dba80e099e7f08c6c4f28c738e1dc10fa52f41bfab3e3f0579cf751768684ea37fb
7
- data.tar.gz: f753b9c6c7362464de58317d0bfcadd9fdf1ce587468568a07524fe9fecbb371460c1604b2a800563ae2bbacd705ffa1c1542519361f6aae4278151289df6998
6
+ metadata.gz: 95643efc73118307c0c090e5ce3c1887c2039e74b6049cebb0132ec0b57266783485f972bf7ba3f6f904240814eb2df978f7f484a5ee69b473d4e375886f8177
7
+ data.tar.gz: be4478bfce890caeae51f703bed4e13772c60443b9bdb06172a6ed8f52fe5ab228d71c9e03f795a02eb7e49da4bb097fd1eed2e0869ab740e207253e259bc07f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.4.1
2
+ * Fix issue with missing identifier from ActiveRecord (#21)
3
+
1
4
  ## 0.4.0
2
5
  * change `NotificationListener` to ignore queries to INFORMATION_SCHEMA
3
6
  * change `NotificationListener` to not ignore queries with an empty identifier, for example, when running with `ActiveRecord::Base.connection.execute`
data/CONTRIBUTORS.md CHANGED
@@ -1,3 +1,4 @@
1
1
  - @fabioperrella
2
2
  - @julik
3
3
  - @lorenzograndi4
4
+ - @lloydwatkin
data/README.md CHANGED
@@ -75,6 +75,36 @@ it 'uses an index for all the queries' do
75
75
  end
76
76
  ```
77
77
 
78
+ #### Run for all rspec tests
79
+
80
+ By adding the following to your `rspec` configuration the `have_used_db_indexes` will run on each individual test and error if an index has not been used:
81
+
82
+ ```ruby
83
+ Rspec.configure do |config|
84
+ config.around(:each) do |example|
85
+ unless example.metadata[:skip_index_spy]
86
+ expect { example.run }.to(have_used_db_indexes)
87
+ else
88
+ example.run
89
+ end
90
+ end
91
+
92
+ config.after(:all) do
93
+ WtActiverecordIndexSpy.export_html_results
94
+ end
95
+ end
96
+ ```
97
+
98
+ If you wish to skip index checking for specific tests you can then annotate your test as follows:
99
+
100
+ ```ruby
101
+ describe 'Will not check indexes', :skip_index_spy do
102
+ # ...or...
103
+ context 'Does not check indexes', :skip_index_spy do
104
+ # ...or...
105
+ it 'will not check indexes', :skip_index_spy do
106
+ ```
107
+
78
108
  ### 2 - Watching all queries from a start point
79
109
 
80
110
  Add this line to enable it:
@@ -42,7 +42,7 @@ module WtActiverecordIndexSpy
42
42
  def call(_name, _start, _finish, _message_id, values)
43
43
  query = values[:sql]
44
44
  logger.debug "query: #{query}"
45
- identifier = values[:name]
45
+ identifier = values[:name].to_s
46
46
 
47
47
  if ignore_query?(query: query, name: identifier)
48
48
  logger.debug "query type ignored, name: #{identifier}, query: #{query}"
@@ -70,7 +70,6 @@ module WtActiverecordIndexSpy
70
70
  origin: reduce_origin(origin),
71
71
  certainity_level: certainity_level
72
72
  )
73
-
74
73
  @aggregator.add(item)
75
74
  end
76
75
  # rubocop:enable Metrics/AbcSize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WtActiverecordIndexSpy
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wt_activerecord_index_spy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Perrella
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord