testy_cookie 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/Rakefile +5 -2
- data/lib/testy_cookie/helper.rb +10 -2
- data/lib/testy_cookie/railtie.rb +4 -0
- data/lib/testy_cookie/version.rb +1 -1
- data/lib/testy_cookie.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9058e564410e428c62d5a15b0212da57b831a9dd3d23b9657199db26501290b2
|
4
|
+
data.tar.gz: '078ba0cb6cea4d6f4ea85215356c338ad8cddb6d5858e0d2b59e520fdde5af9d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da1663b2b3d7336b510dbbcd362477b7c6240d7a059f1f46e9996b1fbf2b732f44d2b20d0bcd3fbf5a000807ea1cab4c9fa269201e014f4f57100fa01d55a97
|
7
|
+
data.tar.gz: d8689d075e88e0289364564ad5eb84f0627d7cb8692c8dd67fd3bec8ec71b1656796431c3ab93a0189b0c4bc92d0e67fc95792bc877484ce2588d2aee2cfb2d2
|
data/README.md
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# TestyCookie
|
2
2
|
|
3
|
-
`TestyCookie` provides a helper
|
3
|
+
`TestyCookie` gem provides a helper for accessing plain, permanent, signed, and encrypted cookies in Rails controller, integration, and request tests.
|
4
4
|
|
5
5
|
## Why do I need a custom helper?
|
6
6
|
|
7
|
-
`ActionDispatch::IntegrationTest` based tests and RSpec request specs do not provide `encrypted`, `permanent` and `signed` stores
|
7
|
+
In Rails, `ActionDispatch::IntegrationTest` based tests and RSpec request specs do not provide `encrypted`, `permanent` and `signed` stores when the default `cookies` helper is used (it returns `Rack::Test::CookieJar` instance). `TestyCookie` resolves this limitation by initializing a proper `ActionDispatch::Cookies::CookieJar` instance which support these stores. The included helper also propagates any changes back to the original `Rack::Test::CookieJar` instance making them correctly read in application controllers.
|
8
8
|
|
9
|
-
In `ActionController::TestCase` tests and RSpec controller specs
|
9
|
+
In `ActionController::TestCase` tests and RSpec controller specs, `cookie_jar` serves as an alias for the default `cookies` method which returns `ActionDispatch::Cookies::CookieJar` instance correctly.
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
Inside your controller / integration / request test, call `
|
13
|
+
Inside your controller / integration / request test, call `cookie_jar` helper to access cookies:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
cookie_jar.encrypted[:key]
|
17
|
+
cookie_jar.signed[:key] = value
|
18
|
+
cookie_jar.signed.encrypted.permanent[:key] = value
|
19
19
|
```
|
20
20
|
|
21
21
|
## Installation
|
data/Rakefile
CHANGED
data/lib/testy_cookie/helper.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
module TestyCookie
|
2
2
|
module Helper
|
3
|
+
def cookie_jar
|
4
|
+
@_testy_cookie_cookie_jar ||= Jar.new(self)
|
5
|
+
@_testy_cookie_cookie_jar.cookies
|
6
|
+
end
|
7
|
+
|
3
8
|
def cookies_jar
|
4
|
-
|
5
|
-
|
9
|
+
DEPRECATOR.warn(<<~MSG.squish.freeze)
|
10
|
+
`cookies_jar` is deprecated and will be removed in the next major version. Please use `cookie_jar` instead.
|
11
|
+
MSG
|
12
|
+
|
13
|
+
cookie_jar
|
6
14
|
end
|
7
15
|
end
|
8
16
|
end
|
data/lib/testy_cookie/railtie.rb
CHANGED
data/lib/testy_cookie/version.rb
CHANGED
data/lib/testy_cookie.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testy_cookie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Mendelowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|