minitest-substitute 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f27cada1056bf6ab2bc4d31d05eb6434d7434f196d59f43a449377d46e258df
4
- data.tar.gz: 85aa4a49208eb50dd5f52826489ddb96b636896b56e3f2242990ab2e650f4075
3
+ metadata.gz: 9f8802ed1f575511d0d40b4c9c6aa83ac9e0438a4e516a3e9d371d64cbeec44c
4
+ data.tar.gz: 94dab332d69b4340512030e332d20b68975a80b0860f7e8cdb72334c25cfd076
5
5
  SHA512:
6
- metadata.gz: 8564e7186a0967d7e8bf94b140c76640e8aea84c0d3e7144a1d312c05d7461c59a04b4450b9e279616be85adca22db87abcffbd88de5e743d5c0b6e560881191
7
- data.tar.gz: 780c0a5bfd68c52e27fd5ce6786c18845ddb5d7e26bb4c1133dccf1f2189e306845900e3011744e9026b6e836147abe5b6fe9b64e1d6a10fea8d625b12ec9093
6
+ metadata.gz: 9ebd589721d0d15745712e3b280cf395bce7d185ccdbe9fc728213c87a7991d7b8ba442e853ce7932e673bc6693e98b6712b3bf75878ce240b6eeb7298ae0a97
7
+ data.tar.gz: fc1cb86a0d3f3123afcde191b906c154044975f4fe95eb8b0f9af0639aa27c822da7377f36e0213fcc380d2b776ed00c5db5bace1a46c6945e994ca61928f7a2
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Nothing so far
4
4
 
5
+ ## 1.0.0
6
+
7
+ #### Breaking Changes
8
+ * Switch from `with` to `substitute` because Rails 7 pollutes `Object` for
9
+ everybody by introducing `Object#with`. 💣
10
+
5
11
  ## 0.3.0
6
12
 
7
13
  #### Additions
data/README.md CHANGED
@@ -39,6 +39,24 @@ Finally, require this gem in your `test_helper.rb` or `spec_helper.rb`:
39
39
  require 'minitest/substitute'
40
40
  ```
41
41
 
42
+ ## Update from 0.x.x to 1.x.x
43
+
44
+ Rails 7 has polluted `Object` for everybody by introducing `Object#with`. To prevent collisions, Minitest::Substitute has switched from `with` to `substitute` as of version 1.0.0.
45
+
46
+ After having updated this gem, you'll have to adapt all your tests accordingly:
47
+
48
+ ```ruby
49
+ # Version 0.x.x
50
+ with '@version', 2, on: config do
51
+ config.instance_variable_get('@version') # => 2
52
+ end
53
+
54
+ # Version 1.x.x
55
+ substitute '@version', 2, on: config do
56
+ config.instance_variable_get('@version') # => 2
57
+ end
58
+ ```
59
+
42
60
  ## Usage
43
61
 
44
62
  ### Block
@@ -55,7 +73,7 @@ end
55
73
  config = Config.new
56
74
 
57
75
  config.instance_variable_get('@version') # => 1
58
- with '@version', 2, on: config do
76
+ substitute '@version', 2, on: config do
59
77
  config.instance_variable_get('@version') # => 2
60
78
  end
61
79
  config.instance_variable_get('@version') # => 1
@@ -71,7 +89,7 @@ class Config
71
89
  end
72
90
 
73
91
  Config.class_variable_get('@@counter') # => 0
74
- with '@@counter', 42, on: Config do
92
+ substitute '@@counter', 42, on: Config do
75
93
  Config.class_variable_get('@@counter') # => 42
76
94
  end
77
95
  Config.class_variable_get('@@counter') # => 0
@@ -81,7 +99,7 @@ Same goes for global variables:
81
99
 
