summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2019-01-27 00:15:29 -0500
committerAustin Ziegler <austin@zieglers.ca>2019-01-27 23:26:05 -0500
commit45ea1b30c7de0ad840f72afb82fd41eb2b9590db (patch)
tree22f879cbd21a183bac5c17f754c0aa598531d968 /spec
parent07ed577eba341f0ff0d7eebf4c1c2cc23083cba7 (diff)
downloaddiff-lcs-45ea1b30c7de0ad840f72afb82fd41eb2b9590db.tar.gz
Applied Rubocop rules that I like
- Other linting configuration also applied. - Soft-deprecating versions older than 2.3.
Diffstat (limited to 'spec')
-rw-r--r--spec/change_spec.rb14
-rw-r--r--spec/diff_spec.rb28
-rw-r--r--spec/hunk_spec.rb26
-rw-r--r--spec/issues_spec.rb28
-rw-r--r--spec/lcs_spec.rb20
-rw-r--r--spec/ldiff_spec.rb22
-rw-r--r--spec/patch_spec.rb192
-rw-r--r--spec/sdiff_spec.rb178
-rw-r--r--spec/spec_helper.rb141
-rw-r--r--spec/traverse_balanced_spec.rb346
-rw-r--r--spec/traverse_sequences_spec.rb56
11 files changed, 542 insertions, 509 deletions
diff --git a/spec/change_spec.rb b/spec/change_spec.rb
index dfe385f..b5ad0cb 100644
--- a/spec/change_spec.rb
+++ b/spec/change_spec.rb
@@ -1,9 +1,9 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
describe Diff::LCS::Change do
- describe "an add" do
+ describe 'an add' do
subject { described_class.new('+', 0, 'element') }
it { should_not be_deleting }
it { should be_adding }
@@ -13,7 +13,7 @@ describe Diff::LCS::Change do
it { should_not be_finished_b }
end
- describe "a delete" do
+ describe 'a delete' do
subject { described_class.new('-', 0, 'element') }
it { should be_deleting }
it { should_not be_adding }
@@ -23,7 +23,7 @@ describe Diff::LCS::Change do
it { should_not be_finished_b }
end
- describe "an unchanged" do
+ describe 'an unchanged' do
subject { described_class.new('=', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
@@ -33,7 +33,7 @@ describe Diff::LCS::Change do
it { should_not be_finished_b }
end
- describe "a changed" do
+ describe 'a changed' do
subject { described_class.new('!', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
@@ -43,7 +43,7 @@ describe Diff::LCS::Change do
it { should_not be_finished_b }
end
- describe "a finished_a" do
+ describe 'a finished_a' do
subject { described_class.new('>', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
@@ -53,7 +53,7 @@ describe Diff::LCS::Change do
it { should_not be_finished_b }
end
- describe "a finished_b" do
+ describe 'a finished_b' do
subject { described_class.new('<', 0, 'element') }
it { should_not be_deleting }
it { should_not be_adding }
diff --git a/spec/diff_spec.rb b/spec/diff_spec.rb
index 020ff44..e7d632a 100644
--- a/spec/diff_spec.rb
+++ b/spec/diff_spec.rb
@@ -1,33 +1,37 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe Diff::LCS, ".diff" do
+describe Diff::LCS, '.diff' do
include Diff::LCS::SpecHelper::Matchers
- it "correctly diffs seq1 to seq2" do
+ it 'correctly diffs seq1 to seq2' do
diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
expect(change_diff(correct_forward_diff)).to eq(diff_s1_s2)
end
- it "correctly diffs seq2 to seq1" do
+ it 'correctly diffs seq2 to seq1' do
diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
expect(change_diff(correct_backward_diff)).to eq(diff_s2_s1)
end
- it "correctly diffs against an empty sequence" do
+ it 'correctly diffs against an empty sequence' do
diff = Diff::LCS.diff(word_sequence, [])
correct_diff = [
- [ [ '-', 0, 'abcd' ],
- [ '-', 1, 'efgh' ],
- [ '-', 2, 'ijkl' ],
- [ '-', 3, 'mnopqrstuvwxyz' ] ]
+ [
+ ['-', 0, 'abcd'],
+ ['-', 1, 'efgh'],
+ ['-', 2, 'ijkl'],
+ ['-', 3, 'mnopqrstuvwxyz']
+ ]
]
expect(change_diff(correct_diff)).to eq(diff)
diff = Diff::LCS.diff([], word_sequence)
- correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
+ correct_diff.each do |hunk|
+ hunk.each do |change| change[0] = '+' end
+ end
expect(change_diff(correct_diff)).to eq(diff)
end
@@ -37,11 +41,11 @@ describe Diff::LCS, ".diff" do
expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
end
- it "returns an empty diff with (hello, hello)" do
+ it 'returns an empty diff with (hello, hello)' do
expect(Diff::LCS.diff(hello, hello)).to be_empty
end
- it "returns an empty diff with (hello_ary, hello_ary)" do
+ it 'returns an empty diff with (hello_ary, hello_ary)' do
expect(Diff::LCS.diff(hello_ary, hello_ary)).to be_empty
end
end
diff --git a/spec/hunk_spec.rb b/spec/hunk_spec.rb
index 0711e0d..5a45072 100644
--- a/spec/hunk_spec.rb
+++ b/spec/hunk_spec.rb
@@ -1,4 +1,4 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
@@ -6,52 +6,52 @@ if String.method_defined?(:encoding)
require 'diff/lcs/hunk'
describe Diff::LCS::Hunk do
- let(:old_data) { ["Tu avec carté {count} itém has".encode('UTF-16LE')] }
- let(:new_data) { ["Tu avec carte {count} item has".encode('UTF-16LE')] }
+ let(:old_data) { ['Tu avec carté {count} itém has'.encode('UTF-16LE')] }
+ let(:new_data) { ['Tu avec carte {count} item has'.encode('UTF-16LE')] }
let(:pieces) { Diff::LCS.diff old_data, new_data }
let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
it 'produces a unified diff from the two pieces' do
- expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
+ expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
@@ -1,2 +1,2 @@
-Tu avec carté {count} itém has
+Tu avec carte {count} item has
- EOD
+ EXPECTED
expect(hunk.diff(:unified)).to eq(expected)
end
it 'produces a context diff from the two pieces' do
- expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
+ expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
***************
*** 1,2 ****
!Tu avec carté {count} itém has
--- 1,2 ----
!Tu avec carte {count} item has
- EOD
+ EXPECTED
expect(hunk.diff(:context)).to eq(expected)
end
it 'produces an old diff from the two pieces' do
- expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
+ expected = <<-EXPECTED.gsub(/^ +/, '').encode('UTF-16LE').chomp
1,2c1,2
< Tu avec carté {count} itém has
---
> Tu avec carte {count} item has
- EOD
+ EXPECTED
expect(hunk.diff(:old)).to eq(expected)
end
it 'produces a reverse ed diff from the two pieces' do
- expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
+ expected = <<-EXPECTED.gsub(/^ +/, '').encode('UTF-16LE').chomp
c1,2
Tu avec carte {count} item has
.
- EOD
+ EXPECTED
expect(hunk.diff(:reverse_ed)).to eq(expected)
end
@@ -60,10 +60,10 @@ if String.method_defined?(:encoding)
let(:old_data) { [] }
it 'produces a unified diff' do
- expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
+ expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
@@ -1 +1,2 @@
+Tu avec carte {count} item has
- EOD
+ EXPECTED
expect(hunk.diff(:unified)).to eq(expected)
end
diff --git a/spec/issues_spec.rb b/spec/issues_spec.rb
index 7638249..79ddd0b 100644
--- a/spec/issues_spec.rb
+++ b/spec/issues_spec.rb
@@ -1,8 +1,8 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe "Diff::LCS Issues" do
+describe 'Diff::LCS Issues' do
include Diff::LCS::SpecHelper::Matchers
describe 'issue #1' do
@@ -26,23 +26,31 @@ describe "Diff::LCS Issues" do
describe 'string' do
it_has_behavior 'handles simple diffs', 'aX', 'bXaX', [
- [ [ '+', 0, 'b' ],
- [ '+', 1, 'X' ] ],
+ [
+ ['+', 0, 'b'],
+ ['+', 1, 'X']
+ ]
]
it_has_behavior 'handles simple diffs', 'bXaX', 'aX', [
- [ [ '-', 0, 'b' ],
- [ '-', 1, 'X' ] ],
+ [
+ ['-', 0, 'b'],
+ ['-', 1, 'X']
+ ]
]
end
describe 'array' do
it_has_behavior 'handles simple diffs', %w(a X), %w(b X a X), [
- [ [ '+', 0, 'b' ],
- [ '+', 1, 'X' ] ],
+ [
+ ['+', 0, 'b'],
+ ['+', 1, 'X']
+ ]
]
it_has_behavior 'handles simple diffs', %w(b X a X), %w(a X), [
- [ [ '-', 0, 'b' ],
- [ '-', 1, 'X' ] ],
+ [
+ ['-', 0, 'b'],
+ ['-', 1, 'X']
+ ]
]
end
end
diff --git a/spec/lcs_spec.rb b/spec/lcs_spec.rb
index 28533e3..94428fd 100644
--- a/spec/lcs_spec.rb
+++ b/spec/lcs_spec.rb
@@ -1,11 +1,11 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe Diff::LCS::Internals, ".lcs" do
+describe Diff::LCS::Internals, '.lcs' do
include Diff::LCS::SpecHelper::Matchers
- it "returns a meaningful LCS array with (seq1, seq2)" do
+ it 'returns a meaningful LCS array with (seq1, seq2)' do
res = Diff::LCS::Internals.lcs(seq1, seq2)
# The result of the LCS (less the +nil+ values) must be as long as the
# correct result.
@@ -20,37 +20,37 @@ describe Diff::LCS::Internals, ".lcs" do
expect(x_seq2).to eq(correct_lcs)
end
- it "returns all indexes with (hello, hello)" do
+ it 'returns all indexes with (hello, hello)' do
expect(Diff::LCS::Internals.lcs(hello, hello)).to \
eq((0...hello.size).to_a)
end
- it "returns all indexes with (hello_ary, hello_ary)" do
+ it 'returns all indexes with (hello_ary, hello_ary)' do
expect(Diff::LCS::Internals.lcs(hello_ary, hello_ary)).to \
eq((0...hello_ary.size).to_a)
end
end
-describe Diff::LCS, ".LCS" do
+describe Diff::LCS, '.LCS' do
include Diff::LCS::SpecHelper::Matchers
- it "returns the correct compacted values from Diff::LCS.LCS" do
+ it 'returns the correct compacted values from Diff::LCS.LCS' do
res = Diff::LCS.LCS(seq1, seq2)
expect(res).to eq(correct_lcs)
expect(res.compact).to eq(res)
end
- it "is transitive" do
+ it 'is transitive' do
res = Diff::LCS.LCS(seq2, seq1)
expect(res).to eq(correct_lcs)
expect(res.compact).to eq(res)
end
- it "returns %W(h e l l o) with (hello, hello)" do
+ it 'returns %W(h e l l o) with (hello, hello)' do
expect(Diff::LCS.LCS(hello, hello)).to eq(hello.split(//))
end
- it "returns hello_ary with (hello_ary, hello_ary)" do
+ it 'returns hello_ary with (hello_ary, hello_ary)' do
expect(Diff::LCS.LCS(hello_ary, hello_ary)).to eq(hello_ary)
end
end
diff --git a/spec/ldiff_spec.rb b/spec/ldiff_spec.rb
index ad1377f..113c0dd 100644
--- a/spec/ldiff_spec.rb
+++ b/spec/ldiff_spec.rb
@@ -1,8 +1,8 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe "Diff::LCS.diff" do
+describe 'Diff::LCS.diff' do
include Diff::LCS::SpecHelper::Matchers
it 'correctly diffs seq1 to seq2' do
@@ -18,16 +18,20 @@ describe "Diff::LCS.diff" do
it 'correctly diffs against an empty sequence' do
diff = Diff::LCS.diff(word_sequence, [])
correct_diff = [
- [ [ '-', 0, 'abcd' ],
- [ '-', 1, 'efgh' ],
- [ '-', 2, 'ijkl' ],
- [ '-', 3, 'mnopqrstuvwxyz' ] ]
+ [
+ ['-', 0, 'abcd'],
+ ['-', 1, 'efgh'],
+ ['-', 2, 'ijkl'],
+ ['-', 3, 'mnopqrstuvwxyz']
+ ]
]
expect(change_diff(correct_diff)).to eq(diff)
diff = Diff::LCS.diff([], word_sequence)
- correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
+ correct_diff.each do |hunk|
+ hunk.each do |change| change[0] = '+' end
+ end
expect(change_diff(correct_diff)).to eq(diff)
end
@@ -37,11 +41,11 @@ describe "Diff::LCS.diff" do
expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
end
- it "returns an empty diff with (hello, hello)" do
+ it 'returns an empty diff with (hello, hello)' do
expect(Diff::LCS.diff(hello, hello)).to eq([])
end
- it "returns an empty diff with (hello_ary, hello_ary)" do
+ it 'returns an empty diff with (hello_ary, hello_ary)' do
expect(Diff::LCS.diff(hello_ary, hello_ary)).to eq([])
end
end
diff --git a/spec/patch_spec.rb b/spec/patch_spec.rb
index 9f1a4f1..11b0981 100644
--- a/spec/patch_spec.rb
+++ b/spec/patch_spec.rb
@@ -1,54 +1,54 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe "Diff::LCS.patch" do
+describe 'Diff::LCS.patch' do
include Diff::LCS::SpecHelper::Matchers
- shared_examples "patch sequences correctly" do
- it "correctly patches left-to-right (patch autodiscovery)" do
+ shared_examples 'patch sequences correctly' do
+ it 'correctly patches left-to-right (patch autodiscovery)' do
expect(Diff::LCS.patch(s1, patch_set)).to eq(s2)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(s1, patch_set, :patch)).to eq(s2)
expect(Diff::LCS.patch!(s1, patch_set)).to eq(s2)
end
- it "correctly patches right-to-left (unpatch autodiscovery)" do
+ it 'correctly patches right-to-left (unpatch autodiscovery)' do
expect(Diff::LCS.patch(s2, patch_set)).to eq(s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(s2, patch_set, :unpatch)).to eq(s1)
expect(Diff::LCS.unpatch!(s2, patch_set)).to eq(s1)
end
end
- describe "using a Diff::LCS.diff patchset" do
- describe "an empty patchset returns the source" do
- it "works on a string (hello)" do
+ describe 'using a Diff::LCS.diff patchset' do
+ describe 'an empty patchset returns the source' do
+ it 'works on a string (hello)' do
diff = Diff::LCS.diff(hello, hello)
- expect(Diff::LCS::patch(hello, diff)).to eq(hello)
+ expect(Diff::LCS.patch(hello, diff)).to eq(hello)
end
- it "works on an array %W(h e l l o)" do
+ it 'works on an array %W(h e l l o)' do
diff = Diff::LCS.diff(hello_ary, hello_ary)
- expect(Diff::LCS::patch(hello_ary, diff)).to eq(hello_ary)
+ expect(Diff::LCS.patch(hello_ary, diff)).to eq(hello_ary)
end
end
- describe "with default diff callbacks (DiffCallbacks)" do
- describe "forward (s1 -> s2)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'with default diff callbacks (DiffCallbacks)' do
+ describe 'forward (s1 -> s2)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) { Diff::LCS.diff(seq1, seq2) }
end
end
- describe "reverse (s2 -> s1)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'reverse (s2 -> s1)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) { Diff::LCS.diff(seq2, seq1) }
@@ -56,9 +56,9 @@ describe "Diff::LCS.patch" do
end
end
- describe "with context diff callbacks (ContextDiffCallbacks)" do
- describe "forward (s1 -> s2)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'with context diff callbacks (ContextDiffCallbacks)' do
+ describe 'forward (s1 -> s2)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
@@ -67,8 +67,8 @@ describe "Diff::LCS.patch" do
end
end
- describe "reverse (s2 -> s1)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'reverse (s2 -> s1)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
@@ -78,9 +78,9 @@ describe "Diff::LCS.patch" do
end
end
- describe "with sdiff callbacks (SDiffCallbacks)" do
- describe "forward (s1 -> s2)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'with sdiff callbacks (SDiffCallbacks)' do
+ describe 'forward (s1 -> s2)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
@@ -89,8 +89,8 @@ describe "Diff::LCS.patch" do
end
end
- describe "reverse (s2 -> s1)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'reverse (s2 -> s1)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
@@ -101,20 +101,20 @@ describe "Diff::LCS.patch" do
end
end
- describe "using a Diff::LCS.sdiff patchset" do
- describe "an empty patchset returns the source" do
- it "works on a string (hello)" do
- expect(Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello))).to eq(hello)
+ describe 'using a Diff::LCS.sdiff patchset' do
+ describe 'an empty patchset returns the source' do
+ it 'works on a string (hello)' do
+ expect(Diff::LCS.patch(hello, Diff::LCS.sdiff(hello, hello))).to eq(hello)
end
- it "works on an array %W(h e l l o)" do
- expect(Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
+ it 'works on an array %W(h e l l o)' do
+ expect(Diff::LCS.patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
end
end
- describe "with default diff callbacks (DiffCallbacks)" do
- describe "forward (s1 -> s2)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'with default diff callbacks (DiffCallbacks)' do
+ describe 'forward (s1 -> s2)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
@@ -123,8 +123,8 @@ describe "Diff::LCS.patch" do
end
end
- describe "reverse (s2 -> s1)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'reverse (s2 -> s1)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
@@ -134,9 +134,9 @@ describe "Diff::LCS.patch" do
end
end
- describe "with context diff callbacks (DiffCallbacks)" do
- describe "forward (s1 -> s2)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'with context diff callbacks (DiffCallbacks)' do
+ describe 'forward (s1 -> s2)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) {
@@ -145,8 +145,8 @@ describe "Diff::LCS.patch" do
end
end
- describe "reverse (s2 -> s1)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'reverse (s2 -> s1)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) {
@@ -156,17 +156,17 @@ describe "Diff::LCS.patch" do
end
end
- describe "with sdiff callbacks (SDiffCallbacks)" do
- describe "forward (s1 -> s2)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'with sdiff callbacks (SDiffCallbacks)' do
+ describe 'forward (s1 -> s2)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) }
end
end
- describe "reverse (s2 -> s1)" do
- it_has_behavior "patch sequences correctly" do
+ describe 'reverse (s2 -> s1)' do
+ it_has_behavior 'patch sequences correctly' do
let(:s1) { seq2 }
let(:s2) { seq1 }
let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) }
@@ -179,43 +179,43 @@ describe "Diff::LCS.patch" do
# to s2 patches"), this cannot use the "patch sequences correctly" shared
# set. Once the bug in autodiscovery is fixed, this can be converted as
# above.
- describe "fix bug 891: patchsets do not contain the last equal part" do
+ describe 'fix bug 891: patchsets do not contain the last equal part' do
before :each do
- @s1 = %w(a b c d e f g h i j k)
+ @s1 = %w(a b c d e f g h i j k) # rubocop:disable Layout/SpaceInsideArrayPercentLiteral
@s2 = %w(a b c d D e f g h i j k)
end
- describe "using Diff::LCS.diff with default diff callbacks" do
+ describe 'using Diff::LCS.diff with default diff callbacks' do
before :each do
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
end
- it "autodiscovers s1 to s2 patches" do
+ it 'autodiscovers s1 to s2 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 patches" do
+ it 'autodiscovers s2 to s1 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 the left-to-right patches" do
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -223,39 +223,37 @@ describe "Diff::LCS.patch" do
end
end
- describe "using Diff::LCS.diff with context diff callbacks" do
+ describe 'using Diff::LCS.diff with context diff callbacks' do
before :each do
- @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2,
- Diff::LCS::ContextDiffCallbacks)
- @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1,
- Diff::LCS::ContextDiffCallbacks)
+ @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
+ @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
end
- it "autodiscovers s1 to s2 patches" do
+ it 'autodiscovers s1 to s2 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 patches" do
+ it 'autodiscovers s2 to s1 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 the left-to-right patches" do
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -263,39 +261,37 @@ describe "Diff::LCS.patch" do
end
end
- describe "using Diff::LCS.diff with sdiff callbacks" do
+ describe 'using Diff::LCS.diff with sdiff callbacks' do
before(:each) do
- @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2,
- Diff::LCS::SDiffCallbacks)
- @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1,
- Diff::LCS::SDiffCallbacks)
+ @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
+ @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
end
- it "autodiscovers s1 to s2 patches" do
+ it 'autodiscovers s1 to s2 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 patches" do
+ it 'autodiscovers s2 to s1 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 the left-to-right patches" do
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -303,37 +299,37 @@ describe "Diff::LCS.patch" do
end
end
- describe "using Diff::LCS.sdiff with default sdiff callbacks" do
+ describe 'using Diff::LCS.sdiff with default sdiff callbacks' do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2)
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
end
- it "autodiscovers s1 to s2 patches" do
+ it 'autodiscovers s1 to s2 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 patches" do
+ it 'autodiscovers s2 to s1 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 the left-to-right patches" do
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -341,39 +337,37 @@ describe "Diff::LCS.patch" do
end
end
- describe "using Diff::LCS.sdiff with context diff callbacks" do
+ describe 'using Diff::LCS.sdiff with context diff callbacks' do
before(:each) do
- @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2,
- Diff::LCS::ContextDiffCallbacks)
- @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1,
- Diff::LCS::ContextDiffCallbacks)
+ @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
+ @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
end
- it "autodiscovers s1 to s2 patches" do
+ it 'autodiscovers s1 to s2 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 patches" do
+ it 'autodiscovers s2 to s1 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 the left-to-right patches" do
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -381,37 +375,37 @@ describe "Diff::LCS.patch" do
end
end
- describe "using Diff::LCS.sdiff with default diff callbacks" do
+ describe 'using Diff::LCS.sdiff with default diff callbacks' do
before(:each) do
@patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks)
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
end
- it "autodiscovers s1 to s2 patches" do
+ it 'autodiscovers s1 to s2 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 patches" do
+ it 'autodiscovers s2 to s1 patches' do
expect do
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
end.to_not raise_error
end
- it "autodiscovers s2 to s1 the left-to-right patches" do
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
end
- it "correctly patches left-to-right (explicit patch)" do
+ it 'correctly patches left-to-right (explicit patch)' do
expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
end
- it "correctly patches right-to-left (explicit unpatch)" do
+ it 'correctly patches right-to-left (explicit unpatch)' do
expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
diff --git a/spec/sdiff_spec.rb b/spec/sdiff_spec.rb
index d619eb4..06d39d6 100644
--- a/spec/sdiff_spec.rb
+++ b/spec/sdiff_spec.rb
@@ -1,214 +1,214 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe "Diff::LCS.sdiff" do
+describe 'Diff::LCS.sdiff' do
include Diff::LCS::SpecHelper::Matchers
- shared_examples "compare sequences correctly" do
- it "compares s1 -> s2 correctly" do
+ shared_examples 'compare sequences correctly' do
+ it 'compares s1 -> s2 correctly' do
expect(Diff::LCS.sdiff(s1, s2)).to eq(context_diff(result))
end
- it "compares s2 -> s1 correctly" do
+ it 'compares s2 -> s1 correctly' do
expect(Diff::LCS.sdiff(s2, s1)).to eq(context_diff(reverse_sdiff(result)))
end
end
- describe "using seq1 & seq2" do
+ describe 'using seq1 & seq2' do
let(:s1) { seq1 }
let(:s2) { seq2 }
let(:result) { correct_forward_sdiff }
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)" do
+ describe 'using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)' do
let(:s1) { %w(abc def yyy xxx ghi jkl) }
let(:s2) { %w(abc dxf xxx ghi jkl) }
let(:result) {
[
- [ '=', [ 0, 'abc' ], [ 0, 'abc' ] ],
- [ '!', [ 1, 'def' ], [ 1, 'dxf' ] ],
- [ '-', [ 2, 'yyy' ], [ 2, nil ] ],
- [ '=', [ 3, 'xxx' ], [ 2, 'xxx' ] ],
- [ '=', [ 4, 'ghi' ], [ 3, 'ghi' ] ],
- [ '=', [ 5, 'jkl' ], [ 4, 'jkl' ] ]
+ ['=', [0, 'abc'], [0, 'abc']],
+ ['!', [1, 'def'], [1, 'dxf']],
+ ['-', [2, 'yyy'], [2, nil]],
+ ['=', [3, 'xxx'], [2, 'xxx']],
+ ['=', [4, 'ghi'], [3, 'ghi']],
+ ['=', [5, 'jkl'], [4, 'jkl']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(a b c d e) & %w(a e)" do
+ describe 'using %w(a b c d e) & %w(a e)' do
let(:s1) { %w(a b c d e) }
let(:s2) { %w(a e) }
let(:result) {
[
- [ '=', [ 0, 'a' ], [ 0, 'a' ] ],
- [ '-', [ 1, 'b' ], [ 1, nil ] ],
- [ '-', [ 2, 'c' ], [ 1, nil ] ],
- [ '-', [ 3, 'd' ], [ 1, nil ] ],
- [ '=', [ 4, 'e' ], [ 1, 'e' ] ]
+ ['=', [0, 'a'], [0, 'a']],
+ ['-', [1, 'b'], [1, nil]],
+ ['-', [2, 'c'], [1, nil]],
+ ['-', [3, 'd'], [1, nil]],
+ ['=', [4, 'e'], [1, 'e']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(a e) & %w(a b c d e)" do
+ describe 'using %w(a e) & %w(a b c d e)' do
let(:s1) { %w(a e) }
let(:s2) { %w(a b c d e) }
let(:result) {
[
- [ '=', [ 0, 'a' ], [ 0, 'a' ] ],
- [ '+', [ 1, nil ], [ 1, 'b' ] ],
- [ '+', [ 1, nil ], [ 2, 'c' ] ],
- [ '+', [ 1, nil ], [ 3, 'd' ] ],
- [ '=', [ 1, 'e' ], [ 4, 'e' ] ]
+ ['=', [0, 'a'], [0, 'a']],
+ ['+', [1, nil], [1, 'b']],
+ ['+', [1, nil], [2, 'c']],
+ ['+', [1, nil], [3, 'd']],
+ ['=', [1, 'e'], [4, 'e']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(v x a e) & %w(w y a b c d e)" do
+ describe 'using %w(v x a e) & %w(w y a b c d e)' do
let(:s1) { %w(v x a e) }
let(:s2) { %w(w y a b c d e) }
let(:result) {
[
- [ '!', [ 0, 'v' ], [ 0, 'w' ] ],
- [ '!', [ 1, 'x' ], [ 1, 'y' ] ],
- [ '=', [ 2, 'a' ], [ 2, 'a' ] ],
- [ '+', [ 3, nil ], [ 3, 'b' ] ],
- [ '+', [ 3, nil ], [ 4, 'c' ] ],
- [ '+', [ 3, nil ], [ 5, 'd' ] ],
- [ '=', [ 3, 'e' ], [ 6, 'e' ] ]
+ ['!', [0, 'v'], [0, 'w']],
+ ['!', [1, 'x'], [1, 'y']],
+ ['=', [2, 'a'], [2, 'a']],
+ ['+', [3, nil], [3, 'b']],
+ ['+', [3, nil], [4, 'c']],
+ ['+', [3, nil], [5, 'd']],
+ ['=', [3, 'e'], [6, 'e']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(x a e) & %w(a b c d e)" do
+ describe 'using %w(x a e) & %w(a b c d e)' do
let(:s1) { %w(x a e) }
let(:s2) { %w(a b c d e) }
let(:result) {
[
- [ '-', [ 0, 'x' ], [ 0, nil ] ],
- [ '=', [ 1, 'a' ], [ 0, 'a' ] ],
- [ '+', [ 2, nil ], [ 1, 'b' ] ],
- [ '+', [ 2, nil ], [ 2, 'c' ] ],
- [ '+', [ 2, nil ], [ 3, 'd' ] ],
- [ '=', [ 2, 'e' ], [ 4, 'e' ] ]
+ ['-', [0, 'x'], [0, nil]],
+ ['=', [1, 'a'], [0, 'a']],
+ ['+', [2, nil], [1, 'b']],
+ ['+', [2, nil], [2, 'c']],
+ ['+', [2, nil], [3, 'd']],
+ ['=', [2, 'e'], [4, 'e']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(a e) & %w(x a b c d e)" do
+ describe 'using %w(a e) & %w(x a b c d e)' do
let(:s1) { %w(a e) }
let(:s2) { %w(x a b c d e) }
let(:result) {
[
- [ '+', [ 0, nil ], [ 0, 'x' ] ],
- [ '=', [ 0, 'a' ], [ 1, 'a' ] ],
- [ '+', [ 1, nil ], [ 2, 'b' ] ],
- [ '+', [ 1, nil ], [ 3, 'c' ] ],
- [ '+', [ 1, nil ], [ 4, 'd' ] ],
- [ '=', [ 1, 'e' ], [ 5, 'e' ] ]
+ ['+', [0, nil], [0, 'x']],
+ ['=', [0, 'a'], [1, 'a']],
+ ['+', [1, nil], [2, 'b']],
+ ['+', [1, nil], [3, 'c']],
+ ['+', [1, nil], [4, 'd']],
+ ['=', [1, 'e'], [5, 'e']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(a e v) & %w(x a b c d e w x)" do
+ describe 'using %w(a e v) & %w(x a b c d e w x)' do
let(:s1) { %w(a e v) }
let(:s2) { %w(x a b c d e w x) }
let(:result) {
[
- [ '+', [ 0, nil ], [ 0, 'x' ] ],
- [ '=', [ 0, 'a' ], [ 1, 'a' ] ],
- [ '+', [ 1, nil ], [ 2, 'b' ] ],
- [ '+', [ 1, nil ], [ 3, 'c' ] ],
- [ '+', [ 1, nil ], [ 4, 'd' ] ],
- [ '=', [ 1, 'e' ], [ 5, 'e' ] ],
- [ '!', [ 2, 'v' ], [ 6, 'w' ] ],
- [ '+', [ 3, nil ], [ 7, 'x' ] ]
+ ['+', [0, nil], [0, 'x']],
+ ['=', [0, 'a'], [1, 'a']],
+ ['+', [1, nil], [2, 'b']],
+ ['+', [1, nil], [3, 'c']],
+ ['+', [1, nil], [4, 'd']],
+ ['=', [1, 'e'], [5, 'e']],
+ ['!', [2, 'v'], [6, 'w']],
+ ['+', [3, nil], [7, 'x']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w() & %w(a b c)" do
+ describe 'using %w() & %w(a b c)' do
let(:s1) { %w() }
let(:s2) { %w(a b c) }
let(:result) {
[
- [ '+', [ 0, nil ], [ 0, 'a' ] ],
- [ '+', [ 0, nil ], [ 1, 'b' ] ],
- [ '+', [ 0, nil ], [ 2, 'c' ] ]
+ ['+', [0, nil], [0, 'a']],
+ ['+', [0, nil], [1, 'b']],
+ ['+', [0, nil], [2, 'c']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(a b c) & %w(1)" do
+ describe 'using %w(a b c) & %w(1)' do
let(:s1) { %w(a b c) }
let(:s2) { %w(1) }
let(:result) {
[
- [ '!', [ 0, 'a' ], [ 0, '1' ] ],
- [ '-', [ 1, 'b' ], [ 1, nil ] ],
- [ '-', [ 2, 'c' ], [ 1, nil ] ]
+ ['!', [0, 'a'], [0, '1']],
+ ['-', [1, 'b'], [1, nil]],
+ ['-', [2, 'c'], [1, nil]]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(a b c) & %w(c)" do
+ describe 'using %w(a b c) & %w(c)' do
let(:s1) { %w(a b c) }
let(:s2) { %w(c) }
let(:result) {
[
- [ '-', [ 0, 'a' ], [ 0, nil ] ],
- [ '-', [ 1, 'b' ], [ 0, nil ] ],
- [ '=', [ 2, 'c' ], [ 0, 'c' ] ]
+ ['-', [0, 'a'], [0, nil]],
+ ['-', [1, 'b'], [0, nil]],
+ ['=', [2, 'c'], [0, 'c']]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using %w(abcd efgh ijkl mnop) & []" do
+ describe 'using %w(abcd efgh ijkl mnop) & []' do
let(:s1) { %w(abcd efgh ijkl mnop) }
let(:s2) { [] }
let(:result) {
[
- [ '-', [ 0, 'abcd' ], [ 0, nil ] ],
- [ '-', [ 1, 'efgh' ], [ 0, nil ] ],
- [ '-', [ 2, 'ijkl' ], [ 0, nil ] ],
- [ '-', [ 3, 'mnop' ], [ 0, nil ] ]
+ ['-', [0, 'abcd'], [0, nil]],
+ ['-', [1, 'efgh'], [0, nil]],
+ ['-', [2, 'ijkl'], [0, nil]],
+ ['-', [3, 'mnop'], [0, nil]]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
- describe "using [[1,2]] & []" do
- let(:s1) { [ [ 1, 2 ] ] }
+ describe 'using [[1,2]] & []' do
+ let(:s1) { [[1, 2]] }
let(:s2) { [] }
let(:result) {
[
- [ '-', [ 0, [ 1, 2 ] ], [ 0, nil ] ]
+ ['-', [0, [1, 2]], [0, nil]]
]
}
- it_has_behavior "compare sequences correctly"
+ it_has_behavior 'compare sequences correctly'
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 27298c4..4899c49 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,4 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'rubygems'
require 'pathname'
@@ -10,14 +10,14 @@ if ENV['COVERALLS']
elsif ENV['COVERAGE']
require 'simplecov'
- def require_do(resource, &block)
+ def require_do(resource)
require resource
- block.call
+ yield if block_given?
rescue LoadError
nil
end
- formatters = [ SimpleCov::Formatter::HTMLFormatter ]
+ formatters = [SimpleCov::Formatter::HTMLFormatter]
require_do('simplecov-rcov') {
formatters << SimpleCov::Formatter::RcovFormatter
@@ -44,11 +44,11 @@ require 'diff-lcs'
module Diff::LCS::SpecHelper
def hello
- "hello"
+ 'hello'
end
def hello_ary
- %W(h e l l o)
+ %w(h e l l o)
end
def seq1
@@ -77,50 +77,69 @@ module Diff::LCS::SpecHelper
def correct_forward_diff
[
- [ [ '-', 0, 'a' ] ],
- [ [ '+', 2, 'd' ] ],
- [ [ '-', 4, 'h' ],
- [ '+', 4, 'f' ] ],
- [ [ '+', 6, 'k' ] ],
- [ [ '-', 8, 'n' ],
- [ '-', 9, 'p' ],
- [ '+', 9, 'r' ],
- [ '+', 10, 's' ],
- [ '+', 11, 't' ] ]
+ [
+ ['-', 0, 'a']
+ ],
+ [
+ ['+', 2, 'd']
+ ],
+ [
+ ['-', 4, 'h'],
+ ['+', 4, 'f']
+ ],
+ [
+ ['+', 6, 'k']
+ ],
+ [
+ ['-', 8, 'n'],
+ ['-', 9, 'p'],
+ ['+', 9, 'r'],
+ ['+', 10, 's'],
+ ['+', 11, 't']
+ ]
]
end
def correct_backward_diff
[
- [ [ '+', 0, 'a' ] ],
- [ [ '-', 2, 'd' ] ],
- [ [ '-', 4, 'f' ],
- [ '+', 4, 'h' ] ],
- [ [ '-', 6, 'k' ] ],
[
- [ '-', 9, 'r' ],
- [ '-', 10, 's' ],
- [ '+', 8, 'n' ],
- [ '-', 11, 't' ],
- [ '+', 9, 'p' ] ]
+ ['+', 0, 'a']
+ ],
+ [
+ ['-', 2, 'd']
+ ],
+ [
+ ['-', 4, 'f'],
+ ['+', 4, 'h']
+ ],
+ [
+ ['-', 6, 'k']
+ ],
+ [
+ ['-', 9, 'r'],
+ ['-', 10, 's'],
+ ['+', 8, 'n'],
+ ['-', 11, 't'],
+ ['+', 9, 'p']
+ ]
]
end
def correct_forward_sdiff
[
- [ '-', [ 0, 'a' ], [ 0, nil ] ],
- [ '=', [ 1, 'b' ], [ 0, 'b' ] ],
- [ '=', [ 2, 'c' ], [ 1, 'c' ] ],
- [ '+', [ 3, nil ], [ 2, 'd' ] ],
- [ '=', [ 3, 'e' ], [ 3, 'e' ] ],
- [ '!', [ 4, 'h' ], [ 4, 'f' ] ],
- [ '=', [ 5, 'j' ], [ 5, 'j' ] ],
- [ '+', [ 6, nil ], [ 6, 'k' ] ],
- [ '=', [ 6, 'l' ], [ 7, 'l' ] ],
- [ '=', [ 7, 'm' ], [ 8, 'm' ] ],
- [ '!', [ 8, 'n' ], [ 9, 'r' ] ],
- [ '!', [ 9, 'p' ], [ 10, 's' ] ],
- [ '+', [ 10, nil ], [ 11, 't' ] ]
+ ['-', [0, 'a'], [0, nil]],
+ ['=', [1, 'b'], [0, 'b']],
+ ['=', [2, 'c'], [1, 'c']],
+ ['+', [3, nil], [2, 'd']],
+ ['=', [3, 'e'], [3, 'e']],
+ ['!', [4, 'h'], [4, 'f']],
+ ['=', [5, 'j'], [5, 'j']],
+ ['+', [6, nil], [6, 'k']],
+ ['=', [6, 'l'], [7, 'l']],
+ ['=', [7, 'm'], [8, 'm']],
+ ['!', [8, 'n'], [9, 'r']],
+ ['!', [9, 'p'], [10, 's']],
+ ['+', [10, nil], [11, 't']]
]
end
@@ -144,13 +163,13 @@ module Diff::LCS::SpecHelper
end
def format_diffs(diffs)
- diffs.map do |e|
+ diffs.map { |e|
if e.kind_of?(Array)
- e.map { |f| f.to_a.join }.join(", ")
+ e.map { |f| f.to_a.join }.join(', ')
else
e.to_a.join
end
- end.join("\n")
+ }.join("\n")
end
def map_diffs(diffs, klass = Diff::LCS::ContextChange)
@@ -171,8 +190,8 @@ module Diff::LCS::SpecHelper
def balanced_reverse(change_result)
new_result = []
- change_result.each { |line|
- line = [ line[0], line[2], line[1] ]
+ change_result.each do |line|
+ line = [line[0], line[2], line[1]]
case line[0]
when '<'
line[0] = '>'
@@ -180,21 +199,21 @@ module Diff::LCS::SpecHelper
line[0] = '<'
end
new_result << line
- }
- new_result.sort_by { |line| [ line[1], line[2] ] }
+ end
+ new_result.sort_by { |line| [line[1], line[2]] }
end
def map_to_no_change(change_result)
new_result = []
- change_result.each { |line|
+ change_result.each do |line|
case line[0]
when '!'
- new_result << [ '<', line[1], line[2] ]
- new_result << [ '>', line[1] + 1, line[2] ]
+ new_result << ['<', line[1], line[2]]
+ new_result << ['>', line[1] + 1, line[2]]
else
new_result << line
end
- }
+ end
new_result
end
@@ -231,14 +250,18 @@ module Diff::LCS::SpecHelper
end
def finished_a(event)
- @done_a << [event.old_element, event.old_position,
- event.new_element, event.new_position]
+ @done_a << [
+ event.old_element, event.old_position,
+ event.new_element, event.new_position
+ ]
end
def finished_b(event)
- p "called #finished_b"
- @done_b << [event.old_element, event.old_position,
- event.new_element, event.new_position]
+ p 'called #finished_b'
+ @done_b << [
+ event.old_element, event.old_position,
+ event.new_element, event.new_position
+ ]
end
end
callbacks.reset
@@ -264,19 +287,19 @@ module Diff::LCS::SpecHelper
end
def match(event)
- @result << [ "=", event.old_position, event.new_position ]
+ @result << ['=', event.old_position, event.new_position]
end
def discard_a(event)
- @result << [ "<", event.old_position, event.new_position ]
+ @result << ['<', event.old_position, event.new_position]
end
def discard_b(event)
- @result << [ ">", event.old_position, event.new_position ]
+ @result << ['>', event.old_position, event.new_position]
end
def change(event)
- @result << [ "!", event.old_position, event.new_position ]
+ @result << ['!', event.old_position, event.new_position]
end
end
cb.reset
diff --git a/spec/traverse_balanced_spec.rb b/spec/traverse_balanced_spec.rb
index 95e60ec..9ee68ea 100644
--- a/spec/traverse_balanced_spec.rb
+++ b/spec/traverse_balanced_spec.rb
@@ -1,310 +1,310 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe "Diff::LCS.traverse_balanced" do
+describe 'Diff::LCS.traverse_balanced' do
include Diff::LCS::SpecHelper::Matchers
- shared_examples "with a #change callback" do |s1, s2, result|
- it "traverses s1 -> s2 correctly" do
+ shared_examples 'with a #change callback' do |s1, s2, result|
+ it 'traverses s1 -> s2 correctly' do
traversal = balanced_traversal(s1, s2, :balanced_callback)
expect(traversal.result).to eq(result)
end
- it "traverses s2 -> s1 correctly" do
+ it 'traverses s2 -> s1 correctly' do
traversal = balanced_traversal(s2, s1, :balanced_callback)
expect(traversal.result).to eq(balanced_reverse(result))
end
end
- shared_examples "without a #change callback" do |s1, s2, result|
- it "traverses s1 -> s2 correctly" do
+ shared_examples 'without a #change callback' do |s1, s2, result|
+ it 'traverses s1 -> s2 correctly' do
traversal = balanced_traversal(s1, s2, :balanced_callback_no_change)
expect(traversal.result).to eq(map_to_no_change(result))
end
- it "traverses s2 -> s1 correctly" do
+ it 'traverses s2 -> s1 correctly' do
traversal = balanced_traversal(s2, s1, :balanced_callback_no_change)
expect(traversal.result).to eq(map_to_no_change(balanced_reverse(result)))
end
end
describe "identical string sequences ('abc')" do
- s1 = s2 = "abc"
+ s1 = s2 = 'abc'
result = [
- [ '=', 0, 0 ],
- [ '=', 1, 1 ],
- [ '=', 2, 2 ]
+ ['=', 0, 0],
+ ['=', 1, 1],
+ ['=', 2, 2]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "identical array sequences %w(a b c)" do
+ describe 'identical array sequences %w(a b c)' do
s1 = s2 = %w(a b c)
result = [
- [ '=', 0, 0 ],
- [ '=', 1, 1 ],
- [ '=', 2, 2 ]
+ ['=', 0, 0],
+ ['=', 1, 1],
+ ['=', 2, 2]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(a b c) & %w(a x c)" do
+ describe 'sequences %w(a b c) & %w(a x c)' do
s1 = %w(a b c)
s2 = %w(a x c)
result = [
- [ '=', 0, 0 ],
- [ '!', 1, 1 ],
- [ '=', 2, 2 ]
+ ['=', 0, 0],
+ ['!', 1, 1],
+ ['=', 2, 2]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(a x y c) & %w(a v w c)" do
+ describe 'sequences %w(a x y c) & %w(a v w c)' do
s1 = %w(a x y c)
s2 = %w(a v w c)
result = [
- [ '=', 0, 0 ],
- [ '!', 1, 1 ],
- [ '!', 2, 2 ],
- [ '=', 3, 3 ]
+ ['=', 0, 0],
+ ['!', 1, 1],
+ ['!', 2, 2],
+ ['=', 3, 3]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(x y c) & %w(v w c)" do
+ describe 'sequences %w(x y c) & %w(v w c)' do
s1 = %w(x y c)
s2 = %w(v w c)
result = [
- [ '!', 0, 0 ],
- [ '!', 1, 1 ],
- [ '=', 2, 2 ]
+ ['!', 0, 0],
+ ['!', 1, 1],
+ ['=', 2, 2]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(a x y z) & %w(b v w)" do
+ describe 'sequences %w(a x y z) & %w(b v w)' do
s1 = %w(a x y z)
s2 = %w(b v w)
result = [
- [ '!', 0, 0 ],
- [ '!', 1, 1 ],
- [ '!', 2, 2 ],
- [ '<', 3, 3 ]
+ ['!', 0, 0],
+ ['!', 1, 1],
+ ['!', 2, 2],
+ ['<', 3, 3]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(a z) & %w(a)" do
+ describe 'sequences %w(a z) & %w(a)' do
s1 = %w(a z)
s2 = %w(a)
result = [
- [ '=', 0, 0 ],
- [ '<', 1, 1 ]
+ ['=', 0, 0],
+ ['<', 1, 1]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(z a) & %w(a)" do
+ describe 'sequences %w(z a) & %w(a)' do
s1 = %w(z a)
s2 = %w(a)
result = [
- [ '<', 0, 0 ],
- [ '=', 1, 0 ]
+ ['<', 0, 0],
+ ['=', 1, 0]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(a b c) & %w(x y z)" do
+ describe 'sequences %w(a b c) & %w(x y z)' do
s1 = %w(a b c)
s2 = %w(x y z)
result = [
- [ '!', 0, 0 ],
- [ '!', 1, 1 ],
- [ '!', 2, 2 ]
+ ['!', 0, 0],
+ ['!', 1, 1],
+ ['!', 2, 2]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "sequences %w(abcd efgh ijkl mnoopqrstuvwxyz) & []" do
+ describe 'sequences %w(abcd efgh ijkl mnoopqrstuvwxyz) & []' do
s1 = %w(abcd efgh ijkl mnopqrstuvwxyz)
s2 = []
result = [
- [ '<', 0, 0 ],
- [ '<', 1, 0 ],
- [ '<', 2, 0 ],
- [ '<', 3, 0 ]
+ ['<', 0, 0],
+ ['<', 1, 0],
+ ['<', 2, 0],
+ ['<', 3, 0]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(a b c) & %Q(a x c)" do
- s1 = %Q(a b c)
- s2 = %Q(a x c)
+ describe 'strings %q(a b c) & %q(a x c)' do
+ s1 = 'a b c'
+ s2 = 'a x c'
result = [
- [ '=', 0, 0 ],
- [ '=', 1, 1 ],
- [ '!', 2, 2 ],
- [ '=', 3, 3 ],
- [ '=', 4, 4 ]
+ ['=', 0, 0],
+ ['=', 1, 1],
+ ['!', 2, 2],
+ ['=', 3, 3],
+ ['=', 4, 4]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(a x y c) & %Q(a v w c)" do
- s1 = %Q(a x y c)
- s2 = %Q(a v w c)
+ describe 'strings %q(a x y c) & %q(a v w c)' do
+ s1 = 'a x y c'
+ s2 = 'a v w c'
result = [
- [ '=', 0, 0 ],
- [ '=', 1, 1 ],
- [ '!', 2, 2 ],
- [ '=', 3, 3 ],
- [ '!', 4, 4 ],
- [ '=', 5, 5 ],
- [ '=', 6, 6 ]
+ ['=', 0, 0],
+ ['=', 1, 1],
+ ['!', 2, 2],
+ ['=', 3, 3],
+ ['!', 4, 4],
+ ['=', 5, 5],
+ ['=', 6, 6]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(x y c) & %Q(v w c)" do
- s1 = %Q(x y c)
- s2 = %Q(v w c)
+ describe 'strings %q(x y c) & %q(v w c)' do
+ s1 = 'x y c'
+ s2 = 'v w c'
result = [
- [ '!', 0, 0 ],
- [ '=', 1, 1 ],
- [ '!', 2, 2 ],
- [ '=', 3, 3 ],
- [ '=', 4, 4 ]
+ ['!', 0, 0],
+ ['=', 1, 1],
+ ['!', 2, 2],
+ ['=', 3, 3],
+ ['=', 4, 4]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(a x y z) & %Q(b v w)" do
- s1 = %Q(a x y z)
- s2 = %Q(b v w)
+ describe 'strings %q(a x y z) & %q(b v w)' do
+ s1 = 'a x y z'
+ s2 = 'b v w'
result = [
- [ '!', 0, 0 ],
- [ '=', 1, 1 ],
- [ '!', 2, 2 ],
- [ '=', 3, 3 ],
- [ '!', 4, 4 ],
- [ '<', 5, 5 ],
- [ '<', 6, 5 ]
+ ['!', 0, 0],
+ ['=', 1, 1],
+ ['!', 2, 2],
+ ['=', 3, 3],
+ ['!', 4, 4],
+ ['<', 5, 5],
+ ['<', 6, 5]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(a z) & %Q(a)" do
- s1 = %Q(a z)
- s2 = %Q(a)
+ describe 'strings %q(a z) & %q(a)' do
+ s1 = 'a z'
+ s2 = 'a'
result = [
- [ '=', 0, 0 ],
- [ '<', 1, 1 ],
- [ '<', 2, 1 ]
+ ['=', 0, 0],
+ ['<', 1, 1],
+ ['<', 2, 1]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(z a) & %Q(a)" do
- s1 = %Q(z a)
- s2 = %Q(a)
+ describe 'strings %q(z a) & %q(a)' do
+ s1 = 'z a'
+ s2 = 'a'
result = [
- [ '<', 0, 0 ],
- [ '<', 1, 0 ],
- [ '=', 2, 0 ]
+ ['<', 0, 0],
+ ['<', 1, 0],
+ ['=', 2, 0]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(a b c) & %Q(x y z)" do
- s1 = %Q(a b c)
- s2 = %Q(x y z)
+ describe 'strings %q(a b c) & %q(x y z)' do
+ s1 = 'a b c'
+ s2 = 'x y z'
result = [
- [ '!', 0, 0 ],
- [ '=', 1, 1 ],
- [ '!', 2, 2 ],
- [ '=', 3, 3 ],
- [ '!', 4, 4 ]
+ ['!', 0, 0],
+ ['=', 1, 1],
+ ['!', 2, 2],
+ ['=', 3, 3],
+ ['!', 4, 4]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
- describe "strings %Q(abcd efgh ijkl mnopqrstuvwxyz) & %Q()" do
- s1 = %Q(abcd efgh ijkl mnopqrstuvwxyz)
- s2 = ""
+ describe 'strings %q(abcd efgh ijkl mnopqrstuvwxyz) & %q()' do
+ s1 = 'abcd efgh ijkl mnopqrstuvwxyz'
+ s2 = ''
result = [
- [ '<', 0, 0 ],
- [ '<', 1, 0 ],
- [ '<', 2, 0 ],
- [ '<', 3, 0 ],
- [ '<', 4, 0 ],
- [ '<', 5, 0 ],
- [ '<', 6, 0 ],
- [ '<', 7, 0 ],
- [ '<', 8, 0 ],
- [ '<', 9, 0 ],
- [ '<', 10, 0 ],
- [ '<', 11, 0 ],
- [ '<', 12, 0 ],
- [ '<', 13, 0 ],
- [ '<', 14, 0 ],
- [ '<', 15, 0 ],
- [ '<', 16, 0 ],
- [ '<', 17, 0 ],
- [ '<', 18, 0 ],
- [ '<', 19, 0 ],
- [ '<', 20, 0 ],
- [ '<', 21, 0 ],
- [ '<', 22, 0 ],
- [ '<', 23, 0 ],
- [ '<', 24, 0 ],
- [ '<', 25, 0 ],
- [ '<', 26, 0 ],
- [ '<', 27, 0 ],
- [ '<', 28, 0 ],
+ ['<', 0, 0],
+ ['<', 1, 0],
+ ['<', 2, 0],
+ ['<', 3, 0],
+ ['<', 4, 0],
+ ['<', 5, 0],
+ ['<', 6, 0],
+ ['<', 7, 0],
+ ['<', 8, 0],
+ ['<', 9, 0],
+ ['<', 10, 0],
+ ['<', 11, 0],
+ ['<', 12, 0],
+ ['<', 13, 0],
+ ['<', 14, 0],
+ ['<', 15, 0],
+ ['<', 16, 0],
+ ['<', 17, 0],
+ ['<', 18, 0],
+ ['<', 19, 0],
+ ['<', 20, 0],
+ ['<', 21, 0],
+ ['<', 22, 0],
+ ['<', 23, 0],
+ ['<', 24, 0],
+ ['<', 25, 0],
+ ['<', 26, 0],
+ ['<', 27, 0],
+ ['<', 28, 0]
]
- it_has_behavior "with a #change callback", s1, s2, result
- it_has_behavior "without a #change callback", s1, s2, result
+ it_has_behavior 'with a #change callback', s1, s2, result
+ it_has_behavior 'without a #change callback', s1, s2, result
end
end
diff --git a/spec/traverse_sequences_spec.rb b/spec/traverse_sequences_spec.rb
index 1252d53..ea7a129 100644
--- a/spec/traverse_sequences_spec.rb
+++ b/spec/traverse_sequences_spec.rb
@@ -1,10 +1,10 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'spec_helper'
-describe "Diff::LCS.traverse_sequences" do
- describe "callback with no finishers" do
- describe "over (seq1, seq2)" do
+describe 'Diff::LCS.traverse_sequences' do
+ describe 'callback with no finishers' do
+ describe 'over (seq1, seq2)' do
before(:each) do
@callback_s1_s2 = simple_callback_no_finishers
Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2)
@@ -13,27 +13,27 @@ describe "Diff::LCS.traverse_sequences" do
Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1)
end
- it "has the correct LCS result on left-matches" do
+ it 'has the correct LCS result on left-matches' do
expect(@callback_s1_s2.matched_a).to eq(correct_lcs)
expect(@callback_s2_s1.matched_a).to eq(correct_lcs)
end
- it "has the correct LCS result on right-matches" do
+ it 'has the correct LCS result on right-matches' do
expect(@callback_s1_s2.matched_b).to eq(correct_lcs)
expect(@callback_s2_s1.matched_b).to eq(correct_lcs)
end
- it "has the correct skipped sequences with the left sequence" do
+ it 'has the correct skipped sequences with the left sequence' do
expect(@callback_s1_s2.discards_a).to eq(skipped_seq1)
expect(@callback_s2_s1.discards_a).to eq(skipped_seq2)
end
- it "has the correct skipped sequences with the right sequence" do
+ it 'has the correct skipped sequences with the right sequence' do
expect(@callback_s1_s2.discards_b).to eq(skipped_seq2)
expect(@callback_s2_s1.discards_b).to eq(skipped_seq1)
end
- it "does not have anything done markers from the left or right sequences" do
+ it 'does not have anything done markers from the left or right sequences' do
expect(@callback_s1_s2.done_a).to be_empty
expect(@callback_s1_s2.done_b).to be_empty
expect(@callback_s2_s1.done_a).to be_empty
@@ -41,64 +41,64 @@ describe "Diff::LCS.traverse_sequences" do
end
end
- describe "over (hello, hello)" do
+ describe 'over (hello, hello)' do
before(:each) do
@callback = simple_callback_no_finishers
Diff::LCS.traverse_sequences(hello, hello, @callback)
end
- it "has the correct LCS result on left-matches" do
+ it 'has the correct LCS result on left-matches' do
expect(@callback.matched_a).to eq(hello.split(//))
end
- it "has the correct LCS result on right-matches" do
+ it 'has the correct LCS result on right-matches' do
expect(@callback.matched_b).to eq(hello.split(//))
end
- it "has the correct skipped sequences with the left sequence", :only => true do
+ it 'has the correct skipped sequences with the left sequence', :only => true do
expect(@callback.discards_a).to be_empty
end
- it "has the correct skipped sequences with the right sequence" do
+ it 'has the correct skipped sequences with the right sequence' do
expect(@callback.discards_b).to be_empty
end
- it "does not have anything done markers from the left or right sequences" do
+ it 'does not have anything done markers from the left or right sequences' do
expect(@callback.done_a).to be_empty
expect(@callback.done_b).to be_empty
end
end
- describe "over (hello_ary, hello_ary)" do
+ describe 'over (hello_ary, hello_ary)' do
before(:each) do
@callback = simple_callback_no_finishers
Diff::LCS.traverse_sequences(hello_ary, hello_ary, @callback)
end
- it "has the correct LCS result on left-matches" do
+ it 'has the correct LCS result on left-matches' do
expect(@callback.matched_a).to eq(hello_ary)
end
- it "has the correct LCS result on right-matches" do
+ it 'has the correct LCS result on right-matches' do
expect(@callback.matched_b).to eq(hello_ary)
end
- it "has the correct skipped sequences with the left sequence" do
+ it 'has the correct skipped sequences with the left sequence' do
expect(@callback.discards_a).to be_empty
end
- it "has the correct skipped sequences with the right sequence" do
+ it 'has the correct skipped sequences with the right sequence' do
expect(@callback.discards_b).to be_empty
end
- it "does not have anything done markers from the left or right sequences" do
+ it 'does not have anything done markers from the left or right sequences' do
expect(@callback.done_a).to be_empty
expect(@callback.done_b).to be_empty
end
end
end
- describe "callback with finisher" do
+ describe 'callback with finisher' do
before(:each) do
@callback_s1_s2 = simple_callback
Diff::LCS.traverse_sequences(seq1, seq2, @callback_s1_s2)
@@ -106,28 +106,28 @@ describe "Diff::LCS.traverse_sequences" do
Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1)
end
- it "has the correct LCS result on left-matches" do
+ it 'has the correct LCS result on left-matches' do
expect(@callback_s1_s2.matched_a).to eq(correct_lcs)
expect(@callback_s2_s1.matched_a).to eq(correct_lcs)
end
- it "has the correct LCS result on right-matches" do
+ it 'has the correct LCS result on right-matches' do
expect(@callback_s1_s2.matched_b).to eq(correct_lcs)
expect(@callback_s2_s1.matched_b).to eq(correct_lcs)
end
- it "has the correct skipped sequences for the left sequence" do
+ it 'has the correct skipped sequences for the left sequence' do
expect(@callback_s1_s2.discards_a).to eq(skipped_seq1)
expect(@callback_s2_s1.discards_a).to eq(skipped_seq2)
end
- it "has the correct skipped sequences for the right sequence" do
+ it 'has the correct skipped sequences for the right sequence' do
expect(@callback_s1_s2.discards_b).to eq(skipped_seq2)
expect(@callback_s2_s1.discards_b).to eq(skipped_seq1)
end
- it "has done markers differently-sized sequences" do
- expect(@callback_s1_s2.done_a).to eq([[ "p", 9, "s", 10 ]])
+ it 'has done markers differently-sized sequences' do
+ expect(@callback_s1_s2.done_a).to eq([['p', 9, 's', 10]])
expect(@callback_s1_s2.done_b).to be_empty
# 20110731 I don't yet understand why this particular behaviour