From b4082877fd2c014cdb76287aec017cee71d005a0 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Thu, 20 Nov 2014 12:33:10 -0700 Subject: [PATCH] Be better about looking for warnings on Travis --- spec/warnings_spy/partitioner.rb | 13 ++++++++++--- spec/warnings_spy/reader.rb | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/spec/warnings_spy/partitioner.rb b/spec/warnings_spy/partitioner.rb index 8d58bf58..c6a70531 100644 --- a/spec/warnings_spy/partitioner.rb +++ b/spec/warnings_spy/partitioner.rb @@ -13,9 +13,7 @@ class WarningsSpy def partition @relevant_warning_groups, @irrelevant_warning_groups = - warning_groups.partition do |group| - group.any? { |line| line.include?(search_text) } - end + warning_groups.partition { |group| relevant_warnings?(group) } end protected @@ -25,5 +23,14 @@ class WarningsSpy private def_delegators :reader, :warning_groups + + def relevant_warnings?(group) + first_line = group[0] + first_line.start_with?("#{project_root}/lib") + end + + def project_root + File.expand_path('../../..') + end end end diff --git a/spec/warnings_spy/reader.rb b/spec/warnings_spy/reader.rb index fb685275..5dfcde09 100644 --- a/spec/warnings_spy/reader.rb +++ b/spec/warnings_spy/reader.rb @@ -28,14 +28,14 @@ class WarningsSpy def process_line(line) if start_of_group?(line) add_group(current_group) - current_group.clear + @current_group = [] end current_group << line end def start_of_group?(line) - line =~ /^\W/ + line =~ /^\S/ end def add_group(group)