1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

fix bug discovered while investigating #1552

This commit is contained in:
robert 2016-07-09 02:13:22 +01:00
parent f2cdb9a2e5
commit ed94afb476
3 changed files with 23 additions and 25 deletions

View file

@ -51,7 +51,7 @@ module Pry::Config::Behavior
#
def [](key)
key = key.to_s
@lookup[key] or (@default and @default[key])
key?(key) ? @lookup[key] : (@default and @default[key])
end
#

View file

@ -134,17 +134,12 @@ describe "show-doc" do
# @param foo
def initialize(foo); end
}
begin
t = pry_tester(binding)
expect(t.eval("show-doc _c#initialize")).to match(/_c.new :foo/)
Pry.config.color = true
# I don't want the test to rely on which colour codes are there, just to
# assert that "something" is being colourized.
expect(t.eval("show-doc _c#initialize")).not_to match(/_c.new :foo/)
ensure
Pry.config.color = false
end
t = pry_tester(binding)
expect(t.eval("show-doc _c#initialize")).to match(/_c.new :foo/)
# I don't want the test to rely on which colour codes are there, just to
# assert that "something" is being colourized.
t.eval("_pry_.color = true")
expect(t.eval("show-doc _c#initialize")).not_to match(/_c.new :foo/)
end
it "should syntax highlight `code` in rdoc" do
@ -155,17 +150,12 @@ describe "show-doc" do
def initialize(foo); end
}
begin
t = pry_tester(binding)
expect(t.eval("show-doc _c#initialize")).to match(/_c.new\(:foo\)/)
Pry.config.color = true
# I don't want the test to rely on which colour codes are there, just to
# assert that "something" is being colourized.
expect(t.eval("show-doc _c#initialize")).not_to match(/_c.new\(:foo\)/)
ensure
Pry.config.color = false
end
t = pry_tester(binding)
expect(t.eval("show-doc _c#initialize")).to match(/_c.new\(:foo\)/)
# I don't want the test to rely on which colour codes are there, just to
# assert that "something" is being colourized.
t.eval("_pry_.color = true")
expect(t.eval("show-doc _c#initialize")).not_to match(/_c.new\(:foo\)/)
end
it "should not syntax highlight `` inside code" do

View file

@ -1,7 +1,15 @@
require_relative 'helper'
describe Pry::Config do
describe "bug #1552" do
specify "a local key has precendence over its default when the stored value is false" do
local = Pry::Config.from_hash({}, Pry::Config.from_hash('color' => true))
local.color = false
expect(local.color).to eq(false)
end
end
describe "bug #1277" do
specify "a local key has precendence over a inherited method of the same name" do
specify "a local key has precendence over an inherited method of the same name" do
local = Pry::Config.from_hash(output: 'foobar')
local.extend Module.new { def output(); 'broken'; end }
expect(local.output).to eq('foobar')