forked from drnic/github-tmbundle
/
test_show_line_in_commit_in_github.rb
51 lines (46 loc) · 1.87 KB
/
test_show_line_in_commit_in_github.rb
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
require File.dirname(__FILE__) + "/test_helper"
require "show_in_github"
class TestShowLineInCommitInGitHub < Test::Unit::TestCase
attr_reader :git
def setup
@git = GitManager.new __FILE__
@file = git.relative_file
puts "These tests require the project to be checked out of git to work" unless @git
end
def test_find_first_commit_for_this_file
line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03"
actual = git.find_commit_with_line(line_in_first_commit)
assert_equal(expected, actual.to_s)
end
def test_find_line_in_diff
# diff_parent is a reverse diff, so added lines prefix with -; removed lines +
diff_parent = <<-DIFF
diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb
deleted file mode 100644
index 63b416f..0000000
--- a/Support/test/test_show_line_in_commit_in_github.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestShowLineInCommitInGitHub < Test::Unit::TestCase
- def test_find_first_commit_for_this_file
-
- end
-end
\ No newline at end of file
DIFF
current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
assert git.line_in_diff?(diff_parent, current_line), "should find line in diff"
assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff"
end
def test_github_url_for_line_in_commit
url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit")
expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2"
assert_equal(expected, url)
end
should_eventually "test_file_index_within_multi_file_commit" do
end
end