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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +6 -0
- data/README.md +28 -10
- data/lib/minitest/substitute/spec.rb +1 -1
- data/lib/minitest/substitute/{with.rb → substitute.rb} +2 -2
- data/lib/minitest/substitute/version.rb +1 -1
- data/lib/minitest/substitute.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +17 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f8802ed1f575511d0d40b4c9c6aa83ac9e0438a4e516a3e9d371d64cbeec44c
|
4
|
+
data.tar.gz: 94dab332d69b4340512030e332d20b68975a80b0860f7e8cdb72334c25cfd076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ebd589721d0d15745712e3b280cf395bce7d185ccdbe9fc728213c87a7991d7b8ba442e853ce7932e673bc6693e98b6712b3bf75878ce240b6eeb7298ae0a97
|
7
|
+
data.tar.gz: fc1cb86a0d3f3123afcde191b906c154044975f4fe95eb8b0f9af0639aa27c822da7377f36e0213fcc380d2b776ed00c5db5bace1a46c6945e994ca61928f7a2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 `
|
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
|
-
|
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
|
-
|
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 `
|
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
|
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
|
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
|
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
|
data/lib/minitest/substitute.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative 'substitute/version'
|
4
4
|
|
5
5
|
require_relative 'substitute/substitutor'
|
6
|
-
require_relative 'substitute/
|
6
|
+
require_relative 'substitute/substitute'
|
7
7
|
require_relative 'substitute/spec'
|
8
8
|
|
9
|
-
include Minitest::Substitute::
|
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.
|
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
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MIIC+jCCAeKgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhydWJ5
|
14
|
+
L0RDPWJpdGNldGVyYS9EQz1jb20wHhcNMjMxMTEwMTgyMzM2WhcNMjQxMTA5MTgy
|
15
|
+
MzM2WjAjMSE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Zb1iu3aDk8sd0uMgukCY8
|
28
|
+
TUmlP5A6NeGdeDJIoLgromAKs+nvI7TWzhQq9ODs51XhxgUFRCvBqUTpjTQigw==
|
31
29
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
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.
|
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
|