Skip to content

Add comprehensive test suite with RSpec, Rubocop, and CI#1

Closed
dblock wants to merge 14 commits intomainfrom
add-rspec-tests
Closed

Add comprehensive test suite with RSpec, Rubocop, and CI#1
dblock wants to merge 14 commits intomainfrom
add-rspec-tests

Conversation

@dblock
Copy link
Copy Markdown
Owner

@dblock dblock commented Dec 25, 2025

Summary

This PR adds a complete test infrastructure to the project:

  • RSpec test suite with 36 passing tests
    • 17 tests for DangerPrComment::Reporter class
    • 3 tests for DangerPrComment::VERSION constant
    • 19 tests for install-workflows.sh shell script
  • Rubocop code style enforcement with extensions for Rake and RSpec
  • GitHub Actions workflows for automated testing
  • Rake tasks for running tests and linting

Changes

Testing Infrastructure

  • Add RSpec 3.13 with comprehensive spec_helper configuration
  • Create tests for Reporter class covering all methods and edge cases
  • Create integration tests for install-workflows.sh script
  • Add .rspec configuration for formatted output
  • Add .rspec_status to .gitignore

Code Quality

  • Add Rubocop 1.69+ with rubocop-rake and rubocop-rspec extensions
  • Configure .rubocop.yml with sensible defaults for gem projects
  • Auto-fix existing code style violations
  • All code passes Rubocop checks

CI/CD

  • Add GitHub Actions workflow for running RSpec tests (Ruby 3.3)
  • Add GitHub Actions workflow for running Rubocop
  • Add test status badge to README

Development Experience

  • Update Rakefile with tasks for spec and rubocop
  • Default rake task runs both tests and linting
  • Organize Gemfile with development and test groups
  • Make install-workflows.sh executable

Test Coverage

Reporter Class (17 tests)

  • Initialization and state management
  • JSON export functionality with various scenarios
  • Edge case handling (nil values, missing files, missing PR numbers)
  • Message object extraction
  • Pretty-formatted JSON output

Version Constant (3 tests)

  • Version presence and type validation
  • Semantic versioning format compliance

Install Workflows Script (19 tests)

  • Basic installation and file creation
  • YAML content validation for both workflows
  • --force flag behavior
  • --root option for custom directories
  • --help option
  • Error handling for invalid options

Running Tests

# Run all tests
bundle exec rake

# Run only RSpec tests
bundle exec rake spec

# Run only Rubocop
bundle exec rake rubocop

# Run specific test file
bundle exec rspec spec/danger-pr-comment/reporter_spec.rb

All tests pass and all Rubocop checks pass.

🤖 Generated with Claude Code

dblock and others added 14 commits December 25, 2025 07:25
- Add RSpec 3.13 as development dependency
- Create comprehensive tests for Reporter class (17 examples)
- Add tests for VERSION constant validation
- Configure RSpec with spec_helper and .rspec
- Set up rake task for running tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Test against Ruby 3.3
- Run on push to all branches and all pull requests
- Use bundler-cache for faster builds
- Verify both rspec and rake commands work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Move rspec development dependency to Gemfile
- Remove development dependencies from gemspec

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add Rubocop 1.69 to Gemfile in development group
- Create .rubocop.yml configuration
- Disable overly strict cops for gem project
- Create GitHub Actions workflow to run Rubocop
- Auto-correct Rubocop offenses in existing files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add rubocop-rake and rubocop-rspec gems
- Configure plugins in .rubocop.yml
- Disable overly strict RSpec cops
- Auto-correct RSpec style offenses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove rake task execution from test workflow
- Keep Rubocop in separate workflow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Create 19 test cases covering all script functionality
- Test basic installation, file creation, and content validation
- Test --force flag behavior and file overwriting
- Test --root option for custom directories
- Test --help option and error handling
- Make install-workflows.sh executable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Rename run_script to run_script? (predicate method convention)
- Add rubocop:disable comment for RSpec/DescribeClass
- Change describe to 'Workflow installation script'
- Scope disable comment with enable at end of file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Exclude spec/scripts/**/*_spec.rb from RSpec/DescribeClass cop
- Remove inline rubocop:disable/enable comments from spec file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dblock
Copy link
Copy Markdown
Owner Author

dblock commented Dec 25, 2025

Closing - will create PR on upstream repository instead

@dblock dblock closed this Dec 25, 2025
@dblock dblock deleted the add-rspec-tests branch January 2, 2026 20:54
dblock added a commit that referenced this pull request Jan 2, 2026
Add comprehensive test suite with RSpec, Rubocop, and CI
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.

1 participant