-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSpec's `expect` has two forms: - scalar: `expect(result).to be_truthy` - block: `expect { thunk }.not_to raise_error(RuntimeError)` So what happens when you mix them? ```ruby thunk = -> { 1 / 0 } expect(thunk).not_to raise_error(RuntimeError) ``` If you do that, RSpec complains: > The implicit block expectation syntax is deprecated, you should pass a > block rather than an argument to `expect` to use the provided block > expectation matcher or the matcher must implement > `supports_value_expectations?` The easy solution is to pass the Proc as a block, using `&`: ``` thunk = -> { 1 / 0 } expect(&thunk).not_to raise_error(RuntimeError) ```
- Loading branch information
1 parent
9b9b24f
commit 388f93f
Showing
4 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,6 @@ | |
raise_error(KeyError, /Did you mean\?/) | ||
end | ||
|
||
expect(actual).to matcher | ||
expect(&actual).to matcher | ||
end | ||
end |