Rubocop: Lint/AmbiguousBlockAssociation with Rspec syntax

Created on 31 Mar 2017  路  2Comments  路  Source: rubocop-hq/rubocop

I'm quite lost with this example:

expect do
  make_request
end.to enqueue_job(DeliverEventWebhookJob)
  .with { |event_name, _claim_id| expect(event_name).to eq("claim_renewed") }

The offence is:

W: Lint/AmbiguousBlockAssociation: Parenthesize the param with to make sure that the block will be associated with the to method call.
    expect do ...
    ^^^^^^^^^

I tried few other ways, but either Rubocop is not happy or it's not a valid Ruby syntax.

$ rubocop -V
0.48.0 (using Parser 2.4.0.0, running on ruby 2.4.1 x86_64-linux)

Most helpful comment

I would probably recommend disabling this cop for specs, since it's a deliberate idiom in RSpec. 馃檪

Lint/AmbiguousBlockAssociation:
  Exclude:
    - "spec/**/*"

All 2 comments

I would probably recommend disabling this cop for specs, since it's a deliberate idiom in RSpec. 馃檪

Lint/AmbiguousBlockAssociation:
  Exclude:
    - "spec/**/*"

Exactly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kirrmann picture kirrmann  路  3Comments

cabello picture cabello  路  3Comments

deivid-rodriguez picture deivid-rodriguez  路  3Comments

Aqualon picture Aqualon  路  3Comments

Ana06 picture Ana06  路  3Comments