ar-query-matchers 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +25 -2
  5. metadata +34 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac905a2afca1579c9f829cb80ec5ea9db151311b7970e3a35f90528d0d9524b0
4
- data.tar.gz: 5f1413a65d8276a0b282070be3d86f8a910224e51ac8fff893d3882c62986f25
3
+ metadata.gz: 5265f76d235538ee76fd8ed78d460357bd35efc1b9f96286cd674c646dfa9080
4
+ data.tar.gz: 368284e4b46d07c1331805e1224f15f66f82757a69dcc2d2eccb097331e154e9
5
5
  SHA512:
6
- metadata.gz: 8c76ea6089d6e15a9ae2dcd9d07319756caa09d36d3645373a5362b04c677c67432305cd9598368231aaacd872604d73df20ca5c93c4d9e2bcd92ceea1860e90
7
- data.tar.gz: ba4fb57beaf019f17ac41fbc66cb974bcb76616db0d0b5ce1a3028e87b66d8cf2f6b954342ee59ca52162debb6e4cf7478ae41266f0fad53c353437fea3849d8
6
+ metadata.gz: 6b6f19694c17e3462faccfcb5928e907a269947264f2a9902d7bcfb4a5ea0c88aeb99deff97198abbe5f42d25d6f844dcdff738967ef783e6a1230cadb3ce0aa
7
+ data.tar.gz: 55615a4c940d4dfdfbba8625fea16bcc64c537e31c31f690fc7fcc1d2b3ca7a775d5b68e145e472a478b0c8a787239fdc3c2cb8d42fbf66fcf581231499b4131
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] - 2019-09-15
10
+ ### Changed
11
+ - Package the CHANGELOG and README in the gem.
12
+ - Add additional gemspec metadata
13
+
14
+ ## [0.1.0] - 2019-09-14
15
+ ### Added
16
+ - First versions as a public ruby gem.
17
+
18
+ [Unreleased]: https://github.com/gusto/ar-query-matchers/compare/v0.2.0...HEAD
19
+ [0.2.0]: https://github.com/gusto/ar-query-matchers/releases/tag/v0.2.0
20
+ [0.1.0]: https://github.com/gusto/ar-query-matchers/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Matan Zruya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,13 +1,36 @@
1
1
  ## AR Query Matchers
