Permalink
Browse files

Add support for diff-lcs 1.2.x while maintaining backwards compatibil…

…ity with diff-lcs 1.1.3. Updated gemspec to support either as a runtime dependency.
  • Loading branch information...
petergoldstein committed Jan 22, 2013
1 parent b468a19 commit feba881729ec4edd9b9bd9b4716df36b34760efc
Showing with 8 additions and 2 deletions.
  1. +7 −1 lib/rspec/expectations/differ.rb
  2. +1 −1 rspec-expectations.gemspec
@@ -25,7 +25,13 @@ def diff_as_string(data_new, data_old)
# diff includes lines of context. Otherwise, we might print
# redundant lines.
if (context_lines > 0) and hunk.overlaps?(oldhunk)
- hunk.unshift(oldhunk)
+ if hunk.respond_to?(:merge)
+ # diff-lcs 1.2.x
+ hunk.merge(oldhunk)
+ else
+ # diff-lcs 1.1.3
+ hunk.unshift(oldhunk)
+ end
else
output << oldhunk.diff(format)
end
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]
s.require_path = "lib"
- s.add_runtime_dependency 'diff-lcs', '~> 1.1.3'
+ s.add_runtime_dependency 'diff-lcs', '>= 1.1.3'
s.add_development_dependency 'rake', '~> 10.0.0'
s.add_development_dependency 'cucumber', '~> 1.1.9'

0 comments on commit feba881

Please sign in to comment.