diff --git a/.gitignore b/.gitignore index 7c0d341..b014a3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.bundle/ /.yardoc /Gemfile.lock +/gemfiles/*.gemfile.lock /_yardoc/ /coverage/ /doc/ @@ -8,3 +9,6 @@ /spec/reports/ /tmp/ /spec/dummy/db/*.sqlite3 +*.gem +.rspec_status +.idea/ diff --git a/.rubocop.yml b/.rubocop.yml index 6bcf4d5..78e3c8a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,10 +3,11 @@ AllCops: DisplayCopNames: true DisplayStyleGuide: true StyleGuideCopsOnly: true - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.6 Exclude: - spec/dummy/db/schema.rb - + - vendor/bundle/**/* + - gemfiles/vendor/**/* Metrics/ParameterLists: Max: 5 @@ -14,7 +15,7 @@ Style/Alias: Enabled: false Style/ClassAndModuleChildren: - EnforcedStyle: compact + Enabled: false Style/FileName: Enabled: false diff --git a/.travis.yml b/.travis.yml index e88c00b..6f2aff7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,27 @@ sudo: false language: ruby cache: bundler +before_install: + - gem update --system + - gem uninstall -v '>= 1' -i $(rvm gemdir)@global -ax bundler || true + - gem install bundler -v 1.3.0 + - gem update --system script: - bundle exec rake rvm: - - 2.3.0 + - 2.3 + - 2.6 - ruby-head gemfile: - gemfiles/rails_4.2.gemfile - gemfiles/rails_5.0.gemfile - gemfiles/rails_5.1.gemfile -before_install: gem install bundler + - gemfiles/rails_6.0.gemfile matrix: + exclude: + - rvm: 2.3 + gemfile: gemfiles/rails_6.0.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_4.2.gemfile allow_failures: - rvm: ruby-head diff --git a/Appraisals b/Appraisals index 25bd5ce..f2e010b 100644 --- a/Appraisals +++ b/Appraisals @@ -1,16 +1,19 @@ - -appraise 'rails-4.2' do - gem 'rails', '~> 4.2.0' +appraise "rails-4.2" do + gem "rails", "~> 4.2.0" + gem "sqlite3", "~> 1.3.0" end -appraise 'rails-5.0' do - gem 'rails', '~> 5.0.0' +appraise "rails-5.0" do + gem "rails", "~> 5.0.0" + gem "sqlite3", "~> 1.3.0" end -appraise 'rails-5.1' do - gem 'rails', '~> 5.1.0' +appraise "rails-5.1" do + gem "rails", "~> 5.1.0" + gem "sqlite3", "~> 1.3.0" end -appraise 'rails-6.0' do - gem 'rails', '~> 6.0.0' +appraise "rails-6.0" do + gem "rails", "~> 6.0.0" + gem "sqlite3", "~> 1.4" end diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f9b7cb..5185e15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.0.3] - [2019-10-02] + +### Added +- Support of Rails 6 (@quikly) +- Cached queries are ignored (@tyok) + ## [0.0.2] - [2017-05-17] ### Added @@ -16,3 +22,4 @@ This is a first public release (@nepalez) [Unreleased]: https://github.com/tram-rb/tram-policy [0.0.1]: https://github.com/nepalez/rspec-sqlimit/releases/tag/v0.0.1 [0.0.2]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.1...v0.0.2 +[0.0.3]: https://github.com/nepalez/rspec-sqlimit/compare/v0.0.2...v0.0.3 diff --git a/Gemfile b/Gemfile index a8673f5..cfd5a31 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,9 @@ source "https://rubygems.org" # Specify your gem's dependencies in tram-form.gemspec gemspec +gem "rails" +gem "sqlite3" + group :test, :development do gem "pry" gem "pry-byebug" diff --git a/Rakefile b/Rakefile index a5a139b..c507ff2 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,9 @@ load "spec/dummy/Rakefile" # Declares gem's own tasks. desc "Runs test suite over all rails versions." task :default do - if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/ + if ENV["BUNDLE_GEMFILE"] =~ /gemfiles/ + Rake::Task["dummy:db:create"].reenable + Rake::Task["dummy:db:migrate"].reenable Rake::Task[:spec].invoke else Rake::Task[:appraise].invoke @@ -17,10 +19,11 @@ task :default do end desc "Runs test suite." -task spec: %w(dummy:db:create dummy:db:migrate) do +task default: %w[dummy:db:create dummy:db:migrate] do exec "bundle exec rspec spec" + exec "bundle exec rubocop" end task :appraise do - exec 'appraisal install && appraisal rake' + exec "appraisal install && appraisal rake" end diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index e016f2e..38b6ff4 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "rails", "~> 4.2.0" +gem "sqlite3", "~> 1.3.0" group :test, :development do gem "pry" diff --git a/gemfiles/rails_4.2.gemfile.lock b/gemfiles/rails_4.2.gemfile.lock deleted file mode 100644 index 961c6f3..0000000 --- a/gemfiles/rails_4.2.gemfile.lock +++ /dev/null @@ -1,164 +0,0 @@ -PATH - remote: .. - specs: - rspec-sqlimit (0.0.2) - rails (> 4.2, < 7.0) - rspec (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.9) - actionview (= 4.2.9) - activesupport (= 4.2.9) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.9) - activesupport (= 4.2.9) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.9) - activesupport (= 4.2.9) - globalid (>= 0.3.0) - activemodel (4.2.9) - activesupport (= 4.2.9) - builder (~> 3.1) - activerecord (4.2.9) - activemodel (= 4.2.9) - activesupport (= 4.2.9) - arel (~> 6.0) - activesupport (4.2.9) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - appraisal (2.2.0) - bundler - rake - thor (>= 0.14.0) - arel (6.0.4) - ast (2.4.0) - builder (3.2.3) - byebug (10.0.0) - coderay (1.1.2) - concurrent-ruby (1.0.5) - crass (1.0.3) - database_cleaner (1.6.2) - diff-lcs (1.3) - erubis (2.7.0) - globalid (0.4.1) - activesupport (>= 4.2.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - loofah (2.2.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.0) - mini_mime (>= 0.1.1) - method_source (0.9.0) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - parallel (1.12.1) - parser (2.5.0.3) - ast (~> 2.4.0) - powerpack (0.1.1) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - rack (1.6.8) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.9) - actionmailer (= 4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) - activemodel (= 4.2.9) - activerecord (= 4.2.9) - activesupport (= 4.2.9) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.9) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (4.2.9) - actionpack (= 4.2.9) - activesupport (= 4.2.9) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (3.0.0) - rake (12.3.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - rubocop (0.53.0) - parallel (~> 1.10) - parser (>= 2.5) - powerpack (~> 0.1) - rainbow (>= 2.2.2, < 4.0) - ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - sprockets (3.7.1) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.3.13) - thor (0.20.0) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.3.0) - -PLATFORMS - ruby - -DEPENDENCIES - appraisal (~> 2.2) - database_cleaner (~> 1.5) - pry - pry-byebug - rails (~> 4.2.0) - rake (> 10.0) - rspec (~> 3.0) - rspec-sqlimit! - rubocop (~> 0.44) - sqlite3 (~> 1.3) - -BUNDLED WITH - 1.16.1 diff --git a/gemfiles/rails_5.0.gemfile b/gemfiles/rails_5.0.gemfile index a71a0cd..deaf249 100644 --- a/gemfiles/rails_5.0.gemfile +++ b/gemfiles/rails_5.0.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "rails", "~> 5.0.0" +gem "sqlite3", "~> 1.3.0" group :test, :development do gem "pry" diff --git a/gemfiles/rails_5.0.gemfile.lock b/gemfiles/rails_5.0.gemfile.lock deleted file mode 100644 index 6ea9afc..0000000 --- a/gemfiles/rails_5.0.gemfile.lock +++ /dev/null @@ -1,170 +0,0 @@ -PATH - remote: .. - specs: - rspec-sqlimit (0.0.2) - rails (> 4.2, < 7.0) - rspec (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (5.0.6) - actionpack (= 5.0.6) - nio4r (>= 1.2, < 3.0) - websocket-driver (~> 0.6.1) - actionmailer (5.0.6) - actionpack (= 5.0.6) - actionview (= 5.0.6) - activejob (= 5.0.6) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.0.6) - actionview (= 5.0.6) - activesupport (= 5.0.6) - rack (~> 2.0) - rack-test (~> 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.6) - activesupport (= 5.0.6) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.0.6) - activesupport (= 5.0.6) - globalid (>= 0.3.6) - activemodel (5.0.6) - activesupport (= 5.0.6) - activerecord (5.0.6) - activemodel (= 5.0.6) - activesupport (= 5.0.6) - arel (~> 7.0) - activesupport (5.0.6) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) - minitest (~> 5.1) - tzinfo (~> 1.1) - appraisal (2.2.0) - bundler - rake - thor (>= 0.14.0) - arel (7.1.4) - ast (2.4.0) - builder (3.2.3) - byebug (10.0.0) - coderay (1.1.2) - concurrent-ruby (1.0.5) - crass (1.0.3) - database_cleaner (1.6.2) - diff-lcs (1.3) - erubis (2.7.0) - globalid (0.4.1) - activesupport (>= 4.2.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - loofah (2.2.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.0) - mini_mime (>= 0.1.1) - method_source (0.9.0) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - nio4r (2.2.0) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - parallel (1.12.1) - parser (2.5.0.3) - ast (~> 2.4.0) - powerpack (0.1.1) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - rack (2.0.4) - rack-test (0.6.3) - rack (>= 1.0) - rails (5.0.6) - actioncable (= 5.0.6) - actionmailer (= 5.0.6) - actionpack (= 5.0.6) - actionview (= 5.0.6) - activejob (= 5.0.6) - activemodel (= 5.0.6) - activerecord (= 5.0.6) - activesupport (= 5.0.6) - bundler (>= 1.3.0) - railties (= 5.0.6) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (5.0.6) - actionpack (= 5.0.6) - activesupport (= 5.0.6) - method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (3.0.0) - rake (12.3.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - rubocop (0.53.0) - parallel (~> 1.10) - parser (>= 2.5) - powerpack (~> 0.1) - rainbow (>= 2.2.2, < 4.0) - ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - sprockets (3.7.1) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.3.13) - thor (0.20.0) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.3.0) - websocket-driver (0.6.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) - -PLATFORMS - ruby - -DEPENDENCIES - appraisal (~> 2.2) - database_cleaner (~> 1.5) - pry - pry-byebug - rails (~> 5.0.0) - rake (> 10.0) - rspec (~> 3.0) - rspec-sqlimit! - rubocop (~> 0.44) - sqlite3 (~> 1.3) - -BUNDLED WITH - 1.16.1 diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile index 191fd5a..2ae2aa0 100644 --- a/gemfiles/rails_5.1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "rails", "~> 5.1.0" +gem "sqlite3", "~> 1.3.0" group :test, :development do gem "pry" diff --git a/gemfiles/rails_5.1.gemfile.lock b/gemfiles/rails_5.1.gemfile.lock deleted file mode 100644 index 482d6bb..0000000 --- a/gemfiles/rails_5.1.gemfile.lock +++ /dev/null @@ -1,170 +0,0 @@ -PATH - remote: .. - specs: - rspec-sqlimit (0.0.2) - rails (> 4.2, < 7.0) - rspec (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (5.1.5) - actionpack (= 5.1.5) - nio4r (~> 2.0) - websocket-driver (~> 0.6.1) - actionmailer (5.1.5) - actionpack (= 5.1.5) - actionview (= 5.1.5) - activejob (= 5.1.5) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.1.5) - actionview (= 5.1.5) - activesupport (= 5.1.5) - rack (~> 2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.5) - activesupport (= 5.1.5) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.5) - activesupport (= 5.1.5) - globalid (>= 0.3.6) - activemodel (5.1.5) - activesupport (= 5.1.5) - activerecord (5.1.5) - activemodel (= 5.1.5) - activesupport (= 5.1.5) - arel (~> 8.0) - activesupport (5.1.5) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) - minitest (~> 5.1) - tzinfo (~> 1.1) - appraisal (2.2.0) - bundler - rake - thor (>= 0.14.0) - arel (8.0.0) - ast (2.4.0) - builder (3.2.3) - byebug (10.0.0) - coderay (1.1.2) - concurrent-ruby (1.0.5) - crass (1.0.3) - database_cleaner (1.6.2) - diff-lcs (1.3) - erubi (1.7.1) - globalid (0.4.1) - activesupport (>= 4.2.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - loofah (2.2.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.0) - mini_mime (>= 0.1.1) - method_source (0.9.0) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - nio4r (2.2.0) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - parallel (1.12.1) - parser (2.5.0.3) - ast (~> 2.4.0) - powerpack (0.1.1) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - rack (2.0.4) - rack-test (0.8.3) - rack (>= 1.0, < 3) - rails (5.1.5) - actioncable (= 5.1.5) - actionmailer (= 5.1.5) - actionpack (= 5.1.5) - actionview (= 5.1.5) - activejob (= 5.1.5) - activemodel (= 5.1.5) - activerecord (= 5.1.5) - activesupport (= 5.1.5) - bundler (>= 1.3.0) - railties (= 5.1.5) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (5.1.5) - actionpack (= 5.1.5) - activesupport (= 5.1.5) - method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (3.0.0) - rake (12.3.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - rubocop (0.53.0) - parallel (~> 1.10) - parser (>= 2.5) - powerpack (~> 0.1) - rainbow (>= 2.2.2, < 4.0) - ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - sprockets (3.7.1) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.3.13) - thor (0.20.0) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.3.0) - websocket-driver (0.6.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) - -PLATFORMS - ruby - -DEPENDENCIES - appraisal (~> 2.2) - database_cleaner (~> 1.5) - pry - pry-byebug - rails (~> 5.1.0) - rake (> 10.0) - rspec (~> 3.0) - rspec-sqlimit! - rubocop (~> 0.44) - sqlite3 (~> 1.3) - -BUNDLED WITH - 1.16.1 diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index c940327..23de545 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "rails", "~> 6.0.0" +gem "sqlite3", "~> 1.4" group :test, :development do gem "pry" diff --git a/gemfiles/rails_6.0.gemfile.lock b/gemfiles/rails_6.0.gemfile.lock deleted file mode 100644 index 0636563..0000000 --- a/gemfiles/rails_6.0.gemfile.lock +++ /dev/null @@ -1,194 +0,0 @@ -PATH - remote: .. - specs: - rspec-sqlimit (0.0.2) - rails (> 4.2, < 7.0) - rspec (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (6.0.0) - actionpack (= 6.0.0) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - mail (>= 2.7.1) - actionmailer (6.0.0) - actionpack (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.0) - actionpack (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - nokogiri (>= 1.8.5) - actionview (6.0.0) - activesupport (= 6.0.0) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.0) - activesupport (= 6.0.0) - globalid (>= 0.3.6) - activemodel (6.0.0) - activesupport (= 6.0.0) - activerecord (6.0.0) - activemodel (= 6.0.0) - activesupport (= 6.0.0) - activestorage (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - marcel (~> 0.3.1) - activesupport (6.0.0) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) - appraisal (2.2.0) - bundler - rake - thor (>= 0.14.0) - ast (2.4.0) - builder (3.2.3) - byebug (11.0.1) - coderay (1.1.2) - concurrent-ruby (1.1.5) - crass (1.0.4) - database_cleaner (1.7.0) - diff-lcs (1.3) - erubi (1.8.0) - globalid (0.4.2) - activesupport (>= 4.2.0) - i18n (1.6.0) - concurrent-ruby (~> 1.0) - jaro_winkler (1.5.3) - loofah (2.2.3) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) - mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.3) - mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.11.3) - nio4r (2.4.0) - nokogiri (1.10.4) - mini_portile2 (~> 2.4.0) - parallel (1.17.0) - parser (2.6.3.0) - ast (~> 2.4.0) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.7.0) - byebug (~> 11.0) - pry (~> 0.10) - rack (2.0.7) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.0.0) - actioncable (= 6.0.0) - actionmailbox (= 6.0.0) - actionmailer (= 6.0.0) - actionpack (= 6.0.0) - actiontext (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) - activemodel (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - bundler (>= 1.3.0) - railties (= 6.0.0) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.2.0) - loofah (~> 2.2, >= 2.2.2) - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) - method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) - rainbow (3.0.0) - rake (12.3.3) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.2) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.4) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.2) - rubocop (0.74.0) - jaro_winkler (~> 1.5.1) - parallel (~> 1.10) - parser (>= 2.6) - rainbow (>= 2.2.2, < 4.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - ruby-progressbar (1.10.1) - sprockets (3.7.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.4.1) - thor (0.20.3) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.6.0) - websocket-driver (0.7.1) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.4) - zeitwerk (2.1.9) - -PLATFORMS - ruby - -DEPENDENCIES - appraisal (~> 2.2) - database_cleaner (~> 1.5) - pry - pry-byebug - rails (~> 6.0.0) - rake (> 10.0) - rspec (~> 3.0) - rspec-sqlimit! - rubocop (~> 0.44) - sqlite3 (~> 1.3) - -BUNDLED WITH - 1.15.2 diff --git a/lib/rspec/sqlimit/counter.rb b/lib/rspec/sqlimit/counter.rb index 515d2cf..cf29933 100644 --- a/lib/rspec/sqlimit/counter.rb +++ b/lib/rspec/sqlimit/counter.rb @@ -30,7 +30,7 @@ def count def callback @callback ||= lambda do |_name, start, finish, _message_id, values| - return if %w(CACHE SCHEMA).include? values[:name] + return if %w[CACHE SCHEMA].include? values[:name] return if cached_query?(values) queries << { sql: values[:sql], @@ -41,7 +41,9 @@ def callback end def type_cast(binds) - binds.map { |column, value| ActiveRecord::Base.connection.type_cast(value, column) } + binds.map do |column, value| + ActiveRecord::Base.connection.type_cast(value, column) + end end def cached_query?(values) diff --git a/lib/rspec/sqlimit/reporter.rb b/lib/rspec/sqlimit/reporter.rb index a0141c0..fda7dab 100644 --- a/lib/rspec/sqlimit/reporter.rb +++ b/lib/rspec/sqlimit/reporter.rb @@ -28,8 +28,9 @@ def lines def line(query, index) prefix = (matcher && query[:sql] =~ matcher) ? "->" : " " - binds = query[:binds].any? ? "; #{query[:binds]} " : '' - "#{prefix} #{index + 1}) #{query[:sql]}#{binds} (#{query[:duration].round(3)} ms)" + binds = query[:binds].any? ? "; #{query[:binds]} " : "" + "#{prefix} #{index + 1}) #{query[:sql]}#{binds}" \ + " (#{query[:duration].round(3)} ms)" end end end diff --git a/rspec-sqlimit.gemspec b/rspec-sqlimit.gemspec index 3373408..da89c36 100644 --- a/rspec-sqlimit.gemspec +++ b/rspec-sqlimit.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |gem| gem.name = "rspec-sqlimit" - gem.version = "0.0.2" + gem.version = "0.0.3" gem.author = "Andrew Kozin (nepalez)" gem.email = "andrew.kozin@gmail.com" gem.homepage = "https://github.com/nepalez/rspec-sqlimit" @@ -21,5 +21,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency "rake", "> 10.0" gem.add_development_dependency "sqlite3", "~> 1.3" gem.add_development_dependency "database_cleaner", "~> 1.5" - gem.add_development_dependency "rubocop", "~> 0.44" + gem.add_development_dependency "rubocop", "~> 0.49" end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index c10f262..d455c70 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170211104800) do +ActiveRecord::Schema.define(version: 2017_02_11_104800) do create_table "users", force: :cascade do |t| end diff --git a/spec/dummy/lib/dummy/compatibility.rb b/spec/dummy/lib/dummy/compatibility.rb index 118d10c..6e961f5 100644 --- a/spec/dummy/lib/dummy/compatibility.rb +++ b/spec/dummy/lib/dummy/compatibility.rb @@ -3,7 +3,7 @@ unless ActiveRecord::Migration.respond_to?(:[]) class ActiveRecord::Migration class << self - def [](version) + def [](_version) self end end diff --git a/spec/rspec/sqlimit/reporter_spec.rb b/spec/rspec/sqlimit/reporter_spec.rb index ca0f4e2..84ddbb1 100644 --- a/spec/rspec/sqlimit/reporter_spec.rb +++ b/spec/rspec/sqlimit/reporter_spec.rb @@ -3,8 +3,8 @@ describe RSpec::SQLimit::Reporter do subject { described_class.new(counter) } - context 'no params were passed to the query' do - let(:counter) { RSpec::SQLimit::Counter[/CREATE/, Proc.new{ User.create }] } + context "no params were passed to the query" do + let(:counter) { RSpec::SQLimit::Counter[/CREATE/, proc{ User.create }] } it "doesn't print binds" do # INSERT INTO "users" DEFAULT VALUES (0.284 ms) @@ -12,9 +12,11 @@ end end - context 'query contains params' do - context 'nil was passed as param' do - let(:counter) { RSpec::SQLimit::Counter[/CREATE/, Proc.new{ User.create(id: nil) }] } + context "query contains params" do + context "nil was passed as param" do + let(:counter) do + RSpec::SQLimit::Counter[/CREATE/, proc { User.create(id: nil) }] + end it "doesn't print binds" do # INSERT INTO "users" DEFAULT VALUES (0.284 ms) @@ -22,29 +24,39 @@ end end - context 'single param was passed' do - let(:counter) { RSpec::SQLimit::Counter[/CREATE/, Proc.new{ User.create(id: 1) }] } + context "single param was passed" do + let(:counter) do + RSpec::SQLimit::Counter[/CREATE/, proc { User.create(id: 1) }] + end - it 'prints param as an array with one element' do + it "prints param as an array with one element" do # INSERT INTO "users" ("id") VALUES (?); [1] (0.234 ms) expect(subject.call).to include("VALUES (?); [1]") end end - context 'array was passed as a param' do - let(:counter) { RSpec::SQLimit::Counter[/SELECT/, Proc.new{ User.where(id: [1, 2, 3]).to_a }] } + context "array was passed as a param" do + let(:counter) do + RSpec::SQLimit::Counter[ + /SELECT/, proc { User.where(id: [1, 2, 3]).to_a } + ] + end - it 'prints all params' do + it "prints all params" do + # rubocop: disable Metrics/LineLength # SELECT "users".* FROM "users" WHERE "users"."id" IN (1, 2, 3) (0.17 ms)) # Rails >= 6: # SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?, ?); [1, 2, 3] (0.121 ms) + # rubocop: enable Metrics/LineLength expect(subject.call).to include("1, 2, 3") end end end - context 'activerecord query caching was enabled' do - let(:counter) { RSpec::SQLimit::Counter[nil, Proc.new{ queries }] } + context "activerecord query caching was enabled" do + let(:counter) do + RSpec::SQLimit::Counter[/SELECT "users"/, proc { queries }] + end let(:queries) do User.cache do @@ -55,7 +67,7 @@ end end - it 'ignores cached queries' do + it "ignores cached queries" do expect(subject.call).to include("2 queries were invoked") end end diff --git a/spec/rspec/sqlimit_spec.rb b/spec/rspec/sqlimit_spec.rb index 219a9bd..ece0035 100644 --- a/spec/rspec/sqlimit_spec.rb +++ b/spec/rspec/sqlimit_spec.rb @@ -33,7 +33,9 @@ end it "works when array is used as a restriction" do - expect { (User.where id: [1, 2, 3]).to_a }.to exceed_query_limit(0).with(/SELECT/) + expect { (User.where id: [1, 2, 3]).to_a } + .to exceed_query_limit(0) + .with(/SELECT/) end it "works when actual number of queries is below the limit" do