public
Fork of francois/piston
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/technicalpickles/piston.git
Cleaned up Piston::Repository tests.

  * test_if_guess_return_GIT_repository_when_url_is_git_repository
  * test_if_guess_return_SVN_repository_when_url_is_svn_repository
      These tests don't belong in Piston::Repository.  They test whether
      Piston::Svn::Repository and Piston::Git::Repository return true to
      #understands_url?.  These are unit tests belong in the appropriate
      subclass of Piston::Repository tests, which they already do.

  * test_handlers
      Bad name, renamed to: 
      test_guess_raises_unhandled_url_exception_when_no_repository_handler
      _found

  * test_at
      Renamed and rewrote.  #at is now a subclass responsibility.

  * test_url
  * test_initialize
      Bad names, renamed to: 
      test_initialize_stores_url_parameter_in_url_accessor

  * test_add_handler
      Rewrote using mocks, and testing only #add_handler behavior, nothing 
      else.
francois (author)
Fri May 09 07:47:05 -0700 2008
commit  46ed4501e7a9620227373fe600b8124d582daaf9
tree    a57b89adfc57dbb7fe49f32ef0595b4aade24825
parent  24c8b6fae1e43014a140a04e0fbfd97efee866f9
...
27
28
29
 
30
31
32
...
73
74
75
76
77
78
79
80
...
27
28
29
30
31
32
33
...
74
75
76
 
 
77
78
79
0
@@ -27,6 +27,7 @@ lib/piston/svn/revision.rb
0
 lib/piston/svn/working_copy.rb
0
 lib/piston/version.rb
0
 lib/piston/working_copy.rb
0
+lib/subclass_responsibility_error.rb
0
 log/.gitignore
0
 samples/common.rb
0
 samples/import_git_git.rb
0
@@ -73,8 +74,6 @@ test/unit/svn/working_copy/test_finalization.rb
0
 test/unit/svn/working_copy/test_guessing.rb
0
 test/unit/svn/working_copy/test_rememberance.rb
0
 test/unit/test_import.rb
0
-test/unit/test_piston.rb
0
-test/unit/test_repository_guessing.rb
0
 test/unit/working_copy/test_guessing.rb
0
 test/unit/working_copy/test_rememberance.rb
0
 tmp/.gitignore
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+require "subclass_responsibility_error"
0
+
0
 require "piston/repository"
0
 require "piston/revision"
0
 require "piston/working_copy"
...
43
44
45
46
47
 
48
49
50
...
43
44
45
 
 
46
47
48
49
0
@@ -43,8 +43,7 @@ module Piston
0
     end
0
 
0
     def at(revision)
0
- logger.info {"Targeting #{self} at #{revision.inspect}"}
0
- Piston::Revision.new(self, revision)
0
+ raise SubclassResponsibilityError, "Piston::Repository#at should be implemented by a subclass."
0
     end
0
 
0
     def to_s
...
2
3
4
5
6
 
7
8
9
10
11
12
13
...
16
17
18
19
20
21
22
...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
 
 
 
45
46
47
48
49
50
51
52
53
54
55
 
 
56
57
58
 
 
59
60
61
62
63
64
65
66
67
68
69
 
 
 
 
 
70
71
...
2
3
4
 
 
5
6
7
8
 
9
10
11
...
14
15
16
 
17
18
19
...
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
0
@@ -2,12 +2,10 @@ require File.dirname(__FILE__) + "/../test_helper"
0
 
0
 class TestRepository < Test::Unit::TestCase
0
   def setup
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
   end
0
 
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
   end
0
 
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
 
0
     handler = mock("handler")
0
@@ -28,44 +25,26 @@ class TestRepository < Test::Unit::TestCase
0
     assert_equal handler_instance, Piston::Repository.guess(url)
0
   end
0
 
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
- end
0
-
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
- end
0
-
0
- def test_guess_when_unhandled_url
0
- assert_raise(Piston::Repository::UnhandledUrl) { Piston::Repository.guess("invalid") }
0
- end
0
-
0
- def test_handlers
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
+ end
0
   end
0
 
0
   def test_add_handler
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
- end
0
-
0
- def test_initialize
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
   end
0
 
0
- def test_url
0
+ def test_initialize_stores_url_parameter_in_url_accessor
0
+ @repository = Piston::Repository.new("url")
0
     assert_equal "url", @repository.url
0
   end
0
 
0
- def test_at
0
- revision = @repository.at("2")
0
- assert_equal @repository, revision.repository
0
- assert_equal "2", revision.revision
0
- end
0
-
0
- def test_to_s
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
0
+ @repository.at(:any)
0
+ end
0
   end
0
 end

Comments

    No one has commented yet.