开发者

Assert_difference in Rails 3

开发者 https://www.devze.com 2023-02-10 02:20 出处:网络
Is this really the best way? ass开发者_Go百科ert_difference(\'u.point\', 10) do assert_difference(\'u.point_logs.count\') do

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消