ar-query-matchers 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/ar_query_matchers.rb +9 -3
- data/lib/ar_query_matchers/queries/query_counter.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c028b70b3fbf9ea3e703744480dfb98f6a1ef9b6ab2e90fc4c05879cb2eecff
|
4
|
+
data.tar.gz: c1191c7af4628af475e2e180ec3dd0233e80d69c0d5991d8278292fed6e1aec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f220e3dff11f0b978b6de20314646783814fadfc7cc15ad51d59236a76def60e98f77fe5495217f572046fffbd15a568b0f5827c56874a1b8dd71ec4c3822e04
|
7
|
+
data.tar.gz: 10ee5a3e0c6a39836d59649a0df91eb64f5967e8cc5df0d874755e33f1894d6f251f3f9e82bbc4395e97b67a1c820aaab929c3df05226e4d9c52e91fc133ddf7
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.5.1] - 2020-11-19
|
10
|
+
### Changed
|
11
|
+
- Removes zero count expectations from hash before comparing
|
12
|
+
|
9
13
|
## [0.5.0] - 2020-07-23
|
10
14
|
### Changed
|
11
15
|
- Add time information to query counter
|
@@ -27,7 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
27
31
|
### Added
|
28
32
|
- First versions as a public ruby gem.
|
29
33
|
|
30
|
-
[Unreleased]: https://github.com/gusto/ar-query-matchers/compare/v0.5.
|
34
|
+
[Unreleased]: https://github.com/gusto/ar-query-matchers/compare/v0.5.1...HEAD
|
35
|
+
[0.5.1]: https://github.com/gusto/ar-query-matchers/releases/tag/v0.5.1
|
31
36
|
[0.5.0]: https://github.com/gusto/ar-query-matchers/releases/tag/v0.5.0
|
32
37
|
[0.4.0]: https://github.com/gusto/ar-query-matchers/releases/tag/v0.4.0
|
33
38
|
[0.3.0]: https://github.com/gusto/ar-query-matchers/releases/tag/v0.3.0
|
data/lib/ar_query_matchers.rb
CHANGED
@@ -7,6 +7,12 @@ require 'bigdecimal'
|
|
7
7
|
|
8
8
|
module ArQueryMatchers
|
9
9
|
module ArQueryMatchers
|
10
|
+
class Utility
|
11
|
+
def self.remove_superfluous_expectations(expected)
|
12
|
+
expected.select { |_, v| v.positive? }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
10
16
|
module CreateModels
|
11
17
|
# The following will succeed:
|
12
18
|
# expect {
|
@@ -23,7 +29,7 @@ module ArQueryMatchers
|
|
23
29
|
|
24
30
|
match do |block|
|
25
31
|
@query_stats = Queries::CreateCounter.instrument(&block)
|
26
|
-
expected == @query_stats.query_counts
|
32
|
+
Utility.remove_superfluous_expectations(expected) == @query_stats.query_counts
|
27
33
|
end
|
28
34
|
|
29
35
|
def failure_text
|
@@ -83,7 +89,7 @@ module ArQueryMatchers
|
|
83
89
|
|
84
90
|
match do |block|
|
85
91
|
@query_stats = Queries::LoadCounter.instrument(&block)
|
86
|
-
expected == @query_stats.query_counts
|
92
|
+
Utility.remove_superfluous_expectations(expected) == @query_stats.query_counts
|
87
93
|
end
|
88
94
|
|
89
95
|
def failure_text
|
@@ -147,7 +153,7 @@ module ArQueryMatchers
|
|
147
153
|
|
148
154
|
match do |block|
|
149
155
|
@query_stats = Queries::UpdateCounter.instrument(&block)
|
150
|
-
expected == @query_stats.query_counts
|
156
|
+
Utility.remove_superfluous_expectations(expected) == @query_stats.query_counts
|
151
157
|
end
|
152
158
|
|
153
159
|
def failure_text
|
@@ -79,7 +79,7 @@ module ArQueryMatchers
|
|
79
79
|
return if payload[:cached]
|
80
80
|
|
81
81
|
# Given a `sql.active_record` event, figure out which model is being
|
82
|
-
# accessed. Some of the simpler queries have a :
|
82
|
+
# accessed. Some of the simpler queries have a :name key that makes this
|
83
83
|
# really easy. Others require parsing the SQL by hand.
|
84
84
|
model_name = @query_filter.filter_map(payload[:name] || '', payload[:sql] || '')&.model_name
|
85
85
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-query-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matan Zruya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.1.4
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: Ruby test matchers for instrumenting ActiveRecord query counts
|