Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Style/SymbolProc? #2217

Closed
bquorning opened this issue Sep 5, 2015 · 0 comments
Closed

Bug in Style/SymbolProc? #2217

bquorning opened this issue Sep 5, 2015 · 0 comments

Comments

@bquorning
Copy link
Contributor

In the RSpec documentation it is described how a stub can yield to the caller's block:

Taking that code and removing the argument to #call results in this code:

# encoding: utf-8
RSpec.describe 'When the caller passes a block' do
  it 'can be yielded to from your implementation block' do
    dbl = double
    allow(dbl).to receive(:foo) { |&block| block.call }
    expect { |probe| dbl.foo(&probe) }.to yield_control
  end
end

Running RuboCop v0.34.0 gives me this offense:

test.rb:5:19: C: Pass &:call as an argument to receive instead of a block.
    allow(dbl).to receive(:foo) { |&block| block.call }
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RuboCop is happy if I change receive(:foo) { |&block| block.call } into receive(:foo, &:call), but it doesn’t work. I guess the cop doesn’t take the & in |&block| into consideration.

cc @lumeet

@bbatsov bbatsov closed this as completed in e39056a Sep 6, 2015
bbatsov added a commit that referenced this issue Sep 6, 2015
[Fix #2217] Allow block arguments in SymbolProc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant