Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (42 sloc) 1.431 kb
d01a4cf @mojombo convert to Grit module, refactor to be more OO
mojombo authored
1 require File.dirname(__FILE__) + '/helper'
2
3 class TestGit < Test::Unit::TestCase
2c6af5a @mojombo implement Repo.commits
mojombo authored
4 def setup
5 @git = Git.new(File.join(File.dirname(__FILE__), *%w[..]))
6 end
d01a4cf @mojombo convert to Grit module, refactor to be more OO
mojombo authored
7
8 def test_method_missing
ca78e94 @cristibalan allow letters in git version test
cristibalan authored
9 assert_match(/^git version [\w\.]*$/, @git.version)
d01a4cf @mojombo convert to Grit module, refactor to be more OO
mojombo authored
10 end
3b19302 @mojombo big refactor to do lazy loading
mojombo authored
11
12 def test_transform_options
8c7f4e1 @mojombo dynamically rewrite ruby style git options
mojombo authored
13 assert_equal ["-s"], @git.transform_options({:s => true})
301edd4 @mojombo quote all git parameters
mojombo authored
14 assert_equal ["-s '5'"], @git.transform_options({:s => 5})
8c7f4e1 @mojombo dynamically rewrite ruby style git options
mojombo authored
15
16 assert_equal ["--max-count"], @git.transform_options({:max_count => true})
301edd4 @mojombo quote all git parameters
mojombo authored
17 assert_equal ["--max-count='5'"], @git.transform_options({:max_count => 5})
8c7f4e1 @mojombo dynamically rewrite ruby style git options
mojombo authored
18
80f136f fix tests on other machines
tom authored
19 assert_equal ["-s", "-t"], @git.transform_options({:s => true, :t => true}).sort
3b19302 @mojombo big refactor to do lazy loading
mojombo authored
20 end
30e367c @defunkt timeout code and tests
defunkt authored
21
22 def test_uses_custom_sh_method
23 @git.expects(:sh)
24 @git.something
25 end
26
27 def test_can_skip_timeout
28 @git.expects(:wild_sh)
29 @git.something(:timeout => false)
30 end
31
32 def test_raises_if_too_many_bytes
33 @git.instance_variable_set(:@bytes_read, 6000000)
34 assert_raises Grit::Git::GitTimeout do
35 @git.something
36 end
37 end
38
39 def test_raises_on_slow_shell
40 Grit::Git.git_timeout = 0.5
41 Open4.expects(:popen4).returns([ nil, nil, mock(:read => proc { sleep 1 }), nil ])
42 assert_raises Grit::Git::GitTimeout do
43 @git.something
44 end
45 end
46
47 def test_works_fine_if_quick
48 output = 'output'
49 Open4.expects(:popen4).returns([ nil, nil, mock(:read => output), nil ])
50 assert_equal output, @git.something
51 end
ca78e94 @cristibalan allow letters in git version test
cristibalan authored
52 end
Something went wrong with that request. Please try again.