As I’ve been writing test suites for a Rails app, I’ve noticed that there are two different ways to create tests, a test block and a regular method:
test "the truth" do
assert true
end
vs.
def test_for_something_else
assert true
end
Is there any difference between the two testing structures? When should I use one over the other?
Edit: On further inspection, tests written as methods are counted in rake:stats while those written with the test syntax are not. There’s one difference…
I think the block syntax was added due to the popularity of Behaviour-Driven-Development frameworks such as RSpec, with their more natural Should do X… syntax. In the end it’s a matter of personal preference.