开发者

Rails 3 - RSpec doesn't feel right [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likel开发者_开发技巧y solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I feel one of the most confusing ways to code is to do so in English. I feel it is quite cumbersome. Ruby, I actually like, and Rails is taking some getting used to, but I definitely see the benefits and can get past the parts I don't like as much. I mean, it's a learning curve. But, the curve has tremendous benefits and isn't that steep of a climb. The part that allows me to respect rails the most, is that it is mostly configuration in the form of convention, once configured, I am right back to the coding I love.

I am not a web developer, never really have been. I am more of an application developer, but all of that aside:

I am ready to dive into unit testing. I am obviously leaning toward Test::Unit. Before I do this, I want to ask the community for thoughts. What should I use? What gems might be useful? Why are these gems useful/necessary? Should I reconsider Test::Unit? Why?


_begin_religious_war_

Test::Unit is nice for one-offs, Shoulda + Mocha is better (imho) for full applications where you really wanna leverage mock objects and reuse. webrat for integration testing is pretty straightforward and can do everything I've needed it to up to this point.

There is no right answer obviously. Test::Unit is in the core, which can't be beat as far as configuring them to use in your application.

If they all did the same thing, it would be a waste of time for the developers of rspec/cucumber/shoulda/etc. so obviously, Test::Unit isn't the best answer for everyone, but its the 'default' testing package for Ruby and so its the bar the rest measure themselves against.

p.s. Beyond generally avoiding subjective questions, you should REALLY avoid question titles that make subjective statement like "I Hate RSpec". You may, but I've done strictly-speced projects (such as for government/military contractors) where rSpec was priceless and the absolute best fit for our testing needs.


As long as you are actually testing, Test::Unit or Rspec, doesn't matter. They will both help you achieve the same results, with perhaps different philosophy (this might not be the right word) to them.

  • What should I use?

Your choice, Test::Unit, Rspec, maybe a combination?... But, the key here is that you are using them to help you test your code.

  • What gems might be useful?

There are a quite a variety out there. You'll have to ultimately go through and see which ones work for you best. shoulda, valid_attribute, pickle, factory_girl, faker, fakeweb, fakefs, timecop, rr are a few I use consistently in my unit tests.

  • Why are these gems useful/necessary?

Useful, sure, the awesome developers have taken out some of the "wheel creation" out for your life.

Necessary, maybe. This answer ultimately depends on your goal and your approach.

  • Should I reconsider Test::Unit? Why?

Sure, why not. It couldn't hurt. It's like tasting foods you never tried. If you don't take a real taste how will you know if you like it or not.

Ultimately, I don't think you can go wrong either way if you are serious about testing your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