3 ms·
RoR doesn't "encourage" unit testing, it forces you to write thousands of meaningless unit tests which just make up for the lack of strong type system. Unit tes
by michas 13y ago
RoR doesn't "encourage" unit testing, it forces you to write thousands of meaningless unit tests which just make up for the lack of strong type system. Unit tests should test code logic, not parameter types.
- drewinglis 13y agoThere are gems like shoulda (https://github.com/thoughtbot/shoulda https://github.com/thoughtbot/shoulda) that make it really easy to do the 'types and typos' kind of unit tests. The marginal time required for any given class is negligible.
- huntedsnark 13y agoPerhaps I've just missed it in the past but where does Rails advocate testing parameter types? There are examples of testing model validations, but you would want to test that in a strongly typed language as well. I don't think I've ever run across a test for something like "this id should be an integer" in Rails, if that's what you mean.
- aparadja 13y agoHas RoR really started forcing you to write unit tests? By the thousands? I've written several RoR apps in the past where I didn't unit test at all. Perhaps I misunderstood you.
- tjbiddle 13y agoThen don't write meaningless types. If you're needing to constantly test parameter types - Then you need to work harder on ensuring your input is the correct type before calling a method. It should subconsciously tell you to put more effort into knowing what you're working with. Unit tests are meant to test behavior - When I do X, I want Y to happen. Rspec is great for this - I did X, I should see A, B, and C get called - and if they return to me this value then my final result should be Z.