diff --git a/lib/rspec/expectations/differ.rb b/lib/rspec/expectations/differ.rb index 38bd47d46..8aeb23dc1 100644 --- a/lib/rspec/expectations/differ.rb +++ b/lib/rspec/expectations/differ.rb @@ -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 diff --git a/rspec-expectations.gemspec b/rspec-expectations.gemspec index f66d3d2d2..859a6f9a0 100644 --- a/rspec-expectations.gemspec +++ b/rspec-expectations.gemspec @@ -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'