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

Lots of warnings about when running unit tests #302

Closed
danielparks opened this issue Sep 23, 2022 · 3 comments · Fixed by #308
Closed

Lots of warnings about when running unit tests #302

danielparks opened this issue Sep 23, 2022 · 3 comments · Fixed by #308
Labels

Comments

@danielparks
Copy link
Contributor

danielparks commented Sep 23, 2022

Describe the Bug

Running bundle exec rake spec generates lots of warnings even though the tests run successfully.

Most of the warnings are about two calls to ERB.new. The unique warnings are:

…/puppet-strings/lib/puppet-strings/markdown/table_of_contents.rb:21: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
…/puppet-strings/lib/puppet-strings/markdown/table_of_contents.rb:21: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
…/puppet-strings/lib/puppet-strings/markdown/base.rb:186: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
…/puppet-strings/lib/puppet-strings/markdown/base.rb:186: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.

There are also a bunch of “errors” that don’t result in test failures. They are all identical: (Update: I split this out into #307)

[error]: Failed to parse (stdin): Syntax error at 'param1' (line: 5, column: 19)

I have tested this with Ruby 2.6.0p0 (not 2.3.0, see #301) and 3.1.2p20. In 2.6.0 the ERB warnings are not present, but the “ Failed to parse” messages are present in both.

Expected Behavior

No extra output when running unit tests.

Steps to Reproduce

Steps to reproduce the behavior:

  1. bundle exec rake spec

Environment

  • ruby 3.1.2p20
  • Current main branch (dba16ed)
@danielparks
Copy link
Contributor Author

After a bunch of testing, it looks like the parse error is at

plan plann(String $param1, $param2, Integer $param3 = 1) {

The ERB error, on the other hand, is easy to fix as long as the minimum ruby version is 2.6.0.

danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 25, 2022
Unfortunately, this fix will not work with Ruby <2.6.0.
danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 25, 2022
This has to special case Ruby <2.6.0 since those versions will interpret
the keyword argument as a hash passed as the second argument.

Without this change running this code in Ruby 2.6+ will generate
warnings about the parameters passed to `ERB.new`.
@danielparks
Copy link
Contributor Author

I fixed the ERB error for all supported Ruby versions: main...danielparks:puppet-strings:fix_erb

danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
This has to special case Ruby <2.6.0 since those versions will interpret
the keyword argument as a hash passed as the second argument.

Without this change running this code in Ruby 2.6+ will generate
warnings about the parameters passed to `ERB.new`.
danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
This has to special case Ruby <2.6.0 since those versions will interpret
the keyword argument as a hash passed as the second argument.

Without this change running this code in Ruby 2.6+ will generate
warnings about the parameters passed to `ERB.new`.
danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
This has to special case Ruby <2.6.0 since those versions will interpret
the keyword argument as a hash passed as the second argument.

Without this change running this code in Ruby 2.6+ will generate
warnings about the parameters passed to `ERB.new`.
danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
This has to special case Ruby <2.6.0 since those versions will interpret
the keyword argument as a hash passed as the second argument.

Without this change running this code in Ruby 2.6+ will generate
warnings about the parameters passed to `ERB.new`.
@chelnak chelnak linked a pull request Sep 26, 2022 that will close this issue
chelnak pushed a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
This has to special case Ruby <2.6.0 since those versions will interpret
the keyword argument as a hash passed as the second argument.

Without this change running this code in Ruby 2.6+ will generate
warnings about the parameters passed to `ERB.new`.
@chelnak
Copy link
Contributor

chelnak commented Sep 26, 2022

Fixed in #302 - Thanks @danielparks

@chelnak chelnak closed this as completed Sep 26, 2022
chelnak added a commit that referenced this issue Sep 26, 2022
(#302) Fix warnings generated by ERB.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants