#289 √ resolved
mainej

[PATCH] Enumerable#count should count nils, if requested

Reported by mainej | January 29th, 2008 @ 10:08 PM | in 1.0 preview

There's no spec for Enumerable#count so the first patch adds one (in spec/core/enumerable, which I think is the right spot).

Then, when you try to count the number of nils in an Enumerable you always get an error.

> bin/mspec spec/core/enumerable/count_spec.rb 
Started
.E..

1)
Enumerable#count counts nils if given nil as an argument ERROR
not callable

The second patch fixes that.

Comments and changes to this ticket

  • zimbatm

    zimbatm January 30th, 2008 @ 12:42 AM

    • → State changed from “new” to “open”

    Is it possible to have a "shared" spec for enumerables ? see spec/ruby/1.8/shared

  • mainej

    mainej January 30th, 2008 @ 05:31 PM

    Seems like a philosophical question. Wouldn't this just test whether include Enumerable works as advertised? Seems like "shared" specs would be more useful for two objects that share an interface and some functionality, but implement it in different ways.

    In this case, Enumerable#count is a Rubinius extension to MRI. Is testing extensions the preferred use of shared specs? If you really want to create a shared Enumerable spec, I would think it would be more useful to have a shared version of all the specs in spec/ruby/1.8/core/enumerable. On the other hand, I could be confused - I'm still getting my mind around the testing strategy for Rubinius.

  • Eero Saynatkari

    Eero Saynatkari January 30th, 2008 @ 08:03 PM

    • → State changed from “open” to “resolved”

    Committed as b131b80d and 7dfa583c. Please reference this ticket number and the commit hashes with evan.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket