Skip to content

Instantly share code, notes, and snippets.

@sjgjohnston
Last active December 24, 2015 16:29
Show Gist options
  • Save sjgjohnston/6828189 to your computer and use it in GitHub Desktop.
Save sjgjohnston/6828189 to your computer and use it in GitHub Desktop.
GA WDI - Week 2 - Day 4 (Thursday) Homework

DHH Offended By Proliferation of RSpec

Reference:

Issue(s):

  • 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

Public opinion:

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

My viewpoint: RSpec seems like the better choice...

  • 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment