rspec-sqlimit 0.0.5 → 1.0.0

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: 0ef12b607f4a6ec3c874a69637dd3e9717224998ca13177d8a907b6c6f413068
4
- data.tar.gz: 3d490548445a3bc92381a19d624a09e2a591ccbcabe4d0a0c8d2bdd2028d6ed1
3
+ metadata.gz: a12eaeb4ffd02e07ab3b5dbd6b7491a0f0198a49adcd97ce1c710f326f104b57
4
+ data.tar.gz: 32bc1dc6eeb7fbd854c830a3cebdd3fa297d1e2fd8c7d641e5c9b8fcac93c0af
5
5
  SHA512:
6
- metadata.gz: 5c05ef3f272c574a748cb5d4065122ad0b649a94078f01f9520ae18d855a9c8e1ca386f8a085bb3ea1cf9e3c87e011b9288b44eb39930757c7d5e3456df37faf
7
- data.tar.gz: ab6c401133cb90c82e0d8123d47394570ea143ba9af068c2f8b04e1c8ab474dbccb3dd61e999ce53e44019a7350693ff7a2026bea6adf7791778c14cabf89465
6
+ metadata.gz: db1e68306ed17a5dd02786ab19bcfcbd69ceec78bd27b1b116a69a61c9ec21830b86261f9e378bbd27225dd3df140d61704d08e39c19a5c977fe197c2727dcbf
7
+ data.tar.gz: 9bd174fe74bf0dcba9078d0fe7613900bc86453926a0dcdc6daecca5cf1d9ce7448142285eea5a7c808c2f2e2962ea1e6bac8b841949d12df1a3332e0974b9c9
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [1.0.0] - [2025-03-06]
9
+ - Support Rails 8+. (@palkan)
10
+
11
+ ## [0.0.6] - [2023-10-06]
12
+ - Support of Rails 7+ (@terracatta)
13
+
8
14
  ## [0.0.5] - [2022-02-13]
9
15
  - Support of Rails 7 (@kivanio)
10
16
  - Fix README (@rcclemente)
@@ -34,3 +40,4 @@ This is a first public release (@nepalez)
34
40
  [0.0.3]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.2...v0.0.3
35
41
  [0.0.4]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.3...v0.0.4
36
42
  [0.0.5]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.4...v0.0.5
43
+ [0.0.6]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.4...v0.0.5
data/README.md CHANGED
@@ -7,9 +7,6 @@ It wraps [the answer at Stack Overflow][stack-answer] by [Ryan Bigg][ryan-bigg],
7
7
  For motivation and details see my [blog post "Fighting the Hydra of N+1 queries" in the Martian Chronicles][hydra].
8
8
 
9
9
  [![Gem Version][gem-badger]][gem]
10
- [![Build Status][travis-badger]][travis]
11
- [![Dependency Status][gemnasium-badger]][gemnasium]
12
- [![Code Climate][codeclimate-badger]][codeclimate]
13
10
 
14
11
  <a href="https://evilmartians.com/">
15
12
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
@@ -89,14 +86,8 @@ In the last example you can see that binded values are shown after the query fol
89
86
 
90
87
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
91
88
 
92
- [codeclimate-badger]: https://img.shields.io/codeclimate/github/nepalez/rspec-sqlimit.svg?style=flat
93
- [codeclimate]: https://codeclimate.com/github/nepalez/rspec-sqlimit
94
89
  [gem-badger]: https://img.shields.io/gem/v/rspec-sqlimit.svg?style=flat
95
90
  [gem]: https://rubygems.org/gems/rspec-sqlimit
96
- [gemnasium-badger]: https://img.shields.io/gemnasium/nepalez/rspec-sqlimit.svg?style=flat
97
- [gemnasium]: https://gemnasium.com/nepalez/rspec-sqlimit
98
- [travis-badger]: https://img.shields.io/travis/nepalez/rspec-sqlimit/master.svg?style=flat
99
- [travis]: https://travis-ci.org/nepalez/rspec-sqlimit
100
91
  [stack-answer]: http://stackoverflow.com/a/5492207/1869912
101
92
  [ryan-bigg]: http://ryanbigg.com/
102
93
  [notification]: http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sqlimit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin (nepalez)
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-12 00:00:00.000000000 Z
11
+ date: 2025-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '7.1'
19
+ version: 4.2.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">"
28
- - !ruby/object:Gem::Version
29
- version: '4.2'
30
- - - "<"
24
+ - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: '7.1'
26
+ version: 4.2.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rspec
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,91 +38,7 @@ dependencies:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
40
  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'
