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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 384c7f2580df5b1770079715553e53e3b70b086b926ffd041a048b3d29b4ba86
4
- data.tar.gz: 63ae8ea44b06a00779f96fe6e8a90bb10296efdde57f54501d1d24d08c543945
3
+ metadata.gz: 9058e564410e428c62d5a15b0212da57b831a9dd3d23b9657199db26501290b2
4
+ data.tar.gz: '078ba0cb6cea4d6f4ea85215356c338ad8cddb6d5858e0d2b59e520fdde5af9d'
5
5
  SHA512:
6
- metadata.gz: b5357627e4477c395d3373cfae8b8bdd39c6c94b26e7d6c10867acff294bf0f586fef2d40319980d3e8cd9a8ed78005eb19fd2a7b48336903b524e7bb638aadd
7
- data.tar.gz: 690bb781ff91473eb1b8b96a7d7e28a1208472acd775650477066921d6317c6b8fa20c3575b73e4c4ecfcf42c9382d936d83ddf33f3054af99d7b7547f902864
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 to access plain, permanent, signed and encrypted cookies consistently in Rails controller / integration / request tests.
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 on the default `cookies` jar. `TestyCookie` workaround it by initializing `ActionDispatch::Cookies::CookieJar` instance and propagating all changes back to the original `cookies` object (`Rack::Test::CookieJar` instance).
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 (which are going to be deprecated), it's just an alias for the default `cookies` method.
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 `cookies_jar` helper to access cookies jar:
13
+ Inside your controller / integration / request test, call `cookie_jar` helper to access cookies:
14
14
 
15
15
  ```ruby
16
- cookies_jar.encrypted[:key]
17
- cookies_jar.signed[:key] = value
18
- cookies_jar.signed.encrypted.permanent[:key] = value
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
@@ -10,6 +10,9 @@ task :test_dummy do
10
10
  end
11
11
  end
12
12
 
13
- Rake::Task[:test].enhance [:test_dummy]
13
+ task :test_all do
14
+ Rake::Task["test"].invoke
15
+ Rake::Task[:test_dummy].invoke
16
+ end
14
17
 
15
- task default: :test
18
+ task default: :test_all
@@ -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
- @cookies_jar ||= Jar.new(self)
5
- @cookies_jar.cookies
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
@@ -10,5 +10,9 @@ module TestyCookie
10
10
  end
11
11
  end
12
12
  end
13
+
14
+ initializer "testy_cookie.deprecator" do |app|
15
+ app.deprecators[:testy_cookie] = DEPRECATOR
16
+ end
13
17
  end
14
18
  end
@@ -1,3 +1,3 @@
1
1
  module TestyCookie
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/testy_cookie.rb CHANGED
@@ -5,4 +5,5 @@ require "testy_cookie/railtie"
5
5
  require "testy_cookie/version"
6
6
 
7
7
  module TestyCookie
8
+ DEPRECATOR = ActiveSupport::Deprecation.new("2.0", "TestyCookie")
8
9
  end
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.0.0
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-02-22 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails