Assert_difference in Rails 3
Is this really the best way?
ass开发者_Go百科ert_difference('u.point', 10) do
assert_difference('u.point_logs.count') do
assert_difference('a.point', 5) do
assert_difference('a.point_logs.count') do
u.give_points(:description => 'Test', :points => 10.0)
end
end
end
end
Regards,
Jacob
As far as I can see, this is the best way if one wants to avoid splitting it up into two blocks.
I strongly encourage you to write more tests to stress specific features. You can write one test to assert the difference on a
and write one test to assert the difference on u
.
精彩评论