Skip to content

Migrate bundled module specs from mocha to rspec-mocks/voxpupuli-test#216

Merged
nmburgan merged 4 commits intomainfrom
module_tests
Apr 15, 2026
Merged

Migrate bundled module specs from mocha to rspec-mocks/voxpupuli-test#216
nmburgan merged 4 commits intomainfrom
module_tests

Conversation

@nmburgan
Copy link
Copy Markdown
Member

@nmburgan nmburgan commented Apr 14, 2026

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:

  • read the CONTRIBUTING.md document
  • read and accepted the Developer Certificate of Origin document and added a Signed-off-by annotation to each of my commits
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

nmburgan and others added 2 commits April 14, 2026 17:13
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>
@nmburgan nmburgan changed the title Migrate bundled module specs from mocha to rspec-mocks Migrate bundled module specs from mocha to rspec-mocks/voxpupuli-test Apr 14, 2026
Comment thread .rubocop_todo.yml Outdated
Signed-off-by: nmburgan <13688219+nmburgan@users.noreply.github.com>
@jay7x
Copy link
Copy Markdown
Contributor

jay7x commented Apr 15, 2026

LGTM, except minor UX issue. It's impossible to understand where those rspec spec were executed. See https://github.com/OpenVoxProject/openbolt/actions/runs/24417507542/job/71333286533?pr=216 e.g.

Though, I believe the path should be displayed as part of an error if any..

@nmburgan
Copy link
Copy Markdown
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>
@nmburgan nmburgan merged commit 4b35ac6 into main Apr 15, 2026
11 checks passed
@nmburgan nmburgan deleted the module_tests branch April 15, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants