Skip to content

Commit

Permalink
Add names for department to Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Eres authored and bbatsov committed Mar 22, 2021
1 parent 44e5553 commit 62ca1ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rubocop/cop/registry.rb
Expand Up @@ -184,6 +184,10 @@ def names
cops.map(&:cop_name)
end

def names_for_department(department)
cops.select { |cop| cop.department == department.to_sym }.map(&:cop_name)
end

def ==(other)
cops == other.cops
end
Expand Down
7 changes: 7 additions & 0 deletions spec/rubocop/cop/registry_spec.rb
Expand Up @@ -350,4 +350,11 @@
expect(registry.department?('Foo')).to be false
end
end

describe 'names_for_department' do
it 'returns array of cops for specified department' do
expect(registry.names_for_department('Lint'))
.to eq %w[Lint/BooleanSymbol Lint/DuplicateMethods]
end
end
end

0 comments on commit 62ca1ae

Please sign in to comment.