Commit be41d0e1bfb61abeb12c33c2344e374adc7803cf
1 parent
14798b8e
Exists in
master
and in
4 other branches
Gitlab::Git::Diff specs
Showing
1 changed file
with
34 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
| 1 | +require "spec_helper" | ||
| 2 | + | ||
| 3 | +describe Gitlab::Git::Diff do | ||
| 4 | + before do | ||
| 5 | + @raw_diff_hash = { | ||
| 6 | + diff: 'Hello world', | ||
| 7 | + new_path: 'temp.rb', | ||
| 8 | + old_path: 'test.rb', | ||
| 9 | + a_mode: '100644', | ||
| 10 | + b_mode: '100644', | ||
| 11 | + new_file: false, | ||
| 12 | + renamed_file: true, | ||
| 13 | + deleted_file: false, | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + @grit_diff = double('Grit::Diff', @raw_diff_hash) | ||
| 17 | + end | ||
| 18 | + | ||
| 19 | + context 'init from grit' do | ||
| 20 | + before do | ||
| 21 | + @diff = Gitlab::Git::Diff.new(@raw_diff_hash) | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + it { @diff.to_hash.should == @raw_diff_hash } | ||
| 25 | + end | ||
| 26 | + | ||
| 27 | + context 'init from hash' do | ||
| 28 | + before do | ||
| 29 | + @diff = Gitlab::Git::Diff.new(@grit_diff) | ||
| 30 | + end | ||
| 31 | + | ||
| 32 | + it { @diff.to_hash.should == @raw_diff_hash } | ||
| 33 | + end | ||
| 34 | +end |