Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So because RoR encourages unit tests, it's bad?

You should be writing tests for all code - Not just dynamic languages. Compilers catch things like typos and type differences as you said; but there's so much more to test suites than that.

Your last 3 points have nothing to do with the post; they're just essentially more information added to other headings.

So your main point in the end is "Rails is slow" - I personally haven't dug too much into the performance of rails compared to others - But in general: It will improve - as all things do.



Static typing and unit testing are complementary tools. It seems to me that proponents of dynamic languages tend to treat unit testing as the one tool that makes everything look like a nail.


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.


Perhaps 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.


Then 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.


Has 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.


There are gems like 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: