OSDN Git Service

Gitlab::Git::Diff specs
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 16 Apr 2013 13:30:16 +0000 (16:30 +0300)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 16 Apr 2013 13:30:16 +0000 (16:30 +0300)
spec/lib/gitlab/git/diff_spec.rb [new file with mode: 0644]

diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb
new file mode 100644 (file)
index 0000000..5191b11
--- /dev/null
@@ -0,0 +1,34 @@
+require "spec_helper"
+
+describe Gitlab::Git::Diff do
+  before do
+    @raw_diff_hash = {
+      diff: 'Hello world',
+      new_path: 'temp.rb',
+      old_path: 'test.rb',
+      a_mode: '100644',
+      b_mode: '100644',
+      new_file: false,
+      renamed_file: true,
+      deleted_file: false,
+    }
+
+    @grit_diff = double('Grit::Diff', @raw_diff_hash)
+  end
+
+  context 'init from grit' do
+    before do
+      @diff = Gitlab::Git::Diff.new(@raw_diff_hash)
+    end
+
+    it { @diff.to_hash.should == @raw_diff_hash }
+  end
+
+  context 'init from hash' do
+    before do
+      @diff = Gitlab::Git::Diff.new(@grit_diff)
+    end
+
+    it { @diff.to_hash.should == @raw_diff_hash }
+  end
+end