News for hackers. Stuff that matters.
Re:Learn how to test Rails using Test::Unit instead of Rspec by criley on Thursday March 21, 2013 @04:16PM (#5418597)
My experience:

I just started the process of converting our few hundred Test::Unit tests to Rspec simply because Test Unit documentation is terrible. Our tests need a lot of work and I'm not that experienced at writing test scripts. I have to learn this as I do it, and I struggled to find resources for learning Test::Unit.

Every blog post, tutorial and guide I can find was written for Rspec.

As much as I'd love to continue using Test::Unit and save myself the hassle of converting from one to the other, I found learning Test::Unit to be one giant brick wall after another.

No one is discussing it, no one is blogging about it, no one is writing stack overflow questions about the issues. (I say, in a discussion about a blog post about it... but this is the exception not the rule, sadly)

For me it was a simple decision: If I want community support, I need to be using the tool the community is actually supporting.

(Not that Rspec documentation is that much better-- I've now resorted to just reading public github repos and looking for spec/ directories to scrutinize and learn from. If anyone has links to any good repos that use rspec tests, I'd love it if you could send them my way! I need more good repos to learn from!)

Re:Learn how to test Rails using Test::Unit instead of Rspec by tamersalama on Thursday March 21, 2013 @06:19PM (#5419607)
"because Test Unit documentation is terrible"

Are you confusing Test Unit documentation with 'How/What to test' documentation? I can't think of any documentation required if what you use is a group of asserts.

Test::Unit in a nutshell: `test "should do something"; ...; end` is what gets run in each of the files. `setup` is called before each test. `teardown` is called after each test. use `assert_*` at your discretion.

Re:Learn how to test Rails using Test::Unit instead of Rspec by rhizome on Thursday March 21, 2013 @06:27PM (#5419645)
You know, recently I had reason to look into the teardown method (DatabaseCleaner, dontchaknow), and I never did find anything conclusive that it was something that test-unit used. Sure, it was mentioned in many many DatabaseCleaner questions/answers/threads, but nothing I could really rely on since invariably these were also using Rspec. That is, my unanswered question was "Is teardown solely an Rspec thing?"
Re:Learn how to test Rails using Test::Unit instead of Rspec by gyardley on Thursday March 21, 2013 @10:11PM (#5420938)
Setup and teardown are in the Rails testing guide.

http://guides.rubyonrails.org/testing.html#setup-and-teardow...

Re:Learn how to test Rails using Test::Unit instead of Rspec by rhizome on Friday March 22, 2013 @04:07PM (#5425325)
I suppose so, but the readability of the guides are an (perhaps-idiosyncratic) issue for me.
Re:Learn how to test Rails using Test::Unit instead of Rspec by genericsteele on Thursday March 21, 2013 @04:24PM (#5418674)
"For me it was a simple decision: If I want community support, I need to be using the tool the community is actually supporting."

Truth. And the community is really split on this one. The side that makes the decisions about what goes into rails prefer unit tests, while a large chunk of the users prefer spec-based.

Re:Learn how to test Rails using Test::Unit instead of Rspec by richardjordan on Thursday March 21, 2013 @05:01PM (#5418965)
This was my experience too. I tried to use Test::Unit because I was learning from scratch, Rails 2.something, and Test::Unit was "The Rails Way". But I was fumbling in the dark. The community around RSpec picked me up and carried me to the testing promised land.
Re:Learn how to test Rails using Test::Unit instead of Rspec by evolve2k on Thursday March 21, 2013 @05:55PM (#5419402)
This. That was totally my experience too, after freaking out learning rails the friendly rspec syntax and natural readability felt like I'd reached a pub while lost in the desert.
Re:Learn how to test Rails using Test::Unit instead of Rspec by rhizome on Thursday March 21, 2013 @04:24PM (#5418672)
Hear hear. I am dreading the technical debt I have in test-unit, and meanwhile the (Rails) world is moving on to Minitest and the world appears to be settling on Rspec syntax regardless. Nowhere to be found is even a conversion HOWTO, so test-unit starts feeling even more like a ghetto, and increases my conversion anxiety, which is all too bad, since I like what I consider to be the simplicity of test-unit.
Re:Learn how to test Rails using Test::Unit instead of Rspec by mapgrep on Thursday March 21, 2013 @05:08PM (#5419012)
>I am dreading the technical debt I have in test-unit, and meanwhile the (Rails) world is moving on to Minitest

Minitest and Test::Unit are part of the same package since 1.9, with Test::Unit implemented as a simple compatibility layer on top of Minitest:

http://www.rubyinside.com/a-minitestspec-tutorial-elegant-sp...

The Minitest assertions are quite similar to the old Test::Unit assertions, a large number are identical:

http://rubydoc.info/stdlib/minitest/1.9.3/MiniTest/Assertion...

Re:Learn how to test Rails using Test::Unit instead of Rspec by rhizome on Thursday March 21, 2013 @06:22PM (#5419629)
Right, and I've seen many pages like the rubyinside one leaving me still hungry with questions like, "So, no more test_helper.rb or what?" Couldn't find that in either of those links.

This is really more of a general documentation quibble on my part though, since I'm the dope who can't read through my questions and find the answers in the source (or wherever). I've been planning on making a blog post about 1:1 mapping of concepts between Test::Unit and Minitest learned from my own transformation, but as I've mentioned, I haven't been able to undertake that yet.

Re:Learn how to test Rails using Test::Unit instead of Rspec by mapgrep on Thursday March 21, 2013 @06:28PM (#5419654)
The docs really are lacking in this case; I expected the Test::Unit docs would document what's being stubbed and not in MiniTest but there's nothing there on that as near as I can tell.

As a rule, I miss the thoroughness of CPAN/Perl docs. Some ruby packages have amazing docs but often I feel at sea, particularly with regard to high level overviews and examples.