Skip to content

Commit

Permalink
Optional Rails.cache reset before each test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jul 25, 2023
1 parent b237bc8 commit 8ad0070
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
6 changes: 0 additions & 6 deletions spec/acceptance/cache_store_config_with_rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
Rack::Attack.throttle("by ip", limit: 1, period: 60) do |request|
request.ip
end

Rack::Attack.instance_variable_set(:@cache, nil)
end

after do
Rack::Attack.instance_variable_set(:@cache, nil)
end

it "fails when Rails.cache is not set" do
Expand Down
11 changes: 5 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require "minitest/autorun"
require "minitest/pride"
require "rack/test"
# require "rails"
require "active_support"
require "rack/attack"

Expand All @@ -28,11 +27,11 @@ def safe_require(name)
class MiniTest::Spec
include Rack::Test::Methods

# if Object.const_defined?(:Rails)
# before do
# Rails.cache = nil
# end
# end
before do
if Object.const_defined?(:Rails)
Rails.cache.clear
end
end

after do
Rack::Attack.clear_configuration
Expand Down

0 comments on commit 8ad0070

Please sign in to comment.