Skip to content

test: add unit tests and wire up cookstyle autocorrect#1

Merged
ramereth merged 2 commits into
mainfrom
add-unit-tests
Apr 24, 2026
Merged

test: add unit tests and wire up cookstyle autocorrect#1
ramereth merged 2 commits into
mainfrom
add-unit-tests

Conversation

@ramereth
Copy link
Copy Markdown
Collaborator

  • Add RSpec test suite (.rspec, spec/spec_helper.rb) with 20 specs:
    • spec/kitchen-sync/version_spec.rb: validate VERSION constant
    • spec/kitchen-sync/checksums_spec.rb: invoke bundled checksums.rb
      against tmpdirs and validate JSON output
    • spec/kitchen-sync/core_ext_spec.rb: cover the ChefBase#init_command
      monkey-patch using a stub ChefBase (test-kitchen 4 no longer ships it)
    • spec/kitchen/transport/{rsync,sftp}_spec.rb: validate transport class
      structure, defaults, and constants
  • Add rspec ~> 3.0 development dependency
  • Add rake spec task plus test/unit aliases (with desc so they show
    up in rake -T); default task now runs spec then style
  • Add unit test job to .github/workflows/lint.yml gated on cookstyle/yamllint
  • Apply cookstyle/chefstyle autocorrect across lib/ and gemspec:
    • Switch single-quoted strings to double-quoted
    • Replace deprecated File.exists? with File.exist?
    • Replace "..." % args with format(...)
    • Add unless defined?(...) guards to stdlib requires
    • Fix indentation, guard-clause spacing, and end alignment
    • Freeze mutable string constants
    • Use each_with_object instead of inject returning memo
    • Use $CHILD_STATUS / $INPUT_RECORD_SEPARATOR via English
    • Update copyright header format and bump rubygems source to https
  • Drop dead File.directory?(local) no-op left by autocorrect in sftp.rb

Signed-off-by: Lance Albertson lance@osuosl.org

Description

Please describe what this change achieves

Issues Resolved

List any existing issues this PR resolves, or any Discourse or
StackOverflow discussions that are relevant

Type of Change

Our release process assumes you are using Conventional Commit messages.

The most important prefixes you should have in mind are:

  • _fix_: which represents bug fixes, and correlates to a SemVer patch.
  • _feat_: which represents a new feature, and correlates to a SemVer minor.
  • _feat!_:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a major version change.

If you have not included a conventional commit message this can be fixed on merge.

Check List

- Add RSpec test suite (.rspec, spec/spec_helper.rb) with 20 specs:
  - spec/kitchen-sync/version_spec.rb: validate VERSION constant
  - spec/kitchen-sync/checksums_spec.rb: invoke bundled checksums.rb
    against tmpdirs and validate JSON output
  - spec/kitchen-sync/core_ext_spec.rb: cover the ChefBase#init_command
    monkey-patch using a stub ChefBase (test-kitchen 4 no longer ships it)
  - spec/kitchen/transport/{rsync,sftp}_spec.rb: validate transport class
    structure, defaults, and constants
- Add `rspec ~> 3.0` development dependency
- Add rake `spec` task plus `test`/`unit` aliases (with desc so they show
  up in `rake -T`); default task now runs `spec` then `style`
- Add unit test job to .github/workflows/lint.yml gated on cookstyle/yamllint
- Apply cookstyle/chefstyle autocorrect across lib/ and gemspec:
  - Switch single-quoted strings to double-quoted
  - Replace deprecated File.exists? with File.exist?
  - Replace `"..." % args` with format(...)
  - Add `unless defined?(...)` guards to stdlib requires
  - Fix indentation, guard-clause spacing, and end alignment
  - Freeze mutable string constants
  - Use `each_with_object` instead of `inject` returning memo
  - Use $CHILD_STATUS / $INPUT_RECORD_SEPARATOR via English
  - Update copyright header format and bump rubygems source to https
- Drop dead `File.directory?(local)` no-op left by autocorrect in sftp.rb

Signed-off-by: Lance Albertson <lance@osuosl.org>
Signed-off-by: Lance Albertson <lance@osuosl.org>
Copy link
Copy Markdown

@Stromweld Stromweld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, not sure what the require "English" is for in a couple of places. Never seen that one before.

@ramereth
Copy link
Copy Markdown
Collaborator Author

Good question.

This require is needed because this file logs the rsync exit code using
$CHILD_STATUS.exitstatus. CHILDSTATUS is not a standalone core global; it is
the English alias for CHILD_STATUS, provided by requiring the English standard
library. Without require "English", that alias is not available and this
warning path would break.

Upstream Ruby docs:

If we wanted to drop require "English", we would need to switch this code to
use $?.exitstatus instead.

@ramereth ramereth merged commit 1406f42 into main Apr 24, 2026
9 of 10 checks passed
@ramereth ramereth deleted the add-unit-tests branch April 24, 2026 17:43
@Stromweld
Copy link
Copy Markdown

nice good to know thanks

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.

2 participants