DHH on Unit Testing : Is RSpec indeed needlessly complicated?

前端 未结 3 1521
一生所求
一生所求 2021-02-08 08:15

I happen to be a subscriber of Ruby Inside, since I\'m particularly interested in Rails. Yesterday, the creator of Rails, David Heinemeier Hansson, pretty much said that he\'s j

3条回答
  •  没有蜡笔的小新
    2021-02-08 08:28

    My recommendation would be to use either Shoulda (extends Test::Unit) or RSpec with Capybara, and -no- Cucumber.

    I think that the use of either RSpec or Shoulda for nested contexts is definitely worth doing. RSpec is definitely heavy-weight (perhaps overweight) though, and I'm on the fence with it for that reason.

    Cucumber, I've finally come to understand, is waaay more cumbersome than it's usually worth. You can accomplish what you need more simply and robustly with plain ol' integration tests and Capybara. Remember -- Capybara != Cucumber, and Capybara is quite capable all on its own.

    Shoulda is nice, because it simply adds conveniences to the standard Test::Unit framework, and is therefore much lighter-weight than RSpec (technically, each solves a different set of problems, but they both provide nested-context capabilities). RSpec has the advantage of making assertions read more naturally, and also generating more helpful failure messages in many cases, without the need for writing message arguments on the assertions.

    Also, remember that Cucumber does not actually require RSpec, so if you want to keep using Cucumber, you can do that with just Test::Unit. Choices abound.

提交回复
热议问题