Skip to content

Commit

Permalink
issue #505: rubocop preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDKelley committed Nov 10, 2020
1 parent a4ab1a7 commit 64a0272
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/listen/thread.rb
Expand Up @@ -21,7 +21,7 @@ def new(name, &block)
end

def rescue_and_log(method_name, *args, caller_stack: nil)
yield *args
yield(*args)
rescue Exception => ex
_log_exception(ex, method_name, caller_stack: caller_stack)
end
Expand Down
16 changes: 8 additions & 8 deletions spec/lib/listen/thread_spec.rb
Expand Up @@ -43,14 +43,14 @@
end

it "rescues and logs exceptions" do
expect(Listen.logger).to receive(:error)
.with(/Exception rescued in listen-worker_thread:\nArgumentError: boom!\n.*\/listen\/thread_spec\.rb/)
expect(Listen.logger).to receive(:error).
with(/Exception rescued in listen-worker_thread:\nArgumentError: boom!\n.*\/listen\/thread_spec\.rb/)
subject.join
end

it "rescues and logs backtrace + exception backtrace" do
expect(Listen.logger).to receive(:error)
.with(/Exception rescued in listen-worker_thread:\nArgumentError: boom!\n.*\/listen\/thread\.rb.*--- Thread.new ---.*\/listen\/thread_spec\.rb/m)
expect(Listen.logger).to receive(:error).
with(/Exception rescued in listen-worker_thread:\nArgumentError: boom!\n.*\/listen\/thread\.rb.*--- Thread.new ---.*\/listen\/thread_spec\.rb/m)
subject.join
end
end
Expand All @@ -59,8 +59,8 @@
let(:block) { raise_nested_exception_block }

it "details exception causes" do
expect(Listen.logger).to receive(:error)
.with(/RuntimeError: nested outer\n--- Caused by: ---\nRuntimeError: nested inner\n--- Caused by: ---\nArgumentError: boom!/)
expect(Listen.logger).to receive(:error).
with(/RuntimeError: nested outer\n--- Caused by: ---\nRuntimeError: nested inner\n--- Caused by: ---\nArgumentError: boom!/)
subject.join
end
end
Expand All @@ -77,8 +77,8 @@

describe '.rescue_and_log' do
it 'rescues and logs nested exceptions' do
expect(Listen.logger).to receive(:error)
.with(/Exception rescued in method:\nRuntimeError: nested outer\n--- Caused by: ---\nRuntimeError: nested inner\n--- Caused by: ---\nArgumentError: boom!/) do |message|
expect(Listen.logger).to receive(:error).
with(/Exception rescued in method:\nRuntimeError: nested outer\n--- Caused by: ---\nRuntimeError: nested inner\n--- Caused by: ---\nArgumentError: boom!/) do |message|
expect(message).to_not match(/Thread\.new/)
end
described_class.rescue_and_log("method", &raise_nested_exception_block)
Expand Down

0 comments on commit 64a0272

Please sign in to comment.