diff options
author | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 13:13:46 +1100 |
---|---|---|
committer | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 13:13:46 +1100 |
commit | a72fbdc67d2be6937fd94baf9372bbb994b01be1 (patch) | |
tree | 35dd74ac150dc10c0557fcfbe00eda6031add347 /spec | |
parent | c977dfc8017f03f8fa70351b5ddedad9ad88fa4d (diff) | |
download | diff-lcs-a72fbdc67d2be6937fd94baf9372bbb994b01be1.tar.gz |
wrap tests in 187 protection too
Diffstat (limited to 'spec')
-rw-r--r-- | spec/hunk_spec.rb | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/spec/hunk_spec.rb b/spec/hunk_spec.rb index a7da631..9c21bce 100644 --- a/spec/hunk_spec.rb +++ b/spec/hunk_spec.rb @@ -4,23 +4,25 @@ require 'spec_helper' 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(:peices) { Diff::LCS.diff old_data, new_data } - let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, peices[0], 3, 0) } + if String.method_defined?(:encoding) - it 'should be able to produce a unified diff from the two peices' do - expected = + 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(:peices) { Diff::LCS.diff old_data, new_data } + let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, peices[0], 3, 0) } + + it 'should be able to produce a unified diff from the two peices' do + expected = (<<-EOD.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 - end + expect(hunk.diff(:unified).to_s == expected).to eql true + end - it 'should be able to produce a context diff from the two peices' do - expected = + it 'should be able to produce a context diff from the two peices' do + expected = (<<-EOD.encode('UTF-16LE').chomp) *************** *** 1,2 **** @@ -28,11 +30,11 @@ Tu avec carté {count} itém has --- 1,2 ---- Tu avec carte {count} item has EOD - expect(hunk.diff(:context).to_s == expected).to eql true - end + expect(hunk.diff(:context).to_s == expected).to eql true + end - it 'should be able to produce an old diff from the two peices' do - expected = + it 'should be able to produce an old diff from the two peices' do + expected = (<<-EOD.encode('UTF-16LE').chomp) 1,2c1,2 < Tu avec carté {count} itém has @@ -40,18 +42,18 @@ EOD > Tu avec carte {count} item has EOD - expect(hunk.diff(:old).to_s == expected).to eql true - end + expect(hunk.diff(:old).to_s == expected).to eql true + end - it 'should be able to produce a reverse ed diff from the two peices' do - expected = + it 'should be able to produce a reverse ed diff from the two peices' do + expected = (<<-EOD.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_s == expected).to eql true + end end - end |