File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -661,7 +661,9 @@ def actual_for_diff
661
661
662
662
def expected_for_matcher_text
663
663
if @expected_message
664
- "#<#{ @expected_error . name } #{ @expected_message . inspect } >"
664
+ "#<#{ @expected_error . name } #{ description_of ( @expected_message ) } >"
665
+ elsif @expected_error . is_a? Regexp
666
+ "#<Exception #{ description_of ( @expected_error ) } >"
665
667
else
666
668
"#<#{ @expected_error . name } >"
667
669
end
Original file line number Diff line number Diff line change 18
18
end
19
19
end
20
20
21
+ context "with regular expression as message (and assuming a RuntimeError)" do
22
+ it "returns the correct output" do
23
+ expect ( raise_error ( /hell/ ) . description ) . to eq (
24
+ %|raise error #<Exception /hell/>| ,
25
+ )
26
+ end
27
+ end
28
+
21
29
context "with both an exception and a message" do
22
30
it "returns the correct output" do
23
31
expect ( raise_error ( RuntimeError , "hell" ) . description ) . to eq (
24
32
%|raise error #<RuntimeError "hell">| ,
25
33
)
26
34
end
27
35
end
36
+
37
+ context "with an exception and a regular expression as message" do
38
+ it "returns the correct output" do
39
+ expect ( raise_error ( RuntimeError , /hell/ ) . description ) . to eq (
40
+ %|raise error #<RuntimeError /hell/>| ,
41
+ )
42
+ end
43
+ end
28
44
end
29
45
end
You can’t perform that action at this time.
0 commit comments