request_migrations 1.0.2 → 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: 1575eecb9ad23c9dae9534b03a31acbcef8c6ed7bf46f4ffca1748ef21fcead4
4
- data.tar.gz: 141dbbf4576e8b2da641ab32bd377173bbe61717d330c741c0b10c5cf9eff854
3
+ metadata.gz: c2224934d0be51149ebf90a756ae9cfd9172ee83310609c9cfc94c49c4c75166
4
+ data.tar.gz: 3de2f808de4c02d7de89ec9baae0b5d68cadab94d8118e13688a941de791d3cf
5
5
  SHA512:
6
- metadata.gz: 119241518c4d8a9a954bd4918a6e2edbc0338938c7173953a406821f34f0f4da735e7819b7cc0e929be45c78a7da88f035f1456d5b98d53d6cb00b0fca1c8362
7
- data.tar.gz: 5afffe316b08692daeaf2366fab161f23794b80326112a2b4c4ece1a13f0d40f8d61423aa81d4bf28c62274acf8a33dd63c01214295524cd7691c42203a71575
6
+ metadata.gz: 944f3e23fe55b3d9eb56cdf0491871bfecea72a5c9a57b15f8827152b7cf5a21ab0e0ac6c1f254a9afabe4fc980562b864e96a2868ec864a314d41876e1af987
7
+ data.tar.gz: e3fa22992ac3aadcd34ce860310f6a496f4aa7f54179090863bcf993582e2c757fa07677862973b817edc2d209b289284e19ec040249c62011ad20ceb41ee0c6
data/README.md CHANGED
@@ -405,6 +405,21 @@ describe CombineNamesForUserMigration do
405
405
  end
406
406
  ```
407
407
 
408
+ To avoid polluting the global configuration, you can use `RequestMigrations::Testing`
409
+ within your application's `spec/rails_helper.rb` (or similar).
410
+
411
+ ```ruby
412
+ Rspec.configure do |config|
413
+ config.before :each do
414
+ RequestMigrations::Testing.setup!
415
+ end
416
+
417
+ config.after :each do
418
+ RequestMigrations::Testing.teardown!
419
+ end
420
+ end
421
+ ```
422
+
408
423
  ## Tips and tricks
409
424
 
410
425
  Over the years, we're learned a thing or two about versioning an API. We'll share tips here.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RequestMigrations
4
- VERSION = "1.0.2"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RequestMigrations
4
+ class Testing
5
+ @@config = RequestMigrations::Configuration.new
6
+
7
+ ##
8
+ # setup! stores the original config and replaces it with a clone for testing.
9
+ def self.setup!
10
+ @@config = RequestMigrations.config
11
+
12
+ RequestMigrations.reset!
13
+ RequestMigrations.configure do |config|
14
+ @@config.config.each { |(k, v)| config.config[k] = v }
15
+ end
16
+ end
17
+
18
+ ##
19
+ # teardown! restores the original config.
20
+ def self.teardown!
21
+ RequestMigrations.config = @@config
22
+ end
23
+ end
24
+ end
@@ -43,6 +43,18 @@ module RequestMigrations
43
43
  # config returns the current config.
44
44
  def self.config = @config ||= Configuration.new
45
45
 
46
+ ##
47
+ # @private
48
+ def self.config=(cfg)
49
+ @config = cfg
50
+ end
51
+
52
+ ##
53
+ # @private
54
+ def self.reset!
55
+ @config = RequestMigrations::Configuration.new
56
+ end
57
+
46
58
  ##
47
59
  # logger returns the configured logger.
48
60
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeke Gabrielse
@@ -74,6 +74,7 @@ files:
74
74
  - lib/request_migrations/migrator.rb
75
75
  - lib/request_migrations/railtie.rb
76
76
  - lib/request_migrations/router.rb
77
+ - lib/request_migrations/testing.rb
77
78
  - lib/request_migrations/version.rb
78
79
  homepage: https://github.com/keygen-sh/request_migrations
79
80
  licenses: