octopolo 1.5.3 → 1.6.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/lib/octopolo/cli.rb +13 -16
- data/lib/octopolo/question.rb +65 -0
- data/lib/octopolo/scripts/issue.rb +44 -16
- data/lib/octopolo/scripts/pull_request.rb +2 -2
- data/lib/octopolo/version.rb +1 -1
- data/octopolo.gemspec +1 -0
- data/spec/octopolo/cli_spec.rb +9 -15
- data/spec/octopolo/question_spec.rb +116 -0
- data/spec/octopolo/scripts/issue_spec.rb +18 -14
- data/spec/octopolo/scripts/pull_request_spec.rb +20 -16
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6c2464407620ef918f0d0ee0ad12915a2a0a7d9
|
4
|
+
data.tar.gz: 1f6dcc51285cc5fd4e2ec43a467cfa22448c0432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98638e6c9af7ac3005cf640c5a61caf8830b62ae9cef93751427f75f0439992e02ba1f64b7a715cf967607ee8f146e8220911076043885152469bc0c1500f674
|
7
|
+
data.tar.gz: 0ba49cdf629d378b30d1789ea946cc8dc1487d777a5c00c5ec6bfe640f61db00080ee288b844a9a5a830818a7cbc11dc38d598e4892f817c5366dc5338995afb
|
data/CHANGELOG.markdown
CHANGED
data/lib/octopolo/cli.rb
CHANGED
@@ -112,23 +112,20 @@ module Octopolo
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
def self.ask(question, choices
|
115
|
+
def self.ask(question, choices)
|
116
116
|
return choices.first if choices.size == 1
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
say "#{i+1}) #{choice}"
|
122
|
-
end
|
117
|
+
|
118
|
+
say question
|
119
|
+
choices.each_with_index do |choice, i|
|
120
|
+
say "#{i+1}) #{choice}"
|
123
121
|
end
|
124
122
|
|
125
123
|
selection = nil
|
126
124
|
while not choices.include?(selection)
|
127
125
|
selection = prompt
|
128
|
-
break if choices.include?(selection)
|
129
|
-
#
|
130
|
-
|
131
|
-
selection = choices[selection_index] if selection_index >= 0
|
126
|
+
break if choices.include?(selection) # passed in the value of the choice
|
127
|
+
selection_index = selection.to_i - 1 # passed in a 1-based index of the choice
|
128
|
+
selection = choices[selection_index] if selection_index >= 0 # gather the value of the choice
|
132
129
|
break if choices.include?(selection)
|
133
130
|
say "Not a valid choice."
|
134
131
|
end
|
@@ -143,11 +140,11 @@ module Octopolo
|
|
143
140
|
# Returns a Boolean
|
144
141
|
def self.ask_boolean(question)
|
145
142
|
answer = prompt("#{question} (y/n)")
|
146
|
-
#
|
147
|
-
answer =~ /^y/i
|
143
|
+
# Return true if the answer starts with "Y" or "y"; else return false
|
144
|
+
!!(answer =~ /^y/i)
|
148
145
|
end
|
149
146
|
|
150
|
-
def self.prompt
|
147
|
+
def self.prompt(prompt_text="> ")
|
151
148
|
highline.ask prompt_text do |conf|
|
152
149
|
conf.readline = true
|
153
150
|
end.to_s
|
@@ -163,7 +160,7 @@ module Octopolo
|
|
163
160
|
# plan = CLI.prompt_multiline "QA Plan:"
|
164
161
|
#
|
165
162
|
# Returns a String containing the value the user entered
|
166
|
-
def self.prompt_multiline
|
163
|
+
def self.prompt_multiline(prompt_text)
|
167
164
|
highline.ask(prompt_text) do |conf|
|
168
165
|
# accept text until the first blank line (instead of stopping at the
|
169
166
|
# first newline), to allow multiple lines of input
|
@@ -177,7 +174,7 @@ module Octopolo
|
|
177
174
|
# prompt_text - The text to display before the prompt; e.g., "Password: "
|
178
175
|
#
|
179
176
|
# Returns a String containing the value the user entered
|
180
|
-
def self.prompt_secret
|
177
|
+
def self.prompt_secret(prompt_text)
|
181
178
|
highline.ask(prompt_text) do |conf|
|
182
179
|
# do not display the text input
|
183
180
|
conf.echo = false
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Octopolo
|
2
|
+
class Question
|
3
|
+
include CLIWrapper
|
4
|
+
|
5
|
+
attr_accessor :prompt, :type, :choices, :add_label_based_on_boolean
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
self.prompt = options[:prompt]
|
9
|
+
self.type = options[:type] || nil
|
10
|
+
self.choices = options[:choices] || nil
|
11
|
+
self.add_label_based_on_boolean = options[:add_label_based_on_boolean] || nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# Runs the question method based on what the :type was initialized as.
|
15
|
+
def run_based_on_type
|
16
|
+
case @type
|
17
|
+
when :ask
|
18
|
+
ask
|
19
|
+
when :ask_boolean
|
20
|
+
ask_boolean
|
21
|
+
when :prompt
|
22
|
+
prompt
|
23
|
+
when :prompt_multiline
|
24
|
+
prompt_multiline
|
25
|
+
when :prompt_secret
|
26
|
+
prompt_secret
|
27
|
+
else
|
28
|
+
"Question type is invalid... not asking a question."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Asks the client to ask the question and returns the answer in string form.
|
33
|
+
def ask
|
34
|
+
cli.ask(@prompt, @choices)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Asks the client to ask the true/false question and returns the answer in boolean form UNLESS we get
|
38
|
+
# true and we want to add a label, in which case it will return the name of the label
|
39
|
+
# in string form.
|
40
|
+
def ask_boolean
|
41
|
+
response = cli.ask_boolean(@prompt)
|
42
|
+
|
43
|
+
if response && @add_label_based_on_boolean
|
44
|
+
@add_label_based_on_boolean[:label_name]
|
45
|
+
else
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Asks the client to ask the question and returns the answer in string form.
|
51
|
+
def prompt
|
52
|
+
cli.prompt(@prompt)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Asks the client to ask the question and returns the answer in string form.
|
56
|
+
def prompt_multiline
|
57
|
+
cli.prompt_multiline(@prompt)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Asks the client to ask the question and returns the answer in string form.
|
61
|
+
def prompt_secret
|
62
|
+
cli.prompt_secret(@prompt)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -4,6 +4,7 @@ require_relative "../github/issue"
|
|
4
4
|
require_relative "../github/issue_creator"
|
5
5
|
require_relative "../pivotal/story_commenter"
|
6
6
|
require_relative "../jira/story_commenter"
|
7
|
+
require_relative "../question"
|
7
8
|
|
8
9
|
module Octopolo
|
9
10
|
module Scripts
|
@@ -16,7 +17,7 @@ module Octopolo
|
|
16
17
|
attr_accessor :issue
|
17
18
|
attr_accessor :pivotal_ids
|
18
19
|
attr_accessor :jira_ids
|
19
|
-
attr_accessor :
|
20
|
+
attr_accessor :labels
|
20
21
|
attr_accessor :options
|
21
22
|
|
22
23
|
def self.execute(options={})
|
@@ -33,7 +34,7 @@ module Octopolo
|
|
33
34
|
create_issue
|
34
35
|
update_pivotal
|
35
36
|
update_jira
|
36
|
-
|
37
|
+
update_labels
|
37
38
|
open_in_browser
|
38
39
|
end
|
39
40
|
end
|
@@ -42,7 +43,7 @@ module Octopolo
|
|
42
43
|
def ask_questionaire
|
43
44
|
announce
|
44
45
|
ask_title
|
45
|
-
|
46
|
+
ask_labels
|
46
47
|
ask_pivotal_ids if config.use_pivotal_tracker
|
47
48
|
ask_jira_ids if config.use_jira
|
48
49
|
end
|
@@ -56,27 +57,36 @@ module Octopolo
|
|
56
57
|
|
57
58
|
# Protected: Ask for a title for the issue
|
58
59
|
def ask_title
|
59
|
-
self.title =
|
60
|
+
self.title = Octopolo::Question.new(prompt: "Title:").prompt
|
60
61
|
end
|
61
62
|
protected :ask_title
|
62
63
|
|
63
64
|
# Protected: Ask for a label for the issue
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
def ask_labels
|
66
|
+
self.labels = []
|
67
|
+
|
68
|
+
label_questions.each do |question|
|
69
|
+
label_name = question.run_based_on_type
|
70
|
+
if label_name.is_a? String
|
71
|
+
self.labels << label_hash[label_name] if label_hash[label_name]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
self.labels
|
68
76
|
end
|
69
|
-
protected :
|
77
|
+
protected :ask_labels
|
70
78
|
|
71
79
|
# Protected: Ask for a Pivotal Tracker story IDs
|
72
80
|
def ask_pivotal_ids
|
73
|
-
|
81
|
+
response = Octopolo::Question.new(prompt: "Pivotal Tracker story ID(s):").prompt
|
82
|
+
self.pivotal_ids = response.split(/[\s,]+/)
|
74
83
|
end
|
75
84
|
protected :ask_pivotal_ids
|
76
85
|
|
77
|
-
# Protected: Ask for a
|
86
|
+
# Protected: Ask for a Jira Tracker story IDs
|
78
87
|
def ask_jira_ids
|
79
|
-
|
88
|
+
response = Octopolo::Question.new(prompt: "Jira story ID(s):").prompt
|
89
|
+
self.jira_ids = response.split(/[\s,]+/)
|
80
90
|
end
|
81
91
|
protected :ask_pivotal_ids
|
82
92
|
|
@@ -108,14 +118,32 @@ module Octopolo
|
|
108
118
|
end
|
109
119
|
protected :open_in_browser
|
110
120
|
|
121
|
+
def label_questions
|
122
|
+
[
|
123
|
+
Octopolo::Question.new(
|
124
|
+
prompt: label_prompt,
|
125
|
+
type: :ask,
|
126
|
+
choices: generate_generic_label_choices
|
127
|
+
)
|
128
|
+
]
|
129
|
+
end
|
130
|
+
|
111
131
|
def label_prompt
|
112
|
-
|
132
|
+
"Label:"
|
133
|
+
end
|
134
|
+
|
135
|
+
def generate_generic_label_choices
|
136
|
+
Octopolo::GitHub::Label.get_names(label_choices).concat(["None"])
|
113
137
|
end
|
114
138
|
|
115
139
|
def label_choices
|
116
140
|
Octopolo::GitHub::Label.all
|
117
141
|
end
|
118
142
|
|
143
|
+
def label_hash
|
144
|
+
Hash[label_choices.map{ |l| [l.name, l] }]
|
145
|
+
end
|
146
|
+
|
119
147
|
def update_pivotal
|
120
148
|
pivotal_ids.each do |story_id|
|
121
149
|
Pivotal::StoryCommenter.new(story_id, issue.url).perform
|
@@ -130,10 +158,10 @@ module Octopolo
|
|
130
158
|
end
|
131
159
|
protected :update_jira
|
132
160
|
|
133
|
-
def
|
134
|
-
issue.add_labels(
|
161
|
+
def update_labels
|
162
|
+
issue.add_labels(labels) unless labels.nil?
|
135
163
|
end
|
136
|
-
protected :
|
164
|
+
protected :update_labels
|
137
165
|
|
138
166
|
end
|
139
167
|
end
|
@@ -31,7 +31,7 @@ module Octopolo
|
|
31
31
|
create_pull_request
|
32
32
|
update_pivotal
|
33
33
|
update_jira
|
34
|
-
|
34
|
+
update_labels
|
35
35
|
open_in_browser
|
36
36
|
end
|
37
37
|
end
|
@@ -41,7 +41,7 @@ module Octopolo
|
|
41
41
|
alert_reserved_and_exit if git.reserved_branch?
|
42
42
|
announce
|
43
43
|
ask_title
|
44
|
-
|
44
|
+
ask_labels
|
45
45
|
ask_pivotal_ids if config.use_pivotal_tracker
|
46
46
|
ask_jira_ids if config.use_jira
|
47
47
|
end
|
data/lib/octopolo/version.rb
CHANGED
data/octopolo.gemspec
CHANGED
@@ -30,5 +30,6 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_development_dependency 'rspec', '~> 2.99'
|
31
31
|
gem.add_development_dependency 'guard', '~> 2.6'
|
32
32
|
gem.add_development_dependency 'guard-rspec', '~> 4.3'
|
33
|
+
gem.add_development_dependency 'hitimes', '~> 1.2.6'
|
33
34
|
gem.add_development_dependency 'octopolo-plugin-example', '~> 0'
|
34
35
|
end
|
data/spec/octopolo/cli_spec.rb
CHANGED
@@ -135,16 +135,6 @@ module Octopolo
|
|
135
135
|
subject.ask(question, choices)
|
136
136
|
end
|
137
137
|
|
138
|
-
it "skips printing the question and choices if told not to (useful to avoid cluttering spec output)" do
|
139
|
-
subject.should_receive(:say).with(question).never
|
140
|
-
subject.should_receive(:say).with("1) sandwich").never
|
141
|
-
subject.should_receive(:say).with("2) carrots").never
|
142
|
-
subject.should_receive(:say).with("3) cake").never
|
143
|
-
subject.should_receive(:prompt).and_return(valid_string_answer) # only specifying return value to prevent infinite loop
|
144
|
-
|
145
|
-
subject.ask(question, choices, true)
|
146
|
-
end
|
147
|
-
|
148
138
|
it "simply returns the value if given only one choice" do
|
149
139
|
subject.should_receive(:say).never
|
150
140
|
subject.should_receive(:prompt).never
|
@@ -155,38 +145,42 @@ module Octopolo
|
|
155
145
|
context "when answering with the string value" do
|
156
146
|
it "returns the user's selection, if in the available choices" do
|
157
147
|
subject.should_receive(:prompt).and_return(valid_string_answer)
|
158
|
-
subject.ask(question, choices
|
148
|
+
subject.ask(question, choices).should == valid_string_answer
|
159
149
|
end
|
160
150
|
|
161
151
|
it "asks again if given a string other than one of the choices" do
|
162
152
|
subject.should_receive(:prompt).and_return(invalid_string_answer)
|
153
|
+
allow(subject).to receive(:say)
|
163
154
|
subject.should_receive(:say).with("Not a valid choice.")
|
164
155
|
subject.should_receive(:prompt).and_return(valid_string_answer)
|
165
156
|
|
166
|
-
subject.ask(question, choices
|
157
|
+
subject.ask(question, choices).should == valid_string_answer
|
167
158
|
end
|
168
159
|
end
|
169
160
|
|
170
161
|
context "when answering with the numeric value" do
|
171
162
|
it "returns the user's selection, if in the available choices" do
|
172
163
|
subject.should_receive(:prompt).and_return(valid_numeric_answer)
|
173
|
-
subject.
|
164
|
+
allow(subject).to receive(:say)
|
165
|
+
subject.ask(question, choices).should == valid_string_answer
|
174
166
|
end
|
175
167
|
|
176
168
|
it "asks again if given a answer 0 or less" do
|
177
169
|
subject.should_receive(:prompt).and_return(invalid_low_numeric_answer)
|
178
170
|
subject.should_receive(:say).with("Not a valid choice.")
|
171
|
+
allow(subject).to receive(:say)
|
179
172
|
subject.should_receive(:prompt).and_return(valid_numeric_answer)
|
180
173
|
|
181
|
-
subject.ask(question, choices
|
174
|
+
subject.ask(question, choices).should == valid_string_answer
|
182
175
|
end
|
183
176
|
|
184
177
|
it "asks again if given a answer greater than the list of choices" do
|
185
178
|
subject.should_receive(:prompt).and_return(invalid_high_numeric_answer)
|
186
179
|
subject.should_receive(:say).with("Not a valid choice.")
|
180
|
+
allow(subject).to receive(:say)
|
187
181
|
subject.should_receive(:prompt).and_return(valid_numeric_answer)
|
188
182
|
|
189
|
-
subject.ask(question, choices
|
183
|
+
subject.ask(question, choices).should == valid_string_answer
|
190
184
|
end
|
191
185
|
end
|
192
186
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative "../../lib/octopolo/question"
|
2
|
+
|
3
|
+
describe Octopolo::Question do
|
4
|
+
let(:prompt_1) do
|
5
|
+
{
|
6
|
+
prompt: "test-prompt",
|
7
|
+
type: :ask,
|
8
|
+
choices: ["choice1", "choice2"]
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:prompt_2) do
|
13
|
+
{
|
14
|
+
prompt: "test-prompt",
|
15
|
+
type: :ask_boolean
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:prompt_label) do
|
20
|
+
{
|
21
|
+
prompt:"test-prompt",
|
22
|
+
type: :ask_boolean,
|
23
|
+
add_label_based_on_boolean: {
|
24
|
+
label_name: "test_label"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:prompt_3) do
|
30
|
+
{
|
31
|
+
prompt: "test-prompt",
|
32
|
+
type: :prompt
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
let(:prompt_4) do
|
38
|
+
{
|
39
|
+
prompt: "test-prompt",
|
40
|
+
type: :prompt_multiline
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
let(:prompt_5) do
|
46
|
+
{
|
47
|
+
prompt: "test-prompt",
|
48
|
+
type: :prompt_secret
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:cli) { stub(:cli) }
|
53
|
+
|
54
|
+
before do
|
55
|
+
Octopolo::Question.any_instance.stub({
|
56
|
+
:cli => cli
|
57
|
+
})
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#ask" do
|
61
|
+
it "should have the client call .ask" do
|
62
|
+
expect(cli).to receive(:ask) {"1"}
|
63
|
+
Octopolo::Question.new(prompt_1).ask
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#ask_boolean" do
|
68
|
+
it "should have the client call .ask_boolean" do
|
69
|
+
expect(cli).to receive(:ask_boolean) {"yes"}
|
70
|
+
Octopolo::Question.new(prompt_2).ask_boolean
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "we don't want to add a label" do
|
74
|
+
it "should return the boolean response the client returns: false" do
|
75
|
+
allow(cli).to receive(:ask_boolean) {false}
|
76
|
+
resp = Octopolo::Question.new(prompt_2).ask_boolean
|
77
|
+
expect(resp).to eq(false)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return the boolean response the client returns: true" do
|
81
|
+
allow(cli).to receive(:ask_boolean) {true}
|
82
|
+
resp = Octopolo::Question.new(prompt_2).ask_boolean
|
83
|
+
expect(resp).to eq(true)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "we do want to add a label" do
|
88
|
+
it "should return the name of the label if client returns true" do
|
89
|
+
allow(cli).to receive(:ask_boolean) {true}
|
90
|
+
resp = Octopolo::Question.new(prompt_label).ask_boolean
|
91
|
+
expect(resp).to eq("test_label")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#prompt" do
|
97
|
+
it "should have the client call .prompt" do
|
98
|
+
expect(cli).to receive(:prompt) {"yes"}
|
99
|
+
Octopolo::Question.new(prompt_3).prompt
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#prompt_multiline" do
|
104
|
+
it "should have the client call .prompt_multiline" do
|
105
|
+
expect(cli).to receive(:prompt_multiline) {"yes"}
|
106
|
+
Octopolo::Question.new(prompt_4).prompt_multiline
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#prompt_secret" do
|
111
|
+
it "should have the client call .prompt_secret" do
|
112
|
+
expect(cli).to receive(:prompt_secret) {"yes"}
|
113
|
+
Octopolo::Question.new(prompt_5).prompt_secret
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -26,6 +26,10 @@ module Octopolo
|
|
26
26
|
:config => config,
|
27
27
|
:git => git
|
28
28
|
})
|
29
|
+
|
30
|
+
Octopolo::Question.any_instance.stub({
|
31
|
+
:cli => cli
|
32
|
+
})
|
29
33
|
end
|
30
34
|
|
31
35
|
context "#new" do
|
@@ -41,7 +45,7 @@ module Octopolo
|
|
41
45
|
expect(subject).to receive(:create_issue)
|
42
46
|
expect(subject).to receive(:update_pivotal)
|
43
47
|
expect(subject).to receive(:update_jira)
|
44
|
-
expect(subject).to receive(:
|
48
|
+
expect(subject).to receive(:update_labels)
|
45
49
|
expect(subject).to receive(:open_in_browser)
|
46
50
|
|
47
51
|
subject.execute
|
@@ -59,7 +63,7 @@ module Octopolo
|
|
59
63
|
expect(subject).to receive(:ask_title)
|
60
64
|
expect(subject).to receive(:ask_pivotal_ids)
|
61
65
|
expect(subject).to receive(:ask_jira_ids)
|
62
|
-
expect(subject).to receive(:
|
66
|
+
expect(subject).to receive(:ask_labels)
|
63
67
|
|
64
68
|
subject.send(:ask_questionaire)
|
65
69
|
end
|
@@ -82,22 +86,22 @@ module Octopolo
|
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
|
-
context "#
|
89
|
+
context "#ask_labels" do
|
86
90
|
let(:label1) {Octopolo::GitHub::Label.new(name: "low-risk", color: '151515')}
|
87
91
|
let(:label2) {Octopolo::GitHub::Label.new(name: "high-risk", color: '151515')}
|
88
|
-
let(:choices) {["low-risk","high-risk"
|
92
|
+
let(:choices) {["low-risk","high-risk"]}
|
89
93
|
|
90
94
|
it "asks for and capture a label" do
|
91
95
|
allow(Octopolo::GitHub::Label).to receive(:all) {[label1,label2]}
|
92
|
-
expect(cli).to receive(:ask).with("Label:", choices)
|
93
|
-
subject.send(:
|
96
|
+
expect(cli).to receive(:ask).with("Label:", choices.concat(["None"]))
|
97
|
+
subject.send(:ask_labels)
|
94
98
|
end
|
95
99
|
|
96
100
|
it "asks for a label" do
|
97
101
|
allow(Octopolo::GitHub::Label).to receive(:all) {[label1,label2]}
|
98
102
|
allow(Octopolo::GitHub::Label).to receive(:get_names) {choices}
|
99
103
|
allow(cli).to receive(:ask) {"low-risk"}
|
100
|
-
expect(subject.send(:
|
104
|
+
expect(subject.send(:ask_labels)).to eq([label1])
|
101
105
|
end
|
102
106
|
end
|
103
107
|
|
@@ -194,23 +198,23 @@ module Octopolo
|
|
194
198
|
end
|
195
199
|
end
|
196
200
|
|
197
|
-
context "#
|
201
|
+
context "#update_labels" do
|
198
202
|
before do
|
199
|
-
subject.
|
203
|
+
subject.labels = "high-risk"
|
200
204
|
subject.issue = stub()
|
201
205
|
end
|
202
|
-
it "calls
|
206
|
+
it "calls update_labels with proper arguments" do
|
203
207
|
expect(subject.issue).to receive(:add_labels).with('high-risk')
|
204
|
-
subject.send(:
|
208
|
+
subject.send(:update_labels)
|
205
209
|
end
|
206
210
|
|
207
211
|
context "doesn't know yet label" do
|
208
212
|
before do
|
209
|
-
subject.
|
213
|
+
subject.labels = nil
|
210
214
|
end
|
211
|
-
it "doesn't call
|
215
|
+
it "doesn't call update_labels when label is don't know yet" do
|
212
216
|
expect(subject.issue).to_not receive(:add_labels)
|
213
|
-
subject.send(:
|
217
|
+
subject.send(:update_labels)
|
214
218
|
end
|
215
219
|
end
|
216
220
|
|
@@ -25,6 +25,10 @@ module Octopolo
|
|
25
25
|
:config => config,
|
26
26
|
:git => git
|
27
27
|
})
|
28
|
+
|
29
|
+
Octopolo::Question.any_instance.stub({
|
30
|
+
:cli => cli
|
31
|
+
})
|
28
32
|
end
|
29
33
|
|
30
34
|
context "#new" do
|
@@ -44,7 +48,7 @@ module Octopolo
|
|
44
48
|
expect(subject).to receive(:create_pull_request)
|
45
49
|
expect(subject).to receive(:update_pivotal)
|
46
50
|
expect(subject).to receive(:update_jira)
|
47
|
-
expect(subject).to receive(:
|
51
|
+
expect(subject).to receive(:update_labels)
|
48
52
|
expect(subject).to receive(:open_in_browser)
|
49
53
|
|
50
54
|
subject.execute
|
@@ -62,7 +66,7 @@ module Octopolo
|
|
62
66
|
expect(subject).to receive(:ask_title)
|
63
67
|
expect(subject).to receive(:ask_pivotal_ids)
|
64
68
|
expect(subject).to receive(:ask_jira_ids)
|
65
|
-
expect(subject).to receive(:
|
69
|
+
expect(subject).to receive(:ask_labels)
|
66
70
|
|
67
71
|
subject.send(:ask_questionaire)
|
68
72
|
end
|
@@ -73,7 +77,7 @@ module Octopolo
|
|
73
77
|
subject.stub(:ask_title)
|
74
78
|
subject.stub(:ask_pivotal_ids)
|
75
79
|
subject.stub(:ask_jira_ids)
|
76
|
-
subject.stub(:
|
80
|
+
subject.stub(:ask_labels)
|
77
81
|
end
|
78
82
|
it "exits when branch name is reserved" do
|
79
83
|
subject.git.stub(:reserved_branch?).and_return true
|
@@ -114,22 +118,22 @@ module Octopolo
|
|
114
118
|
end
|
115
119
|
end
|
116
120
|
|
117
|
-
context "#
|
121
|
+
context "#ask_labels" do
|
118
122
|
let(:label1) {Octopolo::GitHub::Label.new(name: "low-risk", color: '151515')}
|
119
123
|
let(:label2) {Octopolo::GitHub::Label.new(name: "high-risk", color: '151515')}
|
120
|
-
let(:choices) {["low-risk","high-risk"
|
124
|
+
let(:choices) {["low-risk","high-risk"]}
|
121
125
|
|
122
126
|
it "asks for and capture a label" do
|
123
127
|
allow(Octopolo::GitHub::Label).to receive(:all) {[label1,label2]}
|
124
|
-
expect(cli).to receive(:ask).with("Label:", choices)
|
125
|
-
subject.send(:
|
128
|
+
expect(cli).to receive(:ask).with("Label:", choices.concat(["None"]))
|
129
|
+
subject.send(:ask_labels)
|
126
130
|
end
|
127
131
|
|
128
132
|
it "asks for a label" do
|
129
133
|
allow(Octopolo::GitHub::Label).to receive(:all) {[label1,label2]}
|
130
134
|
allow(Octopolo::GitHub::Label).to receive(:get_names) {choices}
|
131
135
|
allow(cli).to receive(:ask) {"low-risk"}
|
132
|
-
expect(subject.send(:
|
136
|
+
expect(subject.send(:ask_labels)).to eq([label1])
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
@@ -233,23 +237,23 @@ module Octopolo
|
|
233
237
|
end
|
234
238
|
end
|
235
239
|
|
236
|
-
context "#
|
240
|
+
context "#update_labels" do
|
237
241
|
before do
|
238
|
-
subject.
|
242
|
+
subject.labels = ["high-risk"]
|
239
243
|
subject.pull_request = stub()
|
240
244
|
end
|
241
|
-
it "calls
|
242
|
-
expect(subject.pull_request).to receive(:add_labels).with('high-risk')
|
243
|
-
subject.send(:
|
245
|
+
it "calls update_labels with proper arguments" do
|
246
|
+
expect(subject.pull_request).to receive(:add_labels).with(['high-risk'])
|
247
|
+
subject.send(:update_labels)
|
244
248
|
end
|
245
249
|
|
246
250
|
context "doesn't know yet label" do
|
247
251
|
before do
|
248
|
-
subject.
|
252
|
+
subject.labels = nil
|
249
253
|
end
|
250
|
-
it "doesn't call
|
254
|
+
it "doesn't call update_labels when label is don't know yet" do
|
251
255
|
expect(subject.pull_request).to_not receive(:add_labels)
|
252
|
-
subject.send(:
|
256
|
+
subject.send(:update_labels)
|
253
257
|
end
|
254
258
|
end
|
255
259
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Byrne
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gli
|
@@ -194,6 +194,20 @@ dependencies:
|
|
194
194
|
- - "~>"
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '4.3'
|
197
|
+
- !ruby/object:Gem::Dependency
|
198
|
+
name: hitimes
|
199
|
+
requirement: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - "~>"
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: 1.2.6
|
204
|
+
type: :development
|
205
|
+
prerelease: false
|
206
|
+
version_requirements: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - "~>"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 1.2.6
|
197
211
|
- !ruby/object:Gem::Dependency
|
198
212
|
name: octopolo-plugin-example
|
199
213
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,6 +284,7 @@ files:
|
|
270
284
|
- lib/octopolo/pivotal.rb
|
271
285
|
- lib/octopolo/pivotal/story_commenter.rb
|
272
286
|
- lib/octopolo/pull_request_merger.rb
|
287
|
+
- lib/octopolo/question.rb
|
273
288
|
- lib/octopolo/renderer.rb
|
274
289
|
- lib/octopolo/reports.rb
|
275
290
|
- lib/octopolo/scripts.rb
|
@@ -313,6 +328,7 @@ files:
|
|
313
328
|
- spec/octopolo/pivotal/story_commenter_spec.rb
|
314
329
|
- spec/octopolo/pivotal_spec.rb
|
315
330
|
- spec/octopolo/pull_request_merger_spec.rb
|
331
|
+
- spec/octopolo/question_spec.rb
|
316
332
|
- spec/octopolo/renderer_spec.rb
|
317
333
|
- spec/octopolo/scripts/accept_pull_spec.rb
|
318
334
|
- spec/octopolo/scripts/compare_release_spec.rb
|
@@ -382,6 +398,7 @@ test_files:
|
|
382
398
|
- spec/octopolo/pivotal/story_commenter_spec.rb
|
383
399
|
- spec/octopolo/pivotal_spec.rb
|
384
400
|
- spec/octopolo/pull_request_merger_spec.rb
|
401
|
+
- spec/octopolo/question_spec.rb
|
385
402
|
- spec/octopolo/renderer_spec.rb
|
386
403
|
- spec/octopolo/scripts/accept_pull_spec.rb
|
387
404
|
- spec/octopolo/scripts/compare_release_spec.rb
|