Skip to content

Commit e2f4e3d

Browse files
authored
Return nil if class constant cannot be found (#71)
* add rescue block * remove nokogiri update
1 parent 69bcee9 commit e2f4e3d

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
code_ownership (1.33.0)
4+
code_ownership (1.33.1)
55
code_teams (~> 1.0)
66
packs
77
sorbet-runtime (>= 0.5.10821)

code_ownership.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = 'code_ownership'
3-
spec.version = '1.33.0'
3+
spec.version = '1.33.1'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['[email protected]']
66
spec.summary = 'A gem to help engineering teams declare ownership of code'

lib/code_ownership/private.rb

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def self.path_from_klass(klass)
7070
else
7171
nil
7272
end
73+
rescue NameError
74+
nil
7375
end
7476

7577
#

spec/lib/code_ownership_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@
210210
expect(CodeOwnership).to_not have_received(:for_file)
211211
expect(Object).to_not have_received(:const_source_location)
212212
end
213+
214+
it 'returns nil if the class constant cannot be found' do
215+
allow(CodeOwnership).to receive(:for_file)
216+
allow(Object).to receive(:const_source_location).and_raise(NameError)
217+
expect(CodeOwnership.for_class(MyFile)).to eq nil
218+
end
213219
end
214220

215221
describe '.for_team' do

0 commit comments

Comments
 (0)