rspec-sqlimit 0.0.1 → 0.0.5
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 +5 -5
- data/.gitignore +5 -0
- data/.rubocop.yml +4 -3
- data/.travis.yml +29 -5
- data/Appraisals +24 -0
- data/CHANGELOG.md +36 -0
- data/Gemfile +3 -0
- data/README.md +6 -27
- data/Rakefile +18 -2
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_4.2.gemfile +13 -0
- data/gemfiles/rails_5.0.gemfile +13 -0
- data/gemfiles/rails_5.1.gemfile +13 -0
- data/gemfiles/rails_6.0.gemfile +13 -0
- data/gemfiles/rails_7.0.gemfile +13 -0
- data/lib/rspec/sqlimit/counter.rb +18 -2
- data/lib/rspec/sqlimit/reporter.rb +3 -2
- data/rspec-sqlimit.gemspec +4 -3
- data/spec/dummy/db/migrate/20170211104800_create_users.rb +1 -1
- data/spec/dummy/lib/dummy/compatibility.rb +11 -0
- data/spec/dummy/lib/dummy.rb +1 -0
- data/spec/rspec/sqlimit/reporter_spec.rb +74 -0
- data/spec/rspec/sqlimit_spec.rb +18 -0
- metadata +37 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0ef12b607f4a6ec3c874a69637dd3e9717224998ca13177d8a907b6c6f413068
|
|
4
|
+
data.tar.gz: 3d490548445a3bc92381a19d624a09e2a591ccbcabe4d0a0c8d2bdd2028d6ed1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c05ef3f272c574a748cb5d4065122ad0b649a94078f01f9520ae18d855a9c8e1ca386f8a085bb3ea1cf9e3c87e011b9288b44eb39930757c7d5e3456df37faf
|
|
7
|
+
data.tar.gz: ab6c401133cb90c82e0d8123d47394570ea143ba9af068c2f8b04e1c8ab474dbccb3dd61e999ce53e44019a7350693ff7a2026bea6adf7791778c14cabf89465
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -3,10 +3,11 @@ AllCops:
|
|
|
3
3
|
DisplayCopNames: true
|
|
4
4
|
DisplayStyleGuide: true
|
|
5
5
|
StyleGuideCopsOnly: true
|
|
6
|
-
TargetRubyVersion: 2.
|
|
6
|
+
TargetRubyVersion: 2.6
|
|
7
7
|
Exclude:
|
|
8
8
|
- spec/dummy/db/schema.rb
|
|
9
|
-
|
|
9
|
+
- vendor/bundle/**/*
|
|
10
|
+
- gemfiles/vendor/**/*
|
|
10
11
|
Metrics/ParameterLists:
|
|
11
12
|
Max: 5
|
|
12
13
|
|
|
@@ -14,7 +15,7 @@ Style/Alias:
|
|
|
14
15
|
Enabled: false
|
|
15
16
|
|
|
16
17
|
Style/ClassAndModuleChildren:
|
|
17
|
-
|
|
18
|
+
Enabled: false
|
|
18
19
|
|
|
19
20
|
Style/FileName:
|
|
20
21
|
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
---
|
|
2
|
-
sudo:
|
|
2
|
+
sudo: false
|
|
3
3
|
language: ruby
|
|
4
|
-
cache:
|
|
4
|
+
cache: bundler
|
|
5
|
+
before_install:
|
|
6
|
+
- gem update --system
|
|
7
|
+
- gem uninstall -v '>= 1' -i $(rvm gemdir)@global -ax bundler || true
|
|
8
|
+
- gem install bundler -v 1.3.0
|
|
9
|
+
- gem update --system
|
|
5
10
|
script:
|
|
6
|
-
- bundle exec
|
|
11
|
+
- bundle exec rake
|
|
7
12
|
rvm:
|
|
8
|
-
- 2.3
|
|
13
|
+
- 2.3
|
|
14
|
+
- 2.6
|
|
15
|
+
- 2.7
|
|
16
|
+
- 3.0
|
|
9
17
|
- ruby-head
|
|
10
|
-
|
|
18
|
+
gemfile:
|
|
19
|
+
- gemfiles/rails_4.2.gemfile
|
|
20
|
+
- gemfiles/rails_5.0.gemfile
|
|
21
|
+
- gemfiles/rails_5.1.gemfile
|
|
22
|
+
- gemfiles/rails_6.0.gemfile
|
|
23
|
+
- gemfiles/rails_7.0.gemfile
|
|
11
24
|
matrix:
|
|
25
|
+
exclude:
|
|
26
|
+
- rvm: 2.3
|
|
27
|
+
gemfile: gemfiles/rails_7.0.gemfile
|
|
28
|
+
- rvm: 2.3
|
|
29
|
+
gemfile: gemfiles/rails_6.0.gemfile
|
|
30
|
+
- rvm: 3.0
|
|
31
|
+
gemfile: gemfiles/rails_4.2.gemfile
|
|
32
|
+
- rvm: 2.7
|
|
33
|
+
gemfile: gemfiles/rails_4.2.gemfile
|
|
34
|
+
- rvm: ruby-head
|
|
35
|
+
gemfile: gemfiles/rails_4.2.gemfile
|
|
12
36
|
allow_failures:
|
|
13
37
|
- rvm: ruby-head
|
data/Appraisals
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
appraise "rails-4.2" do
|
|
2
|
+
gem "rails", "~> 4.2.0"
|
|
3
|
+
gem "sqlite3", "~> 1.3.0"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
appraise "rails-5.0" do
|
|
7
|
+
gem "rails", "~> 5.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.0"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
appraise "rails-5.1" do
|
|
12
|
+
gem "rails", "~> 5.1.0"
|
|
13
|
+
gem "sqlite3", "~> 1.3.0"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
appraise "rails-6.0" do
|
|
17
|
+
gem "rails", "~> 6.0.0"
|
|
18
|
+
gem "sqlite3", "~> 1.4"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
appraise "rails-7.0" do
|
|
22
|
+
gem "rails", "~> 7.0.0"
|
|
23
|
+
gem "sqlite3", "~> 1.4"
|
|
24
|
+
end
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [0.0.5] - [2022-02-13]
|
|
9
|
+
- Support of Rails 7 (@kivanio)
|
|
10
|
+
- Fix README (@rcclemente)
|
|
11
|
+
|
|
12
|
+
## [0.0.4] - [2021-03-21]
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Issue #10 about safe processing of blank :binding key (following @blackst0ne)
|
|
16
|
+
|
|
17
|
+
## [0.0.3] - [2019-10-02]
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- Support of Rails 6 (@quikly)
|
|
21
|
+
- Cached queries are ignored (@tyok)
|
|
22
|
+
|
|
23
|
+
## [0.0.2] - [2017-05-17]
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- All variables of SQL queries are bound to error messages (@Dobrodushny)
|
|
27
|
+
|
|
28
|
+
## [0.0.1] - [2017-02-12]
|
|
29
|
+
This is a first public release (@nepalez)
|
|
30
|
+
|
|
31
|
+
[Unreleased]: https://github.com/tram-rb/tram-policy
|
|
32
|
+
[0.0.1]: https://github.com/nepalez/rspec-sqlimit/releases/tag/v0.0.1
|
|
33
|
+
[0.0.2]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.1...v0.0.2
|
|
34
|
+
[0.0.3]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.2...v0.0.3
|
|
35
|
+
[0.0.4]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.3...v0.0.4
|
|
36
|
+
[0.0.5]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.4...v0.0.5
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@ RSpec matcher to control number of SQL queries executed by a block of code.
|
|
|
4
4
|
|
|
5
5
|
It wraps [the answer at Stack Overflow][stack-answer] by [Ryan Bigg][ryan-bigg], which based on Active Support [Notification][notification] and [Instrumentation][instrumentation] mechanisms.
|
|
6
6
|
|
|
7
|
+
For motivation and details see my [blog post "Fighting the Hydra of N+1 queries" in the Martian Chronicles][hydra].
|
|
8
|
+
|
|
7
9
|
[![Gem Version][gem-badger]][gem]
|
|
8
10
|
[![Build Status][travis-badger]][travis]
|
|
9
11
|
[![Dependency Status][gemnasium-badger]][gemnasium]
|
|
@@ -66,31 +68,7 @@ require "rspec-sqlimit"
|
|
|
66
68
|
|
|
67
69
|
RSpec.describe "N+1 safety" do
|
|
68
70
|
it "doesn't send unnecessary requests to db" do
|
|
69
|
-
expect { User.create }.not_to exceed_query_limit(
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
Failure/Error: expect { User.create }.not_to exceed_query_limit(0).with(/INSERT/)
|
|
76
|
-
|
|
77
|
-
Expected to run maximum 0 queries that match (?-mix:INSERT)
|
|
78
|
-
The following 1 queries were invoked among others (see mark ->):
|
|
79
|
-
1) begin transaction (0.072 ms)
|
|
80
|
-
-> 2) INSERT INTO "users" DEFAULT VALUES (0.368 ms)
|
|
81
|
-
3) commit transaction (147.559 ms)
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Further Development
|
|
85
|
-
|
|
86
|
-
For now the gem uses unbinded Active Record queries in error descriptions. For example, when your query contains arguments, the error message will look like
|
|
87
|
-
|
|
88
|
-
```ruby
|
|
89
|
-
require "rspec-sqlimit"
|
|
90
|
-
|
|
91
|
-
RSpec.describe "N+1 safety" do
|
|
92
|
-
it "doesn't send unnecessary requests to db" do
|
|
93
|
-
expect { User.create(name: "Joe") }.not_to exceed_query_limit(1)
|
|
71
|
+
expect { User.create name: "Joe" }.not_to exceed_query_limit(0).with(/^INSERT/)
|
|
94
72
|
end
|
|
95
73
|
end
|
|
96
74
|
```
|
|
@@ -101,11 +79,11 @@ Failure/Error: expect { User.create }.not_to exceed_query_limit(0).with(/INSERT/
|
|
|
101
79
|
Expected to run maximum 0 queries that match (?-mix:INSERT)
|
|
102
80
|
The following 1 queries were invoked among others (see mark ->):
|
|
103
81
|
1) begin transaction (0.072 ms)
|
|
104
|
-
-> 2) INSERT INTO "users" ("name") VALUES (?) (0.368 ms)
|
|
82
|
+
-> 2) INSERT INTO "users" ("name") VALUES (?); ["Joe"] (0.368 ms)
|
|
105
83
|
3) commit transaction (147.559 ms)
|
|
106
84
|
```
|
|
107
85
|
|
|
108
|
-
|
|
86
|
+
In the last example you can see that binded values are shown after the query following the Rails convention.
|
|
109
87
|
|
|
110
88
|
## License
|
|
111
89
|
|
|
@@ -124,3 +102,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
|
124
102
|
[notification]: http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html
|
|
125
103
|
[instrumentation]: http://guides.rubyonrails.org/active_support_instrumentation.html
|
|
126
104
|
[hook]: http://guides.rubyonrails.org/active_support_instrumentation.html#sql-active-record
|
|
105
|
+
[hydra]: https://evilmartians.com/chronicles/fighting-the-hydra-of-n-plus-one-queries
|
data/Rakefile
CHANGED
|
@@ -7,7 +7,23 @@ require "rspec/core/rake_task"
|
|
|
7
7
|
load "spec/dummy/Rakefile"
|
|
8
8
|
|
|
9
9
|
# Declares gem's own tasks.
|
|
10
|
+
desc "Runs test suite over all rails versions."
|
|
11
|
+
task :default do
|
|
12
|
+
if ENV["BUNDLE_GEMFILE"] =~ /gemfiles/
|
|
13
|
+
Rake::Task["dummy:db:create"].reenable
|
|
14
|
+
Rake::Task["dummy:db:migrate"].reenable
|
|
15
|
+
Rake::Task[:spec].invoke
|
|
16
|
+
else
|
|
17
|
+
Rake::Task[:appraise].invoke
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
10
21
|
desc "Runs test suite."
|
|
11
|
-
task default: %w
|
|
12
|
-
|
|
22
|
+
task default: %w[dummy:db:create dummy:db:migrate] do
|
|
23
|
+
exec "bundle exec rspec spec"
|
|
24
|
+
exec "bundle exec rubocop"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
task :appraise do
|
|
28
|
+
exec "appraisal install && appraisal rake"
|
|
13
29
|
end
|
|
@@ -30,9 +30,25 @@ module RSpec::SQLimit
|
|
|
30
30
|
|
|
31
31
|
def callback
|
|
32
32
|
@callback ||= lambda do |_name, start, finish, _message_id, values|
|
|
33
|
-
return if %w
|
|
34
|
-
|
|
33
|
+
return if %w[CACHE SCHEMA].include? values[:name]
|
|
34
|
+
return if cached_query?(values)
|
|
35
|
+
|
|
36
|
+
queries << {
|
|
37
|
+
sql: values[:sql],
|
|
38
|
+
duration: (finish - start) * 1_000,
|
|
39
|
+
binds: values[:type_casted_binds] || type_cast(values[:binds])
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def type_cast(binds)
|
|
45
|
+
binds.map do |column, value|
|
|
46
|
+
ActiveRecord::Base.connection.type_cast(value, column)
|
|
35
47
|
end
|
|
36
48
|
end
|
|
49
|
+
|
|
50
|
+
def cached_query?(values)
|
|
51
|
+
values[:type_casted_binds].respond_to?(:call)
|
|
52
|
+
end
|
|
37
53
|
end
|
|
38
54
|
end
|
|
@@ -11,7 +11,6 @@ module RSpec::SQLimit
|
|
|
11
11
|
|
|
12
12
|
def call
|
|
13
13
|
suffix = " among others (see mark ->)" if @matcher
|
|
14
|
-
|
|
15
14
|
return "No queries were invoked" if @queries.empty?
|
|
16
15
|
|
|
17
16
|
<<-MESSAGE.gsub(/ +\|/, "")
|
|
@@ -28,7 +27,9 @@ module RSpec::SQLimit
|
|
|
28
27
|
|
|
29
28
|
def line(query, index)
|
|
30
29
|
prefix = (matcher && query[:sql] =~ matcher) ? "->" : " "
|
|
31
|
-
|
|
30
|
+
binds = query[:binds]&.any? ? "; #{query[:binds]} " : ""
|
|
31
|
+
"#{prefix} #{index + 1}) #{query[:sql]}#{binds}" \
|
|
32
|
+
" (#{query[:duration].round(3)} ms)"
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
end
|
data/rspec-sqlimit.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |gem|
|
|
2
2
|
gem.name = "rspec-sqlimit"
|
|
3
|
-
gem.version = "0.0.
|
|
3
|
+
gem.version = "0.0.5"
|
|
4
4
|
gem.author = "Andrew Kozin (nepalez)"
|
|
5
5
|
gem.email = "andrew.kozin@gmail.com"
|
|
6
6
|
gem.homepage = "https://github.com/nepalez/rspec-sqlimit"
|
|
@@ -13,12 +13,13 @@ Gem::Specification.new do |gem|
|
|
|
13
13
|
|
|
14
14
|
gem.required_ruby_version = ">= 2.3"
|
|
15
15
|
|
|
16
|
-
gem.add_runtime_dependency "
|
|
16
|
+
gem.add_runtime_dependency "activerecord", "> 4.2", "< 7.1"
|
|
17
17
|
gem.add_runtime_dependency "rspec", "~> 3.0"
|
|
18
18
|
|
|
19
|
+
gem.add_development_dependency "appraisal", "~> 2.2"
|
|
19
20
|
gem.add_development_dependency "rspec", "~> 3.0"
|
|
20
21
|
gem.add_development_dependency "rake", "> 10.0"
|
|
21
22
|
gem.add_development_dependency "sqlite3", "~> 1.3"
|
|
22
23
|
gem.add_development_dependency "database_cleaner", "~> 1.5"
|
|
23
|
-
gem.add_development_dependency "rubocop", "~> 0.
|
|
24
|
+
gem.add_development_dependency "rubocop", "~> 0.49"
|
|
24
25
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# ActiveRecord::Migration['5.0'] syntax is not supported prior to Rails 5.0
|
|
2
|
+
# This snippet supports it on Rails 4.2
|
|
3
|
+
unless ActiveRecord::Migration.respond_to?(:[])
|
|
4
|
+
class ActiveRecord::Migration
|
|
5
|
+
class << self
|
|
6
|
+
def [](_version)
|
|
7
|
+
self
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/spec/dummy/lib/dummy.rb
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe RSpec::SQLimit::Reporter do
|
|
4
|
+
subject { described_class.new(counter) }
|
|
5
|
+
|
|
6
|
+
context "no params were passed to the query" do
|
|
7
|
+
let(:counter) { RSpec::SQLimit::Counter[/CREATE/, proc{ User.create }] }
|
|
8
|
+
|
|
9
|
+
it "doesn't print binds" do
|
|
10
|
+
# INSERT INTO "users" DEFAULT VALUES (0.284 ms)
|
|
11
|
+
expect(subject.call).to include("DEFAULT VALUES")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "query contains params" do
|
|
16
|
+
context "nil was passed as param" do
|
|
17
|
+
let(:counter) do
|
|
18
|
+
RSpec::SQLimit::Counter[/CREATE/, proc { User.create(id: nil) }]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "doesn't print binds" do
|
|
22
|
+
# INSERT INTO "users" DEFAULT VALUES (0.284 ms)
|
|
23
|
+
expect(subject.call).to include("DEFAULT VALUES")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context "single param was passed" do
|
|
28
|
+
let(:counter) do
|
|
29
|
+
RSpec::SQLimit::Counter[/CREATE/, proc { User.create(id: 1) }]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "prints param as an array with one element" do
|
|
33
|
+
# INSERT INTO "users" ("id") VALUES (?); [1] (0.234 ms)
|
|
34
|
+
expect(subject.call).to include("VALUES (?); [1]")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "array was passed as a param" do
|
|
39
|
+
let(:counter) do
|
|
40
|
+
RSpec::SQLimit::Counter[
|
|
41
|
+
/SELECT/, proc { User.where(id: [1, 2, 3]).to_a }
|
|
42
|
+
]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "prints all params" do
|
|
46
|
+
# rubocop: disable Metrics/LineLength
|
|
47
|
+
# SELECT "users".* FROM "users" WHERE "users"."id" IN (1, 2, 3) (0.17 ms))
|
|
48
|
+
# Rails >= 6:
|
|
49
|
+
# SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?, ?); [1, 2, 3] (0.121 ms)
|
|
50
|
+
# rubocop: enable Metrics/LineLength
|
|
51
|
+
expect(subject.call).to include("1, 2, 3")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "activerecord query caching was enabled" do
|
|
57
|
+
let(:counter) do
|
|
58
|
+
RSpec::SQLimit::Counter[/SELECT "users"/, proc { queries }]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
let(:queries) do
|
|
62
|
+
User.cache do
|
|
63
|
+
User.where(id: 1).to_a
|
|
64
|
+
User.where(id: 1).to_a
|
|
65
|
+
User.where(id: [2, 3]).to_a
|
|
66
|
+
User.where(id: [2, 3]).to_a
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "ignores cached queries" do
|
|
71
|
+
expect(subject.call).to include("2 queries were invoked")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/spec/rspec/sqlimit_spec.rb
CHANGED
|
@@ -6,6 +6,14 @@ describe "exceed_query_limit" do
|
|
|
6
6
|
expect { User.new }.not_to exceed_query_limit(0)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
it "works when nil is used as a parameter" do
|
|
10
|
+
expect { User.create id: nil }.to exceed_query_limit(0)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "works when array is used as a restriction" do
|
|
14
|
+
expect { (User.where id: [1, 2, 3]).to_a }.to exceed_query_limit(0)
|
|
15
|
+
end
|
|
16
|
+
|
|
9
17
|
it "works when actual number of queries is below the limit" do
|
|
10
18
|
expect { User.create }.not_to exceed_query_limit(3)
|
|
11
19
|
end
|
|
@@ -20,6 +28,16 @@ describe "exceed_query_limit" do
|
|
|
20
28
|
expect { User.new }.not_to exceed_query_limit(0).with(/INSERT/)
|
|
21
29
|
end
|
|
22
30
|
|
|
31
|
+
it "works when nil is used as a parameter" do
|
|
32
|
+
expect { User.create id: nil }.to exceed_query_limit(0).with(/INSERT/)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "works when array is used as a restriction" do
|
|
36
|
+
expect { (User.where id: [1, 2, 3]).to_a }
|
|
37
|
+
.to exceed_query_limit(0)
|
|
38
|
+
.with(/SELECT/)
|
|
39
|
+
end
|
|
40
|
+
|
|
23
41
|
it "works when actual number of queries is below the limit" do
|
|
24
42
|
expect { User.create }.not_to exceed_query_limit(1).with(/INSERT/)
|
|
25
43
|
end
|
metadata
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-sqlimit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kozin (nepalez)
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: activerecord
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '4.
|
|
19
|
+
version: '4.2'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '7.1'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">"
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '4.
|
|
29
|
+
version: '4.2'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '7.1'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: rspec
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,6 +44,20 @@ dependencies:
|
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: '3.0'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: appraisal
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.2'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '2.2'
|
|
47
61
|
- !ruby/object:Gem::Dependency
|
|
48
62
|
name: rspec
|
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -106,30 +120,39 @@ dependencies:
|
|
|
106
120
|
requirements:
|
|
107
121
|
- - "~>"
|
|
108
122
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0.
|
|
123
|
+
version: '0.49'
|
|
110
124
|
type: :development
|
|
111
125
|
prerelease: false
|
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
127
|
requirements:
|
|
114
128
|
- - "~>"
|
|
115
129
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0.
|
|
130
|
+
version: '0.49'
|
|
117
131
|
description:
|
|
118
132
|
email: andrew.kozin@gmail.com
|
|
119
133
|
executables: []
|
|
120
134
|
extensions: []
|
|
121
135
|
extra_rdoc_files:
|
|
122
136
|
- README.md
|
|
137
|
+
- CHANGELOG.md
|
|
123
138
|
files:
|
|
124
139
|
- ".codeclimate.yml"
|
|
125
140
|
- ".gitignore"
|
|
126
141
|
- ".rspec"
|
|
127
142
|
- ".rubocop.yml"
|
|
128
143
|
- ".travis.yml"
|
|
144
|
+
- Appraisals
|
|
145
|
+
- CHANGELOG.md
|
|
129
146
|
- Gemfile
|
|
130
147
|
- LICENSE.txt
|
|
131
148
|
- README.md
|
|
132
149
|
- Rakefile
|
|
150
|
+
- gemfiles/.bundle/config
|
|
151
|
+
- gemfiles/rails_4.2.gemfile
|
|
152
|
+
- gemfiles/rails_5.0.gemfile
|
|
153
|
+
- gemfiles/rails_5.1.gemfile
|
|
154
|
+
- gemfiles/rails_6.0.gemfile
|
|
155
|
+
- gemfiles/rails_7.0.gemfile
|
|
133
156
|
- lib/rspec-sqlimit.rb
|
|
134
157
|
- lib/rspec/sqlimit.rb
|
|
135
158
|
- lib/rspec/sqlimit/counter.rb
|
|
@@ -141,9 +164,10 @@ files:
|
|
|
141
164
|
- spec/dummy/config/environment.rb
|
|
142
165
|
- spec/dummy/db/migrate/20170211104800_create_users.rb
|
|
143
166
|
- spec/dummy/db/schema.rb
|
|
144
|
-
- spec/dummy/db/test.sqlite3
|
|
145
167
|
- spec/dummy/lib/dummy.rb
|
|
146
168
|
- spec/dummy/lib/dummy/application.rb
|
|
169
|
+
- spec/dummy/lib/dummy/compatibility.rb
|
|
170
|
+
- spec/rspec/sqlimit/reporter_spec.rb
|
|
147
171
|
- spec/rspec/sqlimit_spec.rb
|
|
148
172
|
- spec/spec_helper.rb
|
|
149
173
|
homepage: https://github.com/nepalez/rspec-sqlimit
|
|
@@ -165,8 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
189
|
- !ruby/object:Gem::Version
|
|
166
190
|
version: '0'
|
|
167
191
|
requirements: []
|
|
168
|
-
|
|
169
|
-
rubygems_version: 2.5.2
|
|
192
|
+
rubygems_version: 3.2.3
|
|
170
193
|
signing_key:
|
|
171
194
|
specification_version: 4
|
|
172
195
|
summary: RSpec matcher to control SQL queries made by block of code
|
|
@@ -177,8 +200,9 @@ test_files:
|
|
|
177
200
|
- spec/dummy/config/environment.rb
|
|
178
201
|
- spec/dummy/db/migrate/20170211104800_create_users.rb
|
|
179
202
|
- spec/dummy/db/schema.rb
|
|
180
|
-
- spec/dummy/db/test.sqlite3
|
|
181
203
|
- spec/dummy/lib/dummy.rb
|
|
182
204
|
- spec/dummy/lib/dummy/application.rb
|
|
205
|
+
- spec/dummy/lib/dummy/compatibility.rb
|
|
206
|
+
- spec/rspec/sqlimit/reporter_spec.rb
|
|
183
207
|
- spec/rspec/sqlimit_spec.rb
|
|
184
208
|
- spec/spec_helper.rb
|
data/spec/dummy/db/test.sqlite3
DELETED
|
Binary file
|