Skip to content
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

Stub node_version more clearly in tests #1234

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

louis-antonopoulos
Copy link
Contributor

This PR:

  • Reworks the stubbing of node_version in tests in preparation for resolving Issue 1233

Co-authored-by: Steve Polito [email protected]

Object.any_instance.stubs(:`).returns("v1.7.4\n")
actual = Suspenders::Generators::PrerequisitesGenerator.new.node_version

assert_match(/^1\.7\.4$/, actual)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevepolitodesign and I tried using assert_equal here, but the \n in the stub causes the test output to not show expected vs. actual if you introduce a regression.

This Slack conversation has more details.

louis-antonopoulos and others added 3 commits November 1, 2024 16:06
The start-of-line ^ and end-of-line $ ensure that the regular expression isn't matching part of the string. Otherwise,

assert_match(/20\.0\.0/, file)

would pass if file contained 20.0.00, for example.

Co-authored-by: Steve Polito <[email protected]>
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