rspec-path_matchers 0.2.0 → 0.2.2

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: 485c656106b438d3aa53d5c4795e4d9a6e784e8e8e6aafa4b42aa704e5df9a36
4
- data.tar.gz: '093a33b369d0a8d9c904080c84099f7f9cfe0f4095d2f3e5cba5b06af23ecd94'
3
+ metadata.gz: 57cf9fb73270a021f71c7afa086cee0075e8af63178be97665c11d86ec11576e
4
+ data.tar.gz: c3933b79bd5f5988ad275adc71f4c8a58a73f7b3458e00d531b0a9f594eb5dfa
5
5
  SHA512:
6
- metadata.gz: ef5013d34444c276cae1a37e18071780d1ab79045491222e022a6bd9391480dbf22d68abe8142dfb00036b06a2eb3fdb88823bc8b05029ce6f1bb78093a708b9
7
- data.tar.gz: a28d711d8edc2494e5e228c23f2269f8936d01eb62566d3fe8a35f5a56ba66b3d64bc4e5c8e915dd22570f8f8ffcaa275de95a4a91dd3eb0953eecd09694bf54
6
+ metadata.gz: 5733d93154823932fde435c692c9fa88aeb36e9721b496d0704f78eee3ab7a916735576f074f2438e358a66573a051c55946b8b32a68ee7743e1ec7d3e5938b2
7
+ data.tar.gz: 4b5bd87c18e4b3dea1364ca72990c1616158abb8f44e66124cacd47ae8f71b47550bcceb132d5161fb67968632260e53892139f9706c7e744a6bad5256f69894
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.2.0"
2
+ ".": "0.2.2"
3
3
  }
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --no-private
2
+ --hide-void-return
3
+ --markup-provider=redcarpet
4
+ --markup markdown
5
+ --readme README.md
6
+ - CHANGELOG.md
7
+ - LICENSE.txt
data/CHANGELOG.md CHANGED
@@ -1,5 +1,3 @@
1
- ## [Unreleased]
2
-
3
1
  ## [0.2.0](https://github.com/main-branch/rspec-path_matchers/compare/v0.1.1...v0.2.0) (2025-06-30)
4
2
 
5
3
 
