Skip to content

Commit 860df53

Browse files
Copilotkwerle
andcommitted
Add descriptive error messages to test assertions
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
1 parent 9fb60d8 commit 860df53

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

spec/lib/ruby_language_server/scope_parser_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ module Baz
185185
assert_equal('Foo', foo.name)
186186

187187
children = foo.children
188-
assert_equal(2, children.size)
188+
assert_equal(2, children.size, "Foo should have 2 children, but has #{children.size}")
189189

190190
bar = children.detect { |c| c.name == 'Bar' }
191191
baz = children.detect { |c| c.name == 'Baz' }
192192

193-
assert_not_nil(bar)
194-
assert_not_nil(baz)
195-
assert_equal(0, bar.children.size)
193+
assert_not_nil(bar, "Bar should be a child of Foo")
194+
assert_not_nil(baz, "Baz should be a child of Foo")
195+
assert_equal(0, bar.children.size, "Bar should have no children")
196196
end
197197
end
198198

@@ -213,14 +213,14 @@ class Baz
213213
assert_equal('Foo', foo.name)
214214

215215
children = foo.children
216-
assert_equal(2, children.size)
216+
assert_equal(2, children.size, "Foo should have 2 children, but has #{children.size}")
217217

218218
bar = children.detect { |c| c.name == 'Bar' }
219219
baz = children.detect { |c| c.name == 'Baz' }
220220

221-
assert_not_nil(bar)
222-
assert_not_nil(baz)
223-
assert_equal(0, bar.children.size)
221+
assert_not_nil(bar, "Bar should be a child of Foo")
222+
assert_not_nil(baz, "Baz should be a child of Foo")
223+
assert_equal(0, bar.children.size, "Bar should have no children")
224224
end
225225
end
226226

@@ -241,16 +241,16 @@ module Baz
241241
assert_equal('Foo', foo.name)
242242

243243
children = foo.children
244-
assert_equal(2, children.size)
244+
assert_equal(2, children.size, "Foo should have 2 children, but has #{children.size}")
245245

246246
bar = children.detect { |c| c.name == 'Bar' }
247247
baz = children.detect { |c| c.name == 'Baz' }
248248

249-
assert_not_nil(bar)
250-
assert_not_nil(baz)
251-
assert_equal(:class, bar.type)
252-
assert_equal(:module, baz.type)
253-
assert_equal(0, bar.children.size)
249+
assert_not_nil(bar, "Bar should be a child of Foo")
250+
assert_not_nil(baz, "Baz should be a child of Foo")
251+
assert_equal(:class, bar.type, "Bar should be a class")
252+
assert_equal(:module, baz.type, "Baz should be a module")
253+
assert_equal(0, bar.children.size, "Bar should have no children")
254254
end
255255
end
256256
end

0 commit comments

Comments
 (0)