diff options
author | Austin Ziegler <austin@zieglers.ca> | 2014-05-06 00:08:02 -0400 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2017-01-18 18:16:14 -0500 |
commit | 06ee20e929656d41c301f61fd447105c3840e410 (patch) | |
tree | 7325cd8e3279b71e5bc18302112e47cad3000a40 /spec/hunk_spec.rb | |
parent | 32727d6d0beb48672a1ee2d4a5c20bb81f7e301d (diff) | |
download | diff-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/hunk_spec.rb')
-rw-r--r-- | spec/hunk_spec.rb | 34 |
1 files changed, 17 insertions, 17 deletions
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 |