Comments on: on choosing RSpec as a test framework /2011/04/on-choosing-rspec-as-a-test-framework/ Sarah Allen's reflections on internet software and other topics Sat, 02 Apr 2011 06:19:49 +0000 hourly 1 https://wordpress.org/?v=5.7.1 By: Delicious Bookmarks for April 2nd from 01:19 to 01:46 « Lâmôlabs /2011/04/on-choosing-rspec-as-a-test-framework/#comment-744 Sat, 02 Apr 2011 06:19:49 +0000 /?p=3068#comment-744 […] on choosing RSpec as a test framework | the evolving ultrasaurus – April 2nd ( tags: rspec ruby testing tips tricks examples rails ) […]

]]>
By: Jacob Richardson /2011/04/on-choosing-rspec-as-a-test-framework/#comment-743 Fri, 01 Apr 2011 18:19:26 +0000 /?p=3068#comment-743 Excellent article! I’ve also found that in my experience teaching rails that RSpec is just much easier to understand for newbies.

I use the python unittest library extensively (which has a very similar feel to t/u) but when coding ruby rspec feels like a MUST.

]]>
By: Undecisive /2011/04/on-choosing-rspec-as-a-test-framework/#comment-742 Fri, 01 Apr 2011 17:18:15 +0000 /?p=3068#comment-742 Excellent. I would argue that you should leave the error in there – if any Test::Unit evangelists notice it, you’ve made your point. If any Test::Unit evangelists DON’T notice it until they read the comments, you’ve made your point even stronger.

For my part, I’ve always used rspec and similarly see assert as counter-intuitive (Connascence of position vs Connascence of name, the latter is weaker and so usually better) If people have a preference, use what makes you smile. I’m planning on giving Wrong a try (https://github.com/sconover/wrong) because let’s face it, you can never do enough experimenting.

]]>
By: Dave Jones /2011/04/on-choosing-rspec-as-a-test-framework/#comment-741 Fri, 01 Apr 2011 16:36:14 +0000 /?p=3068#comment-741 @Michael

The tests still pass, because the two are equal no matter their position, but when the test fails, it will complain that didn’t match , which can be really confusing, especially to a newbie.

So:
assert_equal @calc.total, 4
in a failing scenario would report:
Expected nil, got 4

when of course nil is not what the test expected to get in a passing scenario.

]]>
By: Andy /2011/04/on-choosing-rspec-as-a-test-framework/#comment-740 Fri, 01 Apr 2011 16:19:09 +0000 /?p=3068#comment-740 Yah, it might be good to fix the error with assert_equal.

The output will look odd in a failing test if the parameters are switched.

]]>
By: Sarah /2011/04/on-choosing-rspec-as-a-test-framework/#comment-739 Fri, 01 Apr 2011 15:24:38 +0000 /?p=3068#comment-739 LOL! proves my point. It does pass either way, but I think the test output is supposed to indicate what we are actually trying to test, versus what is expected. I think a well-written assertion makes it quicker to diagnose the problem because we can tell the expected value and what it currently is, and knowing one from the other can help isolate a bug.

]]>
By: Michael /2011/04/on-choosing-rspec-as-a-test-framework/#comment-738 Fri, 01 Apr 2011 15:13:35 +0000 /?p=3068#comment-738 You’ve got assert_equal wrong, it is intended to be:

assert_equal(expected, actual)

However, if you check out the rdoc on test/unit assertions – the order doesn’t seem to matter. I reversed them in some existing tests, and all still pass.

]]>
By: Matt Wynne /2011/04/on-choosing-rspec-as-a-test-framework/#comment-737 Fri, 01 Apr 2011 15:04:18 +0000 /?p=3068#comment-737 Thanks for sharing your thoughts and experience Sarah. I find personal experience like this makes the best contribution to any ‘debate’ like this.

For development, don’t forget about RSspec’s nested contexts, and also #let blocks, both of which are wonderful tools for writing really clear tests.

]]>