mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
rubocop: fix offences of the Lint/AmbiguousBlockAssociation cop
This commit is contained in:
parent
eef698b651
commit
c229142739
8 changed files with 50 additions and 33 deletions
|
@ -563,17 +563,6 @@ Layout/TrailingWhitespace:
|
|||
- 'spec/commands/edit_spec.rb'
|
||||
- 'spec/indent_spec.rb'
|
||||
|
||||
# Offense count: 13
|
||||
Lint/AmbiguousBlockAssociation:
|
||||
Exclude:
|
||||
- 'lib/pry/object_path.rb'
|
||||
- 'spec/commands/show_doc_spec.rb'
|
||||
- 'spec/commands/show_source_spec.rb'
|
||||
- 'spec/config_spec.rb'
|
||||
- 'spec/helper.rb'
|
||||
- 'spec/method_spec.rb'
|
||||
- 'spec/pry_output_spec.rb'
|
||||
|
||||
# Offense count: 15
|
||||
# Configuration parameters: AllowSafeAssignment.
|
||||
Lint/AssignmentInCondition:
|
||||
|
|
|
@ -74,9 +74,10 @@ class Pry
|
|||
"Exception: #{err.inspect}"
|
||||
].join("\n")
|
||||
|
||||
raise CommandError.new(msg).tap { |e|
|
||||
e.set_backtrace err.backtrace
|
||||
}
|
||||
command_error = CommandError.new(msg)
|
||||
command_error.set_backtrace(err.backtrace)
|
||||
|
||||
raise command_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -108,11 +108,13 @@ describe "show-doc" do
|
|||
it "finds super method docs without `--super` but with the `super` keyword" do
|
||||
fatty = Grungy.new
|
||||
|
||||
fatty.extend Module.new {
|
||||
fatty.extend(
|
||||
Module.new do
|
||||
def initialize
|
||||
:nibble
|
||||
end
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
# fatty initialize!
|
||||
def fatty.initialize
|
||||
|
|
|
@ -246,11 +246,13 @@ describe "show-source" do
|
|||
it "finds super methods with multiple --super " do
|
||||
o = Foo.new
|
||||
|
||||
o.extend Module.new {
|
||||
o.extend(
|
||||
Module.new do
|
||||
def foo
|
||||
:nibble
|
||||
end
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
def o.foo(*bars)
|
||||
@foo = :wibble
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Pry::Config do
|
|||
describe "bug #1277" 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 }
|
||||
local.extend(Module.new { def output(); 'broken'; end })
|
||||
expect(local.output).to eq('foobar')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,9 +20,11 @@ end.new(nil)
|
|||
|
||||
# to help with tracking down bugs that cause an infinite loop in the test suite
|
||||
if ENV["SET_TRACE_FUNC"]
|
||||
set_trace_func proc { |event, file, line, id, binding, classname|
|
||||
set_trace_func(
|
||||
proc { |event, file, line, id, binding, classname|
|
||||
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
|
|
@ -277,17 +277,25 @@ describe Pry::Method do
|
|||
end
|
||||
|
||||
it 'should be able to find instance methods defined in modules included into this class' do
|
||||
@class = Class.new{ include Module.new{ def meth; 1; end; } }
|
||||
@class = Class.new do
|
||||
include(Module.new { def meth; 1; end })
|
||||
end
|
||||
should_find_method('meth')
|
||||
end
|
||||
|
||||
it 'should be able to find instance methods defined in modules included into super-classes' do
|
||||
@class = Class.new(Class.new{ include Module.new{ def meth; 1; end; } })
|
||||
super_class = Class.new do
|
||||
include(Module.new { def meth; 1; end })
|
||||
end
|
||||
@class = Class.new(super_class)
|
||||
should_find_method('meth')
|
||||
end
|
||||
|
||||
it 'should attribute overridden methods to the sub-class' do
|
||||
@class = Class.new(Class.new{ include Module.new{ def meth; 1; end; } }) { def meth; 2; end }
|
||||
super_class = Class.new do
|
||||
include(Module.new { def meth; 1; end })
|
||||
end
|
||||
@class = Class.new(super_class) { def meth; 2; end }
|
||||
expect(Pry::Method.all_from_class(@class).detect{ |x| x.name == 'meth' }.owner).to eq @class
|
||||
end
|
||||
|
||||
|
@ -314,7 +322,9 @@ describe Pry::Method do
|
|||
end
|
||||
|
||||
it "should find methods defined in modules included into the object's class" do
|
||||
@obj = Class.new{ include Module.new{ def meth; 1; end } }.new
|
||||
@obj = Class.new {
|
||||
include(Module.new { def meth; 1; end })
|
||||
}.new
|
||||
should_find_method('meth')
|
||||
end
|
||||
|
||||
|
@ -326,7 +336,7 @@ describe Pry::Method do
|
|||
|
||||
it "should find methods in modules included into the object's singleton class" do
|
||||
@obj = Object.new
|
||||
@obj.extend Module.new{ def meth; 1; end }
|
||||
@obj.extend(Module.new { def meth; 1; end })
|
||||
should_find_method('meth')
|
||||
end
|
||||
|
||||
|
@ -361,7 +371,9 @@ describe Pry::Method do
|
|||
end
|
||||
|
||||
it "should find methods defined on modules extended into the class" do
|
||||
@class = Class.new{ extend Module.new{ def meth; 1; end; } }
|
||||
@class = Class.new do
|
||||
extend(Module.new { def meth; 1; end })
|
||||
end
|
||||
should_find_method('meth')
|
||||
end
|
||||
|
||||
|
@ -391,7 +403,12 @@ describe Pry::Method do
|
|||
end
|
||||
|
||||
it "should attrbute overridden methods to the class not the module" do
|
||||
@class = Class.new { class << self; def meth; 1; end; end; extend Module.new{ def meth; 1; end; } }
|
||||
@class = Class.new do
|
||||
class << self
|
||||
def meth; 1; end
|
||||
end
|
||||
extend(Module.new { def meth; 1; end })
|
||||
end
|
||||
expect(Pry::Method.all_from_obj(@class).detect{ |x| x.name == 'meth' }.owner).to eq(class << @class; self; end)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,11 @@ describe Pry do
|
|||
|
||||
it "should catch errors serializing exceptions" do
|
||||
Pry.config.print = lambda do |*a|
|
||||
raise Exception.new("catch-22").tap{ |e| class << e; def inspect; raise e; end; end }
|
||||
ex = Exception.new("catch-22")
|
||||
class << ex
|
||||
def inspect; raise ex; end
|
||||
end
|
||||
raise ex
|
||||
end
|
||||
|
||||
expect(mock_pry("1")).to match(/\(pry\) output error: failed to show result/)
|
||||
|
|
Loading…
Reference in a new issue