Skip to content

Commit

Permalink
Avoid undefined instance variable warning on Ruby 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jun 22, 2022
1 parent 70624da commit 9589190
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rack/test/methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def current_session
# Create a new session (or reuse an existing session with the given name),
# and make it the current session for the given block.
def with_session(name)
session = @_rack_test_current_session
session = _rack_test_current_session
yield(@_rack_test_current_session = rack_test_session(name))
ensure
@_rack_test_current_session = session
Expand Down Expand Up @@ -86,6 +86,10 @@ def digest_authorize(username, password) # :nodoc:
:last_response,
:last_request,
)

# Private accessor to avoid uninitialized instance variable warning in Ruby 2.*
attr_accessor :_rack_test_current_session
private :_rack_test_current_session
end
end
end

0 comments on commit 9589190

Please sign in to comment.