@@ -294,5 +294,89 @@ def reproduce_data
294294 expect { subject } . not_to raise_error
295295 end
296296 end
297+
298+ describe 'filters' do
299+ let ( :data ) do
300+ '1 M. N... 000000 100644 100644 0000000000000000000000000000000000000000 ' \
301+ "49351eb5b7e355128f8f569d5b3355c3e2a51d4b file1.txt\u0000 " \
302+ '1 MM N... 000000 100644 100644 0000000000000000000000000000000000000000 ' \
303+ "49351eb5b7e355128f8f569d5b3355c3e2a51d4b file2.txt\u0000 " \
304+ '1 .M N... 000000 100644 100644 0000000000000000000000000000000000000000 ' \
305+ "49351eb5b7e355128f8f569d5b3355c3e2a51d4b file3.txt\u0000 " \
306+ '2 RD N... 100644 100755 000000 1111111111111111111111111111111111111111 ' \
307+ "2222222222222222222222222222222222222222 R100 file4.txt\u0000 " \
308+ "file4_old.txt\u0000 " \
309+ '2 R. N... 100644 100755 000000 1111111111111111111111111111111111111111 ' \
310+ "2222222222222222222222222222222222222222 R100 file5.txt\u0000 " \
311+ "file5_old.txt\u0000 " \
312+ 'u UU N... 100644 100755 000000 100755 ' \
313+ '1111111111111111111111111111111111111111 2222222222222222222222222222222222222222 ' \
314+ '3333333333333333333333333333333333333333 file6.txt' \
315+ "\u0000 " \
316+ "? file7.txt\u0000 " \
317+ "? file8.txt\u0000 " \
318+ "! file9.txt\u0000 "
319+ end
320+
321+ describe '#ignored' do
322+ subject { report . ignored }
323+ it 'should return the ignored entries' do
324+ expect ( subject . map ( &:path ) ) . to eq ( %w[ file9.txt ] )
325+ end
326+ end
327+
328+ describe '#untracked' do
329+ subject { report . untracked }
330+ it 'should return the untracked entries' do
331+ expect ( subject . map ( &:path ) ) . to eq ( %w[ file7.txt file8.txt ] )
332+ end
333+ end
334+
335+ describe '#unstaged' do
336+ subject { report . unstaged }
337+ it 'should return the unstaged entries' do
338+ expect ( subject . map ( &:path ) ) . to eq ( %w[ file2.txt file3.txt file4.txt file7.txt file8.txt ] )
339+ end
340+ end
341+
342+ describe '#staged' do
343+ subject { report . staged }
344+ it 'should return the staged entries' do
345+ expect ( subject . map ( &:path ) ) . to eq ( %w[ file1.txt file2.txt file4.txt file5.txt ] )
346+ end
347+ end
348+
349+ describe '#fully_staged' do
350+ subject { report . fully_staged }
351+ it 'should return the fully staged entries' do
352+ expect ( subject . map ( &:path ) ) . to eq ( %w[ file1.txt file5.txt ] )
353+ end
354+ end
355+
356+ describe '#unmerged' do
357+ subject { report . unmerged }
358+ it 'should return the unmerged entries' do
359+ expect ( subject . map ( &:path ) ) . to eq ( %w[ file6.txt ] )
360+ end
361+ end
362+ end
363+
364+ describe '#merge_conflict?' do
365+ subject { report . merge_conflict? }
366+ context 'when there is a merge conflict' do
367+ let ( :data ) do
368+ 'u UU N... 100644 100755 000000 100755 ' \
369+ '1111111111111111111111111111111111111111 2222222222222222222222222222222222222222 ' \
370+ '3333333333333333333333333333333333333333 file6.txt'
371+ end
372+
373+ it { is_expected . to eq ( true ) }
374+ end
375+
376+ context 'when there is not a merge conflict' do
377+ let ( :data ) { '' }
378+ it { is_expected . to eq ( false ) }
379+ end
380+ end
297381 end
298382end
0 commit comments