[rspec-devel] [ rspec-Patches-6283 ] refactoring of diff support to allow selectable formats and custom differs

noreply at rubyforge.org noreply at rubyforge.org
Mon Oct 23 09:10:55 EDT 2006


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

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Lachie Cox (lachie)
Assigned to: Nobody (None)
Summary: refactoring of diff support to allow selectable formats and custom differs

Initial Comment:
Supports diff formats :unified (as default) and :context using the default differ Spec::Expectations::Differs::Default.

Custom differs may be specified in the same way as custom formatters.

spec --diff                                  # unified
spec --diff unified                          # unified
spec --diff u                                # unified
spec --diff context                          # context
spec --diff c                                # context
spec --require custom --diff Custom::Differ  # loads Custom::Differ

(caveat: you can't say
  spec --diff your_spec.rb
as the option parser will eat the filename. alternatives:
  spec --diff -- your_spec.rb
  spec --diff= your_spec.rb
  spec --diff --colour your_spec.rb
  spec --diff u your_spec.rb
)

I've tried to decouple the Differ workhorse from the hook into Spec::Expectations::Should::Base as much as possible, but it still leaves a bit to be desired.

Spec::Expectations::Differs::Default is now the component with the diff/lcs dependency.

The Differ duckbill is currently:

#new(format=:unified,context_lines=3,colour=false)  # in anticipation of ansi :)
#diff_as_string(string1,string2,format=@format,context_lines=@context_lines)
#diff_as_object(object1,object2,format=@format,context_lines=@context_lines)

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

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


More information about the rspec-devel mailing list