fix (most of) sticky_local_spec.rb.
This commit is contained in:
parent
ef53b2f2c5
commit
71251c5e7f
|
@ -153,7 +153,7 @@ class Pry
|
||||||
# @yield The block that defines the content of the local. The local
|
# @yield The block that defines the content of the local. The local
|
||||||
# will be refreshed at each tick of the repl loop.
|
# will be refreshed at each tick of the repl loop.
|
||||||
def add_sticky_local(name, &block)
|
def add_sticky_local(name, &block)
|
||||||
sticky_locals[name] = block
|
config.extra_sticky_locals[name] = block
|
||||||
end
|
end
|
||||||
|
|
||||||
def sticky_locals
|
def sticky_locals
|
||||||
|
@ -165,7 +165,7 @@ class Pry
|
||||||
_dir_: last_dir,
|
_dir_: last_dir,
|
||||||
_: last_result,
|
_: last_result,
|
||||||
__: output_array[-2]
|
__: output_array[-2]
|
||||||
}
|
}.merge(config.extra_sticky_locals)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Reset the current eval string. If the user has entered part of a multiline
|
# Reset the current eval string. If the user has entered part of a multiline
|
||||||
|
|
|
@ -44,13 +44,11 @@ describe "Sticky locals (_file_ and friends)" do
|
||||||
describe "setting as Pry.config option" do
|
describe "setting as Pry.config option" do
|
||||||
it 'should define a new sticky local for the session (normal value)' do
|
it 'should define a new sticky local for the session (normal value)' do
|
||||||
Pry.config.extra_sticky_locals[:test_local] = :john
|
Pry.config.extra_sticky_locals[:test_local] = :john
|
||||||
|
|
||||||
o = Object.new
|
o = Object.new
|
||||||
redirect_pry_io(InputTester.new("@value = test_local",
|
redirect_pry_io(InputTester.new("@value = test_local",
|
||||||
"exit-all")) do
|
"exit-all")) do
|
||||||
Pry.start(o)
|
Pry.start(o)
|
||||||
end
|
end
|
||||||
|
|
||||||
o.instance_variable_get(:@value).should == :john
|
o.instance_variable_get(:@value).should == :john
|
||||||
Pry.config.extra_sticky_locals = {}
|
Pry.config.extra_sticky_locals = {}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue