diff options
author | Paul Chechetin <paulche@yandex.ru> | 2013-04-16 19:25:33 +0400 |
---|---|---|
committer | Paul Chechetin <paulche@yandex.ru> | 2013-04-16 19:25:33 +0400 |
commit | 9a3793d1a1a8e3e1995960f18ec5a87507a16300 (patch) | |
tree | 9c40d97932e33ed8fc4d00ab5a84c1d44b5fd6d8 | |
parent | c316d76c06b14a9a42bb7251c2884c162a70ce8d (diff) | |
download | pry-9a3793d1a1a8e3e1995960f18ec5a87507a16300.tar.gz |
Fix issue with Puppet
See:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/monkey_patches.rb#L278
-rw-r--r-- | lib/pry/commands/ls.rb | 2 | ||||
-rw-r--r-- | spec/commands/ls_spec.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/pry/commands/ls.rb b/lib/pry/commands/ls.rb index 8578c997..a828f9ac 100644 --- a/lib/pry/commands/ls.rb +++ b/lib/pry/commands/ls.rb @@ -267,7 +267,7 @@ class Pry end def format_variables(type, vars) - vars.sort_by(&:downcase).map{ |var| color(type, var) } + vars.sort_by{ |var| var.to_s.downcase }.map{ |var| color(type, var) } end def format_constants(mod, constants) diff --git a/spec/commands/ls_spec.rb b/spec/commands/ls_spec.rb index 153d79a9..474549ad 100644 --- a/spec/commands/ls_spec.rb +++ b/spec/commands/ls_spec.rb @@ -60,6 +60,24 @@ describe "ls" do pry_eval("ls Net::HTTP::Get.new('localhost')").should =~ /Net::HTTPGenericRequest#methods/ end + it "should work for objects which instance_variables returns array of symbol but there is no Symbol#downcase" do + test_case = "class Object; alias :fg :instance_variables; def instance_variables; fg.map(&:to_sym); end end;" + normalize = "class Object; def instance_variables; fg; end end;" + + test = lambda do + begin + pry_eval(test_case, "class GeFromulate2; @flurb=1.3; end", "cd GeFromulate2", "ls") + pry_eval(normalize) + rescue + pry_eval(normalize) + raise + end + end + + test.should.not.raise + end + + # see: https://travis-ci.org/pry/pry/jobs/5071918 unless Pry::Helpers::BaseHelpers.rbx? it "should handle classes that (pathologically) define .ancestors" do |