82
100
  ```ruby
83
101
  $verbose = false # => false
84
- with '$verbose', true do
102
+ substitute '$verbose', true do
85
103
  $verbose # => true
86
104
  end
87
105
  $verbose # => false
@@ -91,7 +109,7 @@ And it works for globals like `ENV` as well which comes in handy when you have t
91
109
 
92
110
  ```ruby
93
111
  ENV['EDITOR'] # => 'vi'
94
- with "ENV['EDITOR']", 'nano' do
112
+ substitute "ENV['EDITOR']", 'nano' do
95
113
  ENV['EDITOR'] # => 'nano'
96
114
  end
97
115
  ENV['EDITOR'] # => 'vi'
@@ -106,7 +124,7 @@ module Animals
106
124
  end
107
125
 
108
126
  Animals::DOG_MAKES # => 'woof'
109
- with '::Animals::DOG_MAKES', Animals::CAT_MAKES do
127
+ substitute '::Animals::DOG_MAKES', Animals::CAT_MAKES do
110
128
  Animals::DOG_MAKES # => 'meow'
111
129
  end
112
130
  Animals::DOG_MAKES # => 'woof'
@@ -128,13 +146,13 @@ class Cat
128
146
  end
129
147
 
130
148
  Dog.makes # => 'woof'
131
- with '::Dog', Cat do
149
+ substitute '::Dog', Cat do
132
150
  Dog.makes # => 'meow'
133
151
  end
134
152
  Dog.makes # => 'woof'
