mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Don't load ./.pryrc when it is ~/.pryrc [Fixes #682]
This commit is contained in:
parent
03dc165ebf
commit
d830ebbacc
3 changed files with 14 additions and 15 deletions
|
@ -5,7 +5,7 @@ require 'pry/config'
|
|||
class Pry
|
||||
|
||||
# The RC Files to load.
|
||||
RC_FILES = ["~/.pryrc"]
|
||||
HOME_RC_FILE = "~/.pryrc"
|
||||
LOCAL_RC_FILE = "./.pryrc"
|
||||
|
||||
# class accessors
|
||||
|
@ -72,14 +72,14 @@ class Pry
|
|||
# Load the rc files given in the `Pry::RC_FILES` array.
|
||||
# This method can also be used to reload the files if they have changed.
|
||||
def self.load_rc
|
||||
RC_FILES.uniq.each do |file_name|
|
||||
load_file_at_toplevel(file_name)
|
||||
end
|
||||
load_file_at_toplevel(HOME_RC_FILE)
|
||||
end
|
||||
|
||||
# Load the local RC file (./.pryrc)
|
||||
def self.load_local_rc
|
||||
load_file_at_toplevel(LOCAL_RC_FILE)
|
||||
unless File.expand_path(HOME_RC_FILE) == File.expand_path(LOCAL_RC_FILE)
|
||||
load_file_at_toplevel(LOCAL_RC_FILE)
|
||||
end
|
||||
end
|
||||
|
||||
# Load any Ruby files specified with the -r flag on the command line.
|
||||
|
@ -115,7 +115,7 @@ class Pry
|
|||
end
|
||||
|
||||
# Start a Pry REPL.
|
||||
# This method also loads the files specified in `Pry::RC_FILES` the
|
||||
# This method also loads the ~/.pryrc and ./.pryrc as necessary
|
||||
# first time it is invoked.
|
||||
# @param [Object, Binding] target The receiver of the Pry session
|
||||
# @param [Hash] options
|
||||
|
|
|
@ -18,9 +18,6 @@ end
|
|||
# in tests)
|
||||
$VERBOSE = nil
|
||||
|
||||
# Ensure we do not execute any rc files
|
||||
Pry::RC_FILES.clear
|
||||
|
||||
# inject a variable into a binding
|
||||
def inject_var(name, value, b)
|
||||
Thread.current[:__pry_local__] = value
|
||||
|
|
|
@ -274,25 +274,26 @@ describe Pry do
|
|||
describe "test loading rc files" do
|
||||
|
||||
before do
|
||||
Pry::HOME_RC_FILE.replace File.expand_path("../testrc", __FILE__)
|
||||
Pry::LOCAL_RC_FILE.replace File.expand_path("../testrc", __FILE__) + "/../testrc"
|
||||
Pry.instance_variable_set(:@initial_session, true)
|
||||
end
|
||||
|
||||
after do
|
||||
Pry::RC_FILES.clear
|
||||
Pry::HOME_RC_FILE.replace "~/.pryrc"
|
||||
Pry::LOCAL_RC_FILE.replace "./.pryrc"
|
||||
Pry.config.should_load_rc = false
|
||||
Object.remove_const(:TEST_RC) if defined?(TEST_RC)
|
||||
end
|
||||
|
||||
it "should run the rc file only once" do
|
||||
it "should never run the rc file twice" do
|
||||
Pry.config.should_load_rc = true
|
||||
2.times { Pry::RC_FILES << File.expand_path("../testrc", __FILE__) }
|
||||
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput)
|
||||
TEST_RC.should == [0]
|
||||
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput)
|
||||
TEST_RC.should == [0]
|
||||
|
||||
Object.remove_const(:TEST_RC)
|
||||
end
|
||||
|
||||
it "should not load the pryrc if it cannot expand ENV[HOME]" do
|
||||
|
@ -321,8 +322,9 @@ describe Pry do
|
|||
|
||||
describe "that raise exceptions" do
|
||||
before do
|
||||
Pry::RC_FILES << File.expand_path("../testrcbad", __FILE__)
|
||||
Pry::HOME_RC_FILE = File.expand_path("../testrcbad", __FILE__)
|
||||
Pry.config.should_load_rc = true
|
||||
Pry.config.should_load_local_rc = false
|
||||
|
||||
putsed = nil
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue