jriff
jriff

Reputation: 1977

Assert_difference in Rails 3

Is this really the best way?

assert_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

Upvotes: 2

Views: 849

Answers (2)

jriff
jriff

Reputation: 1977

As far as I can see, this is the best way if one wants to avoid splitting it up into two blocks.

Upvotes: 2

Simone Carletti
Simone Carletti

Reputation: 176402

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.

Upvotes: 1

Related Questions