public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
Search Repo:
francois (author)
Fri May 09 07:47:05 -0700 2008
commit  46ed4501e7a9620227373fe600b8124d582daaf9
tree    a57b89adfc57dbb7fe49f32ef0595b4aade24825
parent  24c8b6fae1e43014a140a04e0fbfd97efee866f9
piston / test / unit / test_repository.rb
100644 50 lines (41 sloc) 1.602 kb
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
39
40
41
42
43
44
45
46
47
48
49
50
require File.dirname(__FILE__) + "/../test_helper"
 
class TestRepository < Test::Unit::TestCase
  def setup
    Piston::Repository.send(:handlers).clear
  end
 
  def test_guess_asks_each_handler_in_turn
    Piston::Repository.add_handler(handler = mock("handler"))
    handler.expects(:understands_url?).with("http://a.repos.com/trunk").returns(false)
    assert_raise Piston::Repository::UnhandledUrl do
      Piston::Repository.guess("http://a.repos.com/trunk")
    end
  end
 
  def test_guess_returns_first_handler_that_understands_the_url
    url = "svn://a.repos.com/projects/libcalc/trunk"
 
    handler = mock("handler")
    handler.expects(:understands_url?).with(url).returns(true)
    handler_instance = mock("handler_instance")
    handler.expects(:new).with(url).returns(handler_instance)
 
    Piston::Repository.add_handler handler
    assert_equal handler_instance, Piston::Repository.guess(url)
  end
 
  def test_guess_raises_unhandled_url_exception_when_no_repository_handler_found
    assert_raise(Piston::Repository::UnhandledUrl) do
      Piston::Repository.guess("invalid")
    end
  end
 
  def test_add_handler
    Piston::Repository.add_handler(handler = mock("handler"))
    assert_equal [handler], Piston::Repository.send(:handlers)
  end
 
  def test_initialize_stores_url_parameter_in_url_accessor
    @repository = Piston::Repository.new("url")
    assert_equal "url", @repository.url
  end
 
  def test_at_is_a_subclass_responsibility
    @repository = Piston::Repository.new("url")
    assert_raise(SubclassResponsibilityError) do
      @repository.at(:any)
    end
  end
end