Class: Authentication::Logic::TestCase::MockEncryptedCookieJar
- Inherits:
-
MockCookieJar
- Object
- Hash
- MockCookieJar
- Authentication::Logic::TestCase::MockEncryptedCookieJar
- Defined in:
- lib/auth/logic/test_case/mock_cookie_jar.rb
Overview
Which ActionDispatch class is this a mock of? TODO: Document as with other mocks above.
Instance Attribute Summary collapse
-
#parent_jar ⇒ Object
readonly
helper for testing.
Attributes inherited from MockCookieJar
Class Method Summary collapse
- .decrypt(str) ⇒ Object
-
.encrypt(str) ⇒ Object
simple caesar cipher for testing.
Instance Method Summary collapse
- #[](val) ⇒ Object
- #[]=(key, options) ⇒ Object
-
#initialize(parent_jar) ⇒ MockEncryptedCookieJar
constructor
A new instance of MockEncryptedCookieJar.
Methods inherited from MockCookieJar
Constructor Details
#initialize(parent_jar) ⇒ MockEncryptedCookieJar
Returns a new instance of MockEncryptedCookieJar.
83 84 85 86 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 83 def initialize(parent_jar) @parent_jar = parent_jar parent_jar.each { |k, v| self[k] = v } end |
Instance Attribute Details
#parent_jar ⇒ Object (readonly)
helper for testing
81 82 83 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 81 def parent_jar @parent_jar end |
Class Method Details
.decrypt(str) ⇒ Object
106 107 108 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 106 def self.decrypt(str) str.unpack("U*").map(&:pred).pack("U*") end |
.encrypt(str) ⇒ Object
simple caesar cipher for testing
102 103 104 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 102 def self.encrypt(str) str.unpack("U*").map(&:succ).pack("U*") end |
Instance Method Details
#[](val) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 88 def [](val) = @parent_jar[val] return unless self.class.decrypt() end |
#[]=(key, options) ⇒ Object
95 96 97 98 99 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 95 def []=(key, ) opt = () opt[:value] = self.class.encrypt(opt[:value]) @parent_jar[key] = opt end |