sconover / wrong

Wrong provides a general assert method that takes a predicate block. Assertion failure messages are rich in detail.
MIT License
433 stars 30 forks source link

Endless warnings about uninitialized variable #10

Closed mvz closed 13 years ago

mvz commented 13 years ago

Hi, I run my tests with warnings enabled, and each test outputs:

[...]/wrong-0.5.4/lib/wrong/assert.rb:23: warning: instance variable @_inside_wrong_assert not initialized

Adding the following just before the offending line solves this:

@_inside_wrong_assert ||= false
alexch commented 13 years ago

Hmm. I rarely use -w because I don't agree that everything they warn about is actually a problem. In this case I'm a bit shocked, since "instance variables default to nil" is one of the features that makes Ruby such a concise language. I'm reluctant to clutter our code with a pointless initializer. OTOH, the customer is king... so I'd be happy to hear arguments on the other side.

mvz commented 13 years ago

My argument would be that if you make a gem run without warnings, it can be cleanly used by people who like using -w. That's why I'm running my tests with warnings on, since they're tests for a gem.

alexch commented 13 years ago

I hate it when people come up with reasonable arguments!

OK, you're probably right. This would fall under the "it's a library, so you can't just do anything you want" category, along with monkey patching.

alexch commented 13 years ago

Fixed with release 0.5.4 (and .5 and .6 ... don't ask!) -- please confirm.

mvz commented 13 years ago

Yes, confirmed. Thanks.