Load the version_sat expectation documents in the spec again

What does this MR do?

spec/semver_dialects_spec.rb builds the path of expectation/version_sat with File.expand_path('../..', __dir__). Two levels up was right while the spec lived in spec/unit/, but 251b0d10 (v3.0.0) moved it to spec/ and kept the two levels, so the path points at the directory above the checkout. Dir.glob finds nothing there, the with range for context defines no example, and nothing says so: on master the suite runs 1464 examples with 0 failures, and none of them comes from the 79 documents in expectation/version_sat/*.yaml. The six unit test jobs of the master pipeline at e39d2a55 report exactly those 1464 examples.

The path is built from __dir__, so the working directory does not matter, only where the checkout is. A pipeline checks the project out at /builds/gitlab-org/ruby/gems/semver_dialects, so the spec looks for /builds/gitlab-org/ruby/gems/expectation/version_sat, which does not exist, and a local run looks in the parent directory of the clone.

This MR resolves the path from spec/ with File.expand_path('..', __dir__) and changes nothing else. The suite then runs 305 more examples: the 290 includes and excludes examples of the 64 resolved documents, which all pass on master, and one pending example for each of the 15 confirmed and dismissed documents.

The gem itself does not change, so there is no changelog entry or version bump, as in !127 (merged).

This follows up the review of !130 (merged), where the root_dir problem was confirmed and we agreed it belongs in its own MR. The two branches merge without conflicts, and together they run 1802 examples with 0 failures and 14 pending, since !130 (merged) marks one more document resolved.

What are the relevant issue numbers?

None. I found this while testing !130 (merged) and did not find an issue for it.

Does this MR meet the acceptance criteria?

  • Changelog entry added (not needed: only the spec changes, as in !127 (merged))
  • Documentation created/updated for this project, if necessary (none needed)
  • Tests added for this feature/bug (the change is to the spec: 290 existing examples run again and 15 are listed as pending)
  • Conforms to the code review guidelines
  • Security reports checked/validated by reviewer
Specs, lint and version verification

Run in the ruby:3.2 (3.2.11), ruby:3.3 (3.3.12) and ruby:3.4 (3.4.11) images, the same images the unit test jobs of the !130 (merged) fork pipeline used, amd64, with the tree at /builds/jmrp/semver_dialects as in a fork pipeline and the lockfile frozen. Each command gives the same result on all three versions:

Command master this branch this branch merged with !130 (merged)
bundle exec rspec 1464 examples, 0 failures 1769 examples, 0 failures, 15 pending 1802 examples, 0 failures, 14 pending
bundle exec rspec spec/semver_dialects_spec.rb -e 'with range for', with fail_if_no_examples 0 examples, "All examples were filtered out", exit 1 305 examples, 0 failures, 15 pending 310 examples, 0 failures, 14 pending
bundle exec rubocop 45 files inspected, no offenses detected the same the same
bundle exec rubocop spec/semver_dialects_spec.rb 1 file inspected, no offenses detected the same the same
ruby scripts/version_verification.rb passes passes passes

rspec-core 3.12 has no command-line flag for fail_if_no_examples, so I set it in a file loaded with -r.

Where root_dir points from the checkout's spec/ directory:

File.expand_path('../..', __dir__)  # /builds/jmrp: no expectation files
File.expand_path('..', __dir__)     # /builds/jmrp/semver_dialects: 7 files, 79 documents

I ran amd64 only; the fork pipeline runs both architectures.

Merge request reports

Loading
Loading