Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7779 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

[PATCH] improvements to assert_select messages

Reported by: dchelimsky Assigned to: core
Priority: normal Milestone: 1.x
Component: ActionPack Version: edge
Severity: normal Keywords: docs
Cc:

Description

When assert_select fails because the counts are off you get messages like:

Expected at least 1 elements, found 0

You aren't told what kind of element AND you're told "1 elements" when it could be "1 element".

This patch will result in this message instead:

Expected at least 1 element matching "div", found 0

Also, if the selection criteria includes a range, the message would read:

Expected between 3 and 4 elements matching "p", found 2

I started w/ "Expected at least 1 <div> tag, found 0", but that became too complex as the selection criteria got more complex. This solution works the same regardless of the complexity of the selector.

I see that ticket 6623 deals with the selector criteria, but this patch also deals with the counts and element vs elements.

This patch also patches assert_select_test with the new expected messages.

Attachments

assert_select_messages.patch (5.7 kB) - added by dchelimsky on 03/10/07 03:26:44.

Change History

03/10/07 03:26:44 changed by dchelimsky

  • attachment assert_select_messages.patch added.

03/10/07 08:05:22 changed by bitsweat

  • keywords set to docs.
  • component changed from ActiveRecord to ActionPack.

05/26/07 20:36:30 changed by marcel

  • status changed from new to closed.
  • resolution set to fixed.

Applied in [6860].