@@ -93,8 +93,8 @@ class AnotherTestError < StandardError; end
93
93
it "provides details about mismatched attributes" do
94
94
expect {
95
95
expect {
96
- Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , context : "actual" } )
97
- } . to have_reported_error . with_context ( user_id : 456 , context : "expected" )
96
+ Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , topic : "actual" } )
97
+ } . to have_reported_error . with_context ( user_id : 456 , topic : "expected" )
98
98
} . to fail_with ( /Expected error attributes to match/ )
99
99
end
100
100
@@ -117,23 +117,23 @@ class AnotherTestError < StandardError; end
117
117
it "shows actual context values when attributes don't match" do
118
118
expect {
119
119
expect {
120
- Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , context : "actual" } )
120
+ Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , topic : "actual" } )
121
121
} . to have_reported_error . with_context ( user_id : 456 )
122
- } . to fail_with ( /actual values are.*user_id.*123.*context .*actual/ )
122
+ } . to fail_with ( /actual values are.*user_id.*123.*topic .*actual/ )
123
123
end
124
124
end
125
125
126
126
describe "#with_context" do
127
127
it "passes when attributes match exactly" do
128
128
expect {
129
- Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , context : "test" } )
130
- } . to have_reported_error . with_context ( user_id : 123 , context : "test" )
129
+ Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , topic : "test" } )
130
+ } . to have_reported_error . with_context ( user_id : 123 , topic : "test" )
131
131
end
132
132
133
133
it "passes with partial attribute matching" do
134
134
expect {
135
135
Rails . error . report (
136
- StandardError . new ( "test" ) , context : { user_id : 123 , context : "test" , extra : "data" }
136
+ StandardError . new ( "test" ) , context : { user_id : 123 , extra : "data" }
137
137
)
138
138
} . to have_reported_error . with_context ( user_id : 123 )
139
139
end
@@ -149,8 +149,8 @@ class AnotherTestError < StandardError; end
149
149
it "fails when attributes do not match" do
150
150
expect {
151
151
expect {
152
- Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , context : "actual" } )
153
- } . to have_reported_error . with_context ( user_id : 456 , context : "expected" )
152
+ Rails . error . report ( StandardError . new ( "test" ) , context : { user_id : 123 , topic : "actual" } )
153
+ } . to have_reported_error . with_context ( user_id : 456 , topic : "expected" )
154
154
} . to fail_with ( /Expected error attributes to match/ )
155
155
end
156
156
0 commit comments