/Bundles/eBundles/GitHub.tmbundle/Support/test/test_show_line_in_commit_in_github.rb
Ruby | 51 lines | 45 code | 5 blank | 1 comment | 0 complexity | 992e4b415bd4d1b076d5838b8bea06b6 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.0, CC-BY-SA-3.0, ISC, LGPL-2.1, GPL-2.0
- 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