-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add RSpec test suite and multi-version Ruby CI support #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add comprehensive RSpec test suite with 17 test cases covering: - Module constants validation - allowed_destinations parser (comments, whitespace, CIDR) - Version format validation - CLI command dispatch and output - Update CI workflow to test against Ruby 2.7, 3.0, 3.1, 3.2, 3.3, 3.4 - Add Rakefile with default task running rubocop and rspec - Add bundler-cache to CI for faster builds - Fix CLI#dispatch to parse arguments array instead of global ARGV - Add CLAUDE.md with project architecture and development guidance - Update .gitignore for test artifacts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
WalkthroughAdds RSpec-based tests, test config and helpers, CI matrix testing across Ruby versions, RuboCop and Rake tasks, a developer doc (CLAUDE.md), .gitignore updates, and a small CLI change to parse an explicit arguments array. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant OptionParser
rect rgba(135,206,235,0.12)
Note over CLI,OptionParser: New explicit-arguments parsing
User->>CLI: invoke with args array
CLI->>OptionParser: parse!(arguments)
OptionParser-->>CLI: parsed options
CLI-->>User: execute subcommand / print usage
end
sequenceDiagram
participant GitHubActions as GH Actions
participant Lint
participant Test
participant ReleasePlease
participant Release
rect rgba(144,238,144,0.10)
Note over GH Actions,Test: CI job ordering (changed)
GH Actions->>Lint: run lint
GH Actions->>Test: run test matrix (Ruby 2.7–3.4)
GH Actions->>ReleasePlease: run release-please
ReleasePlease-->>GH Actions: done
Lint-->>GH Actions: done
Test-->>GH Actions: done
GH Actions->>Release: run release (needs: lint, test, release-please)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Comment |
Prevents RuboCop from scanning vendored gems with obsolete configurations that cause CI failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
Gemfile (1)
7-12: Consider grouping development dependencies.While the current structure works, it's more idiomatic to group
rakeandrubocopin a:developmentgroup to clearly separate development tools from runtime dependencies.Apply this diff for a more conventional structure:
-gem 'rake' -gem 'rubocop' - -group :test do +group :development do + gem 'rake' + gem 'rubocop' gem 'rspec', '~> 3.13' endOr use separate groups if you prefer:
-gem 'rake' -gem 'rubocop' - +group :development do + gem 'rake' + gem 'rubocop' +end + group :test do gem 'rspec', '~> 3.13' endspec/deploy_agent_spec.rb (2)
32-67: Consider adding a test case for missing access file.The test suite comprehensively covers parsing behaviors (whitespace, comments, field extraction), but doesn't test what happens when the access file doesn't exist. The implementation uses
File.read(ACCESS_PATH)which will raiseErrno::ENOENTif the file is missing—a realistic production scenario.Add a test case to verify expected behavior when the access file is absent:
it 'handles missing access file' do # Don't create temp_access_file expect { DeployAgent.allowed_destinations }.to raise_error(Errno::ENOENT) # Or if the implementation should handle this gracefully: # expect(DeployAgent.allowed_destinations).to eq([]) end
33-33: Optional: Consider usingDir.tmpdirfor better portability.While
/tmpworks fine for *nix systems (which this project targets), usingDir.tmpdirorTempfilewould make tests more portable across platforms.require 'tmpdir' let(:temp_access_file) { File.join(Dir.tmpdir, "test_access_#{Process.pid}") }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
.github/workflows/ci.yml(2 hunks).gitignore(1 hunks).rspec(1 hunks).rubocop.yml(1 hunks)CLAUDE.md(1 hunks)Gemfile(1 hunks)Rakefile(1 hunks)lib/deploy_agent/cli.rb(1 hunks)spec/deploy_agent/cli_spec.rb(1 hunks)spec/deploy_agent/version_spec.rb(1 hunks)spec/deploy_agent_spec.rb(1 hunks)spec/spec_helper.rb(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
spec/deploy_agent/cli_spec.rb (1)
lib/deploy_agent/cli.rb (3)
dispatch(5-129)dispatch(7-23)version(92-94)
spec/deploy_agent_spec.rb (1)
lib/deploy_agent.rb (1)
allowed_destinations(17-23)
🪛 markdownlint-cli2 (0.18.1)
CLAUDE.md
118-118: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (12)
.rubocop.yml (1)
6-6: LGTM! Standard exclusion for vendored dependencies.Excluding
vendor/**/*is the correct approach when usingbundler-cache, which will install gems to the vendor directory..rspec (1)
1-3: LGTM! Standard RSpec configuration.The configuration options are appropriate and follow RSpec best practices for a well-structured test suite.
.gitignore (1)
8-11: LGTM! Appropriate test artifact exclusions.The patterns correctly exclude RSpec's example status file and coverage reports from version control.
Rakefile (1)
1-10: LGTM! Standard Rake task configuration.The task definitions are idiomatic and align well with the CI workflow and development commands documented in CLAUDE.md.
.github/workflows/ci.yml (3)
12-12: LGTM! Bundler caching improves CI performance.Adding
bundler-cache: trueis a best practice that will speed up workflow runs by caching installed gems.
16-35: Verify support for EOL Ruby versions is intentional.The test matrix includes Ruby 2.7 and 3.0, which have reached end-of-life (March 2023 and March 2024 respectively). While testing against these versions may be intentional for backward compatibility, please confirm this aligns with your support policy.
49-49: LGTM! Proper release gating.Requiring the
testjob to pass before releasing is the correct approach and prevents publishing broken versions.lib/deploy_agent/cli.rb (1)
16-16: LGTM! Enables testable CLI behavior.Explicitly parsing the
argumentsparameter instead of relying on the globalARGVmakes thedispatchmethod testable and more predictable. This change is essential for the new test suite.spec/deploy_agent/version_spec.rb (1)
1-13: LGTM! Clean and effective version validation.The tests appropriately validate both the presence and format of the VERSION constant. The regex pattern correctly uses
\Aand\zanchors for precise semantic version matching.spec/deploy_agent/cli_spec.rb (1)
1-27: LGTM! Comprehensive CLI testing.The test suite effectively covers the key CLI behaviors:
- Command dispatch with valid arguments
- Error handling for invalid commands
- Usage display for missing arguments
- Exact version output validation
The use of output matchers is appropriate for testing CLI interfaces, and the tests correctly leverage the updated
dispatch(arguments)signature.spec/spec_helper.rb (1)
1-24: LGTM! Excellent RSpec configuration following best practices.The configuration includes essential quality safeguards:
disable_monkey_patching!(line 17) keeps the global namespace cleanverify_partial_doubles(line 11) prevents mock misuse- Random ordering (line 22) helps identify test interdependencies
- Example persistence (line 16) enables efficient failure reruns
This is a solid foundation for the test suite.
spec/deploy_agent_spec.rb (1)
6-30: LGTM! Thorough validation of module constants.All six configuration path constants are correctly validated against their expected default locations under
~/.deploy.
🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Chores
Documentation