Should statements
Should statements are a clean, and elegant way of creating tests with meaningful names. Should statements simply create test methods, so they are completely backwards compatible with normal Test::Unit usage.
class QuoteTest < Test::Unit::TestCase
def setup
# normal Test::Unit setup stuff here
end
def test_should_be_true
assert true
end
should "be true" do
assert true
end
end
The above snippet would create two test methods: “test: should be true” and test_should_be_true. At this level, the only differences between the two test methods is in the name. Once you learn about contexts, you’ll find some more useful tricks.