teachers_pet 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +7 -0
- data/Guardfile +3 -1
- data/README.md +53 -28
- data/Rakefile +1 -1
- data/bin/teachers_pet +4 -0
- data/lib/teachers_pet.rb +4 -1
- data/lib/teachers_pet/actions/add_to_team.rb +31 -0
- data/lib/teachers_pet/actions/base.rb +36 -111
- data/lib/teachers_pet/actions/clone_repos.rb +9 -36
- data/lib/teachers_pet/actions/create_repos.rb +16 -39
- data/lib/teachers_pet/actions/create_student_teams.rb +35 -0
- data/lib/teachers_pet/actions/fork_collab.rb +4 -19
- data/lib/teachers_pet/actions/open_issue.rb +17 -32
- data/lib/teachers_pet/actions/push_files.rb +8 -22
- data/lib/teachers_pet/cli.rb +22 -0
- data/lib/teachers_pet/client_decorator.rb +59 -0
- data/lib/teachers_pet/commands/add_to_team.rb +12 -0
- data/lib/teachers_pet/commands/clone_repos.rb +15 -0
- data/lib/teachers_pet/commands/create_repos.rb +15 -0
- data/lib/teachers_pet/commands/create_student_teams.rb +13 -0
- data/lib/teachers_pet/commands/fork_collab.rb +12 -0
- data/lib/teachers_pet/commands/open_issue.rb +18 -0
- data/lib/teachers_pet/commands/push_files.rb +15 -0
- data/lib/teachers_pet/configuration.rb +0 -13
- data/lib/teachers_pet/version.rb +1 -1
- data/spec/actions/base_spec.rb +13 -0
- data/spec/cli_spec.rb +17 -0
- data/spec/commands/add_to_team_spec.rb +43 -0
- data/spec/commands/clone_repos_spec.rb +33 -0
- data/spec/commands/create_repos_spec.rb +55 -0
- data/spec/commands/create_student_teams_spec.rb +90 -0
- data/spec/commands/fork_collab_spec.rb +95 -0
- data/spec/commands/open_issue_spec.rb +63 -0
- data/spec/commands/push_files_spec.rb +33 -0
- data/spec/fixtures/empty +0 -0
- data/spec/fixtures/teams +1 -0
- data/spec/spec_helper.rb +13 -53
- data/spec/support/command_helpers.rb +11 -0
- data/spec/support/common_helpers.rb +52 -0
- data/teachers_pet.gemspec +6 -2
- metadata +89 -29
- data/bin/clone_repos +0 -6
- data/bin/create_repos +0 -6
- data/bin/create_teams +0 -6
- data/bin/fork_collab +0 -6
- data/bin/open_issue +0 -6
- data/bin/push_files +0 -6
- data/lib/teachers_pet/actions/create_teams.rb +0 -101
- data/spec/actions/clone_repos_spec.rb +0 -44
- data/spec/actions/create_repos_spec.rb +0 -65
- data/spec/actions/create_teams_spec.rb +0 -40
- data/spec/actions/open_issue_spec.rb +0 -71
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'open_issue' do
|
4
|
+
include CommandHelpers
|
5
|
+
|
6
|
+
context 'through CLI' do
|
7
|
+
def common_test(labels='')
|
8
|
+
issue_title = "Issue Test"
|
9
|
+
request_stubs = []
|
10
|
+
|
11
|
+
request_stubs << stub_get_json('https://testteacher:abc123@api.github.com/orgs/testorg',
|
12
|
+
login: 'testorg',
|
13
|
+
url: 'https://api.github.com/orgs/testorg'
|
14
|
+
)
|
15
|
+
request_stubs << stub_get_json('https://testteacher:abc123@api.github.com/orgs/testorg/teams?per_page=100', student_teams)
|
16
|
+
student_usernames.each do |username|
|
17
|
+
# Action checks that repos exist already
|
18
|
+
request_stubs << stub_request(:get, "https://testteacher:abc123@api.github.com/repos/testorg/#{username}-testrepo")
|
19
|
+
end
|
20
|
+
|
21
|
+
# create the issue in each repo
|
22
|
+
student_usernames.each do |username|
|
23
|
+
team_id = 0
|
24
|
+
student_teams.each do |st|
|
25
|
+
if st[:name].eql?(username)
|
26
|
+
team_id = st[:id]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
issue_body = File.read(issue_fixture_path).gsub("\n", "\\n")
|
30
|
+
labels_list = labels.split(",").map(&:strip).to_s.delete(' ')
|
31
|
+
request_stubs << stub_request(:post, "https://testteacher:abc123@api.github.com/repos/testorg/#{username}-testrepo/issues").
|
32
|
+
with(body: "{\"labels\":#{labels_list},\"title\":\"#{issue_title}\",\"body\":\"#{issue_body}\"}").
|
33
|
+
to_return(status: 201)
|
34
|
+
end
|
35
|
+
|
36
|
+
teachers_pet(:open_issue,
|
37
|
+
repository: 'testrepo',
|
38
|
+
organization: 'testorg',
|
39
|
+
|
40
|
+
title: issue_title,
|
41
|
+
body: issue_fixture_path,
|
42
|
+
labels: labels,
|
43
|
+
|
44
|
+
students: students_list_fixture_path,
|
45
|
+
|
46
|
+
username: 'testteacher',
|
47
|
+
password: 'abc123'
|
48
|
+
)
|
49
|
+
|
50
|
+
request_stubs.each do |request_stub|
|
51
|
+
expect(request_stub).to have_been_requested.once
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "open issue no labels" do
|
56
|
+
common_test
|
57
|
+
end
|
58
|
+
|
59
|
+
it "open issue with labels" do
|
60
|
+
common_test('bug, feature')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'push_files' do
|
4
|
+
include CommandHelpers
|
5
|
+
|
6
|
+
it "runs" do
|
7
|
+
request_stubs = []
|
8
|
+
request_stubs << stub_get_json('https://testteacher:abc123@api.github.com/orgs/testorg',
|
9
|
+
login: 'testorg',
|
10
|
+
name: 'Test Org',
|
11
|
+
url: 'http://test.org'
|
12
|
+
)
|
13
|
+
request_stubs << stub_get_json('https://testteacher:abc123@api.github.com/orgs/testorg/teams?per_page=100', [
|
14
|
+
{
|
15
|
+
name: 'teststudent'
|
16
|
+
}
|
17
|
+
])
|
18
|
+
|
19
|
+
teachers_pet(:push_files,
|
20
|
+
repository: 'assignment',
|
21
|
+
organization: 'testorg',
|
22
|
+
|
23
|
+
students: students_list_fixture_path,
|
24
|
+
|
25
|
+
username: 'testteacher',
|
26
|
+
password: 'abc123'
|
27
|
+
)
|
28
|
+
|
29
|
+
request_stubs.each do |request_stub|
|
30
|
+
expect(request_stub).to have_been_requested.once
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/fixtures/empty
ADDED
File without changes
|
data/spec/fixtures/teams
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
studentteam1 teststudent1 teststudent2
|
data/spec/spec_helper.rb
CHANGED
@@ -1,64 +1,24 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_group 'Actions' do |src_file|
|
4
|
+
file = src_file.filename
|
5
|
+
file.include?(File.join('lib', 'teachers_pet', 'actions')) && File.basename(file) != 'base.rb'
|
6
|
+
end
|
7
|
+
add_group 'Commands', '/lib/teachers_pet/commands/'
|
8
|
+
add_group 'Specs', '/spec/'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'active_support/core_ext/kernel/reporting'
|
1
12
|
require 'csv'
|
2
13
|
require 'json'
|
3
14
|
require 'webmock/rspec'
|
4
15
|
|
5
16
|
require_relative File.join('..', 'lib', 'teachers_pet')
|
17
|
+
require_rel 'support'
|
6
18
|
|
7
19
|
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
20
|
config.run_all_when_everything_filtered = true
|
10
21
|
config.filter_run :focus
|
11
22
|
config.order = 'random'
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def stub_get_json(url, response)
|
16
|
-
stub_request(:get, url).to_return(
|
17
|
-
headers: {
|
18
|
-
'Content-Type' => 'application/json'
|
19
|
-
},
|
20
|
-
body: response.to_json
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
def students_list_fixture_path
|
25
|
-
File.join(File.dirname(__FILE__), 'fixtures', 'students')
|
26
|
-
end
|
27
|
-
|
28
|
-
def instructors_list_fixture_path
|
29
|
-
File.join(File.dirname(__FILE__), 'fixtures', 'instructors')
|
30
|
-
end
|
31
|
-
|
32
|
-
def issue_fixture_path
|
33
|
-
File.join(File.dirname(__FILE__), 'fixtures', 'issue.md')
|
34
|
-
end
|
35
|
-
|
36
|
-
def student_usernames
|
37
|
-
CSV.read(students_list_fixture_path).flatten
|
38
|
-
end
|
39
|
-
|
40
|
-
def student_teams
|
41
|
-
student_usernames.each_with_index.map do |username, i|
|
42
|
-
{
|
43
|
-
url: "https://api.github.com/teams/#{i}",
|
44
|
-
name: username,
|
45
|
-
id: i
|
46
|
-
}
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def respond(question, response)
|
51
|
-
action.stub(:ask).with(question).and_return(response)
|
52
|
-
end
|
53
|
-
|
54
|
-
def confirm(question, response)
|
55
|
-
action.stub(:confirm).with(question, false).and_return(response)
|
56
|
-
end
|
57
|
-
|
58
|
-
def stub_github_config
|
59
|
-
respond("What is the API endpoint?", TeachersPet::Configuration.apiEndpoint)
|
60
|
-
respond("What is the Web endpoint?", TeachersPet::Configuration.webEndpoint)
|
61
|
-
respond("What is your username? (You must be an owner for the organization)?", 'testteacher')
|
62
|
-
action.stub(get_auth_method: 'password')
|
63
|
-
respond("What is your password?", 'abc123')
|
23
|
+
config.include CommonHelpers
|
64
24
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module CommandHelpers
|
2
|
+
def teachers_pet(action, opts={})
|
3
|
+
script = TeachersPet::Cli.new
|
4
|
+
script.invoke(action, [], opts)
|
5
|
+
end
|
6
|
+
|
7
|
+
def expect_to_be_run_with(cls, opts)
|
8
|
+
expect(cls).to receive(:new).with(opts).once.and_call_original
|
9
|
+
expect_any_instance_of(cls).to receive(:run).once
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module CommonHelpers
|
2
|
+
def stub_get_json(url, response)
|
3
|
+
stub_request(:get, url).to_return(
|
4
|
+
headers: {
|
5
|
+
'Content-Type' => 'application/json'
|
6
|
+
},
|
7
|
+
body: response.to_json
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def fixtures_path
|
12
|
+
File.join(File.dirname(__FILE__), '..', 'fixtures')
|
13
|
+
end
|
14
|
+
|
15
|
+
def fixture_path(filename)
|
16
|
+
File.join(fixtures_path, filename)
|
17
|
+
end
|
18
|
+
|
19
|
+
def students_list_fixture_path
|
20
|
+
fixture_path('students')
|
21
|
+
end
|
22
|
+
|
23
|
+
def instructors_list_fixture_path
|
24
|
+
fixture_path('instructors')
|
25
|
+
end
|
26
|
+
|
27
|
+
def empty_list_fixture_path
|
28
|
+
fixture_path('empty')
|
29
|
+
end
|
30
|
+
|
31
|
+
def issue_fixture_path
|
32
|
+
fixture_path('issue.md')
|
33
|
+
end
|
34
|
+
|
35
|
+
def student_usernames
|
36
|
+
CSV.read(students_list_fixture_path).flatten
|
37
|
+
end
|
38
|
+
|
39
|
+
def instructor_usernames
|
40
|
+
CSV.read(instructors_list_fixture_path).flatten
|
41
|
+
end
|
42
|
+
|
43
|
+
def student_teams
|
44
|
+
student_usernames.each_with_index.map do |username, i|
|
45
|
+
{
|
46
|
+
url: "https://api.github.com/teams/#{i}",
|
47
|
+
name: username,
|
48
|
+
id: i
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/teachers_pet.gemspec
CHANGED
@@ -20,12 +20,16 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.required_ruby_version = '>= 1.9.3'
|
22
22
|
|
23
|
-
s.add_dependency '
|
23
|
+
s.add_dependency 'activesupport', '~> 4.0'
|
24
24
|
s.add_dependency 'octokit', '~> 3.1.0'
|
25
|
+
s.add_dependency 'require_all', '~> 1.3.2'
|
26
|
+
s.add_dependency 'thor', '~> 0.19.1'
|
25
27
|
|
26
28
|
s.add_development_dependency 'bundler', '~> 1.5'
|
27
29
|
s.add_development_dependency 'guard-rspec', '~> 4.2'
|
28
30
|
s.add_development_dependency 'rake'
|
29
|
-
s.add_development_dependency 'rspec', '~>
|
31
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
# https://github.com/colszowka/simplecov/issues/281
|
33
|
+
s.add_development_dependency 'simplecov', '~> 0.7.1'
|
30
34
|
s.add_development_dependency 'webmock', '~> 1.17'
|
31
35
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teachers_pet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Britton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: octokit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: require_all
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.19.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.19.1
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +114,28 @@ dependencies:
|
|
86
114
|
requirements:
|
87
115
|
- - ~>
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.7.1
|
90
132
|
type: :development
|
91
133
|
prerelease: false
|
92
134
|
version_requirements: !ruby/object:Gem::Requirement
|
93
135
|
requirements:
|
94
136
|
- - ~>
|
95
137
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
138
|
+
version: 0.7.1
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
140
|
name: webmock
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,12 +153,7 @@ dependencies:
|
|
111
153
|
description:
|
112
154
|
email: public@johndbritton.com
|
113
155
|
executables:
|
114
|
-
-
|
115
|
-
- create_repos
|
116
|
-
- create_teams
|
117
|
-
- fork_collab
|
118
|
-
- open_issue
|
119
|
-
- push_files
|
156
|
+
- teachers_pet
|
120
157
|
extensions: []
|
121
158
|
extra_rdoc_files: []
|
122
159
|
files:
|
@@ -129,30 +166,44 @@ files:
|
|
129
166
|
- LICENSE
|
130
167
|
- README.md
|
131
168
|
- Rakefile
|
132
|
-
- bin/
|
133
|
-
- bin/create_repos
|
134
|
-
- bin/create_teams
|
135
|
-
- bin/fork_collab
|
136
|
-
- bin/open_issue
|
137
|
-
- bin/push_files
|
169
|
+
- bin/teachers_pet
|
138
170
|
- lib/teachers_pet.rb
|
171
|
+
- lib/teachers_pet/actions/add_to_team.rb
|
139
172
|
- lib/teachers_pet/actions/base.rb
|
140
173
|
- lib/teachers_pet/actions/clone_repos.rb
|
141
174
|
- lib/teachers_pet/actions/create_repos.rb
|
142
|
-
- lib/teachers_pet/actions/
|
175
|
+
- lib/teachers_pet/actions/create_student_teams.rb
|
143
176
|
- lib/teachers_pet/actions/fork_collab.rb
|
144
177
|
- lib/teachers_pet/actions/open_issue.rb
|
145
178
|
- lib/teachers_pet/actions/push_files.rb
|
179
|
+
- lib/teachers_pet/cli.rb
|
180
|
+
- lib/teachers_pet/client_decorator.rb
|
181
|
+
- lib/teachers_pet/commands/add_to_team.rb
|
182
|
+
- lib/teachers_pet/commands/clone_repos.rb
|
183
|
+
- lib/teachers_pet/commands/create_repos.rb
|
184
|
+
- lib/teachers_pet/commands/create_student_teams.rb
|
185
|
+
- lib/teachers_pet/commands/fork_collab.rb
|
186
|
+
- lib/teachers_pet/commands/open_issue.rb
|
187
|
+
- lib/teachers_pet/commands/push_files.rb
|
146
188
|
- lib/teachers_pet/configuration.rb
|
147
189
|
- lib/teachers_pet/version.rb
|
148
|
-
- spec/actions/
|
149
|
-
- spec/
|
150
|
-
- spec/
|
151
|
-
- spec/
|
190
|
+
- spec/actions/base_spec.rb
|
191
|
+
- spec/cli_spec.rb
|
192
|
+
- spec/commands/add_to_team_spec.rb
|
193
|
+
- spec/commands/clone_repos_spec.rb
|
194
|
+
- spec/commands/create_repos_spec.rb
|
195
|
+
- spec/commands/create_student_teams_spec.rb
|
196
|
+
- spec/commands/fork_collab_spec.rb
|
197
|
+
- spec/commands/open_issue_spec.rb
|
198
|
+
- spec/commands/push_files_spec.rb
|
199
|
+
- spec/fixtures/empty
|
152
200
|
- spec/fixtures/instructors
|
153
201
|
- spec/fixtures/issue.md
|
154
202
|
- spec/fixtures/students
|
203
|
+
- spec/fixtures/teams
|
155
204
|
- spec/spec_helper.rb
|
205
|
+
- spec/support/command_helpers.rb
|
206
|
+
- spec/support/common_helpers.rb
|
156
207
|
- teachers_pet.gemspec
|
157
208
|
homepage: http://github.com/education/teachers_pet
|
158
209
|
licenses:
|
@@ -174,16 +225,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
225
|
version: '0'
|
175
226
|
requirements: []
|
176
227
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
228
|
+
rubygems_version: 2.2.2
|
178
229
|
signing_key:
|
179
230
|
specification_version: 4
|
180
231
|
summary: Command line tools to help teachers use GitHub in their classrooms
|
181
232
|
test_files:
|
182
|
-
- spec/actions/
|
183
|
-
- spec/
|
184
|
-
- spec/
|
185
|
-
- spec/
|
233
|
+
- spec/actions/base_spec.rb
|
234
|
+
- spec/cli_spec.rb
|
235
|
+
- spec/commands/add_to_team_spec.rb
|
236
|
+
- spec/commands/clone_repos_spec.rb
|
237
|
+
- spec/commands/create_repos_spec.rb
|
238
|
+
- spec/commands/create_student_teams_spec.rb
|
239
|
+
- spec/commands/fork_collab_spec.rb
|
240
|
+
- spec/commands/open_issue_spec.rb
|
241
|
+
- spec/commands/push_files_spec.rb
|
242
|
+
- spec/fixtures/empty
|
186
243
|
- spec/fixtures/instructors
|
187
244
|
- spec/fixtures/issue.md
|
188
245
|
- spec/fixtures/students
|
246
|
+
- spec/fixtures/teams
|
189
247
|
- spec/spec_helper.rb
|
248
|
+
- spec/support/command_helpers.rb
|
249
|
+
- spec/support/common_helpers.rb
|