minitest-substitute 0.3.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: 5f27cada1056bf6ab2bc4d31d05eb6434d7434f196d59f43a449377d46e258df
4
- data.tar.gz: 85aa4a49208eb50dd5f52826489ddb96b636896b56e3f2242990ab2e650f4075
3
+ metadata.gz: a8d039d7a6420c2f26dd4ac8d2c784c551da02063c1031b1deef94208282e0fd
4
+ data.tar.gz: 92fdb7f95bbc7964f0896770495f08926619d641a68b4d1eb7c0cdecee4ba49c
5
5
  SHA512:
6
- metadata.gz: 8564e7186a0967d7e8bf94b140c76640e8aea84c0d3e7144a1d312c05d7461c59a04b4450b9e279616be85adca22db87abcffbd88de5e743d5c0b6e560881191
7
- data.tar.gz: 780c0a5bfd68c52e27fd5ce6786c18845ddb5d7e26bb4c1133dccf1f2189e306845900e3011744e9026b6e836147abe5b6fe9b64e1d6a10fea8d625b12ec9093
6
+ metadata.gz: 666754cd3d3d459fc317d42dd9f58bd7ba9007fd6bd4047e79a749ee8f745148b3cb9b03de153d530a869252abe90f9f68ab277aacd89e7291eaf1d6f3caf0d9
7
+ data.tar.gz: 5eb31f70af191e1ae64c35a093e8e6eb09f53b88560b36cb72393252985ed435123da2d11fdcbb395c63d6e48f223f13a551bd78a13519ddea9094a5e36167e9
data/CHANGELOG.md CHANGED
@@ -2,25 +2,37 @@
2
2
 
3
3
  Nothing so far
4
4
 
5
+ ## 1.1.0
6
+
7
+ ### Changes
8
+ * Update Ruby to 3.4
9
+ * Add action for trusted release
10
+
11
+ ## 1.0.0
12
+
13
+ ### Breaking Changes
14
+ * Switch from `with` to `substitute` because Rails 7 pollutes `Object` for
15
+ everybody by introducing `Object#with`. 💣
16
+
5
17
  ## 0.3.0
6
18
 
7
- #### Additions
19
+ ### Additions
8
20
  * Substition of constants
9
21
 
10
22
  ## 0.2.1
11
23
 
12
- #### Changes
24
+ ### Changes
13
25
  * Defer evaluation of the substitution value block for specs
14
26
 
15
27
  ## 0.2.0
16
28
 
17
- #### Additions
29
+ ### Additions
18
30
  * Refactor to support class variables as well
19
31
  * Use declared subject as default target for with helper
20
32
 
21
33
  ## 0.1.0
22
34
 
23
- #### Initial Implementation
35
+ ### Initial Implementation
24
36
  * Require Ruby 3.0
25
37
  * Substitution of instance variables
26
38
  * Substitution of global variables
