-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpatches_spec.rb
More file actions
53 lines (46 loc) · 2.01 KB
/
patches_spec.rb
File metadata and controls
53 lines (46 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'spec_helper'
module GitDiffParser
describe Patches do
describe '#parse' do
let(:file0) { 'lib/saddler/reporter/github.rb' }
let(:body0) { File.read('spec/support/fixtures/file0.diff') }
let(:file1) { 'lib/saddler/reporter/github/commit_comment.rb' }
let(:body1) { File.read('spec/support/fixtures/file1.diff') }
let(:file2) { 'lib/saddler/reporter/github/helper.rb' }
let(:body2) { File.read('spec/support/fixtures/file2.diff') }
let(:file3) { 'lib/saddler/reporter/github/support.rb' }
let(:body3) { File.read('spec/support/fixtures/file3.diff') }
let(:sjis_file) { 'spec/support/fixtures/sjis.csv' }
let(:sjis_diff) { sjis_file.gsub(/\.csv\z/, '.diff') }
let(:sjis_body) { File.read(sjis_diff) }
let(:deleted_diff) { 'spec/support/fixtures/deleted.diff' }
let(:deleted_file) { 'spec/support/fixtures/hello.txt' }
let(:deleted_body) { File.read(deleted_diff.gsub(/\.diff\z/, '.body')) }
it 'returns parsed patches' do
diff_body = File.read('spec/support/fixtures/d1bd180-c27866c.diff')
patches = Patches.parse(diff_body)
expect(patches.size).to eq 4
expect(patches[0].file).to eq file0
expect(patches[0].body).to eq body0
expect(patches[1].file).to eq file1
expect(patches[1].body).to eq body1
expect(patches[2].file).to eq file2
expect(patches[2].body).to eq body2
expect(patches[3].file).to eq file3
expect(patches[3].body).to eq body3
end
it 'handles non UTF-8 encoding characters' do
patches = nil
expect { patches = Patches.parse(sjis_body) }.not_to raise_error
expect(patches[0].file).to eq sjis_file
end
it 'returns patches for a deleted file' do
diff_body = File.read(deleted_diff)
patches = Patches.parse(diff_body)
expect(patches.size).to eq 1
expect(patches[0].file).to eq deleted_file
expect(patches[0].body).to eq deleted_body
end
end
end
end