- Source: http://www.rubyinside.com/dhh-offended-by-rspec-debate-4610.html
- DHH: David Heinemeierhansson [http://david.heinemeierhansson.com]
- Test::Unit: http://www.ruby-doc.org/stdlib-2.0.0/libdoc/test/unit/rdoc/Test/Unit.html
- RSpec: https://github.com/rspec/rspec
- RSpec is overcomplicated - offends him aesthetically
- There is no discernable benefit for its added complexity
- DHH respects experimentation, but is sad by the proliferation of RSpec
- Gist from DHH: https://gist.github.com/dhh/893027
- Is DHH being disingenuous in his example code to support Test::Unit over RSpec?
- Test::Unit
- Feels right - simplicity has a huge aesthetic value
- Is easier to get started with...
- Code example...
- if assert respond_with(:success) fails, the two assertions that come after it will not run.
- this is not the case with the RSpec example. So Rspec can seem more robust...
- RSpec:
- Is not about testing, it is about documentation
- Sometimes it's easier just to have it all in one spec.
- Of course personal taste plays into this.
- The examples look relatively similar - it boils down to do you prefer:
- [RSpec] 'assert something' ; or
- [Test::Unit] 'object.should be_true'
- The closer [the code] is to the way I'd describe the behaviour in English, the less likely I am to miss a mistake.
- [RSpec] something.should equal(:something_else) sounds a hell of a lot more natural
- [Test::Unit] assert_equals something, :something_else sounds very robotic and requires me to translate from computer language to human language, however briefly.
- I agree that it is better to have your code reflect how you would describe it in English
- RSpec seems to provide a more natural form of in-built documentation
- RSpec test specs seem more robust, in that they run to completion, not failing to run if a previous assertion [Test::Unit] fails
- Understanding the code should take priority over aesthetics, especially in a shared-code development environmnet
- The initial learning curve is advocated as being harder for RSpec, but that shouldn't be a reason to adopt Test::Unit
- Both approaches can yield equivalent results, if you understand well how to use both systems. After that it come down to how useful it is and the concensus/preferences for the group of developers handling the code as a whole.
- There should be standardization on one methodology to keep things consistent.