-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_source_spec.rb
More file actions
54 lines (43 loc) · 1.51 KB
/
Copy pathgithub_source_spec.rb
File metadata and controls
54 lines (43 loc) · 1.51 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
51
52
53
require './log'
require './github_source'
require 'hashie'
require 'json'
$logger.level = Logger::DEBUG
describe GithubSource, "GithubSource" do
it "load don't duplicates data" do
github_mock = Object.new
allow(Github).to receive_messages(:new => github_mock)
gs = GithubSource.new [{
'user'=>'tet',
'repos'=> ['a', 'b', 'c'],
'token'=>'token'}], nil
repos = { :body => {
:full_name => 'fn',
:description => 'desc',
:html_url => 'hurl',
}}
repos_mock = Object.new
allow(repos_mock).to receive_messages(:get => Hashie::Mash.new(repos))
allow(github_mock).to receive_messages(:repos => repos_mock)
languages_mock = Object.new
languages = {
'C++' => '3431',
'Java' => '1234'
}
allow(repos_mock).to receive_messages(:languages => Hashie::Mash.new(languages))
contributors_mock = Object.new
contributors = {
}
allow(repos_mock).to receive_messages(:contributors => Hashie::Mash.new(contributors))
gs.load
gs.load
gs.load
$logger.debug "Projects json: %s" % gs.projects.to_json
$logger.debug "Projects: %s" % gs.projects['a']
$logger.debug "Projects 'a' json: %s" % gs.projects['a'].to_json
$logger.debug "Projects 'a' info: %s" % gs.projects['a'].info
$logger.debug "Projects 'a' info github_projects: %s" % gs.projects['a'].info['github_projects']
$logger.debug gs.projects['a'].info['github_projects']
expect(gs.projects['a'].info['github_projects'].length).to be 1
end
end