/
plugin_test.rb
38 lines (31 loc) · 1.22 KB
/
plugin_test.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
require 'test/unit'
require 'test/test_helper'
class PluginTest < Test::Unit::TestCase
def test_initialize
assert plugin
assert plugin.repository
assert_nil plugin.name
end
def test_should_raise_invalid_uri_exception_on_nil_url
assert_raise(URI::InvalidURIError) { create_plugin(nil, nil) }
end
def test_should_guess_name_for_git_url
assert_equal 'sashimi', plugin.guess_name
end
def test_should_guess_name_for_svn_url
assert_equal 'sashimi', create_plugin(nil, 'http://dev.repository.com/svn/sashimi').guess_name
assert_equal 'sashimi', create_plugin(nil, 'http://dev.repository.com/svn/sashimi/trunk').guess_name
end
def test_should_instantiate_git_repository_for_git_url
assert_kind_of GitRepository, plugin.repository
end
def test_should_instantiate_svn_repository_for_not_git_url
assert_kind_of SvnRepository, create_plugin(nil, 'http://dev.repository.com/svn/sashimi/trunk').repository
end
def test_should_serialize_to_hash
initialize_repository_for_test do
expected = {'plugin' => {'type' => 'svn', 'summary' => 'Plugin summary'}}
assert_equal(expected, create_plugin('plugin', 'http://dev.repository.com/svn/plugin/trunk').to_hash)
end
end
end