File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ module QueryPackwerk
2626 # TODO: module_function isn't playing nicely with Sorbet
2727 extend self # rubocop:todo Style/ModuleFunction
2828
29+ sig { params ( name : String ) . returns ( T . nilable ( QueryPackwerk ::Package ) ) }
30+ def package ( name )
31+ Packages . where ( name : name ) . first
32+ end
33+
2934 # All violations for a pack
3035 sig { params ( pack_name : String ) . returns ( QueryPackwerk ::Violations ) }
3136 def violations_for ( pack_name )
Original file line number Diff line number Diff line change 44RSpec . describe QueryPackwerk do
55 include_context 'pseudo packs'
66
7+ describe '#package' do
8+ it 'gets a package by name' do
9+ expect ( described_class . package ( package_name ) ) . to be_a ( QueryPackwerk ::Package )
10+ end
11+
12+ it 'returns nil if the package does not exist' do
13+ expect ( described_class . package ( 'not_here' ) ) . to be_nil
14+ end
15+ end
16+
717 describe '#violations_for' do
818 it 'gets all violations for a pack' do
919 violations = described_class . violations_for ( package_name )
You can’t perform that action at this time.
0 commit comments