Created
April 10, 2015 16:58
-
-
Save myronmarston/457b08f4de08a59e3eba to your computer and use it in GitHub Desktop.
Demonstration of using matcher for the first argument to `raise_error`
This file contains hidden or 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
RSpec::Matchers.define :an_exception_caused_by do |cause| | |
match do |exception| | |
cause === exception.cause | |
end | |
end | |
expect { | |
begin | |
"foo".gsub # requires 2 args | |
rescue ArgumentError | |
raise "failed to gsub" | |
end | |
}.to raise_error( an_exception_caused_by(ArgumentError) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment