-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Increase compatibility of the require patch
The previous patch did not declare the overwritten require method as module_function. This led to subtle changes when calling respond_to?(:require) on object later, which could return true when it should not. This commit changes the code to use module_function. It further moves the loader into a module that is prepended, to avoid the addition of method aliases.
- Loading branch information
Showing
3 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Mnemosyne::Probes do | ||
it 'injects the loader into Kernel#require' do | ||
expect(Mnemosyne::Probes).to receive(:required).with('mnemosyne/probes') | ||
require 'mnemosyne/probes' | ||
end | ||
|
||
it 'does not make objects respond to require' do | ||
expect(Object.new).not_to respond_to(:require) | ||
end | ||
end |