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

Ruby 3.1: Add specs for ERB.new #961

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Lint/EmptyWhen:
- language/case_spec.rb
- optional/capi/spec_helper.rb

Lint/ErbNewArguments:
Exclude:
- 'library/erb/new_spec.rb'

Lint/FormatParameterMismatch:
Exclude:
- 'core/kernel/shared/sprintf.rb'
Expand Down
16 changes: 16 additions & 0 deletions library/erb/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,20 @@
ERB.new(@eruby_str).result
->{ ERB.new("<%= list %>").result }.should raise_error(NameError)
end

describe "warning about arguments" do
ruby_version_is "3.1" do
it "warns when passed safe_level and later arguments" do
-> {
ERB.new(@eruby_str, nil, '%')
}.should complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
end

it "does not warn when passed arguments as keyword argument" do
-> {
ERB.new(@eruby_str, trim_mode: '%')
}.should_not complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
end
end
end
end