[rspec-devel] [ rspec-Patches-6207 ] Allows --diff option to diff target and expected's #inspect output

noreply at rubyforge.org noreply at rubyforge.org
Tue Oct 17 22:32:41 EDT 2006


Patches item #6207, was opened at 2006-10-18 12:32
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=6207&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Lachie Cox (lachie)
Assigned to: Nobody (None)
Summary: Allows --diff option to diff target and expected's #inspect output

Initial Comment:
The --diff option mixes in unified diffing to Spec::Expectations::ShouldBase's default message generation.

This patch adds diffing of arbitrary objects to this mixin.

If the 'target' and 'expected' objects both respond to #inspect (which they probably do because Object does) the diff of their inspect strings is added to the message.

The existing behaviour is still default (i.e. diffing of an expected String).

Motivation: This behaviour is most useful when the objects being compared pretty print their structure when #inspect'ed.

For example, this is the case with ASTs constructed by CAST (http://cast.rubyforge.org/).

It's almost useless with Rails models, as their #inspect strings are ugly printed (all on the same line, diff doesn't work so well).

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=6207&group_id=797


More information about the rspec-devel mailing list