Skip to content

Updating tests per #43 on GitHub re: new ggplot2 testing#45

Merged
rossdrucker merged 3 commits intomainfrom
issue-43/ggplot-testing
Jul 27, 2025
Merged

Updating tests per #43 on GitHub re: new ggplot2 testing#45
rossdrucker merged 3 commits intomainfrom
issue-43/ggplot-testing

Conversation

@rossdrucker
Copy link
Collaborator

@rossdrucker rossdrucker commented Jul 26, 2025

See #43

Summary by CodeRabbit

  • Tests
    • Updated plot verification in tests for baseball, basketball, curling, football, hockey, lacrosse, soccer, tennis, and volleyball to use a more robust and idiomatic method for checking plot validity. This improves test clarity and reliability without affecting test coverage or user-facing functionality.
  • Bug Fixes
    • Fixed issue #48 related to ggplot2 test updates.

@vercel
Copy link

vercel bot commented Jul 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sporty-r ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2025 11:21pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 26, 2025

Walkthrough

The test files for various sports plotting functions were updated to use ggplot2::is_ggplot() for verifying that outputs are valid ggplot objects. This replaces previous checks that manually inspected the class vector of plot objects. The change was applied consistently across all relevant test cases without altering test logic or coverage.

Changes

File(s) Change Summary
tests/testthat/test-plots-and-features-baseball.R
tests/testthat/test-plots-and-features-basketball.R
tests/testthat/test-plots-and-features-curling.R
tests/testthat/test-plots-and-features-football.R
tests/testthat/test-plots-and-features-hockey.R
tests/testthat/test-plots-and-features-lacrosse.R
tests/testthat/test-plots-and-features-tennis.R
tests/testthat/test-plots-and-features-volleyball.R
tests/testthat/test-plots-and-features-soccer.R
Replaced manual class vector checks with ggplot2::is_ggplot() in plot verification test assertions
NEWS.md Updated changelog to include bug fix for issue #48 related to ggplot2 test updates

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A bunny hops through fields of code,
Where sports and plots together flowed.
With is_ggplot() now in play,
Simpler checks have come to stay.
Test carrots line up in a row—
Robust and tidy, watch them grow!
🥕✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18d57c5 and 7b5975d.

📒 Files selected for processing (2)
  • NEWS.md (1 hunks)
  • tests/testthat/test-plots-and-features-soccer.R (4 hunks)
✅ Files skipped from review due to trivial changes (2)
  • NEWS.md
  • tests/testthat/test-plots-and-features-soccer.R
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: ubuntu-latest (devel)
  • GitHub Check: ubuntu-latest (release)
  • GitHub Check: pkgdown
  • GitHub Check: ubuntu-latest (oldrel-1)
  • GitHub Check: macOS-latest (release)
  • GitHub Check: windows-latest (release)
  • GitHub Check: lint
  • GitHub Check: test-coverage
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-43/ggplot-testing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (5)
tests/testthat/test-plots-and-features-curling.R (1)

6-7: Prefer expect_s3_class() for brevity & richer failure messages

ggplot2::is_ggplot() works, but testthat::expect_s3_class(wcf_sheet, "ggplot") makes the intent explicit, removes the extra helper call, and yields clearer diagnostics if the check fails. Consider switching across the suite for consistency with common testthat idioms.

tests/testthat/test-plots-and-features-volleyball.R (1)

6-7: Consider expect_s3_class() for concise, idiomatic testing

Same rationale as in the curling tests:

expect_s3_class(ncaa_court, "ggplot")

keeps the assertion terse and leverages testthat-native helpers.

tests/testthat/test-plots-and-features-lacrosse.R (1)

6-7: Swap to expect_s3_class() for alignment with testthat style

Applying expect_s3_class(nll_field, "ggplot") shortens the assertion and unifies style with other object-type checks you may have.

tests/testthat/test-plots-and-features-tennis.R (1)

6-7: Minor style tweak: use expect_s3_class()

For consistency with common testthat practice and the rest of the suite:

expect_s3_class(itf_court, "ggplot")
tests/testthat/test-plots-and-features-hockey.R (1)

6-7: Use expect_s3_class() for clearer intent

Replacing with expect_s3_class(nhl_rink, "ggplot") trims boilerplate and standardises assertions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4251f5 and 18d57c5.

📒 Files selected for processing (9)
  • tests/testthat/test-plots-and-features-baseball.R (3 hunks)
  • tests/testthat/test-plots-and-features-basketball.R (3 hunks)
  • tests/testthat/test-plots-and-features-curling.R (3 hunks)
  • tests/testthat/test-plots-and-features-football.R (3 hunks)
  • tests/testthat/test-plots-and-features-hockey.R (3 hunks)
  • tests/testthat/test-plots-and-features-lacrosse.R (4 hunks)
  • tests/testthat/test-plots-and-features-soccer.R (4 hunks)
  • tests/testthat/test-plots-and-features-tennis.R (2 hunks)
  • tests/testthat/test-plots-and-features-volleyball.R (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: pkgdown
  • GitHub Check: lint
  • GitHub Check: test-coverage
  • GitHub Check: ubuntu-latest (oldrel-1)
  • GitHub Check: ubuntu-latest (devel)
  • GitHub Check: ubuntu-latest (release)
  • GitHub Check: macOS-latest (release)
  • GitHub Check: windows-latest (release)
🔇 Additional comments (12)
tests/testthat/test-plots-and-features-soccer.R (3)

6-7: LGTM! Improved test assertion using ggplot2 API.

The change from manual class checking to ggplot2::is_ggplot() is more robust and idiomatic.


16-17: LGTM! Consistent with modern ggplot2 testing practices.

Good use of the official ggplot2 function for verifying plot objects.


31-32: LGTM! Proper ggplot object verification.

The assertion correctly uses the ggplot2 API for object validation.

tests/testthat/test-plots-and-features-baseball.R (3)

6-7: LGTM! Clean modernization of ggplot verification.

Excellent use of ggplot2::is_ggplot() for robust plot object validation.


16-17: LGTM! Consistent test improvement.

The change aligns with modern ggplot2 testing best practices.


36-37: LGTM! Proper ggplot object assertion.

Good use of the official ggplot2 API for validating plot objects.

tests/testthat/test-plots-and-features-basketball.R (3)

12-14: LGTM! Excellent modernization of multiple plot assertions.

Both plot objects are properly validated using the idiomatic ggplot2 function.


23-24: LGTM! Consistent with ggplot2 best practices.

Proper use of the official API for plot object verification.


43-44: LGTM! Clean test assertion update.

The change correctly uses ggplot2::is_ggplot() for robust validation.

tests/testthat/test-plots-and-features-football.R (3)

6-7: LGTM! Proper modernization of test assertion.

Good use of ggplot2::is_ggplot() for reliable plot object validation.


16-17: LGTM! Consistent test improvement.

The change follows ggplot2 testing best practices effectively.


26-27: LGTM! Clean and idiomatic test assertion.

Excellent use of the official ggplot2 function for object verification.

@rossdrucker rossdrucker merged commit 5dddf47 into main Jul 27, 2025
11 checks passed
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