Skip to content

Commit

Permalink
Fix filter logic [bugfix]
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpb committed May 12, 2021
1 parent c3b23e9 commit 766339b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Pavel_Borisov/2/lib/machinery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def process!
completion_percentage = (processed_count / total_count.to_f * 100).to_i
yield(completion_percentage, item.domain) if block_given?
end
reject_results_with_word!(@filtered_word) if @filtered_word
keep_results_with_word!(@filtered_word) if @filtered_word
self
end

Expand Down Expand Up @@ -136,8 +136,8 @@ def reject_solutions!
end
end

def reject_results_with_word!(word)
@list.reject! do |response|
def keep_results_with_word!(word)
@list.keep_if do |response|
body_text = Nokogiri::HTML.parse(response.body).css('body').text
body_text.downcase.match? word.downcase
end
Expand Down
4 changes: 2 additions & 2 deletions Pavel_Borisov/2/test/machinery_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def test_exclude_solutions_rejects_gitlab
DomainsList.new(TEST_DOMAINS_FILE, { 'exclude-solutions': true }).list.map(&:domain)
end

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

0 comments on commit 766339b

Please sign in to comment.