data/README.md CHANGED
@@ -1,25 +1,21 @@
1
1
  [![Version](https://img.shields.io/gem/v/minitest-substitute.svg?style=flat)](https://rubygems.org/gems/minitest-substitute)
2
2
  [![Tests](https://img.shields.io/github/actions/workflow/status/svoop/minitest-substitute/test.yml?style=flat&label=tests)](https://github.com/svoop/minitest-substitute/actions?workflow=Test)
3
3
  [![Code Climate](https://img.shields.io/codeclimate/maintainability/svoop/minitest-substitute.svg?style=flat)](https://codeclimate.com/github/svoop/minitest-substitute/)
4
- [![Donorbox](https://img.shields.io/badge/donate-on_donorbox-yellow.svg)](https://donorbox.org/bitcetera)
4
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/svoop.svg)](https://github.com/sponsors/svoop)
5
5
 
6
6
  # Minitest::Substitute
7
7
 
8
8
  Simple Minitest helper to replace values such as an instance variable of an object or an environment variable for the duration of a block or a group of tests.
9
9
 
10
- This comes in very handy when you have to derive from default configuration in order to test some aspects of your code.
10
+ This comes in very handy when you have to deviate from default configuration in order to test some aspects of your code.
11
11
 
12
12
  * [Homepage](https://github.com/svoop/minitest-substitute)
13
13
  * [API](https://www.rubydoc.info/gems/minitest-substitute)
14
14
  * Author: [Sven Schwyn - Bitcetera](https://bitcetera.com)
15
15
 
16
- ## Install
17
-
18
- This gem is [cryptographically signed](https://guides.rubygems.org/security/#using-gems) in order to assure it hasn't been tampered with. Unless already done, please add the author's public key as a trusted certificate now:
16
+ Thank you for supporting free and open-source software by sponsoring on [GitHub](https://github.com/sponsors/svoop) or on [Donorbox](https://donorbox.com/bitcetera). Any gesture is appreciated, from a single Euro for a ☕️ cup of coffee to 🍹 early retirement.
19
17
 
20
- ```
21
- gem cert --add <(curl -Ls https://bitcetera.com/downloads/gem-public_cert.pem)
22
- ```
18
+ ## Install
23
19
 
24
20
  Add the following to the <tt>Gemfile</tt> or <tt>gems.rb</tt> of your [Bundler](https://bundler.io) powered Ruby project:
25
21
 
@@ -30,7 +26,7 @@ gem 'minitest-substitute'
30
26
  And then install the bundle:
31
27
 
32
28
  ```
33
- bundle install --trust-policy MediumSecurity
29
+ bundle install
34
30
  ```
35
31
 
36
32
  Finally, require this gem in your `test_helper.rb` or `spec_helper.rb`:
@@ -39,6 +35,24 @@ Finally, require this gem in your `test_helper.rb` or `spec_helper.rb`:
39
35
  require 'minitest/substitute'
40
36
  ```
41
37
 
38
+ ## Update from 0.x.x to 1.x.x
39
+
40
+ 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.
41
+
42
+ After having updated this gem, you'll have to adapt all your tests accordingly:
43
+
44
+ ```ruby
45
+ # Version 0.x.x
46
+ with '@version', 2, on: config do
47
+ config.instance_variable_get('@version') # => 2
48
+ end
49
+
50
+ # Version 1.x.x
51
+ substitute '@version', 2, on: config do
52
+ config.instance_variable_get('@version') # => 2
53
+ end
54
+ ```
55
+
42
56
  ## Usage
43
57
 
44
58
  ### Block
@@ -55,7 +69,7 @@ end
55
69
  config = Config.new
56
70
 
57
71
  config.instance_variable_get('@version') # => 1
58
- with '@version', 2, on: config do
72
+ substitute '@version', 2, on: config do
59
73
  config.instance_variable_get('@version') # => 2
60
74
  end
61
75
  config.instance_variable_get('@version') # => 1
@@ -71,7 +85,7 @@ class Config
71
85
  end
72
86
 
73
87
  Config.class_variable_get('@@counter') # => 0
74
- with '@@counter', 42, on: Config do
88
+ substitute '@@counter', 42, on: Config do
75
89
  Config.class_variable_get('@@counter') # => 42
76
90
  end
77
91
  Config.class_variable_get('@@counter') # => 0
@@ -81,7 +95,7 @@ Same goes for global variables:
81
95
 
82
96
  ```ruby
83
97
  $verbose = false # => false
84
- with '$verbose', true do
98
+ substitute '$verbose', true do
85
99
  $verbose # => true
86
100
  end
87
101
  $verbose # => false
@@ -91,7 +105,7 @@ And it works for globals like `ENV` as well which comes in handy when you have t
91
105
 
92
106
  ```ruby
93
107
  ENV['EDITOR'] # => 'vi'
94
- with "ENV['EDITOR']", 'nano' do
108
+ substitute "ENV['EDITOR']", 'nano' do
95
109
  ENV['EDITOR'] # => 'nano'
96
110
  end
97
111
  ENV['EDITOR'] # => 'vi'
@@ -106,7 +120,7 @@ module Animals
106
120
  end
107
121
 
108
122
  Animals::DOG_MAKES # => 'woof'
109
- with '::Animals::DOG_MAKES', Animals::CAT_MAKES do
123
+ substitute '::Animals::DOG_MAKES', Animals::CAT_MAKES do
110
124
  Animals::DOG_MAKES # => 'meow'
111
125
  end
112
126
  Animals::DOG_MAKES # => 'woof'
@@ -128,13 +142,13 @@ class Cat
128
142
  end
129
143
 
130
144
  Dog.makes # => 'woof'
131
- with '::Dog', Cat do
145
+ substitute '::Dog', Cat do
132
146
  Dog.makes # => 'meow'
133
147
  end
134
148
  Dog.makes # => 'woof'
135
149
  ```
136
150
 
137
- It's safe to nest multiple `with` statements.
151
+ It's safe to nest multiple `substitute` statements.
138
152
 
139
153
  ### Group of Tests
140
154
 
@@ -159,7 +173,7 @@ describe Config do
159
173
  end
160
174
 
161
175
  describe 'sustituted version' do
162
- with '@version', 2, on: Config
176
+ substitute '@version', 2, on: Config
163
177
 
164
178
  it "returns the substituted version" do
165
179
  _(subject.instance_variable_get('@version')).must_equal 2
@@ -195,7 +209,7 @@ describe Config do
195
209
  end
196
210
 
197
211
  describe 'sustituted version' do
198
- with '@version', on: Config do
212
+ substitute '@version', on: Config do
199
213
  version # set using "let" above
200
214
  end
201
215
 
@@ -208,7 +222,7 @@ end
208
222
 
209
223
  If both a substitution value and a substitution block are present, the latter takes precedence.
210
224
 
211
- It's safe to use multiple `with` statements within one `describe` block.
225
+ It's safe to use multiple `substitute` statements within one `describe` block.
212
226
 
213
227
  (The spec integration is borrowed from [minitest-around](https://rubygems.org/gems/minitest-around) for elegance and compatibility.)
214
228
 
@@ -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.1.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
metadata CHANGED
@@ -1,35 +1,13 @@
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.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
8
- autorequire:
9
8
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhydWJ5
14
- L0RDPWJpdGNldGVyYS9EQz1jb20wHhcNMjIxMTA2MTIzNjUwWhcNMjMxMTA2MTIz
15
- NjUwWjAjMSEwHwYDVQQDDBhydWJ5L0RDPWJpdGNldGVyYS9EQz1jb20wggEiMA0G
16
- CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDcLg+IHjXYaUlTSU7R235lQKD8ZhEe
17
- KMhoGlSUonZ/zo1OT3KXcqTCP1iMX743xYs6upEGALCWWwq+nxvlDdnWRjF3AAv7
18
- ikC+Z2BEowjyeCCT/0gvn4ohKcR0JOzzRaIlFUVInlGSAHx2QHZ2N8ntf54lu7nd
19
- L8CiDK8rClsY4JBNGOgH9UC81f+m61UUQuTLxyM2CXfAYkj/sGNTvFRJcNX+nfdC
20
- hM9r2kH1+7wsa8yG7wJ2IkrzNACD8v84oE6qVusN8OLEMUI/NaEPVPbw2LUM149H
21
- PVa0i729A4IhroNnFNmw4wOC93ARNbM1+LW36PLMmKjKudf5Exg8VmDVAgMBAAGj
22
- dzB1MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSfK8MtR62mQ6oN
23
- yoX/VKJzFjLSVDAdBgNVHREEFjAUgRJydWJ5QGJpdGNldGVyYS5jb20wHQYDVR0S
24
- BBYwFIEScnVieUBiaXRjZXRlcmEuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQAYG2na
25
- ye8OE2DANQIFM/xDos/E4DaPWCJjX5xvFKNKHMCeQYPeZvLICCwyw2paE7Otwk6p
26
- uvbg2Ks5ykXsbk5i6vxDoeeOLvmxCqI6m+tHb8v7VZtmwRJm8so0eSX0WvTaKnIf
27
- CAn1bVUggczVdNoBXw9WAILKyw9bvh3Ft740XZrR74sd+m2pGwjCaM8hzLvrVbGP
28
- DyYhlBeRWyQKQ0WDIsiTSRhzK8HwSTUWjvPwx7SEdIU/HZgyrk0ETObKPakVu6bH
29
- kAyiRqgxF4dJviwtqI7mZIomWL63+kXLgjOjMe1SHxfIPo/0ji6+r1p4KYa7o41v
30
- fwIwU1MKlFBdsjkd
31
- -----END CERTIFICATE-----
32
- date: 2023-09-08 00:00:00.000000000 Z
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
33
11
  dependencies:
34
12
  - !ruby/object:Gem::Dependency
35
13
  name: minitest
@@ -167,18 +145,18 @@ email:
167
145
  executables: []
168
146
  extensions: []
169
147
  extra_rdoc_files:
170
- - README.md
171
148
  - CHANGELOG.md
172
149
  - LICENSE.txt
150
+ - README.md
173
151
  files:
174
152
  - CHANGELOG.md
175
153
  - LICENSE.txt
176
154
  - README.md
177
155
  - lib/minitest/substitute.rb
178
156
  - lib/minitest/substitute/spec.rb
157
+ - lib/minitest/substitute/substitute.rb
179
158
  - lib/minitest/substitute/substitutor.rb
180
159
  - lib/minitest/substitute/version.rb
181
- - lib/minitest/substitute/with.rb
182
160
  homepage: https://github.com/svoop/minitest-substitute
183
161
  licenses:
184
162
  - MIT
@@ -188,7 +166,9 @@ metadata:
188
166
  source_code_uri: https://github.com/svoop/minitest-substitute
189
167
  documentation_uri: https://www.rubydoc.info/gems/minitest-substitute
190
168
  bug_tracker_uri: https://github.com/svoop/minitest-substitute/issues
191
- post_install_message:
169
+ post_install_message: '⚠️ Breaking change: minitest-substitute >= 1.0.0 switched from
170
+ "with" to "substitute" to prevent conflicts with Rails 7. Please read the update
171
+ section in the README.'
192
172
  rdoc_options:
193
173
  - "--title"
194
174
  - Minitest::Substitute
@@ -210,8 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
190
  - !ruby/object:Gem::Version
211
191
  version: '0'
212
192
  requirements: []
213
- rubygems_version: 3.4.19
214
- signing_key:
193
+ rubygems_version: 3.6.9
215
194
  specification_version: 4
216
195
  summary: Substitute values for the duration of a block or a group of tests
217
196
  test_files: []
checksums.yaml.gz.sig DELETED
Binary file
data.tar.gz.sig DELETED
@@ -1 +0,0 @@
1
- X��Of��c&]A�T$�'�t>_�DZ�]B?�E�s�VB�����%�_d�����:G�N��U𡙫p���jN|׾���P�����>���7��ۊ�3-ҘCufJ9H�'5�5�/B���gc|>���T��6<�C�}��z��w�ZA�����!�O+�ew�|�J�h�T��ʯ�\Z\M�V!��Li�d,��'#�D��}]�}�M�`�-~��ج��c]�3����~/]�f�Y�LG�<�_ԗH����wb
metadata.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- �(~8ܠ y.�C��O���X��1EP@߽�d��(��A�Rzq�����'|���Lr8p��8�W�mA
2
-
3
- �����ޘ47�z��1�������0'�M��fc^����_"=��k���p?�/2���~�f�� Jz2<Yc���@��"[J�h�O�-��&vTZ���EI���ѽi� �PG�L^��Z�'�Wy��ye����J0��GiF��zZp{&�쬈F�1<,�ߛY�u��)��|��