1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Allow non .aprc File.readable? calls

`stub_dotfile!` was blocking all calls to `File.readable?` instead
of just calls to load the `.aprc` file. This meant that trying to
use other libraries, such as pry, which relied on `File.readable?`
would fail in instances where `stub_dotfile!` had been called.

This change fixes that, while keeping the original intended
behaviour.
This commit is contained in:
Gerard Caulfield 2016-07-01 12:00:56 +10:00
parent 056e5c7263
commit 5b472ccbe6
No known key found for this signature in database
GPG key ID: 623B327128A9BEC3
2 changed files with 3 additions and 2 deletions

View file

@ -173,7 +173,7 @@ module AwesomePrint
# Load ~/.aprc file with custom defaults that override default options. # Load ~/.aprc file with custom defaults that override default options.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def merge_custom_defaults! def merge_custom_defaults!
dotfile = File.join(ENV["HOME"], ".aprc") dotfile = File.join(ENV['HOME'], '.aprc')
load dotfile if File.readable?(dotfile) load dotfile if File.readable?(dotfile)
merge_options!(AwesomePrint.defaults) if AwesomePrint.defaults.is_a?(Hash) merge_options!(AwesomePrint.defaults) if AwesomePrint.defaults.is_a?(Hash)
rescue => e rescue => e

View file

@ -71,7 +71,8 @@ def normalize_object_id_strings(str, options)
end end
def stub_dotfile! def stub_dotfile!
dotfile = File.join(ENV["HOME"], ".aprc") dotfile = File.join(ENV['HOME'], '.aprc')
allow(File).to receive(:readable?).and_call_original
expect(File).to receive(:readable?).at_least(:once).with(dotfile).and_return(false) expect(File).to receive(:readable?).at_least(:once).with(dotfile).and_return(false)
end end