class Authlogic::TestCase::MockEncryptedCookieJar

Which ActionDispatch class is this a mock of? TODO: Document as with other mocks above.

Attributes

parent_jar[R]

Public Class Methods

decrypt(str) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 104
def self.decrypt(str)
  str.unpack("U*").map(&:pred).pack("U*")
end
encrypt(str) click to toggle source

simple caesar cipher for testing

# File lib/authlogic/test_case/mock_cookie_jar.rb, line 100
def self.encrypt(str)
  str.unpack("U*").map(&:succ).pack("U*")
end
new(parent_jar) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 81
def initialize(parent_jar)
  @parent_jar = parent_jar
  parent_jar.each { |k, v| self[k] = v }
end

Public Instance Methods

[](val) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 86
def [](val)
  encrypted_message = @parent_jar[val]
  if encrypted_message
    self.class.decrypt(encrypted_message)
  end
end
[]=(key, options) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 93
def []=(key, options)
  opt = cookie_options_to_hash(options)
  opt[:value] = self.class.encrypt(opt[:value])
  @parent_jar[key] = opt
end