Skip to content

Commit

Permalink
Merge pull request #60 from khiav223577/fix/test_cases
Browse files Browse the repository at this point in the history
Drop the support of ruby 2.2
  • Loading branch information
khiav223577 committed Sep 2, 2023
2 parents 2d02333 + f947b81 commit 8009812
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
ruby:
- 2.2
- 2.3
- 2.6
- 2.7
gemfile:
Expand All @@ -38,7 +38,7 @@ jobs:
- gemfile: 4.2.gemfile
ruby: 2.7
- gemfile: 6.0.gemfile
ruby: 2.2
ruby: 2.3
env:
BUNDLE_GEMFILE: "gemfiles/${{ matrix.gemfile }}"

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ ActiveModelCachers:

- Uses multiple levels of cache ([Multi-level Cache](#multi-level-cache))
- Does not pollute the original ActiveModel API
- Supports ActiveRecord 3.2, 4.2, 5.2, 6.0.
- Has high test coverage

## Supports

- Ruby 2.3 ~ 2.7
- Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0

## Table of contents

1. [Compare with identity_cache](#compare-with-identity_cache)
Expand Down
7 changes: 5 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ def user_destroy_dependents_count
def assert_queries(expected_count, event_key = 'sql.active_record')
sqls = []
subscriber = ActiveSupport::Notifications.subscribe(event_key) do |_, _, _, _, payload|
sqls << " ● #{payload[:sql]}" if payload[:sql] !~ /\A(?:BEGIN TRANSACTION|COMMIT TRANSACTION|BEGIN|COMMIT|PRAGMA table_info)\z/i
next if payload[:sql].start_with?('PRAGMA table_info')
next if payload[:sql] =~ /\A(?:BEGIN TRANSACTION|COMMIT TRANSACTION|BEGIN|COMMIT)\z/i

sqls << " ● #{payload[:sql]}"
end
yield
if expected_count != sqls.size # show all sql queries if query count doesn't equal to expected count.
assert_equal "expect #{expected_count} queries, but have #{sqls.size}", "\n#{sqls.join("\n").gsub('"', "'")}\n"
assert_equal "expect #{expected_count} queries, but have #{sqls.size}", "\n#{sqls.join("\n").tr('"', "'")}\n"
end
assert_equal expected_count, sqls.size
ensure
Expand Down

0 comments on commit 8009812

Please sign in to comment.