Skip to content

Commit

Permalink
For rspec, clear in the around block instead of the before block
Browse files Browse the repository at this point in the history
Due to hook order we clear on around instead of before. This is
because if we clear in before, before runs AFTER around does and
therefore overrides any redis based changes we make in the around
hook.

If we clear in around, we can make changes to redis in BOTH the
around and before hooks!
  • Loading branch information
DropsOfSerenity committed Apr 1, 2024
1 parent f0abc00 commit b4959e3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fakeredis/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

RSpec.configure do |c|

c.before do
c.around do |ex|
Redis::Connection::Memory.reset_all_databases
Redis::Connection::Memory.reset_all_channels
ex.run
end

end

0 comments on commit b4959e3

Please sign in to comment.