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

be with a block is deceptive #1194

Closed
pirj opened this issue Jun 17, 2020 · 3 comments
Closed

be with a block is deceptive #1194

pirj opened this issue Jun 17, 2020 · 3 comments

Comments

@pirj
Copy link
Member

pirj commented Jun 17, 2020

Subject of the issue

    expect([-1,2,3]).to all be(&:positive?)

Found in rubocop/rubocop-rspec#919

Expected behavior

A warning or an error makes it obvious that be doesn't accept a block.

Actual behavior

  is expected to all be

1 example, 0 failures
```
@JonRowe
Copy link
Member

JonRowe commented Jun 17, 2020

There are a lot of places where we don't check for a block and issue a warning, we've generally not subscribed to the philosophy of warning about Rubyisms, in Ruby you can give a block to almost any method and it'll be ignored if its not expected...

@JonRowe
Copy link
Member

JonRowe commented Jun 17, 2020

e.g.

"1".to_i { |x| raise x }
# => 1

@pirj
Copy link
Member Author

pirj commented Jun 18, 2020

Agree, there are a lot more cases than just be. rubocop/rubocop#7798

I guess it's a good job for RuboCop RSpec.

@pirj pirj closed this as completed Jun 18, 2020
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

2 participants