Skip to content

Commit 766339b

Browse files
committed
Fix filter logic [bugfix]
1 parent c3b23e9 commit 766339b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Pavel_Borisov/2/lib/machinery.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def process!
101101
completion_percentage = (processed_count / total_count.to_f * 100).to_i
102102
yield(completion_percentage, item.domain) if block_given?
103103
end
104-
reject_results_with_word!(@filtered_word) if @filtered_word
104+
keep_results_with_word!(@filtered_word) if @filtered_word
105105
self
106106
end
107107

@@ -136,8 +136,8 @@ def reject_solutions!
136136
end
137137
end
138138

139-
def reject_results_with_word!(word)
140-
@list.reject! do |response|
139+
def keep_results_with_word!(word)
140+
@list.keep_if do |response|
141141
body_text = Nokogiri::HTML.parse(response.body).css('body').text
142142
body_text.downcase.match? word.downcase
143143
end

Pavel_Borisov/2/test/machinery_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def test_exclude_solutions_rejects_gitlab
5050
DomainsList.new(TEST_DOMAINS_FILE, { 'exclude-solutions': true }).list.map(&:domain)
5151
end
5252

53-
def test_filter_word_rejects_results_with_word_in_body
54-
assert_equal ['subdomain.example.com', 'gitlab.com'],
53+
def test_filter_word_keeps_only_results_with_word_in_body
54+
assert_equal ['example.com'],
5555
DomainsList.new(TEST_DOMAINS_FILE, { filter: 'example' }).process!.list.map(&:domain)
5656
end
5757
end

0 commit comments

Comments
 (0)