Skip to content

Commit c4f7bb5

Browse files
committed
fix spec for ruby 3.4
1 parent e6028cd commit c4f7bb5

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/coaster/core_ext/array.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ def toggle(value)
1212
def deep_key_count(**options)
1313
sum do |v|
1414
case v
15-
when Hash, Array
16-
v.deep_key_count
15+
when Hash
16+
v.deep_key_count(**options)
17+
when Array
18+
if options[:array_is_element]
19+
1
20+
else
21+
v.deep_key_count(**options)
22+
end
1723
else
1824
1
1925
end

test/test_deep_key_count.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ def test_deep_key_count_array_is_element
2525

2626
assert_equal 2, [1, 2].deep_key_count(array_is_element: true)
2727
assert_equal 2, [1, {b: 2}].deep_key_count(array_is_element: true)
28-
assert_equal 3, [1, {b: 2, c: [1, 2]}].deep_key_count(array_is_element: true)
2928

3029
assert_equal 3, [1, {b: 2}, 3].deep_key_count(array_is_element: true)
30+
31+
assert_equal 3, [1, {b: 2, c: [1, 2]}].deep_key_count(array_is_element: true)
3132
assert_equal 3, [1, {b: 2}, [3, 4]].deep_key_count(array_is_element: true)
3233
end
3334
end

test/test_standard_error.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,25 +211,24 @@ def test_to_detail
211211
detail_front = <<-LOG
212212
[Coaster::TestStandardError::ExampleError] status:20
213213
MESSAGE: Test example error (Coaster::TestStandardError::ExampleError) cause{Test sample error (Coaster::TestStandardError::SampleError)}
214-
@attributes: {\"frog\"=>\"rams\", \"wat\"=>\"cha\"}
214+
@attributes: {\"frog\" => \"rams\", \"wat\" => \"cha\"}
215215
@coaster: true
216216
@digest_backtrace: #{e.digest_backtrace}
217217
@digest_message: a8c7c1
218218
@fingerprint: ["a8c7c1"]
219-
@ins_var: [\"Coaster::TestStandardError::SampleError\", {\"h\"=>1}]
220-
@ins_varr: {\"dd\"=>true}
219+
@ins_var: [\"Coaster::TestStandardError::SampleError\", {\"h\" => 1}]
220+
@ins_varr: {\"dd\" => true}
221221
@level: \"error\"
222222
@raven: {}
223223
@tags: {}
224224
@tkey: nil
225225
BACKTRACE:
226-
#{__FILE__}:193:in `rescue in test_to_detail'
227-
#{__FILE__}:187:in `test_to_detail'
226+
#{__FILE__}:193:in 'Coaster::TestStandardError#test_to_detail'
228227
LOG
229228
detail_cause_front = <<-LOG
230229
CAUSE: [Coaster::TestStandardError::SampleError] status:10
231230
MESSAGE: Test sample error (Coaster::TestStandardError::SampleError)
232-
@attributes: {"frog"=>"rams"}
231+
@attributes: {"frog" => "rams"}
233232
@coaster: true
234233
@digest_backtrace: #{e.cause.digest_backtrace}
235234
@digest_message: cbe233
@@ -239,7 +238,7 @@ def test_to_detail
239238
@tags: {}
240239
@tkey: nil
241240
BACKTRACE:
242-
#{__FILE__}:188:in `test_to_detail'
241+
#{__FILE__}:188:in 'Coaster::TestStandardError#test_to_detail'
243242
LOG
244243
assert detail.start_with?(detail_front)
245244
cause_ix = (detail =~ /CAUSE/)
@@ -331,7 +330,7 @@ def test_to_hash
331330
assert_equal 999999, e.to_hash['status']
332331
assert_equal 500, e.to_hash['http_status']
333332
assert_equal "standard error translation (#{e.digest_message} #{bt})", e.user_message
334-
assert_match(/undefined local variable or method `aa'/, e.to_hash['message'])
333+
assert_match(/undefined local variable or method 'aa'/, e.to_hash['message'])
335334
end
336335

337336
def test_descriptions

0 commit comments

Comments
 (0)