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

Ignore eval method redefined warning #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/ruby_warning_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ def backtrace?(line)
end

def eval_redefined?(line)
line =~ /\(eval\):\d+: warning: previous definition of .+ was here/
line =~ /\(eval\):\d+: (warning: previous definition of .+ was here|warning: method redefined; .+)/
end
end
12 changes: 9 additions & 3 deletions test/ruby_warnings_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "stringio"
STDOUT.sync = true

class RubyWarningsFilterTest < MiniTest::Test
class RubyWarningsFilterTest < Minitest::Test
def setup
@gems_dir = File.expand_path("../gems", __FILE__)
@gems_link_dir = File.expand_path("../gems-link", __FILE__)
Expand Down Expand Up @@ -62,19 +62,25 @@ def test_method_redefined_eval
@err.write "/path/to/ruby/2.2.0/gems/compass-core-1.0.3/lib/gradient_support.rb:319: warning: method redefined; discarding old to_moz\n"
@err.write "(eval):2: warning: previous definition of to_moz was here\n"

@err.write "/path/to/ruby/2.2.0/gems/sitemap_generator-6.3.0/lib/sitemap_generator/templates.rb:10: warning: method redefined; discarding old sitemap_sample\n"
@err.write "(eval):1: warning: method redefined; discarding old sitemap_sample\n"

# in app
@err.write "/path/to/app.rb:123: warning: method redefined; discarding old foo\n"
@err.write "(eval):2: warning: previous definition of foo was here\n"

@err.write "(eval):1: warning: method redefined; discarding old sitemap_sample\n"

@err.write "something other\n"

assert_equal \
"/path/to/app.rb:123: warning: method redefined; discarding old foo\n"\
"(eval):2: warning: previous definition of foo was here\n"\
"(eval):1: warning: method redefined; discarding old sitemap_sample\n"\
"something other\n",
@err.string
assert_equal 2, @err.ruby_warnings

assert_equal 3, @err.ruby_warnings
end

def test_template_warning
Expand Down