2
+ ![badge](https://action-badges.now.sh/gusto/ar-query-matchers?action=Run%20Tests)
2
3
 
3
4
  These RSpec matchers allows guarding against N+1 queries by specifying
4
- exactly how many queries we expect each of our models to perform.
5
+ exactly how many queries you expect each of your ActiveRecord models to perform.
5
6
 
6
7
  They also help us reason about the type of record interactions happening in a block of code.
7
8
 
8
9
  This pattern is a based on how Rails itself tests queries:
9
10
  https://github.com/rails/rails/blob/ac2bc00482c1cf47a57477edb6ab1426a3ba593c/activerecord/test/cases/test_case.rb#L104-L141
10
11
 
12
+ ### Usage
13
+ Include it in your Gemfile:
14
+ ```ruby
15
+ group :test do
16
+ gem 'ar-query-matchers', '~> 0.1.0', require: false
17
+ end
18
+ ```
19
+
20
+ Start using it:
21
+ ```ruby
22
+ require 'ar-query-matchers'
23
+
24
+ RSpec.describe Employee do
25
+ it 'creating an employee creates exactly one record' do
26
+ expect {
27
+ Employee.create!(first_name: 'John', last_name: 'Doe')
28
+ }.to only_create_models('Employee' => '1')
29
+ end
30
+ end
31
+ ```
32
+
33
+ ### Matchers
11
34
  This module defines a few categories of matchers:
12
35
  - **Create**: Which models are created during a block
13
36
  - **Load**: Which models are fetched during a block
@@ -88,4 +111,4 @@ For more information, see:
88
111
  ### Known problems
89
112
  - The Rails 4 `ActiveRecord::Base#pluck` method doesn't issue a
90
113
  `Load` or `Exists` named query and therefore we don't capture the counts with
91
- this tool. This may be fixed in Rails 5/6.
114
+ this tool. This may be fixed in Rails 5/6.
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matan Zruya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-14 00:00:00.000000000 Z
11
+ date: 2019-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -64,6 +64,20 @@ dependencies:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '3.0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: appraisal
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
67
81
  - !ruby/object:Gem::Dependency
68
82
  name: bundler
69
83
  requirement: !ruby/object:Gem::Requirement
@@ -82,30 +96,30 @@ dependencies:
82
96
  name: rake
83
97
  requirement: !ruby/object:Gem::Requirement
84
98
  requirements:
85
- - - "~>"
99
+ - - ">="
86
100
  - !ruby/object:Gem::Version
87
- version: '10.0'
101
+ version: '0'
88
102
  type: :development
89
103
  prerelease: false
90
104
  version_requirements: !ruby/object:Gem::Requirement
91
105
  requirements:
92
- - - "~>"
106
+ - - ">="
93
107
  - !ruby/object:Gem::Version
94
- version: '10.0'
108
+ version: '0'
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: rspec
97
111
  requirement: !ruby/object:Gem::Requirement
98
112
  requirements:
99
- - - "~>"
113
+ - - ">="
100
114
  - !ruby/object:Gem::Version
101
- version: '3.0'
115
+ version: '0'
102
116
  type: :development
103
117
  prerelease: false
104
118
  version_requirements: !ruby/object:Gem::Requirement
105
119
  requirements:
106
- - - "~>"
120
+ - - ">="
107
121
  - !ruby/object:Gem::Version
108
- version: '3.0'
122
+ version: '0'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: rubocop
111
125
  requirement: !ruby/object:Gem::Requirement
@@ -124,23 +138,26 @@ dependencies:
124
138
  name: sqlite3
125
139
  requirement: !ruby/object:Gem::Requirement
126
140
  requirements:
127
- - - "~>"
141
+ - - ">="
128
142
  - !ruby/object:Gem::Version
129
- version: '1.4'
143
+ version: '0'
130
144
  type: :development
131
145
  prerelease: false
132
146
  version_requirements: !ruby/object:Gem::Requirement
133
147
  requirements:
134
- - - "~>"
148
+ - - ">="
135
149
  - !ruby/object:Gem::Version
136
- version: '1.4'
137
- description: ''
150
+ version: '0'
151
+ description: These RSpec matchers allows guarding against N+1 queries by specifying
152
+ exactly how many queries you expect each of your ActiveRecord models to perform.
138
153
  email:
139
154
  - mzruya@gmail.com
140
155
  executables: []
141
156
  extensions: []
142
157
  extra_rdoc_files: []
143
158
  files:
159
+ - CHANGELOG.md
160
+ - LICENSE.txt
144
161
  - README.md
145
162
  - lib/ar_query_matchers.rb
146
163
  - lib/ar_query_matchers/queries/create_counter.rb
@@ -157,7 +174,7 @@ licenses:
157
174
  metadata:
158
175
  homepage_uri: https://github.com/Gusto/ar-query-matchers
159
176
  source_code_uri: https://github.com/Gusto/ar-query-matchers
160
- changelog_uri: https://github.com/Gusto/ar-query-matchers
177
+ changelog_uri: https://github.com/Gusto/ar-query-matchers/blob/master/CHANGELOG.md
161
178
  post_install_message:
162
179
  rdoc_options: []
163
180
  require_paths:
@@ -176,5 +193,5 @@ requirements: []
176
193
  rubygems_version: 3.0.3
177
194
  signing_key:
178
195
  specification_version: 4
179
- summary: ''
196
+ summary: Ruby test matchers for instrumenting ActiveRecord query counts
180
197
  test_files: []