1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/spec/warnings_spy/partitioner.rb
2014-12-16 20:30:05 -07:00

36 lines
738 B
Ruby

require 'forwardable'
class WarningsSpy
class Partitioner
extend Forwardable
attr_reader :relevant_warning_groups, :irrelevant_warning_groups
def initialize(reader, filesystem)
@reader = reader
@search_text = filesystem.project_dir
end
def partition
@relevant_warning_groups, @irrelevant_warning_groups =
warning_groups.partition { |group| relevant_warnings?(group) }
end
protected
attr_reader :reader, :search_text
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