Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Suggestion: raise_error matcher should have no default exception type or default to StandardError #655

@jstultz

Description

@jstultz

Using the raise_error matcher without specifying a particular error type is quite dangerous, as it swallows any sort of exception, including syntax errors and rspec expectation errors. It's hard for me to imagine a reasonable justification for the author of a test not caring at all what type of error is thrown; in my opinion it would be more helpful to users of rspec to be forced to think at least a little bit about what type of error they are expecting.

If there's no agreement on that, then at least perhaps it might be worth considering changing the default from Exception to StandardError.

For quick reference:
https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/raise_error.rb#L11
https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/raise_error.rb#L42-L49

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions