Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

improved reporting of failed expression in assert_difference

#1161

Patch improves message output when an expression specified in #assert_difference fails. This is useful for when there are multiple expressions provided as an array to help identify which one was actually in error.

Currently assert_difference just outputs that the expected and actual value was, but not what actually failed.


assert_difference ['Post.count', 'current_user.posts.count'] do
  save_a_new_post
end

If one of the expressions fails in the above code, there is no way to tell from the assertion failure message which one: <1> expected but was <0>.

With the patch, the message will be: <current_user.posts.count> was expression that failed. <1> expected but was <0>.

Reported by madlep · October 3rd, 2008 @ 05:12 AM

State: committed
Milestone: 2.x
Assigned to: Carl Lerche Carl Lerche
Importance: Low

Activity

  1. Repository
    Repository
    • State changed from new to committed

    (from [00e2ba76b21d3c433a0ecda0de28d931c34d1791]) added nicer failure reporting to #assert_difference to tell you the expression that failed rather than just the expected and actual values

    Signed-off-by: Michael Koziarski michael@koziarski.com [#1161 state:committed] http://github.com/rails/rails/co...

    October 3rd, 2008 @ 08:44 PM

  2. madlep
    madlep

    Noticed that the final commit had an extra "the" added to the generated message, but the included unit test for the change wasn't updated, and is now causing unit test failures.

    October 4th, 2008 @ 08:53 AM

  3. mayanetwork
    mayanetwork
    • Assigned user set to Carl Lerche

    It is of course for you to get aion power leveling and aion kinah to join a company that has some really good  service addresses for you to choose the cheap aion power leveling and fast aion kinah delivery. One thing to note is that there are many cheap wow power leveling and wow gold  companies  allow you to actually choose some really great wow power leveling and wow gold service.

    August 19th, 2010 @ 02:05 AM

  4. mayanetwork
  5. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:14 PM

  6. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 11th, 2010 @ 03:06 AM

  7. five fingers shoes
  8. afra99
    afra99

    Heating experiment is a moncler long waiting process that requires discount moncler jackets persistence and perseverance, while also note that moncler jackets method, first stir a slow fire, after the moncler sale last use of waste heat evaporated to get crystals. Not only the warmth of the small monlcer online store family business, but also make contributions to http://www.monclergo.com/ society.

    November 9th, 2010 @ 12:43 AM

  9. bingbing