mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fixed failing tests, working around bug in 1.8
* proc { |&block| }.arity returns 1 on 1.8, but 0 on 1.9 This is a bug in 1.8 that we had to hack around.
This commit is contained in:
parent
90d6f3eefb
commit
1d57e04c49
1 changed files with 12 additions and 1 deletions
|
@ -408,7 +408,18 @@ class Pry
|
|||
# we need to define this method so we can pass a block in (not
|
||||
# possible with `instance_exec`)
|
||||
class << self; self; end.send(:define_method, :dummy, &block)
|
||||
dummy(*correct_arg_arity(block.arity, args), &command_block)
|
||||
|
||||
# Ruby 1.8 returns arity 1 for proc { |&block }, this is a bug
|
||||
# and different to 1.9 behaviour (which returns 0). The
|
||||
# following hack deals with this bug by retrying the method with
|
||||
# no parameters if an ArgumentError is raised.
|
||||
begin
|
||||
dummy(*correct_arg_arity(block.arity, args), &command_block)
|
||||
rescue ArgumentError => ex
|
||||
if ex.message =~ /1 for 0/
|
||||
dummy(&command_block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def help; description; end
|
||||
|
|
Loading…
Add table
Reference in a new issue