0
@@ -2,12 +2,10 @@ require File.dirname(__FILE__) + "/../test_helper"
0
class TestRepository < Test::Unit::TestCase
0
- Piston::Repository.class_variable_set(:@@handlers, [Piston::Git::Repository, Piston::Svn::Repository])
0
- @repository = Piston::Repository.new("url")
0
+ Piston::Repository.send(:handlers).clear
0
def test_guess_asks_each_handler_in_turn
0
- Piston::Repository.send(:handlers).clear
0
Piston::Repository.add_handler(handler = mock("handler"))
0
handler.expects(:understands_url?).with("http://a.repos.com/trunk").returns(false)
0
assert_raise Piston::Repository::UnhandledUrl do
0
@@ -16,7 +14,6 @@ class TestRepository < Test::Unit::TestCase
0
def test_guess_returns_first_handler_that_understands_the_url
0
- Piston::Repository.send(:handlers).clear
0
url = "svn://a.repos.com/projects/libcalc/trunk"
0
handler = mock("handler")
0
@@ -28,44 +25,26 @@ class TestRepository < Test::Unit::TestCase
0
assert_equal handler_instance, Piston::Repository.guess(url)
0
- def test_if_guess_return_GIT_repository_when_url_is_git_repository
0
- assert_equal Piston::Git::Repository.new("git://github.com/francois/piston.git"), Piston::Repository.guess("git://github.com/francois/piston.git")
0
- def test_if_guess_return_SVN_repository_when_url_is_svn_repository
0
- assert_equal Piston::Svn::Repository.new("svn://svn.com/francois/piston.git"), Piston::Repository.guess("svn://svn.com/francois/piston.git")
0
- def test_guess_when_unhandled_url
0
- assert_raise(Piston::Repository::UnhandledUrl) { Piston::Repository.guess("invalid") }
0
- assert_equal [Piston::Git::Repository, Piston::Svn::Repository], Piston::Repository.handlers
0
+ def test_guess_raises_unhandled_url_exception_when_no_repository_handler_found
0
+ assert_raise(Piston::Repository::UnhandledUrl) do
0
+ Piston::Repository.guess("invalid")
0
- before_add = Piston::Repository.class_variable_get(:@@handlers)
0
- after_add = before_add << Piston::Git::Repository
0
- Piston::Repository.add_handler(Piston::Git::Repository)
0
- assert_equal after_add, Piston::Repository.class_variable_get(:@@handlers)
0
- assert_equal "url", @repository.instance_variable_get(:@url)
0
+ Piston::Repository.add_handler(handler = mock("handler"))
0
+ assert_equal [handler], Piston::Repository.send(:handlers)
0
+ def test_initialize_stores_url_parameter_in_url_accessor
0
+ @repository = Piston::Repository.new("url")
0
assert_equal "url", @repository.url
0
- revision = @repository.at("2")
0
- assert_equal @repository, revision.repository
0
- assert_equal "2", revision.revision
0
- assert_equal "Piston::Repository(url)", @repository.to_s
0
+ def test_at_is_a_subclass_responsibility
0
+ @repository = Piston::Repository.new("url")
0
+ assert_raise(SubclassResponsibilityError) do
Comments
No one has commented yet.