44 class TestError < StandardError ; end
55 class AnotherTestError < StandardError ; end
66
7- it "has an reports_error alias " do
7+ it "is aliased as reports_error " do
88 expect { Rails . error . report ( StandardError . new ( "test error" ) ) } . to reports_error
99 end
1010
11- it "warns that passing value expectation doesn't work " do
11+ it "warns when used as a value expectation " do
1212 expect {
1313 expect ( Rails . error . report ( StandardError . new ( "test error" ) ) ) . to have_reported_error
1414 } . to raise_error ( ArgumentError , "this matcher doesn’t work with value expectations" )
1515 end
1616
17- describe "basic functionality " do
17+ context "without constraint " do
1818 it "passes when an error is reported" do
1919 expect { Rails . error . report ( StandardError . new ( "test error" ) ) } . to have_reported_error
2020 end
2121
22- it "fails when no error is reported" do
22+ it "fails when no errors are reported" do
2323 expect {
2424 expect { "no error" } . to have_reported_error
2525 } . to fail_with ( /Expected the block to report an error, but none was reported./ )
2626 end
2727
28- it "passes when negated and no error is reported" do
28+ it "passes when negated and no errors are reported" do
2929 expect { "no error" } . not_to have_reported_error
3030 end
3131 end
3232
33- describe " error class matching " do
34- it "passes when correct error class is reported" do
33+ context "constrained to a specific error class" do
34+ it "passes when an error with the correct class is reported" do
3535 expect { Rails . error . report ( TestError . new ( "test error" ) ) } . to have_reported_error ( TestError )
3636 end
3737
38- it "fails when wrong error class is reported" do
38+ it "fails when an error with the wrong class is reported" do
3939 expect {
4040 expect {
4141 Rails . error . report ( AnotherTestError . new ( "wrong error" ) )
@@ -44,20 +44,20 @@ class AnotherTestError < StandardError; end
4444 end
4545 end
4646
47- describe "error instance matching" do
48- it "passes when error instance matches exactly" do
47+ context "constrained to a matching error (class and message) " do
48+ it "passes with an error that matches exactly" do
4949 expect {
5050 Rails . error . report ( TestError . new ( "exact message" ) )
5151 } . to have_reported_error ( TestError . new ( "exact message" ) )
5252 end
5353
54- it "passes when error instance has empty expected message" do
54+ it "passes any error of the same class if the expected message is empty " do
5555 expect {
5656 Rails . error . report ( TestError . new ( "any message" ) )
5757 } . to have_reported_error ( TestError . new ( "" ) )
5858 end
5959
60- it "fails when error instance has different message" do
60+ it "fails when the error has different message to the expected " do
6161 expect {
6262 expect {
6363 Rails . error . report ( TestError . new ( "actual message" ) )
@@ -66,14 +66,14 @@ class AnotherTestError < StandardError; end
6666 end
6767 end
6868
69- describe " regex pattern matching" do
70- it "passes when error message matches pattern" do
69+ context "constrained by regex pattern matching" do
70+ it "passes when an error message matches the pattern" do
7171 expect {
7272 Rails . error . report ( StandardError . new ( "error with pattern" ) )
7373 } . to have_reported_error ( /with pattern/ )
7474 end
7575
76- it "fails when error message does not match pattern" do
76+ it "fails when no error messages match the pattern" do
7777 expect {
7878 expect {
7979 Rails . error . report ( StandardError . new ( "error without match" ) )
@@ -82,8 +82,8 @@ class AnotherTestError < StandardError; end
8282 end
8383 end
8484
85- describe "failure messages for attribute mismatches " do
86- it "provides detailed failure message when attributes don't match " do
85+ describe "#failure_message " do
86+ it "provides details about mismatched attributes" do
8787 expect {
8888 expect {
8989 Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , context : "actual" } )
@@ -116,7 +116,7 @@ class AnotherTestError < StandardError; end
116116 end
117117 end
118118
119- describe "attribute matching with .with chain " do
119+ describe "# with" do
120120 it "passes when attributes match exactly" do
121121 expect {
122122 Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , context : "test" } )
0 commit comments