Migrate bundled module specs from mocha to rspec-mocks/voxpupuli-test#216
Merged
Migrate bundled module specs from mocha to rspec-mocks/voxpupuli-test#216
Conversation
The ci:modules rake task had silently been a no-op since commit 722532c removed the per-module Rakefiles in July 2025. It iterated each bundled module directory and shelled out to rake spec, which walked up to the top level Rakefile and errored out because no spec task was defined there. Rewrite ci:modules to invoke rspec directly, update each module spec_helper to configure rspec-puppet with a proper module_path, migrate ~420 mocha-style call sites to rspec-mocks, refactor around(:each) + Puppet.override wrappers into before(:each)/after(:each) push_context pairs (rspec-mocks rejects double setup from around hooks running before example.run), and drop mocha from the Gemfile. Fix test bugs that were silently broken while ci:modules was a no-op: rename pcp:// test targets to remote:// (pcp transport was removed from openvox), delete two tests that exercised a dead pcp-only code path in run_task / run_task_with, correct inventory.get_target typos to get_targets, fix wait_until_available argument expectation, and require bolt/target in the prompt spec_helper so Puppet type signatures load. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nmburgan <13688219+nmburgan@users.noreply.github.com>
Replace 13 near-identical module spec_helper.rb files with three-line wrappers that delegate to bolt-modules/shared_spec_helper.rb. The shared helper configures rspec-puppet's module_path to point at bolt-modules/ and modules/ directly, avoiding fixture symlinks. Canary and aggregate retain their BoltSpec::BoltContext#modulepath override since Bolt's task loader does not split a colon-separated RSpec.configuration.module_path string into individual entries. Adopt voxpupuli-test in the Gemfile to bundle rspec-puppet and friends via a single convention-aligned gem. Drop rspec-puppet and puppet_fixtures as standalone direct deps. Delete the stale .fixtures.yml files in canary and aggregate. Their old symlink-based fixture setup is no longer needed now that the shared helper puts bolt-modules/ on the modulepath directly, and the stale spec/fixtures/modules/boltlib symlinks were in fact causing rspec's default spec discovery to descend into them and re-run boltlib's specs from the wrong module's context. Apply the corresponding rubocop autocorrections to spec files under bolt-modules that rubocop-rspec 3.9 (pulled in transitively by voxpupuli-test) now flags. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nmburgan <13688219+nmburgan@users.noreply.github.com>
bastelfreak
reviewed
Apr 14, 2026
Signed-off-by: nmburgan <13688219+nmburgan@users.noreply.github.com>
Contributor
|
LGTM, except minor UX issue. It's impossible to understand where those Though, I believe the path should be displayed as part of an error if any.. |
jay7x
approved these changes
Apr 15, 2026
Member
Author
|
Yeah, good point. When I have time to get back to this after fixing the release issues, I'll see if I can make that better. |
Signed-off-by: nmburgan <13688219+nmburgan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has both a rspec-only migration, and then one after where we use voxpupuli-test, which is probably the better option. Left both for consideration.
First commit:
The ci:modules rake task had silently been a no-op since commit 722532c removed the per-module Rakefiles in July 2025. It iterated each bundled module directory and shelled out to rake spec, which walked up to the top level Rakefile and errored out because no spec task was defined there.
Rewrite ci:modules to invoke rspec directly, update each module spec_helper to configure rspec-puppet with a proper module_path, migrate ~420 mocha-style call sites to rspec-mocks, refactor around(:each) + Puppet.override wrappers into before(:each)/after(:each) push_context pairs (rspec-mocks rejects double setup from around hooks running before example.run), and drop mocha from the Gemfile.
Fix test bugs that were silently broken while ci:modules was a no-op: rename pcp:// test targets to remote:// (pcp transport was removed from openvox), delete two tests that exercised a dead pcp-only code path in run_task / run_task_with, correct inventory.get_target typos to get_targets, fix wait_until_available argument expectation, and require bolt/target in the prompt spec_helper so Puppet type signatures load.
Second commit:
Consolidate bundled module spec_helpers via shared helper
Replace 13 near-identical module spec_helper.rb files with three-line
wrappers that delegate to bolt-modules/shared_spec_helper.rb. The shared
helper configures rspec-puppet's module_path to point at bolt-modules/
and modules/ directly, avoiding fixture symlinks. Canary and aggregate
retain their BoltSpec::BoltContext#modulepath override since Bolt's task
loader does not split a colon-separated RSpec.configuration.module_path
string into individual entries.
Adopt voxpupuli-test in the Gemfile to bundle rspec-puppet and friends
via a single convention-aligned gem. Drop rspec-puppet and
puppet_fixtures as standalone direct deps.
Delete the stale .fixtures.yml files in canary and aggregate. Their old
symlink-based fixture setup is no longer needed now that the shared
helper puts bolt-modules/ on the modulepath directly, and the stale
spec/fixtures/modules/boltlib symlinks were in fact causing rspec's
default spec discovery to descend into them and re-run boltlib's specs
from the wrong module's context.
Apply the corresponding rubocop autocorrections to spec files under
bolt-modules that rubocop-rspec 3.9 (pulled in transitively by
voxpupuli-test) now flags.
Checklist
I have:
Signed-off-byannotation to each of my commits