61
- - !ruby/object:Gem::Dependency
62
- name: rspec
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '3.0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '3.0'
75
- - !ruby/object:Gem::Dependency
76
- name: rake
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">"
80
- - !ruby/object:Gem::Version
81
- version: '10.0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">"
87
- - !ruby/object:Gem::Version
88
- version: '10.0'
89
- - !ruby/object:Gem::Dependency
90
- name: sqlite3
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '1.3'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '1.3'
103
- - !ruby/object:Gem::Dependency
104
- name: database_cleaner
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '1.5'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '1.5'
117
- - !ruby/object:Gem::Dependency
118
- name: rubocop
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '0.49'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: '0.49'
131
- description:
41
+ description:
132
42
  email: andrew.kozin@gmail.com
133
43
  executables: []
134
44
  extensions: []
@@ -136,45 +46,18 @@ extra_rdoc_files:
136
46
  - README.md
137
47
  - CHANGELOG.md
138
48
  files:
139
- - ".codeclimate.yml"
140
- - ".gitignore"
141
- - ".rspec"
142
- - ".rubocop.yml"
143
- - ".travis.yml"
144
- - Appraisals
145
49
  - CHANGELOG.md
146
- - Gemfile
147
50
  - LICENSE.txt
148
51
  - README.md
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
156
52
  - lib/rspec-sqlimit.rb
157
53
  - lib/rspec/sqlimit.rb
158
54
  - lib/rspec/sqlimit/counter.rb
159
55
  - lib/rspec/sqlimit/reporter.rb
160
- - rspec-sqlimit.gemspec
161
- - spec/dummy/Rakefile
162
- - spec/dummy/app/models/user.rb
163
- - spec/dummy/config/database.yml
164
- - spec/dummy/config/environment.rb
165
- - spec/dummy/db/migrate/20170211104800_create_users.rb
166
- - spec/dummy/db/schema.rb
167
- - spec/dummy/lib/dummy.rb
168
- - spec/dummy/lib/dummy/application.rb
169
- - spec/dummy/lib/dummy/compatibility.rb
170
- - spec/rspec/sqlimit/reporter_spec.rb
171
- - spec/rspec/sqlimit_spec.rb
172
- - spec/spec_helper.rb
173
56
  homepage: https://github.com/nepalez/rspec-sqlimit
174
57
  licenses:
175
58
  - MIT
176
59
  metadata: {}
177
- post_install_message:
60
+ post_install_message:
178
61
  rdoc_options: []
179
62
  require_paths:
180
63
  - lib
@@ -189,20 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
72
  - !ruby/object:Gem::Version
190
73
  version: '0'
191
74
  requirements: []
192
- rubygems_version: 3.2.3
193
- signing_key:
75
+ rubygems_version: 3.5.22
76
+ signing_key:
194
77
  specification_version: 4
195
78
  summary: RSpec matcher to control SQL queries made by block of code
