summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2014-05-06 00:08:02 -0400
committerAustin Ziegler <austin@zieglers.ca>2017-01-18 18:16:14 -0500
commit06ee20e929656d41c301f61fd447105c3840e410 (patch)
tree7325cd8e3279b71e5bc18302112e47cad3000a40 /spec
parent32727d6d0beb48672a1ee2d4a5c20bb81f7e301d (diff)
downloaddiff-lcs-06ee20e929656d41c301f61fd447105c3840e410.tar.gz
diff-lcs 1.3
- Updated testing and gem infrastructure. - Cleaning up documentation. - Modernizing specs. - Silence Ruby 2.4 Fixnum deprecation warnings. Fixes #36, #38. - Ensure test dependencies are loaded. Fixes #33, #34 so that specs can be run independently. - Fix issue #1 with incorrect intuition of patch direction. Tentative fix, but the failure cases pass now.
Diffstat (limited to 'spec')
-rw-r--r--spec/diff_spec.rb28
-rw-r--r--spec/fixtures/ds1.csv50
-rw-r--r--spec/fixtures/ds2.csv51
-rw-r--r--spec/hunk_spec.rb34
-rw-r--r--spec/issues_spec.rb55
-rw-r--r--spec/lcs_spec.rb44
-rw-r--r--spec/ldiff_spec.rb47
-rw-r--r--spec/patch_spec.rb282
-rw-r--r--spec/sdiff_spec.rb8
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--spec/traverse_balanced_spec.rb16
-rw-r--r--spec/traverse_sequences_spec.rb112
12 files changed, 457 insertions, 274 deletions
diff --git a/spec/diff_spec.rb b/spec/diff_spec.rb
index 95d7b40..020ff44 100644
--- a/spec/diff_spec.rb
+++ b/spec/diff_spec.rb
@@ -2,20 +2,20 @@
require 'spec_helper'
-describe "Diff::LCS.diff" do
+describe Diff::LCS, ".diff" do
include Diff::LCS::SpecHelper::Matchers
- it "should correctly diff seq1 to seq2" do
+ it "correctly diffs seq1 to seq2" do
diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
- change_diff(correct_forward_diff).should == diff_s1_s2
+ expect(change_diff(correct_forward_diff)).to eq(diff_s1_s2)
end
- it "should correctly diff seq2 to seq1" do
+ it "correctly diffs seq2 to seq1" do
diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
- change_diff(correct_backward_diff).should == diff_s2_s1
+ expect(change_diff(correct_backward_diff)).to eq(diff_s2_s1)
end
- it "should correctly diff against an empty sequence" do
+ it "correctly diffs against an empty sequence" do
diff = Diff::LCS.diff(word_sequence, [])
correct_diff = [
[ [ '-', 0, 'abcd' ],
@@ -24,24 +24,24 @@ describe "Diff::LCS.diff" do
[ '-', 3, 'mnopqrstuvwxyz' ] ]
]
- change_diff(correct_diff).should == diff
+ expect(change_diff(correct_diff)).to eq(diff)
diff = Diff::LCS.diff([], word_sequence)
correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
- change_diff(correct_diff).should == diff
+ expect(change_diff(correct_diff)).to eq(diff)
end
- it "should correctly diff 'xx' and 'xaxb'" do
+ it "correctly diffs 'xx' and 'xaxb'" do
left = 'xx'
right = 'xaxb'
- Diff::LCS.patch(left, Diff::LCS.diff(left, right)).should == right
+ expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
end
- it "should return an empty diff with (hello, hello)" do
- Diff::LCS.diff(hello, hello).should == []
+ it "returns an empty diff with (hello, hello)" do
+ expect(Diff::LCS.diff(hello, hello)).to be_empty
end
- it "should return an empty diff with (hello_ary, hello_ary)" do
- Diff::LCS.diff(hello_ary, hello_ary).should == []
+ 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/fixtures/ds1.csv b/spec/fixtures/ds1.csv
new file mode 100644
index 0000000..9ac8428
--- /dev/null
+++ b/spec/fixtures/ds1.csv
@@ -0,0 +1,50 @@
+1,3
+2,7
+3,13
+4,21
+5,31
+6,43
+7,57
+8,73
+9,91
+10,111
+11,133
+12,157
+13,183
+14,211
+15,241
+16,273
+17,307
+18,343
+19,381
+20,421
+21,463
+22,507
+23,553
+24,601
+25,651
+26,703
+27,757
+28,813
+29,871
+30,931
+31,993
+32,1057
+33,1123
+34,1191
+35,1261
+36,1333
+37,1407
+38,1483
+39,1561
+40,1641
+41,1723
+42,1807
+43,1893
+44,1981
+45,2071
+46,2163
+47,2257
+48,2353
+49,2451
+50,2500 \ No newline at end of file
diff --git a/spec/fixtures/ds2.csv b/spec/fixtures/ds2.csv
new file mode 100644
index 0000000..797de76
--- /dev/null
+++ b/spec/fixtures/ds2.csv
@@ -0,0 +1,51 @@
+ 1,3
+2,7
+3,13
+4,21
+5,31
+6,42
+7,57
+8,73
+9,91
+10,111
+11,133
+12,157
+13,183
+14,211
+15,241
+16,273
+17,307
+18,343
+19,200
+20,421
+21,463
+22,507
+23,553
+24,601
+25,651
+26,703
+27,757
+28,813
+29,871
+30,931
+31,123
+32,1057
+33,1123
+34,1000
+35,1261
+36,1333
+37,1407
+38,1483
+39,1561
+40,1641
+41,1723
+42,1807
+43,1893
+44,1981
+45,2071
+46,2163
+47,1524
+48,2353
+49,2451
+50,2500
+51,2520
diff --git a/spec/hunk_spec.rb b/spec/hunk_spec.rb
index dc6f532..0711e0d 100644
--- a/spec/hunk_spec.rb
+++ b/spec/hunk_spec.rb
@@ -2,28 +2,26 @@
require 'spec_helper'
-def h(v)
- v.to_s.bytes.to_a.map { |e| "%02x" % e }.join
-end
-
-describe "Diff::LCS::Hunk" do
- if String.method_defined?(:encoding)
+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(:pieces) { Diff::LCS.diff old_data, new_data }
let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
- it 'should be able to produce a unified diff from the two pieces' do
+ it 'produces a unified diff from the two pieces' do
expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
@@ -1,2 +1,2 @@
-Tu avec carté {count} itém has
+Tu avec carte {count} item has
EOD
- expect(hunk.diff(:unified).to_s == expected).to eql true
+
+ expect(hunk.diff(:unified)).to eq(expected)
end
- it 'should be able to produce a context diff from the two pieces' do
+ it 'produces a context diff from the two pieces' do
expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
***************
*** 1,2 ****
@@ -32,10 +30,10 @@ describe "Diff::LCS::Hunk" do
!Tu avec carte {count} item has
EOD
- expect(hunk.diff(:context).to_s == expected).to eql true
+ expect(hunk.diff(:context)).to eq(expected)
end
- it 'should be able to produce an old diff from the two pieces' do
+ it 'produces an old diff from the two pieces' do
expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
1,2c1,2
< Tu avec carté {count} itém has
@@ -43,30 +41,32 @@ describe "Diff::LCS::Hunk" do
> Tu avec carte {count} item has
EOD
- expect(hunk.diff(:old).to_s == expected).to eql true
+
+ expect(hunk.diff(:old)).to eq(expected)
end
- it 'should be able to produce a reverse ed diff from the two pieces' do
+ it 'produces a reverse ed diff from the two pieces' do
expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
c1,2
Tu avec carte {count} item has
.
EOD
- expect(hunk.diff(:reverse_ed).to_s == expected).to eql true
+
+ expect(hunk.diff(:reverse_ed)).to eq(expected)
end
context 'with empty first data set' do
let(:old_data) { [] }
- it 'should be able to produce a unified diff' do
+ it 'produces a unified diff' do
expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
@@ -1 +1,2 @@
+Tu avec carte {count} item has
EOD
- expect(hunk.diff(:unified).to_s == expected).to eql true
+
+ expect(hunk.diff(:unified)).to eq(expected)
end
end
-
end
end
diff --git a/spec/issues_spec.rb b/spec/issues_spec.rb
index c3d8f87..7638249 100644
--- a/spec/issues_spec.rb
+++ b/spec/issues_spec.rb
@@ -5,20 +5,45 @@ require 'spec_helper'
describe "Diff::LCS Issues" do
include Diff::LCS::SpecHelper::Matchers
- it "should not fail to provide a simple patchset (issue 1)" do
- s1, s2 = *%W(aX bXaX)
- correct_forward_diff = [
- [ [ '+', 0, 'b' ],
- [ '+', 1, 'X' ] ],
- ]
-
- diff_s1_s2 = Diff::LCS.diff(s1, s2)
- change_diff(correct_forward_diff).should == diff_s1_s2
- expect do
- Diff::LCS.patch(s1, diff_s1_s2).should == s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
- expect do
- Diff::LCS.patch(s2, diff_s1_s2).should == s1
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ describe 'issue #1' do
+ shared_examples 'handles simple diffs' do |s1, s2, forward_diff|
+ before do
+ @diff_s1_s2 = Diff::LCS.diff(s1, s2)
+ end
+
+ it 'creates the correct diff' do
+ expect(change_diff(forward_diff)).to eq(@diff_s1_s2)
+ end
+
+ it 'creates the correct patch s1->s2' do
+ expect(Diff::LCS.patch(s1, @diff_s1_s2)).to eq(s2)
+ end
+
+ it 'creates the correct patch s2->s1' do
+ expect(Diff::LCS.patch(s2, @diff_s1_s2)).to eq(s1)
+ end
+ end
+
+ describe 'string' do
+ it_has_behavior 'handles simple diffs', 'aX', 'bXaX', [
+ [ [ '+', 0, 'b' ],
+ [ '+', 1, 'X' ] ],
+ ]
+ it_has_behavior 'handles simple diffs', 'bXaX', 'aX', [
+ [ [ '-', 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' ] ],
+ ]
+ it_has_behavior 'handles simple diffs', %w(b X a X), %w(a X), [
+ [ [ '-', 0, 'b' ],
+ [ '-', 1, 'X' ] ],
+ ]
+ end
end
end
diff --git a/spec/lcs_spec.rb b/spec/lcs_spec.rb
index 205d563..28533e3 100644
--- a/spec/lcs_spec.rb
+++ b/spec/lcs_spec.rb
@@ -2,53 +2,55 @@
require 'spec_helper'
-describe "Diff::LCS::Internals.lcs" do
+describe Diff::LCS::Internals, ".lcs" do
include Diff::LCS::SpecHelper::Matchers
- it "should return 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.
- res.compact.size.should == correct_lcs.size
- res.should correctly_map_sequence(seq1).to_other_sequence(seq2)
+ expect(res.compact.size).to eq(correct_lcs.size)
+ expect(res).to correctly_map_sequence(seq1).to_other_sequence(seq2)
# Compact these transformations and they should be the correct LCS.
x_seq1 = (0...res.size).map { |ix| res[ix] ? seq1[ix] : nil }.compact
x_seq2 = (0...res.size).map { |ix| res[ix] ? seq2[res[ix]] : nil }.compact
- x_seq1.should == correct_lcs
- x_seq2.should == correct_lcs
+ expect(x_seq1).to eq(correct_lcs)
+ expect(x_seq2).to eq(correct_lcs)
end
- it "should return all indexes with (hello, hello)" do
- Diff::LCS::Internals.lcs(hello, hello).should == (0...hello.size).to_a
+ it "returns all indexes with (hello, hello)" do
+ expect(Diff::LCS::Internals.lcs(hello, hello)).to \
+ eq((0...hello.size).to_a)
end
- it "should return all indexes with (hello_ary, hello_ary)" do
- Diff::LCS::Internals.lcs(hello_ary, hello_ary).should == (0...hello_ary.size).to_a
+ 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 "should return 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)
- res.should == correct_lcs
- res.compact.should == res
+ expect(res).to eq(correct_lcs)
+ expect(res.compact).to eq(res)
end
- it "should be transitive" do
+ it "is transitive" do
res = Diff::LCS.LCS(seq2, seq1)
- res.should == correct_lcs
- res.compact.should == res
+ expect(res).to eq(correct_lcs)
+ expect(res.compact).to eq(res)
end
- it "should return %W(h e l l o) with (hello, hello)" do
- Diff::LCS.LCS(hello, hello).should == hello.split(//)
+ it "returns %W(h e l l o) with (hello, hello)" do
+ expect(Diff::LCS.LCS(hello, hello)).to eq(hello.split(//))
end
- it "should return hello_ary with (hello_ary, hello_ary)" do
- Diff::LCS.LCS(hello_ary, hello_ary).should == hello_ary
+ 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
new file mode 100644
index 0000000..ad1377f
--- /dev/null
+++ b/spec/ldiff_spec.rb
@@ -0,0 +1,47 @@
+# -*- ruby encoding: utf-8 -*-
+
+require 'spec_helper'
+
+describe "Diff::LCS.diff" do
+ include Diff::LCS::SpecHelper::Matchers
+
+ 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
+ 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
+ diff = Diff::LCS.diff(word_sequence, [])
+ correct_diff = [
+ [ [ '-', 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] = '+' } }
+ expect(change_diff(correct_diff)).to eq(diff)
+ end
+
+ it "correctly diffs 'xx' and 'xaxb'" do
+ left = 'xx'
+ right = 'xaxb'
+ expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
+ end
+
+ 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
+ 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 0fc9160..9f1a4f1 100644
--- a/spec/patch_spec.rb
+++ b/spec/patch_spec.rb
@@ -6,33 +6,35 @@ describe "Diff::LCS.patch" do
include Diff::LCS::SpecHelper::Matchers
shared_examples "patch sequences correctly" do
- it "should correctly patch left-to-right (patch autodiscovery)" do
- Diff::LCS.patch(s1, patch_set).should == s2
+ it "correctly patches left-to-right (patch autodiscovery)" do
+ expect(Diff::LCS.patch(s1, patch_set)).to eq(s2)
end
- it "should correctly patch left-to-right (explicit patch)" do
- Diff::LCS.patch(s1, patch_set, :patch).should == s2
- Diff::LCS.patch!(s1, patch_set).should == s2
+ 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 "should correctly patch right-to-left (unpatch autodiscovery)" do
- Diff::LCS.patch(s2, patch_set).should == s1
+ it "correctly patches right-to-left (unpatch autodiscovery)" do
+ expect(Diff::LCS.patch(s2, patch_set)).to eq(s1)
end
- it "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(s2, patch_set, :unpatch).should == s1
- Diff::LCS.unpatch!(s2, patch_set).should == s1
+ 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
- Diff::LCS::patch(hello, Diff::LCS.diff(hello, hello)).should == hello
+ diff = Diff::LCS.diff(hello, hello)
+ expect(Diff::LCS::patch(hello, diff)).to eq(hello)
end
it "works on an array %W(h e l l o)" do
- Diff::LCS::patch(hello_ary, Diff::LCS.diff(hello_ary, hello_ary)).should == hello_ary
+ diff = Diff::LCS.diff(hello_ary, hello_ary)
+ expect(Diff::LCS::patch(hello_ary, diff)).to eq(hello_ary)
end
end
@@ -102,11 +104,11 @@ describe "Diff::LCS.patch" do
describe "using a Diff::LCS.sdiff patchset" do
describe "an empty patchset returns the source" do
it "works on a string (hello)" do
- Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello)).should == hello
+ 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
- Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary)).should == hello_ary
+ expect(Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
end
end
@@ -178,122 +180,126 @@ describe "Diff::LCS.patch" do
# 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
- before(:each) do
+ before :each do
@s1 = %w(a b c d e f g h i j k)
@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
- before(:each) do
+ before :each do
@patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
@patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
end
- it "should autodiscover s1 to s2 patches" do
+ it "autodiscovers s1 to s2 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 patches" do
+ it "autodiscovers s2 to s1 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 the left-to-right patches" do
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
+ 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 "should correctly patch left-to-right (explicit patch)" do
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
+ 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 "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
+ 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)
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
end
end
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)
+ 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)
end
- it "should autodiscover s1 to s2 patches" do
+ it "autodiscovers s1 to s2 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 patches" do
+ it "autodiscovers s2 to s1 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 the left-to-right patches" do
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
+ 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 "should correctly patch left-to-right (explicit patch)" do
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
+ 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 "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
+ 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)
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
end
end
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 "should autodiscover s1 to s2 patches" do
+ it "autodiscovers s1 to s2 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 patches" do
+ it "autodiscovers s2 to s1 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 the left-to-right patches" do
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
+ 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 "should correctly patch left-to-right (explicit patch)" do
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
+ 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 "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
+ 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)
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
end
end
@@ -303,73 +309,75 @@ describe "Diff::LCS.patch" do
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
end
- it "should autodiscover s1 to s2 patches" do
+ it "autodiscovers s1 to s2 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 patches" do
+ it "autodiscovers s2 to s1 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 the left-to-right patches" do
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
+ 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 "should correctly patch left-to-right (explicit patch)", :only => true do
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
+ 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 "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
+ 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)
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
end
end
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 "should autodiscover s1 to s2 patches" do
+ it "autodiscovers s1 to s2 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 patches" do
+ it "autodiscovers s2 to s1 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 the left-to-right patches" do
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
+ 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 "should correctly patch left-to-right (explicit patch)" do
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
+ 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 "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
+ 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)
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
end
end
@@ -379,35 +387,35 @@ describe "Diff::LCS.patch" do
@patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
end
- it "should autodiscover s1 to s2 patches" do
+ it "autodiscovers s1 to s2 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 patches" do
+ it "autodiscovers s2 to s1 patches" do
expect do
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
- end.to_not raise_error(RuntimeError, /provided patchset/)
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
+ end.to_not raise_error
end
- it "should autodiscover s2 to s1 the left-to-right patches" do
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
+ 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 "should correctly patch left-to-right (explicit patch)" do
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
+ 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 "should correctly patch right-to-left (explicit unpatch)" do
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
+ 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)
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
end
end
end
diff --git a/spec/sdiff_spec.rb b/spec/sdiff_spec.rb
index 7ab3bb6..d619eb4 100644
--- a/spec/sdiff_spec.rb
+++ b/spec/sdiff_spec.rb
@@ -6,12 +6,12 @@ describe "Diff::LCS.sdiff" do
include Diff::LCS::SpecHelper::Matchers
shared_examples "compare sequences correctly" do
- it "should compare s1 -> s2 correctly" do
- Diff::LCS.sdiff(s1, s2).should == context_diff(result)
+ it "compares s1 -> s2 correctly" do
+ expect(Diff::LCS.sdiff(s1, s2)).to eq(context_diff(result))
end
- it "should compare s2 -> s1 correctly" do
- Diff::LCS.sdiff(s2, s1).should == context_diff(reverse_sdiff(result))
+ it "compares s2 -> s1 correctly" do
+ expect(Diff::LCS.sdiff(s2, s1)).to eq(context_diff(reverse_sdiff(result)))
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 48bec6f..27298c4 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -296,14 +296,14 @@ module Diff::LCS::SpecHelper
matcher :be_nil_or_match_values do |ii, s1, s2|
match do |ee|
- ee.should satisfy { |vee| vee.nil? || s1[ii] == s2[ee] }
+ expect(ee).to(satisfy { |vee| vee.nil? || s1[ii] == s2[ee] })
end
end
matcher :correctly_map_sequence do |s1|
match do |actual|
actual.each_with_index { |ee, ii|
- ee.should be_nil_or_match_values(ii, s1, @s2)
+ expect(ee).to be_nil_or_match_values(ii, s1, @s2)
}
end
diff --git a/spec/traverse_balanced_spec.rb b/spec/traverse_balanced_spec.rb
index 63fe1eb..95e60ec 100644
--- a/spec/traverse_balanced_spec.rb
+++ b/spec/traverse_balanced_spec.rb
@@ -6,26 +6,26 @@ describe "Diff::LCS.traverse_balanced" do
include Diff::LCS::SpecHelper::Matchers
shared_examples "with a #change callback" do |s1, s2, result|
- it "should traverse s1 -> s2 correctly" do
+ it "traverses s1 -> s2 correctly" do
traversal = balanced_traversal(s1, s2, :balanced_callback)
- traversal.result.should == result
+ expect(traversal.result).to eq(result)
end
- it "should traverse s2 -> s1 correctly" do
+ it "traverses s2 -> s1 correctly" do
traversal = balanced_traversal(s2, s1, :balanced_callback)
- traversal.result.should == balanced_reverse(result)
+ expect(traversal.result).to eq(balanced_reverse(result))
end
end
shared_examples "without a #change callback" do |s1, s2, result|
- it "should traverse s1 -> s2 correctly" do
+ it "traverses s1 -> s2 correctly" do
traversal = balanced_traversal(s1, s2, :balanced_callback_no_change)
- traversal.result.should == map_to_no_change(result)
+ expect(traversal.result).to eq(map_to_no_change(result))
end
- it "should traverse s2 -> s1 correctly" do
+ it "traverses s2 -> s1 correctly" do
traversal = balanced_traversal(s2, s1, :balanced_callback_no_change)
- traversal.result.should == map_to_no_change(balanced_reverse(result))
+ expect(traversal.result).to eq(map_to_no_change(balanced_reverse(result)))
end
end
diff --git a/spec/traverse_sequences_spec.rb b/spec/traverse_sequences_spec.rb
index f4480df..1252d53 100644
--- a/spec/traverse_sequences_spec.rb
+++ b/spec/traverse_sequences_spec.rb
@@ -13,31 +13,31 @@ describe "Diff::LCS.traverse_sequences" do
Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1)
end
- it "should have the correct LCS result on left-matches" do
- @callback_s1_s2.matched_a.should == correct_lcs
- @callback_s2_s1.matched_a.should == correct_lcs
+ 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 "should have the correct LCS result on right-matches" do
- @callback_s1_s2.matched_b.should == correct_lcs
- @callback_s2_s1.matched_b.should == correct_lcs
+ 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 "should have the correct skipped sequences with the left sequence" do
- @callback_s1_s2.discards_a.should == skipped_seq1
- @callback_s2_s1.discards_a.should == skipped_seq2
+ 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 "should have the correct skipped sequences with the right sequence" do
- @callback_s1_s2.discards_b.should == skipped_seq2
- @callback_s2_s1.discards_b.should == skipped_seq1
+ 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 "should not have anything done markers from the left or right sequences" do
- @callback_s1_s2.done_a.should be_empty
- @callback_s1_s2.done_b.should be_empty
- @callback_s2_s1.done_a.should be_empty
- @callback_s2_s1.done_b.should be_empty
+ 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
+ expect(@callback_s2_s1.done_b).to be_empty
end
end
@@ -47,25 +47,25 @@ describe "Diff::LCS.traverse_sequences" do
Diff::LCS.traverse_sequences(hello, hello, @callback)
end
- it "should have the correct LCS result on left-matches" do
- @callback.matched_a.should == hello.split(//)
+ it "has the correct LCS result on left-matches" do
+ expect(@callback.matched_a).to eq(hello.split(//))
end
- it "should have the correct LCS result on right-matches" do
- @callback.matched_b.should == hello.split(//)
+ it "has the correct LCS result on right-matches" do
+ expect(@callback.matched_b).to eq(hello.split(//))
end
- it "should have the correct skipped sequences with the left sequence", :only => true do
- @callback.discards_a.should be_empty
+ it "has the correct skipped sequences with the left sequence", :only => true do
+ expect(@callback.discards_a).to be_empty
end
- it "should have the correct skipped sequences with the right sequence" do
- @callback.discards_b.should be_empty
+ it "has the correct skipped sequences with the right sequence" do
+ expect(@callback.discards_b).to be_empty
end
- it "should not have anything done markers from the left or right sequences" do
- @callback.done_a.should be_empty
- @callback.done_b.should be_empty
+ 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
@@ -75,25 +75,25 @@ describe "Diff::LCS.traverse_sequences" do
Diff::LCS.traverse_sequences(hello_ary, hello_ary, @callback)
end
- it "should have the correct LCS result on left-matches" do
- @callback.matched_a.should == hello_ary
+ it "has the correct LCS result on left-matches" do
+ expect(@callback.matched_a).to eq(hello_ary)
end
- it "should have the correct LCS result on right-matches" do
- @callback.matched_b.should == hello_ary
+ it "has the correct LCS result on right-matches" do
+ expect(@callback.matched_b).to eq(hello_ary)
end
- it "should have the correct skipped sequences with the left sequence" do
- @callback.discards_a.should be_empty
+ it "has the correct skipped sequences with the left sequence" do
+ expect(@callback.discards_a).to be_empty
end
- it "should have the correct skipped sequences with the right sequence" do
- @callback.discards_b.should be_empty
+ it "has the correct skipped sequences with the right sequence" do
+ expect(@callback.discards_b).to be_empty
end
- it "should not have anything done markers from the left or right sequences" do
- @callback.done_a.should be_empty
- @callback.done_b.should be_empty
+ 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
@@ -106,34 +106,34 @@ describe "Diff::LCS.traverse_sequences" do
Diff::LCS.traverse_sequences(seq2, seq1, @callback_s2_s1)
end
- it "should have the correct LCS result on left-matches" do
- @callback_s1_s2.matched_a.should == correct_lcs
- @callback_s2_s1.matched_a.should == correct_lcs
+ 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 "should have the correct LCS result on right-matches" do
- @callback_s1_s2.matched_b.should == correct_lcs
- @callback_s2_s1.matched_b.should == correct_lcs
+ 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 "should have the correct skipped sequences for the left sequence" do
- @callback_s1_s2.discards_a.should == skipped_seq1
- @callback_s2_s1.discards_a.should == skipped_seq2
+ 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 "should have the correct skipped sequences for the right sequence" do
- @callback_s1_s2.discards_b.should == skipped_seq2
- @callback_s2_s1.discards_b.should == skipped_seq1
+ 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 "should have done markers differently-sized sequences" do
- @callback_s1_s2.done_a.should == [[ "p", 9, "s", 10 ]]
- @callback_s1_s2.done_b.should be_empty
+ 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
# isn't transitive.
- @callback_s2_s1.done_a.should be_empty
- @callback_s2_s1.done_b.should be_empty
+ expect(@callback_s2_s1.done_a).to be_empty
+ expect(@callback_s2_s1.done_b).to be_empty
end
end
end