gitnetworkitis 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.rvmrc +4 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +34 -0
- data/README.rdoc +1 -1
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/gitnetworkitis-0.1.0.gem +0 -0
- data/gitnetworkitis.gemspec +127 -0
- data/lib/gitnetworkitis/network_data.rb +4 -0
- data/spec/base_spec.rb +46 -0
- data/spec/branch_spec.rb +31 -0
- data/spec/commit_spec.rb +8 -0
- data/spec/gitnetworkitis_spec.rb +4 -0
- data/spec/network_data_spec.rb +153 -0
- data/spec/network_meta_spec.rb +59 -0
- data/spec/repository_spec.rb +56 -0
- data/spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=0.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=1.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=2.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=3.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=4.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=5.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=0.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=1.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=2.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=3.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=4.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=0.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=1.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=2.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=3.json +1 -0
- data/spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=4.json +1 -0
- data/spec/responses/girlambition/0-500.json +1 -0
- data/spec/responses/girlambition/1002-1502.json +1 -0
- data/spec/responses/girlambition/1503-2003.json +1 -0
- data/spec/responses/girlambition/2004-2504.json +1 -0
- data/spec/responses/girlambition/2505-3005.json +1 -0
- data/spec/responses/girlambition/3006-3506.json +1 -0
- data/spec/responses/girlambition/3507-4007.json +1 -0
- data/spec/responses/girlambition/4008-4508.json +1 -0
- data/spec/responses/girlambition/4509-4999.json +1 -0
- data/spec/responses/girlambition/501-1001.json +1 -0
- data/spec/responses/girlambition/repos_show_turingstudio_website-girlambition_branches.json +1 -0
- data/spec/responses/girlambition/turingstudio_website-girlambition_network_meta.json +1 -0
- data/spec/responses/loupe/repos_show_turingstudio_loupe.json +1 -0
- data/spec/responses/loupe/repos_show_turingstudio_loupe_branches.json +1 -0
- data/spec/responses/loupe/turingstudio_loupe_068161e2c05a6b8029a7eb410dd27b1dfa531338?start=1&end=5.json +1 -0
- data/spec/responses/loupe/turingstudio_loupe_068161e2c05a6b8029a7eb410dd27b1dfa531338?start=130.json +1 -0
- data/spec/responses/loupe/turingstudio_loupe_branch.json +1 -0
- data/spec/responses/loupe/turingstudio_loupe_network_data.json +1 -0
- data/spec/responses/loupe/turingstudio_loupe_network_meta.json +1 -0
- data/spec/responses/repos_show_jcoutu.json +1 -0
- data/spec/responses/repos_watched_jcoutu.json +1 -0
- data/spec/spec_helper.rb +78 -0
- metadata +77 -39
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "httparty"
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "rspec", "~> 2.1.0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.5.1"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
gem "fakeweb"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
crack (0.1.8)
|
5
|
+
diff-lcs (1.1.2)
|
6
|
+
fakeweb (1.3.0)
|
7
|
+
git (1.2.5)
|
8
|
+
httparty (0.6.1)
|
9
|
+
crack (= 0.1.8)
|
10
|
+
jeweler (1.5.1)
|
11
|
+
bundler (~> 1.0.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rake
|
14
|
+
rake (0.8.7)
|
15
|
+
rcov (0.9.9)
|
16
|
+
rspec (2.1.0)
|
17
|
+
rspec-core (~> 2.1.0)
|
18
|
+
rspec-expectations (~> 2.1.0)
|
19
|
+
rspec-mocks (~> 2.1.0)
|
20
|
+
rspec-core (2.1.0)
|
21
|
+
rspec-expectations (2.1.0)
|
22
|
+
diff-lcs (~> 1.1.2)
|
23
|
+
rspec-mocks (2.1.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.0.0)
|
30
|
+
fakeweb
|
31
|
+
httparty
|
32
|
+
jeweler (~> 1.5.1)
|
33
|
+
rcov
|
34
|
+
rspec (~> 2.1.0)
|
data/README.rdoc
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "gitnetworkitis"
|
16
|
+
gem.homepage = "http://github.com/jcoutu/gitnetworkitis"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = "Git API Gem utilizing the Network API"
|
19
|
+
gem.description = "Git API Gem utilizing the Network API"
|
20
|
+
gem.email = "jcoutu@phaseiiicreations.com"
|
21
|
+
gem.authors = ["Julian Coutu"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "gitnetworkitis #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
Binary file
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gitnetworkitis}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Julian Coutu"]
|
12
|
+
s.date = %q{2011-05-26}
|
13
|
+
s.description = %q{Git API Gem utilizing the Network API}
|
14
|
+
s.email = %q{jcoutu@phaseiiicreations.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
".rvmrc",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"gitnetworkitis-0.1.0.gem",
|
30
|
+
"gitnetworkitis.gemspec",
|
31
|
+
"lib/gitnetworkitis.rb",
|
32
|
+
"lib/gitnetworkitis/base.rb",
|
33
|
+
"lib/gitnetworkitis/branch.rb",
|
34
|
+
"lib/gitnetworkitis/commit.rb",
|
35
|
+
"lib/gitnetworkitis/network_data.rb",
|
36
|
+
"lib/gitnetworkitis/network_meta.rb",
|
37
|
+
"lib/gitnetworkitis/repository.rb",
|
38
|
+
"spec/base_spec.rb",
|
39
|
+
"spec/branch_spec.rb",
|
40
|
+
"spec/commit_spec.rb",
|
41
|
+
"spec/gitnetworkitis_spec.rb",
|
42
|
+
"spec/network_data_spec.rb",
|
43
|
+
"spec/network_meta_spec.rb",
|
44
|
+
"spec/repository_spec.rb",
|
45
|
+
"spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=0.json",
|
46
|
+
"spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=1.json",
|
47
|
+
"spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=2.json",
|
48
|
+
"spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=3.json",
|
49
|
+
"spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=4.json",
|
50
|
+
"spec/responses/branch_pages/turingstudio_loupe_51ac36280d2dfe16c37b66ef344859c9c714c8e1?page=5.json",
|
51
|
+
"spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=0.json",
|
52
|
+
"spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=1.json",
|
53
|
+
"spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=2.json",
|
54
|
+
"spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=3.json",
|
55
|
+
"spec/responses/branch_pages/turingstudio_loupe_bec7b23dc57b14d89fa2829e8c32a108a18e7248?page=4.json",
|
56
|
+
"spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=0.json",
|
57
|
+
"spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=1.json",
|
58
|
+
"spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=2.json",
|
59
|
+
"spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=3.json",
|
60
|
+
"spec/responses/branch_pages/turingstudio_loupe_c3aeb61e37f94bbb67c4f14b52c23b8e54d30d0e?page=4.json",
|
61
|
+
"spec/responses/girlambition/0-500.json",
|
62
|
+
"spec/responses/girlambition/1002-1502.json",
|
63
|
+
"spec/responses/girlambition/1503-2003.json",
|
64
|
+
"spec/responses/girlambition/2004-2504.json",
|
65
|
+
"spec/responses/girlambition/2505-3005.json",
|
66
|
+
"spec/responses/girlambition/3006-3506.json",
|
67
|
+
"spec/responses/girlambition/3507-4007.json",
|
68
|
+
"spec/responses/girlambition/4008-4508.json",
|
69
|
+
"spec/responses/girlambition/4509-4999.json",
|
70
|
+
"spec/responses/girlambition/501-1001.json",
|
71
|
+
"spec/responses/girlambition/repos_show_turingstudio_website-girlambition_branches.json",
|
72
|
+
"spec/responses/girlambition/turingstudio_website-girlambition_network_meta.json",
|
73
|
+
"spec/responses/loupe/repos_show_turingstudio_loupe.json",
|
74
|
+
"spec/responses/loupe/repos_show_turingstudio_loupe_branches.json",
|
75
|
+
"spec/responses/loupe/turingstudio_loupe_068161e2c05a6b8029a7eb410dd27b1dfa531338?start=1&end=5.json",
|
76
|
+
"spec/responses/loupe/turingstudio_loupe_068161e2c05a6b8029a7eb410dd27b1dfa531338?start=130.json",
|
77
|
+
"spec/responses/loupe/turingstudio_loupe_branch.json",
|
78
|
+
"spec/responses/loupe/turingstudio_loupe_network_data.json",
|
79
|
+
"spec/responses/loupe/turingstudio_loupe_network_meta.json",
|
80
|
+
"spec/responses/repos_show_jcoutu.json",
|
81
|
+
"spec/responses/repos_watched_jcoutu.json",
|
82
|
+
"spec/spec_helper.rb"
|
83
|
+
]
|
84
|
+
s.homepage = %q{http://github.com/jcoutu/gitnetworkitis}
|
85
|
+
s.licenses = ["MIT"]
|
86
|
+
s.require_paths = ["lib"]
|
87
|
+
s.rubygems_version = %q{1.5.2}
|
88
|
+
s.summary = %q{Git API Gem utilizing the Network API}
|
89
|
+
s.test_files = [
|
90
|
+
"spec/base_spec.rb",
|
91
|
+
"spec/branch_spec.rb",
|
92
|
+
"spec/commit_spec.rb",
|
93
|
+
"spec/gitnetworkitis_spec.rb",
|
94
|
+
"spec/network_data_spec.rb",
|
95
|
+
"spec/network_meta_spec.rb",
|
96
|
+
"spec/repository_spec.rb",
|
97
|
+
"spec/spec_helper.rb"
|
98
|
+
]
|
99
|
+
|
100
|
+
if s.respond_to? :specification_version then
|
101
|
+
s.specification_version = 3
|
102
|
+
|
103
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
104
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
105
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
|
106
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
107
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
108
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
109
|
+
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
110
|
+
else
|
111
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
112
|
+
s.add_dependency(%q<rspec>, ["~> 2.1.0"])
|
113
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
114
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
115
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
116
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
117
|
+
end
|
118
|
+
else
|
119
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
120
|
+
s.add_dependency(%q<rspec>, ["~> 2.1.0"])
|
121
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
122
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
123
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
124
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
@@ -51,11 +51,15 @@ module GitNetworkitis
|
|
51
51
|
|
52
52
|
private
|
53
53
|
def parse_results(response)
|
54
|
+
begin
|
54
55
|
json_result = parse_json(escape_json(response.body.to_s))
|
55
56
|
result = Array.new
|
56
57
|
json_result["commits"].each do |commit|
|
57
58
|
self.commits.push(parse_attributes(commit, Commit.new(self.username, self.token)))
|
58
59
|
end
|
60
|
+
rescue
|
61
|
+
self.commits = []
|
62
|
+
end
|
59
63
|
end
|
60
64
|
|
61
65
|
end
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Gitnetworkitis::Base" do
|
4
|
+
|
5
|
+
context "#initialize" do
|
6
|
+
it "should allow for username and token to be set on init" do
|
7
|
+
c = GitNetworkitis::Base.new("jcoutu", "0ea98987469a2ef1daee5d1e30b42fd8")
|
8
|
+
c.username.should == "jcoutu"
|
9
|
+
c.token.should == "0ea98987469a2ef1daee5d1e30b42fd8"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "#get" do
|
14
|
+
let(:base_class){GitNetworkitis::Base.new("jcoutu", "0ea98987469a2ef1daee5d1e30b42fd8")}
|
15
|
+
let(:success_response){double(:response => double(:code=>"200"))}
|
16
|
+
let(:failure_response){double(:response => double(:code=>"404"))}
|
17
|
+
|
18
|
+
it "should return the response when successful" do
|
19
|
+
base_class.class.should_receive(:get).and_return success_response
|
20
|
+
t = base_class.get("http://google.com")
|
21
|
+
t.should == success_response
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an exception when unsuccessful" do
|
25
|
+
base_class.class.should_receive(:get).and_return failure_response
|
26
|
+
lambda {base_class.get("http://google.com")}.should raise_error "Unable to find Github Repository"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
context "#parse_json" do
|
32
|
+
|
33
|
+
let(:base_class){GitNetworkitis::Base.new("jcoutu", "0ea98987469a2ef1daee5d1e30b42fd8")}
|
34
|
+
let(:success_response){double(:response => double(:code=>"200"))}
|
35
|
+
let(:failure_response){double(:response => double(:code=>"404"))}
|
36
|
+
|
37
|
+
it "should return the response when successful" do
|
38
|
+
t = base_class.parse_json('{"test":"test"}')
|
39
|
+
t["test"].should == "test"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should raise an exception when unsuccessful" do
|
43
|
+
lambda {base_class.parse_json("http://google.com")}.should raise_error "Unable to parse JSON result"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/branch_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Gitnetworkitis::Branch" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
fake_responses
|
7
|
+
end
|
8
|
+
|
9
|
+
context "find_all" do
|
10
|
+
let(:branch){GitNetworkitis::Branch.new(@username, @token)}
|
11
|
+
let(:test){branch.find_all({:owner=>"turingstudio", :repo => "loupe", :nethash => "068161e2c05a6b8029a7eb410dd27b1dfa531338"})}
|
12
|
+
|
13
|
+
it "should return a collection of branches for a specific repo" do
|
14
|
+
test.should_not be_empty
|
15
|
+
test.first.name.should_not be_empty
|
16
|
+
test.length.should == 3
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "commits" do
|
21
|
+
let(:branch){GitNetworkitis::Branch.new(@username, @token)}
|
22
|
+
let(:test){branch.find_all({:owner=>"turingstudio", :repo => "loupe", :nethash => "068161e2c05a6b8029a7eb410dd27b1dfa531338"})}
|
23
|
+
|
24
|
+
it "should return an array of commits for the branch" do
|
25
|
+
test[0].commits.length.should == 158
|
26
|
+
test[1].commits.length.should == 140
|
27
|
+
test[2].commits.length.should == 138
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/spec/commit_spec.rb
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Gitnetworkitis::NetworkData" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
fake_responses
|
7
|
+
end
|
8
|
+
|
9
|
+
context "find" do
|
10
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
11
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "loupe"})}
|
12
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
13
|
+
let(:test){network_data.find({:owner=>"turingstudio", :repo => "loupe", :network_meta => network_meta})}
|
14
|
+
|
15
|
+
before :each do
|
16
|
+
fake_responses
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should set the commits array" do
|
20
|
+
test.commits.should_not be_empty
|
21
|
+
test.commits.first.parents.should be_empty
|
22
|
+
test.commits.length.should == 134
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set the network_meta" do
|
26
|
+
test.network_meta.should == network_meta
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "find with start set and no end" do
|
31
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
32
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "loupe"})}
|
33
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
34
|
+
let(:test){network_data.find({:owner=>"turingstudio", :repo => "loupe", :network_meta => network_meta, :start => 130})}
|
35
|
+
|
36
|
+
before :each do
|
37
|
+
fake_responses
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should set the commits array" do
|
41
|
+
test.commits.should_not be_empty
|
42
|
+
test.commits.first.parents.should_not be_empty
|
43
|
+
test.commits.length.should == 4
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should set the network_meta" do
|
47
|
+
test.network_meta.should == network_meta
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "find with start set greater than end" do
|
52
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
53
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "loupe"})}
|
54
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
55
|
+
let(:test){network_data.find({:owner=>"turingstudio", :repo => "loupe", :network_meta => network_meta, :start => 130, :end => 1})}
|
56
|
+
|
57
|
+
before :each do
|
58
|
+
fake_responses
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should set the commits array" do
|
62
|
+
test.commits.should be_empty
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set the network_meta" do
|
66
|
+
test.network_meta.should == network_meta
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "find with start and end set" do
|
71
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
72
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "loupe"})}
|
73
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
74
|
+
let(:test){network_data.find({:owner=>"turingstudio", :repo => "loupe", :network_meta => network_meta, :start => 1, :end => 5})}
|
75
|
+
|
76
|
+
before :each do
|
77
|
+
fake_responses
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should set the commits array" do
|
81
|
+
test.commits.should_not be_empty
|
82
|
+
test.commits.first.parents.should_not be_empty
|
83
|
+
test.commits.length.should == 5
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should set the network_meta" do
|
87
|
+
test.network_meta.should == network_meta
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "find with missing aurgument" do
|
92
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
93
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "loupe"})}
|
94
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
95
|
+
|
96
|
+
before :each do
|
97
|
+
fake_responses
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should raise exception if missing owner, repo, and Gitnetworkitis:NetworkMeta" do
|
101
|
+
lambda {network_data.find({:start => 1, :end => 5})}.should raise_error "You must provide an Owner, Repo and Gitnetworkitis:NetworkMeta"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should raise exception if Gitnetworkitis:NetworkMeta" do
|
105
|
+
lambda {network_data.find({:owner=>"turingstudio", :repo => "loupe", :start => 1, :end => 5})}.should raise_error "You must provide an Owner, Repo and Gitnetworkitis:NetworkMeta"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should raise exception if missing owner" do
|
109
|
+
lambda {network_data.find({:repo => "loupe", :network_meta => network_meta, :start => 1, :end => 5})}.should raise_error "You must provide an Owner, Repo and Gitnetworkitis:NetworkMeta"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should raise exception if missing repo" do
|
113
|
+
lambda {network_data.find({:owner=>"turingstudio", :network_meta => network_meta, :start => 1, :end => 5})}.should raise_error "You must provide an Owner, Repo and Gitnetworkitis:NetworkMeta"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
context "find on repo with large amount of commits" do
|
119
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
120
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "website-girlambition"})}
|
121
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
122
|
+
let(:test){network_data.find({:owner=>"turingstudio", :repo => "website-girlambition", :network_meta => network_meta})}
|
123
|
+
|
124
|
+
before :each do
|
125
|
+
fake_responses
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should set the commits array" do
|
129
|
+
test.commits.should_not be_empty
|
130
|
+
test.commits.first.parents.should be_empty
|
131
|
+
test.commits.length.should == 5000
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "find on repo with large amount of commits" do
|
136
|
+
let(:tester){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
137
|
+
let(:network_meta){tester.find({:owner=>"turingstudio", :repo => "website-girlambition"})}
|
138
|
+
let(:network_data){GitNetworkitis::NetworkData.new(@username, @token)}
|
139
|
+
let(:test){network_data.find({:owner=>"turingstudio", :repo => "website-girlambition", :network_meta => network_meta})}
|
140
|
+
|
141
|
+
before :each do
|
142
|
+
fake_responses
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should set the commits array" do
|
146
|
+
test.commits.should_not be_empty
|
147
|
+
test.commits.first.parents.should be_empty
|
148
|
+
test.commits.length.should == 5000
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Gitnetworkitis::NetworkMeta" do
|
4
|
+
context "find" do
|
5
|
+
let(:network_meta){GitNetworkitis::NetworkMeta.new(@username, @token)}
|
6
|
+
let(:test){network_meta.find({:owner=>"turingstudio", :repo => "loupe"})}
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
fake_responses
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should set the nethash" do
|
13
|
+
test = network_meta.find({:owner=>"turingstudio", :repo => "loupe"})
|
14
|
+
test.nethash.should == "068161e2c05a6b8029a7eb410dd27b1dfa531338"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the date array" do
|
18
|
+
test.dates.should_not be_empty
|
19
|
+
test.dates.first.should == "2010-10-08"
|
20
|
+
test.dates.last.should == "2010-12-28"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set focus" do
|
24
|
+
test.focus.should == 133
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should set the users array" do
|
28
|
+
test.users.should_not == nil
|
29
|
+
test.users.length.should == 1
|
30
|
+
test.users[0]["repo"].should == "loupe"
|
31
|
+
test.users[0]["heads"].length.should == 3
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should set blocks" do
|
35
|
+
test.blocks.should_not == nil
|
36
|
+
test.blocks.length.should == 1
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should set spacemap" do
|
40
|
+
test.spacemap.should_not == nil
|
41
|
+
test.spacemap.length.should == 3
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should set branches to a collection of branches for a specific repo" do
|
45
|
+
test.branches.should_not == nil
|
46
|
+
test.branches.length.should == 3
|
47
|
+
end
|
48
|
+
|
49
|
+
context "error returns" do
|
50
|
+
|
51
|
+
it "raise an exception when the repo is not found" do
|
52
|
+
lambda {network_meta.find({:owner=>"bad_owner", :repo => "bad_repo"})}.should raise_error "Unable to find Github Repository"
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Gitnetworkitis::Repository" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
fake_responses
|
7
|
+
end
|
8
|
+
|
9
|
+
context "#find_all_watched" do
|
10
|
+
it "should return an empty array if no credentials are found" do
|
11
|
+
c = GitNetworkitis::Repository.new(nil, nil)
|
12
|
+
repos = c.find_all_watched
|
13
|
+
repos.length.should == 0
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should list a users watched repositories" do
|
17
|
+
c = GitNetworkitis::Repository.new(@username, @token)
|
18
|
+
repos = c.find_all_watched
|
19
|
+
repos.should_not be_empty
|
20
|
+
repos.length.should == 15
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "#find_all_owned" do
|
25
|
+
it "should return an empty array if no credentials are found" do
|
26
|
+
c = GitNetworkitis::Repository.new(nil, nil)
|
27
|
+
repos = c.find_all_owned
|
28
|
+
repos.length.should == 0
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should list a users repositories" do
|
32
|
+
c = GitNetworkitis::Repository.new(@username, @token)
|
33
|
+
repos = c.find_all_owned
|
34
|
+
repos.should_not be_empty
|
35
|
+
repos.length.should == 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "#find" do
|
40
|
+
it "should allow a user to search for a repo based on owner and repo name" do
|
41
|
+
c = GitNetworkitis::Repository.new(@username, @token)
|
42
|
+
repo = c.find({:owner=>"turingstudio", :repo => "loupe"})
|
43
|
+
repo.owner.should == "turingstudio"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "#remote_id" do
|
48
|
+
it "should set the remote_id to owner/name" do
|
49
|
+
c = GitNetworkitis::Repository.new(@username, @token)
|
50
|
+
repo = c.find({:owner=>"turingstudio", :repo => "loupe"})
|
51
|
+
repo.remote_id.should == "turingstudio/loupe"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|