Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 9cceff0

Browse files
committed
Merge pull request #421 from rspec/fix-differ-support
`diff-lcs` has changed its format in 1.4
1 parent 9ee1ad6 commit 9cceff0

File tree

5 files changed

+270
-163
lines changed

5 files changed

+270
-163
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ matrix:
3838
include:
3939
- rvm: jruby-1.7
4040
env: JRUBY_OPTS='--dev --1.8'
41+
- rvm: 2.7.1
42+
env: DIFF_LCS_VERSION="~> 1.3.0"
4143
allow_failures:
4244
- rvm: jruby-head
4345
- rvm: ruby-head

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ else
2121
gem 'rake', '>= 12.3.3'
2222
end
2323

24+
if ENV['DIFF_LCS_VERSION']
25+
gem 'diff-lcs', ENV['DIFF_LCS_VERSION']
26+
else
27+
gem 'diff-lcs', '~> 1.4', '>= 1.4.3'
28+
end
29+
2430
if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
2531
gem "childprocess", "< 1.0.0"
2632
elsif RUBY_VERSION < '2.3.0'

lib/rspec/support/spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'rspec/support/spec/in_sub_process'
33

44
RSpec::Support.require_rspec_support "spec/deprecation_helpers"
5+
RSpec::Support.require_rspec_support "spec/diff_helpers"
56
RSpec::Support.require_rspec_support "spec/with_isolated_stderr"
67
RSpec::Support.require_rspec_support "spec/stderr_splitter"
78
RSpec::Support.require_rspec_support "spec/formatting_support"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'diff/lcs'
2+
3+
module RSpec
4+
module Support
5+
module Spec
6+
module DiffHelpers
7+
# In the updated version of diff-lcs several diff headers change format slightly
8+
# compensate for this and change minimum version in RSpec 4
9+
if ::Diff::LCS::VERSION.to_f < 1.4
10+
def one_line_header(line_number=2)
11+
"-1,#{line_number} +1,#{line_number}"
12+
end
13+
14+
def removing_two_line_header
15+
"-1,3 +1"
16+
end
17+
else
18+
def one_line_header(_=2)
19+
"-1 +1"
20+
end
21+
22+
def removing_two_line_header
23+
"-1,3 +1,5"
24+
end
25+
end
26+
end
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)