196
- test_files:
197
- - spec/dummy/Rakefile
198
- - spec/dummy/app/models/user.rb
199
- - spec/dummy/config/database.yml
200
- - spec/dummy/config/environment.rb
201
- - spec/dummy/db/migrate/20170211104800_create_users.rb
202
- - spec/dummy/db/schema.rb
203
- - spec/dummy/lib/dummy.rb
204
- - spec/dummy/lib/dummy/application.rb
205
- - spec/dummy/lib/dummy/compatibility.rb
206
- - spec/rspec/sqlimit/reporter_spec.rb
207
- - spec/rspec/sqlimit_spec.rb
208
- - spec/spec_helper.rb
79
+ test_files: []
data/.codeclimate.yml DELETED
@@ -1,18 +0,0 @@
1
- ---
2
- engines:
3
- bundler-audit:
4
- enabled: true
5
- duplication:
6
- enabled: true
7
- config:
8
- languages:
9
- - ruby
10
- fixme:
11
- enabled: true
12
- rubocop:
13
- enabled: true
14
- ratings:
15
- paths:
16
- - "**.rb"
17
- exclude_paths:
18
- - spec/
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /gemfiles/*.gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
11
- /spec/dummy/db/*.sqlite3
12
- *.gem
13
- .rspec_status
14
- .idea/
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --require spec_helper
2
- --format documentation
3
- --color
data/.rubocop.yml DELETED
@@ -1,33 +0,0 @@
1
- ---
2
- AllCops:
3
- DisplayCopNames: true
4
- DisplayStyleGuide: true
5
- StyleGuideCopsOnly: true
6
- TargetRubyVersion: 2.6
7
- Exclude:
8
- - spec/dummy/db/schema.rb
9
- - vendor/bundle/**/*
10
- - gemfiles/vendor/**/*
11
- Metrics/ParameterLists:
12
- Max: 5
13
-
14
- Style/Alias:
15
- Enabled: false
16
-
17
- Style/ClassAndModuleChildren:
18
- Enabled: false
19
-
20
- Style/FileName:
21
- Enabled: false
22
-
23
- Style/FrozenStringLiteralComment:
24
- Enabled: false
25
-
26
- Style/ModuleFunction:
27
- Enabled: false
28
-
29
- Style/StringLiterals:
30
- EnforcedStyle: double_quotes
31
-
32
- Style/StringLiteralsInInterpolation:
33
- EnforcedStyle: double_quotes
data/.travis.yml DELETED
@@ -1,37 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
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
10
- script:
11
- - bundle exec rake
12
- rvm:
13
- - 2.3
14
- - 2.6
15
- - 2.7
16
- - 3.0
17
- - ruby-head
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
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
36
- allow_failures:
37
- - rvm: ruby-head
data/Appraisals DELETED
@@ -1,24 +0,0 @@
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/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in tram-form.gemspec
4
- gemspec
5
-
6
- gem "rails"
7
- gem "sqlite3"
8
-
9
- group :test, :development do
10
- gem "pry"
11
- gem "pry-byebug"
12
- end
data/Rakefile DELETED
@@ -1,29 +0,0 @@
1
- require "bundler/setup"
2
- Bundler::GemHelper.install_tasks
3
-
4
- require "rspec/core/rake_task"
5
-
6
- # Adds dummy:db tasks.
7
- load "spec/dummy/Rakefile"
8
-
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
-
21
- desc "Runs test suite."
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"
29
- end
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_RETRY: "1"
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.2.0"
6
- gem "sqlite3", "~> 1.3.0"
7
-
8
- group :test, :development do
9
- gem "pry"
10
- gem "pry-byebug"
11
- end
12
-
13
- gemspec path: "../"
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
- gem "sqlite3", "~> 1.3.0"
7
-
8
- group :test, :development do
9
- gem "pry"
10
- gem "pry-byebug"
11
- end
12
-
13
- gemspec path: "../"
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
- gem "sqlite3", "~> 1.3.0"
7
-
8
- group :test, :development do
9
- gem "pry"
10
- gem "pry-byebug"
11
- end
12
-
13
- gemspec path: "../"
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 6.0.0"
6
- gem "sqlite3", "~> 1.4"
7
-
8
- group :test, :development do
9
- gem "pry"
10
- gem "pry-byebug"
11
- end
12
-
13
- gemspec path: "../"
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 7.0.0"
6
- gem "sqlite3", "~> 1.4"
7
-
8
- group :test, :development do
9
- gem "pry"
10
- gem "pry-byebug"
11
- end
12
-
13
- gemspec path: "../"
@@ -1,25 +0,0 @@
1
- Gem::Specification.new do |gem|
2
- gem.name = "rspec-sqlimit"
3
- gem.version = "0.0.5"
4
- gem.author = "Andrew Kozin (nepalez)"
5
- gem.email = "andrew.kozin@gmail.com"
6
- gem.homepage = "https://github.com/nepalez/rspec-sqlimit"
7
- gem.summary = "RSpec matcher to control SQL queries made by block of code"
8
- gem.license = "MIT"
9
-
10
- gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
11
- gem.test_files = gem.files.grep(/^spec/)
12
- gem.extra_rdoc_files = Dir["README.md", "LICENSE", "CHANGELOG.md"]
13
-
14
- gem.required_ruby_version = ">= 2.3"
15
-
16
- gem.add_runtime_dependency "activerecord", "> 4.2", "< 7.1"
17
- gem.add_runtime_dependency "rspec", "~> 3.0"
18
-
19
- gem.add_development_dependency "appraisal", "~> 2.2"
20
- gem.add_development_dependency "rspec", "~> 3.0"
21
- gem.add_development_dependency "rake", "> 10.0"
22
- gem.add_development_dependency "sqlite3", "~> 1.3"
23
- gem.add_development_dependency "database_cleaner", "~> 1.5"
24
- gem.add_development_dependency "rubocop", "~> 0.49"
25
- end
data/spec/dummy/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- require "active_record"
2
- require "bundler/setup"
3
-
4
- namespace :dummy do
5
- task :environment do
6
- require_relative "lib/dummy"
7
- end
8
-
9
- namespace :db do
10
- task load_config: :environment
11
- end
12
-
13
- load "active_record/railties/databases.rake"
14
- end
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
- has_many :posts
3
- end
@@ -1,6 +0,0 @@
1
- ---
2
- test:
3
- adapter: :sqlite3
4
- database: spec/dummy/db/test.sqlite3
5
- pool: 5
6
- timeout: 5000
@@ -1,10 +0,0 @@
1
- Dummy::Application.configure do |config|
2
- dummy = File.expand_path "../..", __FILE__
3
- database_yml = File.join(dummy, "config/database.yml")
4
-
5
- config.database_configuration = YAML.load File.read(database_yml)
6
- config.db_dir = File.join(dummy, "db")
7
- config.env = :test
8
- config.migrations_paths = [File.join(dummy, "db/migrate")]
9
- config.root = dummy
10
- end
@@ -1,5 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration[4.2]
2
- def change
3
- create_table :users
4
- end
5
- end
@@ -1,18 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema.define(version: 20170211104800) do
14
-
15
- create_table "users", force: :cascade do |t|
16
- end
17
-
18
- end
@@ -1,26 +0,0 @@
1
- module Dummy
2
- class Application
3
- class << self
4
- # Configuration settings wrapper for the
5
- # <tt>ActiveRecord::Tasks::DatabaseTasks</tt>.
6
- #
7
- # Establishes AR connection after configuration.
8
- #
9
- def configure
10
- yield tasks
11
- base.configurations = tasks.database_configuration
12
- base.establish_connection(tasks.env)
13
- end
14
-
15
- private
16
-
17
- def base
18
- @base ||= ActiveRecord::Base
19
- end
20
-
21
- def tasks
22
- @tasks ||= ActiveRecord::Tasks::DatabaseTasks
23
- end
24
- end
25
- end
26
- end
@@ -1,11 +0,0 @@
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
@@ -1,9 +0,0 @@
1
- require "active_record"
2
- require "bundler/setup"
3
-
4
- module Dummy
5
- require_relative "dummy/compatibility"
6
- require_relative "dummy/application"
7
- require_relative "../config/environment"
8
- require_relative "../app/models/user.rb"
9
- end
@@ -1,74 +0,0 @@
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
@@ -1,49 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "exceed_query_limit" do
4
- context "without restrictions" do
5
- it "works when no queries are made" do
6
- expect { User.new }.not_to exceed_query_limit(0)
7
- end
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
-
17
- it "works when actual number of queries is below the limit" do
18
- expect { User.create }.not_to exceed_query_limit(3)
19
- end
20
-
21
- it "works when actual number of queries exceeds the limit" do
22
- expect { User.create }.to exceed_query_limit(2)
23
- end
24
- end
25
-
26
- context "with a restriction" do
27
- it "works when no queries are made" do
28
- expect { User.new }.not_to exceed_query_limit(0).with(/INSERT/)
29
- end
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
-
41
- it "works when actual number of queries is below the limit" do
42
- expect { User.create }.not_to exceed_query_limit(1).with(/INSERT/)
43
- end
44
-
45
- it "works when actual number of queries exceeds the limit" do
46
- expect { User.create id: 3 }.to exceed_query_limit(0).with(/INSERT/)
47
- end
48
- end
49
- end
data/spec/spec_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- require "pry"
2
- require "rspec-sqlimit"
3
- require "database_cleaner"
4
-
5
- require_relative "dummy/lib/dummy"
6
-
7
- DatabaseCleaner.strategy = :truncation
8
-
9
- RSpec.configure do |config|
10
- config.order = :random
11
- config.filter_run focus: true
12
- config.run_all_when_everything_filtered = true
13
-
14
- # Prepare the Test namespace for constants defined in specs
15
- config.after(:each) { DatabaseCleaner.clean }
16
- end