Bug #8975

Confusing code sample for assert_send

Added by Andrew Grimm 7 months ago. Updated 5 months ago.

[ruby-core:57570]
Status:Closed
Priority:Normal
Assignee:Zachary Scott
Category:doc
Target version:-
ruby -v:ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

Test::Unit::Assertsions#assert_send has the code sample

assert_send([[1, 2], :member?, 1]) # -> pass
assert_send([[1, 2], :member?, 4]) # -> fail

Having an array within an array is somewhat confusing. When I first read it, I ignored the extra square brackets. A less confusing example would be

assert_send(["Hello world", :include?, "Hello"]) # -> pass
assert_send(["Hello world", :include?, "Goodbye"]) # -> fail

Associated revisions

Revision 43597
Added by Zachary Scott 5 months ago

  • lib/test/unit/assertions.rb: [DOC] better example for assert_send() Patch by Andrew Grimm [Bug #8975]

History

#1 Updated by Zachary Scott 7 months ago

Thanks for the report Andrew!

I'm really glad we got a doc bug reported for TestUnit, this confirms my suspicion that people are still using TU for legacy apps and still need accurate documentation.

I will have to reconsider how we document TU..

#2 Updated by Zachary Scott 7 months ago

  • Status changed from Open to Assigned

#3 Updated by Andrew Grimm 7 months ago

To be honest, it's not so much a "legacy app" issue as a "legacy programmer" issue.

I started programming back in Ruby 1.8.6. I don't use any opinionated web development frameworks such as Rails (I don't do web development at all, actually!), so nothing told me to switch to minitest. I used 'require "test/unit"' back then, and I still use it now. I don't actually know whether I use test/unit or whether Ruby 1.9/2.0 uses minitest with a compatibility layer. I also don't know what advantages there are in switching from test/unit to minitest.

When I switched from 1.9.x to 2.0, the way that tests were outputted changed, in that you usually don't get a series of dots being printed out for each test. That gave me the impression that whatever I was using was non-legacy.

Is test/unit considered legacy?

I think that documenting the advantages of minitest over test/unit, or that test/unit is considered legacy, may be helpful. Maybe in the documentation for test/unit?

#4 Updated by Zachary Scott 6 months ago

Please see #8778 for reference.

To answer your question, lib/test (test/unit) is a legacy shim.

I don't think documenting minitest advantages will help, because minitest may not stay in the stdlib forever.

We could mention other libraries, including the full TU2 gem for those looking to upgrade. I think the natural progression is TU -> TU2, not TU -> MT

#5 Updated by Zachary Scott 5 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43597.
Andrew, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/test/unit/assertions.rb: [DOC] better example for assert_send() Patch by Andrew Grimm [Bug #8975]

Also available in: Atom PDF