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

Symbol#to_s returns frozen string in Ruby 2.7.0 #1420

Merged
merged 1 commit into from Oct 28, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/brakeman/report/report_text.rb
Expand Up @@ -140,7 +140,7 @@ def generate_templates
end

double_space "Template Output", template_rows.sort_by { |name, value| name.to_s }.map { |template|
[HighLine.new.color(template.first.to_s << "\n", :cyan)] + template[1]
[HighLine.new.color("#{template.first}\n", :cyan)] + template[1]
}.compact
end

Expand Down
26 changes: 16 additions & 10 deletions test/test.rb
Expand Up @@ -58,13 +58,23 @@ def assert_no_warning opts
assert_equal 0, warnings.length, "Found warning when no warning was expected"
end

def find opts = {}, &block
t = opts[:type]
if t.nil? or t == :warning
warnings = report[:generic_warnings]
def warning_table type
case type
when :warning, :generic, nil
:generic_warnings
when :template
:template_warnings
when :controller
:controller_warnings
when :model
:model_warnings
else
warnings = report[(t.to_s << "_warnings").to_sym]
raise "Unknown warning type: #{type.inspect}"
end
end

def find opts = {}, &block
warnings = report[warning_table(opts[:type])]

opts.delete :type

Expand Down Expand Up @@ -93,11 +103,7 @@ def test_number_of_warnings
require 'pp'

expected.each do |type, number|
if type == :warning
warnings = report[:warnings]
else
warnings = report[(type.to_s << "_warnings").to_sym]
end
warnings = report[warning_table(type)]

assert_equal number, warnings.length, lambda { "Expected #{number} #{type} warnings, but found #{warnings.length}:\n#{warnings.map { |w| w.message }.join("\n")}" }
end
Expand Down