diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c866b1..c5cc233 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['3.1', '3.2'] + ruby-version: ["3.2", "3.3", "3.4", "4.0"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} diff --git a/Gemfile.lock b/Gemfile.lock index 814a68c..7acab81 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,84 +1,93 @@ PATH remote: . specs: - rspec-sql (0.0.3) + rspec-sql (0.0.4) activesupport rspec GEM remote: https://rubygems.org/ specs: - activemodel (7.1.3.2) - activesupport (= 7.1.3.2) - activerecord (7.1.3.2) - activemodel (= 7.1.3.2) - activesupport (= 7.1.3.2) + activemodel (8.1.3) + activesupport (= 8.1.3) + activerecord (8.1.3) + activemodel (= 8.1.3) + activesupport (= 8.1.3) timeout (>= 0.4.0) - activesupport (7.1.3.2) + activesupport (8.1.3) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - ast (2.4.2) - base64 (0.2.0) - bigdecimal (3.1.6) - concurrent-ruby (1.2.3) - connection_pool (2.4.1) - diff-lcs (1.5.1) - drb (2.2.0) - ruby2_keywords - i18n (1.14.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + ast (2.4.3) + base64 (0.3.0) + bigdecimal (4.1.2) + concurrent-ruby (1.3.6) + connection_pool (3.0.2) + diff-lcs (1.6.2) + drb (2.2.3) + i18n (1.14.8) concurrent-ruby (~> 1.0) - json (2.7.2) - language_server-protocol (3.17.0.3) - minitest (5.22.2) - mutex_m (0.2.0) - parallel (1.24.0) - parser (3.3.0.5) + json (2.19.5) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) + parallel (1.28.0) + parser (3.3.11.1) ast (~> 2.4.1) racc - racc (1.7.3) + prism (1.9.0) + racc (1.8.1) rainbow (3.1.1) - regexp_parser (2.9.0) - rexml (3.2.6) - rspec (3.13.0) + regexp_parser (2.12.0) + rspec (3.13.2) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.6) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.8) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-support (3.13.0) - rubocop (1.63.1) + rspec-support (3.13.7) + rubocop (1.86.2) json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.1) + parser (>= 3.3.7.2) + prism (~> 1.7) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) - sqlite3 (1.7.2-x86_64-linux) - timeout (0.4.1) + securerandom (0.4.1) + sqlite3 (2.9.4-x86_64-linux-gnu) + timeout (0.6.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + uri (1.1.1) PLATFORMS x86_64-linux diff --git a/rspec-sql.gemspec b/rspec-sql.gemspec index bc646c3..4646610 100644 --- a/rspec-sql.gemspec +++ b/rspec-sql.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = "rspec-sql" - s.version = "0.0.3" + s.version = "0.0.4" s.summary = "RSpec::Sql matcher" s.description = "RSpec matcher for database queries." s.authors = ["Maikel Linke", "Open Food Network contributors"] @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.files = Dir["lib/**/*.rb"] s.homepage = "https://github.com/openfoodfoundation/rspec-sql" s.license = "AGPL-3.0-or-later" - s.required_ruby_version = ">= 3.1", "< 4" + s.required_ruby_version = ">= 3.2" s.metadata = { "changelog_uri" => @@ -20,6 +20,6 @@ Gem::Specification.new do |s| "rubygems_mfa_required" => "true", } - s.add_runtime_dependency "activesupport" - s.add_runtime_dependency "rspec" + s.add_dependency "activesupport" + s.add_dependency "rspec" end diff --git a/spec/lib/rspec/sql_spec.rb b/spec/lib/rspec/sql_spec.rb index 5ea1ffc..b5af0fd 100644 --- a/spec/lib/rspec/sql_spec.rb +++ b/spec/lib/rspec/sql_spec.rb @@ -133,6 +133,8 @@ end it "prints user-friendly message expecting summary" do + skip "testing old ruby" unless RUBY_VERSION < "3.4" + message = error_message do expect { User.last }.to query_database( update: { user: 1 } @@ -156,6 +158,31 @@ TXT end + it "prints user-friendly message expecting summary" do + skip "testing new ruby" if RUBY_VERSION < "3.4" + + message = error_message do + expect { User.last }.to query_database( + update: { user: 1 } + ) + end + + expect(message).to eq <<~TXT + Expected database queries: {update: {user: 1}} + Actual database queries: {select: {users: 1}} + + Diff: + @@ -1 +1 @@ + -:update => {user: 1}, + +:select => {users: 1}, + + + Full query log: + + User Load SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT ? + TXT + end + def error_message yield rescue RSpec::Expectations::ExpectationNotMetError => e