135
153
  ```
136
154
 
137
- It's safe to nest multiple `with` statements.
155
+ It's safe to nest multiple `substitute` statements.
138
156
 
139
157
  ### Group of Tests
140
158
 
@@ -159,7 +177,7 @@ describe Config do
159
177
  end
160
178
 
161
179
  describe 'sustituted version' do
162
- with '@version', 2, on: Config
180
+ substitute '@version', 2, on: Config
163
181
 
164
182
  it "returns the substituted version" do
165
183
  _(subject.instance_variable_get('@version')).must_equal 2
@@ -195,7 +213,7 @@ describe Config do
195
213
  end
196
214
 
197
215
  describe 'sustituted version' do
198
- with '@version', on: Config do
216
+ substitute '@version', on: Config do
199
217
  version # set using "let" above
200
218
  end
201
219
 
@@ -208,7 +226,7 @@ end
208
226
 
209
227
  If both a substitution value and a substitution block are present, the latter takes precedence.
210
228
 
211
- It's safe to use multiple `with` statements within one `describe` block.
229
+ It's safe to use multiple `substitute` statements within one `describe` block.
212
230
 
213
231
  (The spec integration is borrowed from [minitest-around](https://rubygems.org/gems/minitest-around) for elegance and compatibility.)
214
232
 
@@ -11,7 +11,7 @@ Minitest::Spec::DSL.class_eval do
11
11
  # @param on [Object, Symbol, nil] substitute in the context of this object
12
12
  # or in the context of the declared subject if +nil+
13
13
  # @yield temporary substitution value (takes precedence over +substitute+ param)
14
- def with(variable, substitute=nil, on: nil, &block)
14
+ def substitute(variable, substitute=nil, on: nil, &block)
15
15
  substitutor = Minitest::Substitute::Substitutor.new(variable, on: on)
16
16
  before do
17
17
  substitutor.substitute(block ? instance_eval(&block) : substitute)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Minitest
4
4
  module Substitute
5
- module With
5
+ module Substitute
6
6
 
7
7
  # Substitute the variable value for the duration of the given block
8
8
  #
@@ -11,7 +11,7 @@ module Minitest
11
11
  # @param on [Object, nil] substitute in the context of this object
12
12
  # @yield block during which the substitution is made
13
13
  # @return [Object] return value of the yielded block
14
- def with(variable, substitute, on: self)
14
+ def substitute(variable, substitute, on: self)
15
15
  substitutor = Minitest::Substitute::Substitutor.new(variable, on: on).substitute(substitute)
16
16
  substitutor.commit
17
17
  yield.tap do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Substitute
5
- VERSION = '0.3.0'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  require_relative 'substitute/version'
4
4
 
5
5
  require_relative 'substitute/substitutor'
6
- require_relative 'substitute/with'
6
+ require_relative 'substitute/substitute'
7
7
  require_relative 'substitute/spec'
8
8
 
9
- include Minitest::Substitute::With
9
+ include Minitest::Substitute::Substitute
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-substitute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
@@ -10,26 +10,24 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhydWJ5
14
- L0RDPWJpdGNldGVyYS9EQz1jb20wHhcNMjIxMTA2MTIzNjUwWhcNMjMxMTA2MTIz
15
- NjUwWjAjMSEwHwYDVQQDDBhydWJ5L0RDPWJpdGNldGVyYS9EQz1jb20wggEiMA0G
13
+ MIIC+jCCAeKgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhydWJ5
14
+ L0RDPWJpdGNldGVyYS9EQz1jb20wHhcNMjMxMTEwMTgyMzM2WhcNMjQxMTA5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kGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSfK8MtR62mQ6oN
23
+ yoX/VKJzFjLSVDANBgkqhkiG9w0BAQsFAAOCAQEAXhT/LpMArF3JRcZSRkJDY+dU
24
+ GKCRqOefi2iydqh1yIqXyTA9PGR1w5O6O+WS1FvF+sHCwh8fFjCuStg2L8V2RSeo
25
+ aDtfZ5s80sL8wRFxg3kek69cBuI6ozU+rf9DaXlMES4i8+zASsdv9Y4a2BsbhEdE
26
+ 9AtuMcWn5a45TOO0S4Q8OuV0v705V38Ow15J2RDRvkFRySt+//8/Vd57XAJxPXU0
27
+ k/QvZU05f6HMYBrPogJgIzHC/C5N/yeE4BVEuBDn+10Zb1iu3aDk8sd0uMgukCY8
28
+ TUmlP5A6NeGdeDJIoLgromAKs+nvI7TWzhQq9ODs51XhxgUFRCvBqUTpjTQigw==
31
29
  -----END CERTIFICATE-----
32
- date: 2023-09-08 00:00:00.000000000 Z
30
+ date: 2024-03-07 00:00:00.000000000 Z
33
31
  dependencies:
34
32
  - !ruby/object:Gem::Dependency
35
33
  name: minitest
@@ -176,9 +174,9 @@ files:
176
174
  - README.md
177
175
  - lib/minitest/substitute.rb
178
176
  - lib/minitest/substitute/spec.rb
177
+ - lib/minitest/substitute/substitute.rb
179
178
  - lib/minitest/substitute/substitutor.rb
180
179
  - lib/minitest/substitute/version.rb
181
- - lib/minitest/substitute/with.rb
182
180
  homepage: https://github.com/svoop/minitest-substitute
183
181
  licenses:
184
182
  - MIT
@@ -188,7 +186,9 @@ metadata:
188
186
  source_code_uri: https://github.com/svoop/minitest-substitute
189
187
  documentation_uri: https://www.rubydoc.info/gems/minitest-substitute
190
188
  bug_tracker_uri: https://github.com/svoop/minitest-substitute/issues
191
- post_install_message:
189
+ post_install_message: '⚠️ Breaking change: minitest-substitute >= 1.0.0 switched from
190
+ "with" to "substitute" to prevent conflicts with Rails 7. Please read the update
191
+ section in the README.'
192
192
  rdoc_options:
193
193
  - "--title"
194
194
  - Minitest::Substitute
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  - !ruby/object:Gem::Version
211
211
  version: '0'
212
212
  requirements: []
213
- rubygems_version: 3.4.19
213
+ rubygems_version: 3.5.6
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Substitute values for the duration of a block or a group of tests
metadata.gz.sig CHANGED
Binary file