Skip to content

Commit

Permalink
Merge pull request pry#1554 from pry/issue1552
Browse files Browse the repository at this point in the history
fix bug discovered while investigating pry#1552
  • Loading branch information
robert authored Jul 9, 2016
2 parents 17fa19e + ccd0af4 commit c73d0a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/pry/config/behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def default
#
def [](key)
key = key.to_s
@lookup[key] or (@default and @default[key])
key?(key) ? @lookup[key] : (@default and @default[key])
end

#
Expand Down Expand Up @@ -152,7 +152,7 @@ def last_default
last = last.default while last and last.default
last
end

#
# @return [Hash]
# returns a duplicate copy of the lookup table used by self.
Expand Down
34 changes: 12 additions & 22 deletions spec/commands/show_doc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,12 @@ def fatty.initialize
# @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
Expand All @@ -155,17 +150,12 @@ def initialize(foo); end
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
Expand Down
10 changes: 9 additions & 1 deletion spec/config_spec.rb
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit c73d0a2

Please sign in to comment.