PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Bundles/eBundles/GitHub.tmbundle/Support/test/test_show_line_in_commit_in_github.rb

https://bitbucket.org/missdeer/luapack
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
  1. require File.dirname(__FILE__) + "/test_helper"
  2. require "show_in_github"
  3. class TestShowLineInCommitInGitHub < Test::Unit::TestCase
  4. attr_reader :git
  5. def setup
  6. @git = GitManager.new __FILE__
  7. @file = git.relative_file
  8. puts "These tests require the project to be checked out of git to work" unless @git
  9. end
  10. def test_find_first_commit_for_this_file
  11. line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
  12. expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03"
  13. actual = git.find_commit_with_line(line_in_first_commit)
  14. assert_equal(expected, actual.to_s)
  15. end
  16. def test_find_line_in_diff
  17. # diff_parent is a reverse diff, so added lines prefix with -; removed lines +
  18. diff_parent = <<-DIFF
  19. diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb
  20. deleted file mode 100644
  21. index 63b416f..0000000
  22. --- a/Support/test/test_show_line_in_commit_in_github.rb
  23. +++ /dev/null
  24. @@ -1,8 +0,0 @@
  25. -require File.dirname(__FILE__) + "/test_helper"
  26. -require "show_in_github"
  27. -
  28. -class TestShowLineInCommitInGitHub < Test::Unit::TestCase
  29. - def test_find_first_commit_for_this_file
  30. -
  31. - end
  32. -end
  33. \ No newline at end of file
  34. DIFF
  35. current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
  36. assert git.line_in_diff?(diff_parent, current_line), "should find line in diff"
  37. assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff"
  38. end
  39. def test_github_url_for_line_in_commit
  40. url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit")
  41. expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2"
  42. assert_equal(expected, url)
  43. end
  44. should_eventually "test_file_index_within_multi_file_commit" do
  45. end
  46. end