@@ -21,6 +19,32 @@
21
19
  * Update README to give an example toward the top of the doc ([ece4afc](https://github.com/main-branch/rspec-path_matchers/commit/ece4afc3edb1e27e96fa3fe70052c99a73f6a221))
22
20
  * Update README to give an example toward the top of the doc ([5b0f196](https://github.com/main-branch/rspec-path_matchers/commit/5b0f19646fe6cd7b7cba6c057e690b7b54d5c3c3))
23
21
 
22
+ ## [0.2.2](https://github.com/main-branch/rspec-path_matchers/compare/v0.2.1...v0.2.2) (2025-07-01)
23
+
24
+
25
+ ### Features
26
+
27
+ * Ensure windows compatibility for Ruby MRI ([c712b23](https://github.com/main-branch/rspec-path_matchers/commit/c712b23e5e0eac7484278f8dd40866cfc739870d))
28
+
29
+
30
+ ### Other Changes
31
+
32
+ * Add a statement about the precise, easy-to-diagnose failure messages in the README summary ([90e183e](https://github.com/main-branch/rspec-path_matchers/commit/90e183e1e828949db9a89428f5d207303814f92e))
33
+
34
+ ## [0.2.1](https://github.com/main-branch/rspec-path_matchers/compare/v0.2.0...v0.2.1) (2025-07-01)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * Make error messages consistent ([3a5f730](https://github.com/main-branch/rspec-path_matchers/commit/3a5f7301e29601cda438d4b0163909bd9e22cd4b))
40
+ * Update CI badge to point to the correct workflow ([589a588](https://github.com/main-branch/rspec-path_matchers/commit/589a5882e568292b4d6c40e5e37875cc7d9b1ca1))
41
+
42
+
43
+ ### Other Changes
44
+
45
+ * Add doc link badge to README ([7de600b](https://github.com/main-branch/rspec-path_matchers/commit/7de600b5ed554a30f2439863a1d10c4ca078f1ea))
46
+ * Update README to include CHANGELOG badge ([0a871ca](https://github.com/main-branch/rspec-path_matchers/commit/0a871caa763db16e47d2b45273ab4acfca42cb90))
47
+
24
48
  ## [0.1.1](https://github.com/main-branch/rspec-path_matchers/compare/v0.1.0...v0.1.1) (2025-06-25)
25
49
 
26
50
 
data/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  [![Gem
4
4
  Version](https://img.shields.io/gem/v/rspec-path_matchers.svg)](https://rubygems.org/gems/rspec-path_matchers)
5
- [![Build
6
- Status](https://img.shields.io/github/actions/workflow/status/main-branch/rspec-path_matchers/main.yml?branch=main)](https://github.com/main-branch/rspec-path_matchers/actions)
5
+ [![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/rspec-path_matchers/)
6
+ [![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/ruby_git/file/CHANGELOG.md)
7
+ [![Continuous Integration](https://github.com/main-branch/rspec-path_matchers/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/main-branch/rspec-path_matchers/actions/workflows/continuous_integration.yml)
7
8
  [![MIT
8
9
  License](https://img.shields.io/badge/license-MIT-green)](https://opensource.org/licenses/MIT)
9
10
 
@@ -23,13 +24,15 @@ License](https://img.shields.io/badge/license-MIT-green)](https://opensource.org
23
24
 
24
25
  ## Summary
25
26
 
26
- **RSpec::PathMatchers** provides a comprehensive suite of RSpec matchers for
27
- testing directory structures.
27
+ **RSpec::PathMatchers** provides a comprehensive suite of RSpec matchers for testing
28
+ directory structures.
28
29
 
29
30
  Verifying that a generator, build script, or any file-manipulating process has
30
- produced the correct output can be tedious and verbose. This gem makes those
31
- assertions simple, declarative, and easier to read, allowing you to describe an entire
32
- file tree and its properties within your specs.
31
+ produced the correct output can be tedious and verbose.
32
+
33
+ This gem makes it easy to express expectations on an entire directory tree and
34
+ receive precise, easy-to-diagnose failure messages when that tree does not meet its
35
+ expectations.
33
36
 
34
37
  ## Installation
35
38
 
@@ -286,8 +289,8 @@ expect('config').to(
286
289
  ```text
287
290
  'config' was not as expected:
288
291
  - database.xml
289
- expected owner to be "db_user", but was "root"
290
- expected mode to be "0600", but was "0644"
292
+ expected owner to be "db_user", but it was "root"
293
+ expected mode to be "0600", but it was "0644"
291
294
  ```
292
295
 
293
296
  ## Development
@@ -164,7 +164,7 @@ module RSpec
164
164
  end
165
165
 
166
166
  def build_unexpected_entries_message(unexpected_entries)
167
- "contained unexpected entries #{unexpected_entries.sort.inspect}"
167
+ "expected no other entries, but found #{unexpected_entries.sort.inspect}"
168
168
  end
169
169
  end
170
170
  end
@@ -102,7 +102,7 @@ module RSpec
102
102
 
103
103
  types = ['Matcher', *valid_expected_types.map(&:name)].to_sentence(conjunction: 'or')
104
104
 
105
- errors << "expected `#{key}:` to be a #{types}, but was #{expected.inspect}"
105
+ errors << "expected `#{key}:` to be a #{types}, but it was #{expected.inspect}"
106
106
  end
107
107
 
108
108
  protected
@@ -189,6 +189,36 @@ module RSpec
189
189
  #
190
190
  private_class_method def self.literal_match?(actual, expected) = actual == expected
191
191
 
192
+ # Add to `failures` if actual value matches the normalized expected value
193
+ #
194
+ # This is called when expected is not an RSpec matcher.
195
+ #
196
+ # Option subclasses should override this method to provide custom matching
197
+ # logic or custom failure messages.
198
+ #
199
+ # @param actual [Object] the actual value fetched from the file system
200
+ #
201
+ # @param expected [Object] the expected literal value to match against
202
+ #
203
+ # @param failures [Array<RSpec::PathMatchers::Failure>] the array to append
204
+ # failure objects to (if any)
205
+ #
206
+ # @return [void]
207
+ #
208
+ # @api protected
209
+ #
210
+ private_class_method def self.match_literal(actual, expected, failures)
211
+ expected = normalize_expected_literal(expected)
212
+
213
+ return if literal_match?(actual, expected)
214
+
215
+ add_failure(literal_failure_message(actual, expected), failures)
216
+ end
217
+
218
+ private_class_method def self.add_failure(message, failures)
219
+ failures << RSpec::PathMatchers::Failure.new('.', message)
220
+ end
221
+
192
222
  # Generates a failure message for a literal match failure
193
223
  #
194
224
  # This is used when the actual value does not match the expected value.
@@ -201,9 +231,9 @@ module RSpec
201
231
  # @example generate a failure message for a literal match failure
202
232
  # def self.literal_failure_message(actual, expected)
203
233
  # if expected.is_a?(Regexp)
204
- # "expected #{key} to match #{expected.inspect}, but was #{actual.inspect}"
234
+ # "expected #{key} to match #{expected.inspect}, but it was #{actual.inspect}"
205
235
  # else
206
- # "expected #{key} to be #{expected.inspect}, but was #{actual.inspect}"
236
+ # "expected #{key} to be #{expected.inspect}, but it was #{actual.inspect}"
207
237
  # end
208
238
  # end
209
239
  #
@@ -216,19 +246,19 @@ module RSpec
216
246
  # @api protected
217
247
  #
218
248
  private_class_method def self.literal_failure_message(actual, expected)
219
- "expected #{key} to be #{expected.inspect}, but was #{actual.inspect}"
249
+ "expected #{key} to be #{expected.inspect}, but it was #{actual.inspect}"
220
250
  end
221
251
 
222
252
  # Add to `failures` if actual value matches the normalized expected value
223
253
  #
224
- # This is called when expected is not an RSpec matcher.
254
+ # This is called when expected is an RSpec matcher.
225
255
  #
226
256
  # Option subclasses should override this method to provide custom matching
227
257
  # logic or custom failure messages.
228
258
  #
229
259
  # @param actual [Object] the actual value fetched from the file system
230
260
  #
231
- # @param expected [Object] the expected literal value to match against
261
+ # @param expected [RSpec::Matchers::Matcher] the expected matcher to match against
232
262
  #
233
263
  # @param failures [Array<RSpec::PathMatchers::Failure>] the array to append
234
264
  # failure objects to (if any)
@@ -237,42 +267,31 @@ module RSpec
237
267
  #
238
268
  # @api protected
239
269
  #
240
- private_class_method def self.match_literal(actual, expected, failures)
241
- expected = normalize_expected_literal(expected)
242
-
243
- return if literal_match?(actual, expected)
244
-
245
- message = literal_failure_message(actual, expected)
246
- add_failure(message, failures)
247
- end
270
+ private_class_method def self.match_matcher(actual, expected, failures)
271
+ return if expected.matches?(actual)
248
272
 
249
- private_class_method def self.add_failure(message, failures)
250
- failures << RSpec::PathMatchers::Failure.new('.', message)
273
+ add_failure(matcher_failure_message(actual, expected), failures)
251
274
  end
252
275
 
253
- # Add to `failures` if actual value matches the normalized expected value
276
+ # Generates a failure message for a matcher match failure
254
277
  #
255
- # This is called when expected is an RSpec matcher.
278
+ # This is used when the actual value does not match the expected value.
279
+ # It provides a clear message indicating what was expected and what was
280
+ # actually found.
256
281
  #
257
- # Option subclasses should override this method to provide custom matching
258
- # logic or custom failure messages.
282
+ # Option subclasses should override this method to provide custom failure
283
+ # messages for specific types of options.
259
284
  #
260
285
  # @param actual [Object] the actual value fetched from the file system
261
286
  #
262
- # @param expected [RSpec::Matchers::Matcher] the expected matcher to match against
263
- #
264
- # @param failures [Array<RSpec::PathMatchers::Failure>] the array to append
265
- # failure objects to (if any)
287
+ # @param expected [Object] the expected literal value to match against
266
288
  #
267
- # @return [void]
289
+ # @return [String] the failure message
268
290
  #
269
291
  # @api protected
270
292
  #
271
- private_class_method def self.match_matcher(actual, expected, failures)
272
- return if expected.matches?(actual)
273
-
274
- message = "expected #{key} to #{expected.description}, but was #{actual.inspect}"
275
- add_failure(message, failures)
293
+ private_class_method def self.matcher_failure_message(actual, expected)
294
+ "expected #{key} to #{expected.description}, but it was #{actual.inspect}"
276
295
  end
277
296
 
278
297
  # Warning message for unsupported expectations
@@ -11,18 +11,28 @@ module RSpec
11
11
  def self.fetch_actual(path, _failures) = File.read(path)
12
12
  def self.valid_expected_types = [String, Regexp]
13
13
 
14
+ # Override to provide custom matching logic for regexp literals
14
15
  def self.literal_match?(actual, expected)
15
- return expected.match?(actual) if expected.is_a?(Regexp)
16
+ expected.is_a?(Regexp) ? expected.match?(actual) : super
17
+ end
16
18
 
17
- super
19
+ # Handles failures when a matcher is used (e.g., content: include('...'))
20
+ def self.matcher_failure_message(actual, expected)
21
+ actual_summary = actual.length > 100 ? 'did not' : "was #{actual.inspect}"
22
+ "expected content to #{expected.description}, but it #{actual_summary}"
18
23
  end
19
24
 
20
25
  def self.literal_failure_message(actual, expected)
21
- if expected.is_a?(Regexp)
22
- "expected content to match #{expected.inspect}, but got #{actual.inspect}"
23
- else
24
- super
25
- end
26
+ verb = expected.is_a?(Regexp) ? 'match' : 'be'
27
+
28
+ actual_summary =
29
+ if actual.length > 100
30
+ verb == 'match' ? 'did not' : 'was not'
31
+ else
32
+ "was #{actual.inspect}"
33
+ end
34
+
35
+ "expected content to #{verb} #{expected.inspect}, but it #{actual_summary}"
26
36
  end
27
37
  end
28
38
  end
@@ -29,17 +29,16 @@ module RSpec
29
29
  # This is the `xxxx_content: true` case. A successful fetch_actual is sufficient
30
30
  def self.match_literal(_actual, _expected, _failures); end
31
31
 
32
- # Compares the parsed content against the given RSpec matcher.
32
+ # Failure message for when a matcher is used (e.g., `json_content: include(...)`)
33
33
  #
34
34
  # @param (see RSpec::PathMatchers::Options::Base.match_matcher)
35
35
  #
36
36
  # @return [void]
37
37
  #
38
- def self.match_matcher(actual, expected, failures)
39
- return if expected.matches?(actual)
38
+ def self.matcher_failure_message(actual, expected)
39
+ actual_summary = actual.inspect.length > 100 ? 'it did not' : "was #{actual.inspect}"
40
40
 
41
- message = "expected #{content_type} content to #{expected.description}"
42
- add_failure(message, failures)
41
+ "expected #{content_type} content to #{expected.description}, but #{actual_summary}"
43
42
  end
44
43
 
45
44
  # Provides a human-readable description for the option
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module PathMatchers
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-path_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Couball
@@ -213,6 +213,7 @@ files:
213
213
  - ".rspec"
214
214
  - ".rubocop.yml"
215
215
  - ".vscode/settings.json"
216
+ - ".yardopts"
216
217
  - CHANGELOG.md
217
218
  - CODE_OF_CONDUCT.md
218
219
  - LICENSE.txt
@@ -260,8 +261,8 @@ licenses:
260
261
  metadata:
261
262
  homepage_uri: https://github.com/main-branch/rspec-path_matchers
262
263
  source_code_uri: https://github.com/main-branch/rspec-path_matchers
263
- documentation_uri: https://rubydoc.info/gems/rspec-path_matchers/0.2.0
264
- changelog_uri: https://rubydoc.info/gems/rspec-path_matchers/0.2.0/file/CHANGELOG.md
264
+ documentation_uri: https://rubydoc.info/gems/rspec-path_matchers/0.2.2
265
+ changelog_uri: https://rubydoc.info/gems/rspec-path_matchers/0.2.2/file/CHANGELOG.md
265
266
  allowed_push_host: https://rubygems.org
266
267
  rubygems_mfa_required: 'true'
267
268
  rdoc_options: []