Skip to content

Commit ac6cf26

Browse files
committed
fix: Missing gems will no longer attempt to be hooked
Because we're propagating the return value of Logger#info, a warning message causes Config::Package.build_from_gem to return `true`, causing Config::TargetMethods.package_hooks to continue processing hooks on an invalid type (TrueClass instead of Config::Package).
1 parent 2615c13 commit ac6cf26

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/appmap/util.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ def startup_message(msg)
226226
elsif ENV['DEBUG'] == 'true'
227227
warn msg
228228
end
229-
end
229+
230+
nil
231+
end
230232

231233
def ruby_minor_version
232234
@ruby_minor_version ||= RUBY_VERSION.split('.')[0..1].join('.').to_f

spec/config_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,21 @@
243243
FIXTURE
244244
end
245245

246+
describe AppMap::Config::Package do
247+
describe :build_from_gem do
248+
let(:mock_rails) { double(logger: double(info: true)) }
249+
250+
before do
251+
stub_const('Rails', mock_rails)
252+
end
253+
254+
it 'does not return a truthy value on failure' do
255+
result = AppMap::Config::Package.build_from_gem('some_missing_gem_name', optional: true)
256+
expect(result).to_not be_truthy
257+
end
258+
end
259+
end
260+
246261
context do
247262
let(:warnings) { @warnings ||= [] }
248263
let(:warning) { warnings.join }

0 commit comments

Comments
 (0)