, . , :
test "something" do
for item in @collection
assert_something item
end
end
:
test "something" do
for item in @collection
assert_something item
assert_something_else item
end
end
:
test "something" do
for item in @collection
assert_something item
if x == y
assert_something_else item
end
end
end
test "something" do
for item in @collection
assert_something item
end
for item in @collection
assert_something_else item
end
end
, , , , . , , . , , , , . , Foo, @collection.first. , , item . , :
test "items are all Foo" do
for item in @collection
assert_kind_of Foo, item, "Everything in @collection must be Foo."
end
end
test "something" do
assert_something @collection.first
end
The “something” test will fail anyway if there are no objects in the collection Foo, but the previous test makes it completely clear what the real problem is.
In short, avoid this, but if you have every reason to do so, then go ahead. And if this becomes a problem in the future, the test should be simple enough to easily transform it into something less problematic.
source
share