dcuddeback-octopi 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/.gitignore +4 -0
  2. data/.yardoc +0 -0
  3. data/CHANGELOG.md +9 -0
  4. data/LICENSE +20 -0
  5. data/README.markdown +144 -0
  6. data/Rakefile +94 -0
  7. data/VERSION.yml +4 -0
  8. data/contrib/backup.rb +100 -0
  9. data/dcuddeback-octopi.gemspec +108 -0
  10. data/examples/authenticated.rb +20 -0
  11. data/examples/issues.rb +18 -0
  12. data/examples/overall.rb +50 -0
  13. data/lib/ext/string_ext.rb +5 -0
  14. data/lib/octopi/api.rb +213 -0
  15. data/lib/octopi/base.rb +115 -0
  16. data/lib/octopi/blob.rb +25 -0
  17. data/lib/octopi/branch.rb +31 -0
  18. data/lib/octopi/branch_set.rb +11 -0
  19. data/lib/octopi/comment.rb +20 -0
  20. data/lib/octopi/commit.rb +69 -0
  21. data/lib/octopi/deploy_key.rb +27 -0
  22. data/lib/octopi/deploy_key_set.rb +18 -0
  23. data/lib/octopi/error.rb +35 -0
  24. data/lib/octopi/file_object.rb +16 -0
  25. data/lib/octopi/gist.rb +28 -0
  26. data/lib/octopi/issue.rb +111 -0
  27. data/lib/octopi/issue_comment.rb +7 -0
  28. data/lib/octopi/issue_set.rb +21 -0
  29. data/lib/octopi/key.rb +25 -0
  30. data/lib/octopi/key_set.rb +14 -0
  31. data/lib/octopi/plan.rb +5 -0
  32. data/lib/octopi/repository.rb +136 -0
  33. data/lib/octopi/repository_set.rb +9 -0
  34. data/lib/octopi/resource.rb +70 -0
  35. data/lib/octopi/self.rb +33 -0
  36. data/lib/octopi/tag.rb +23 -0
  37. data/lib/octopi/user.rb +131 -0
  38. data/lib/octopi.rb +135 -0
  39. data/test/api_test.rb +58 -0
  40. data/test/authenticated_test.rb +39 -0
  41. data/test/base_test.rb +20 -0
  42. data/test/blob_test.rb +23 -0
  43. data/test/branch_test.rb +20 -0
  44. data/test/commit_test.rb +82 -0
  45. data/test/file_object_test.rb +39 -0
  46. data/test/gist_test.rb +16 -0
  47. data/test/issue_comment.rb +19 -0
  48. data/test/issue_set_test.rb +33 -0
  49. data/test/issue_test.rb +120 -0
  50. data/test/key_set_test.rb +29 -0
  51. data/test/key_test.rb +35 -0
  52. data/test/repository_set_test.rb +23 -0
  53. data/test/repository_test.rb +151 -0
  54. data/test/stubs/commits/fcoury/octopi/octopi.rb +818 -0
  55. data/test/tag_test.rb +20 -0
  56. data/test/test_helper.rb +246 -0
  57. data/test/user_test.rb +92 -0
  58. metadata +151 -0
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class RepositorySetTest < Test::Unit::TestCase
4
+ include Octopi
5
+
6
+ def setup
7
+ fake_everything
8
+ @user = User.find("fcoury")
9
+ end
10
+
11
+
12
+ context RepositorySet do
13
+
14
+ should "return a repository set" do
15
+ assert @user.repositories.is_a?(RepositorySet)
16
+ end
17
+
18
+ should "be able to find a repository" do
19
+ assert_not_nil @user.repositories.find("octopi")
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,151 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class RepositoryTest < Test::Unit::TestCase
4
+ include Octopi
5
+
6
+ def setup
7
+ fake_everything
8
+ @user = User.find("fcoury")
9
+ @private_repos = auth do
10
+ @private = @user.repositories.find("rboard")
11
+ @user.repositories
12
+ end
13
+ @repository = @user.repositories.find("octopi")
14
+ end
15
+
16
+
17
+ context Repository do
18
+
19
+ should "not retry for a repository you don't have access to" do
20
+ FakeWeb.register_uri(:get, "#{yaml_api}/repos/show/github/github", :status => 403)
21
+
22
+ exception = assert_raise APIError do
23
+ Repository.find(:user => "github", :name => "github")
24
+ end
25
+
26
+ assert_equal exception.message, "Github returned status 403, you may not have access to this resource."
27
+ end
28
+
29
+ should "return a repository for a user" do
30
+ assert_not_nil @user.repository(:name => "octopi")
31
+ assert @user.repository(:name => "octopi").is_a?(Repository)
32
+ end
33
+
34
+ should "return a repository for a login" do
35
+ assert_not_nil Repository.find(:user => "fcoury", :name => "octopi")
36
+ end
37
+
38
+ should "be able to look up the repository based on the user and name" do
39
+ assert_not_nil Repository.find(:user => @user, :name => "octopi")
40
+ end
41
+
42
+ should "have a User as the owner" do
43
+ assert @repository.owner.is_a?(User)
44
+ end
45
+
46
+ should "return repositories" do
47
+ assert_equal 45, @user.repositories.size
48
+ end
49
+
50
+ should "return more repositories if authed" do
51
+ assert_equal 44, @private_repos.size
52
+ end
53
+
54
+ should "not return a repository when asked for a private one" do
55
+ exception = assert_raise NotFound do
56
+ @user.repository(:name => "rboard")
57
+ end
58
+
59
+ assert_equal "The Repository you were looking for could not be found, or is private.", exception.message
60
+ end
61
+
62
+ should "return a private repository when authed" do
63
+ auth do
64
+ assert_not_nil @user.repository(:name => "rboard")
65
+ end
66
+ end
67
+
68
+ should "be able to search for similar repositories" do
69
+ repos = Repository.search("ruby", "testing")
70
+ assert_not_nil repos
71
+ assert repos.first.is_a?(Repository)
72
+ end
73
+
74
+ should "be able to find the latest 30 commits" do
75
+ commits = @repository.commits
76
+ assert_not_nil commits
77
+ assert_equal 30, commits.size
78
+ end
79
+
80
+
81
+ should "be able to find all open issues" do
82
+ issues = @repository.issues
83
+ assert_not_nil issues
84
+ assert_equal 21, issues.size
85
+ end
86
+
87
+ should "be able to find all issues" do
88
+ issues = @repository.all_issues
89
+ assert_not_nil issues
90
+ assert_equal 42, issues.size
91
+ end
92
+
93
+ should "be able to find an issue" do
94
+ assert_not_nil @repository.issue(28)
95
+ end
96
+
97
+ should "be able to find all collaborators" do
98
+ @collaborators = @repository.collaborators
99
+ assert_not_nil @collaborators
100
+ assert_equal 1, @collaborators.size
101
+ assert @collaborators.first.is_a?(User)
102
+ end
103
+
104
+ should "be able to create a repository" do
105
+ auth do
106
+ Repository.create(:name => "octopus")
107
+ end
108
+ end
109
+
110
+ should "be able to delete a repository" do
111
+ auth do
112
+ @repository.delete!
113
+ end
114
+ end
115
+
116
+ should "not be able to create a repository when not authed" do
117
+ assert_raise Octopi::AuthenticationRequired do
118
+ Repository.create(:name => "octopus")
119
+ end
120
+ end
121
+
122
+ should "be able to retrieve the branches" do
123
+ branches = @repository.branches
124
+ assert_not_nil branches
125
+ assert_equal 4, branches.size
126
+ end
127
+
128
+ should "be able to retrieve the tags" do
129
+ tags = @repository.tags
130
+ assert_not_nil tags
131
+ assert_equal 9, tags.size
132
+ end
133
+
134
+ should "be able to retrieve the comments" do
135
+ assert_not_nil @repository.comments
136
+ comment = @repository.comments.first
137
+ [:content, :author, :title, :updated, :link, :published, :id, :repository, :commit].each do |f|
138
+ assert_not_nil comment.send(f)
139
+ end
140
+ end
141
+
142
+ should "return the correct clone URL" do
143
+ assert_equal "git://github.com/fcoury/octopi.git", @repository.clone_url
144
+ auth do
145
+ assert_equal "git@github.com:fcoury/rboard.git", @private.clone_url
146
+ end
147
+ end
148
+
149
+
150
+ end
151
+ end