zenflow 0.8.11 → 0.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.markdown +8 -0
- data/VERSION.yml +1 -1
- data/lib/zenflow.rb +1 -1
- data/lib/zenflow/cli.rb +6 -31
- data/lib/zenflow/commands/admin.rb +88 -0
- data/lib/zenflow/helpers/github.rb +96 -53
- data/lib/zenflow/helpers/repo.rb +0 -9
- data/spec/zenflow/{helpers/cli_spec.rb → cli_spec.rb} +20 -93
- data/spec/zenflow/commands/admin_spec.rb +202 -0
- data/spec/zenflow/helpers/github_spec.rb +332 -112
- data/spec/zenflow/helpers/repo_spec.rb +0 -56
- metadata +5 -5
- data/lib/zenflow/commands/hubs.rb +0 -124
- data/spec/zenflow/commands/hubs_spec.rb +0 -372
@@ -20,60 +20,4 @@ describe Zenflow::Repo do
|
|
20
20
|
expect(Zenflow::Repo.slug).to eq("zencoder/zenflow")
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
describe '.is_current_hub?' do
|
25
|
-
before(:each){
|
26
|
-
Zenflow::Repo.should_receive(:url).twice.and_return("git@github.com:zencoder/zenflow.git")
|
27
|
-
}
|
28
|
-
|
29
|
-
context 'when check matches hub' do
|
30
|
-
it 'returns true' do
|
31
|
-
expect(Zenflow::Repo.is_current_hub?("github.com")).to eq(true)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when check does not match hub' do
|
36
|
-
it 'returns false' do
|
37
|
-
expect(Zenflow::Repo.is_current_hub?("my-hub")).to eq(false)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '.is_default_hub?' do
|
43
|
-
context 'when check is not supplied' do
|
44
|
-
context 'and current hub matches default hub' do
|
45
|
-
before(:each){
|
46
|
-
Zenflow::Repo.should_receive(:url).twice.and_return("git@github.com:zencoder/zenflow.git")
|
47
|
-
}
|
48
|
-
|
49
|
-
it 'returns true' do
|
50
|
-
expect(Zenflow::Repo.is_default_hub?).to eq(true)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'and current hub does not match default hub' do
|
55
|
-
before(:each){
|
56
|
-
Zenflow::Repo.should_receive(:url).twice.and_return("git@my-hub:zencoder/zenflow.git")
|
57
|
-
}
|
58
|
-
|
59
|
-
it 'returns true' do
|
60
|
-
expect(Zenflow::Repo.is_default_hub?).to eq(false)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when check is supplied' do
|
66
|
-
context 'and check matches default hub' do
|
67
|
-
it 'returns true' do
|
68
|
-
expect(Zenflow::Repo.is_default_hub?("github.com")).to eq(true)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'and check does not match default hub' do
|
73
|
-
it 'returns false' do
|
74
|
-
expect(Zenflow::Repo.is_default_hub?("my-hub")).to eq(false)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Kittelson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -191,10 +191,10 @@ files:
|
|
191
191
|
- bin/zenflow
|
192
192
|
- lib/zenflow.rb
|
193
193
|
- lib/zenflow/cli.rb
|
194
|
+
- lib/zenflow/commands/admin.rb
|
194
195
|
- lib/zenflow/commands/deploy.rb
|
195
196
|
- lib/zenflow/commands/feature.rb
|
196
197
|
- lib/zenflow/commands/hotfix.rb
|
197
|
-
- lib/zenflow/commands/hubs.rb
|
198
198
|
- lib/zenflow/commands/release.rb
|
199
199
|
- lib/zenflow/commands/reviews.rb
|
200
200
|
- lib/zenflow/helpers/ask.rb
|
@@ -230,17 +230,17 @@ files:
|
|
230
230
|
- spec/fixtures/cassettes/unexisting_pull_request.yml
|
231
231
|
- spec/spec_helper.rb
|
232
232
|
- spec/support/shared_examples_for_version_number.rb
|
233
|
+
- spec/zenflow/cli_spec.rb
|
234
|
+
- spec/zenflow/commands/admin_spec.rb
|
233
235
|
- spec/zenflow/commands/deploy_spec.rb
|
234
236
|
- spec/zenflow/commands/feature_spec.rb
|
235
237
|
- spec/zenflow/commands/hotfix_spec.rb
|
236
|
-
- spec/zenflow/commands/hubs_spec.rb
|
237
238
|
- spec/zenflow/commands/release_spec.rb
|
238
239
|
- spec/zenflow/commands/reviews_spec.rb
|
239
240
|
- spec/zenflow/helpers/ask_spec.rb
|
240
241
|
- spec/zenflow/helpers/branch_command_spec.rb
|
241
242
|
- spec/zenflow/helpers/branch_spec.rb
|
242
243
|
- spec/zenflow/helpers/changelog_spec.rb
|
243
|
-
- spec/zenflow/helpers/cli_spec.rb
|
244
244
|
- spec/zenflow/helpers/github_spec.rb
|
245
245
|
- spec/zenflow/helpers/help_spec.rb
|
246
246
|
- spec/zenflow/helpers/log_spec.rb
|
@@ -1,124 +0,0 @@
|
|
1
|
-
module Zenflow
|
2
|
-
class Hubs < Thor
|
3
|
-
|
4
|
-
desc "list", "Show all configured hubs."
|
5
|
-
def list
|
6
|
-
Zenflow::Log("Recogized hubs")
|
7
|
-
Zenflow::Log(Terminal::Table.new(
|
8
|
-
headings: ['Hub'],
|
9
|
-
rows: get_list_of_hubs()
|
10
|
-
).to_s, indent: false, arrows: false, color: false)
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "current", "Show the current project's hub."
|
14
|
-
def current
|
15
|
-
Zenflow::Log("This project's hub is #{hub_label(Zenflow::Repo.hub)}")
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "describe [HUB]", "Show configuration details for HUB (current project hub if none specified, or default hub if no current project)."
|
19
|
-
def describe(hub=nil)
|
20
|
-
hub = Zenflow::Github.resolve_hub(hub)
|
21
|
-
|
22
|
-
Zenflow::Log("Configuration details for hub #{hub_label(hub)}")
|
23
|
-
|
24
|
-
Zenflow::Log(Terminal::Table.new(
|
25
|
-
headings: ["Parameter", "Github Config Key", "Github Config Value", "Value (with system defaults)"],
|
26
|
-
rows: Zenflow::Github.describe_hub(hub)
|
27
|
-
).to_s, indent: false, arrows: false, color: false)
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "config [HUB]", "Configure the specified HUB (current project hub if none specified, or default hub if no current project)."
|
31
|
-
def config(hub=nil)
|
32
|
-
hub = Zenflow::Github.resolve_hub(hub)
|
33
|
-
|
34
|
-
Zenflow::Log("Configuring #{hub_label(hub)}")
|
35
|
-
|
36
|
-
config_api_base_url(hub)
|
37
|
-
config_user(hub)
|
38
|
-
config_user_agent_base(hub)
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "authorize [HUB]", "Grab an auth token for HUB (current project hub if none specified, or default hub if no current project)."
|
42
|
-
def authorize(hub=nil)
|
43
|
-
hub = Zenflow::Github.resolve_hub(hub)
|
44
|
-
|
45
|
-
Zenflow::Log("Authorizing #{hub_label(hub)}")
|
46
|
-
|
47
|
-
if Zenflow::Github.zenflow_token(hub)
|
48
|
-
if Zenflow::Ask("You already have a token from GitHub. Do you want to set a new one?", :options => ["y", "N"], :default => "n") == "y"
|
49
|
-
Zenflow::Github.authorize(hub)
|
50
|
-
end
|
51
|
-
else
|
52
|
-
Zenflow::Github.authorize(hub)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
no_commands {
|
57
|
-
def get_list_of_hubs
|
58
|
-
hub_config_parameters = Zenflow::Shell.run("git config --get-regexp zenflow\.hub\..*", silent: true).split("\n")
|
59
|
-
|
60
|
-
# unique, sorted, list of hubs with at least one valid config key
|
61
|
-
configured_hubs = hub_config_parameters.inject([]) { |hubs, parameter|
|
62
|
-
if parameter =~ /^zenflow\.hub\.(.*)\.#{config_keys_regex}\s.*$/
|
63
|
-
hubs << [hub_label($1)]
|
64
|
-
end
|
65
|
-
|
66
|
-
hubs
|
67
|
-
}.sort.uniq
|
68
|
-
|
69
|
-
[
|
70
|
-
["#{hub_label(Zenflow::Github::DEFAULT_HUB)}"]
|
71
|
-
] + configured_hubs
|
72
|
-
end
|
73
|
-
|
74
|
-
def hub_label(hub)
|
75
|
-
"#{hub}#{default_hub_tag(hub)}#{current_hub_tag(hub)}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def default_hub_tag(hub)
|
79
|
-
Zenflow::Repo.is_default_hub?(hub) ? " [default]" : ""
|
80
|
-
end
|
81
|
-
|
82
|
-
def current_hub_tag(hub)
|
83
|
-
Zenflow::Repo.is_current_hub?(hub) ? " [current]" : ""
|
84
|
-
end
|
85
|
-
|
86
|
-
def config_keys_regex
|
87
|
-
"(?:#{Zenflow::Github::CONFIG_KEYS.map { |s| s.gsub('.','\\.') }.join('|')})"
|
88
|
-
end
|
89
|
-
|
90
|
-
def config_api_base_url(hub)
|
91
|
-
api_base_url = Zenflow::Github.api_base_url(hub,false)
|
92
|
-
if api_base_url.to_s != ''
|
93
|
-
if Zenflow::Ask("The GitHub API base URL for this hub is currently #{api_base_url}. Do you want to use that?", :options => ["Y", "n"], :default => "y") == "n"
|
94
|
-
Zenflow::Github.set_api_base_url(hub)
|
95
|
-
end
|
96
|
-
else
|
97
|
-
Zenflow::Github.set_api_base_url(hub)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def config_user(hub)
|
102
|
-
user = Zenflow::Github.user(hub)
|
103
|
-
if user.to_s != ''
|
104
|
-
if Zenflow::Ask("The GitHub user for this hub is currently #{user}. Do you want to use that?", :options => ["Y", "n"], :default => "y") == "n"
|
105
|
-
Zenflow::Github.set_user(hub)
|
106
|
-
end
|
107
|
-
else
|
108
|
-
Zenflow::Github.set_user(hub)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def config_user_agent_base(hub)
|
113
|
-
user_agent_base = Zenflow::Github.user_agent_base(hub,false)
|
114
|
-
if user_agent_base.to_s != ''
|
115
|
-
if Zenflow::Ask("The GitHub User Agent base for this hub is currently #{user_agent_base}. Do you want to use that?", :options => ["Y", "n"], :default => "y") == "n"
|
116
|
-
Zenflow::Github.set_user_agent_base(hub)
|
117
|
-
end
|
118
|
-
else
|
119
|
-
Zenflow::Github.set_user_agent_base(hub)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
}
|
123
|
-
end
|
124
|
-
end
|
@@ -1,372 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Zenflow::Hubs do
|
4
|
-
let(:hubs) { Zenflow::Hubs.new }
|
5
|
-
|
6
|
-
describe '.list' do
|
7
|
-
it 'lists recognized hubs in git config' do
|
8
|
-
Zenflow::Shell.should_receive(:run).with("git config --get-regexp zenflow\.hub\..*", silent: true).and_return(
|
9
|
-
<<EOS
|
10
|
-
zenflow.hub.hub.1.api.base.url api_base_url
|
11
|
-
zenflow.hub.yet.another.hub.github.user github_user
|
12
|
-
zenflow.hub.hub.1.token token
|
13
|
-
zenflow.hub.my-hub.token token
|
14
|
-
zenflow.hub.one.more.hub.user.agent.base user_agent_base
|
15
|
-
zenflow.hub.bad.token.hub.goobers user_agent_base
|
16
|
-
EOS
|
17
|
-
)
|
18
|
-
Zenflow::Repo.should_receive(:is_default_hub?).at_least(:once).with(anything()).and_return(false)
|
19
|
-
Zenflow::Repo.should_receive(:is_current_hub?).at_least(:once).with(anything()).and_return(false)
|
20
|
-
Zenflow.should_receive(:Log).with("Recogized hubs")
|
21
|
-
Terminal::Table.should_receive(:new).with(
|
22
|
-
headings: ["Hub"],
|
23
|
-
rows: [
|
24
|
-
["github.com"],
|
25
|
-
["hub.1"],
|
26
|
-
["my-hub"],
|
27
|
-
["one.more.hub"],
|
28
|
-
["yet.another.hub"]
|
29
|
-
]
|
30
|
-
).and_return("log-data")
|
31
|
-
Zenflow.should_receive(:Log).with("log-data", indent: false, arrows: false, color: false)
|
32
|
-
hubs.list
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '.current' do
|
37
|
-
it 'logs the hubs of the current project' do
|
38
|
-
Zenflow::Repo.should_receive(:hub).twice.and_return('my-hub')
|
39
|
-
Zenflow.should_receive(:Log).with("This project's hub is my-hub [current]")
|
40
|
-
hubs.current
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '.describe' do
|
45
|
-
it 'displays config parameters for the hub' do
|
46
|
-
hubs.should_receive(:hub_label).with('my-hub').and_return('my-hub')
|
47
|
-
Zenflow.should_receive(:Log).with("Configuration details for hub my-hub")
|
48
|
-
Zenflow::Github.should_receive(:describe_hub).with('my-hub').and_return([
|
49
|
-
["Parameter 1", "Github Config Key 1", "Github Conifg Value 1", "Value 1"],
|
50
|
-
["Parameter 2", "Github Config Key 2", "Github Conifg Value 2", "Value 2"],
|
51
|
-
["Parameter 3", "Github Config Key 3", "Github Conifg Value 3", "Value 3"]
|
52
|
-
])
|
53
|
-
Terminal::Table.should_receive(:new).with(
|
54
|
-
headings: ["Parameter", "Github Config Key", "Github Config Value", "Value (with system defaults)"],
|
55
|
-
rows: [
|
56
|
-
["Parameter 1", "Github Config Key 1", "Github Conifg Value 1", "Value 1"],
|
57
|
-
["Parameter 2", "Github Config Key 2", "Github Conifg Value 2", "Value 2"],
|
58
|
-
["Parameter 3", "Github Config Key 3", "Github Conifg Value 3", "Value 3"]
|
59
|
-
]
|
60
|
-
).and_return("log-data")
|
61
|
-
Zenflow.should_receive(:Log).with("log-data", {:indent=>false, :arrows=>false, :color=>false})
|
62
|
-
hubs.describe('my-hub')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '.config' do
|
67
|
-
it 'calls the individual parameter config methods' do
|
68
|
-
Zenflow::Github.should_receive(:resolve_hub).with('my-hub').and_return('my-hub')
|
69
|
-
hubs.should_receive(:hub_label).with('my-hub').and_return('my-hub')
|
70
|
-
Zenflow.should_receive(:Log).with("Configuring my-hub")
|
71
|
-
hubs.should_receive(:config_api_base_url).with('my-hub')
|
72
|
-
hubs.should_receive(:config_user).with('my-hub')
|
73
|
-
hubs.should_receive(:config_user_agent_base).with('my-hub')
|
74
|
-
hubs.config('my-hub')
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '.config_user' do
|
79
|
-
context 'when a github user is already saved' do
|
80
|
-
before do
|
81
|
-
Zenflow::Github.should_receive(:user).and_return('user')
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'and the user decides to set a new one' do
|
85
|
-
before do
|
86
|
-
Zenflow.should_receive(:Ask).and_return('n')
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'asks for a user' do
|
90
|
-
Zenflow::Github.should_receive(:set_user)
|
91
|
-
hubs.config_user('my-hub')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'and the user decides not to set a new one' do
|
96
|
-
before do
|
97
|
-
Zenflow.should_receive(:Ask).and_return('y')
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'does not ask for a user' do
|
101
|
-
Zenflow::Github.should_not_receive(:set_user)
|
102
|
-
hubs.config_user('my-hub')
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'when a user is not already saved' do
|
108
|
-
before do
|
109
|
-
Zenflow::Github.should_receive(:user).and_return(nil)
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'asks for a user' do
|
113
|
-
Zenflow::Github.should_receive(:set_user)
|
114
|
-
hubs.config_user('my-hub')
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe '.authorize' do
|
120
|
-
before do
|
121
|
-
Zenflow::Github.should_receive(:resolve_hub).with('my-hub').and_return('my-hub')
|
122
|
-
hubs.should_receive(:hub_label).with('my-hub').and_return('my-hub')
|
123
|
-
Zenflow.should_receive(:Log).with("Authorizing my-hub")
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'when a zenflow_token is already saved' do
|
127
|
-
before do
|
128
|
-
Zenflow::Github.should_receive(:zenflow_token).and_return('super secret token')
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'and the user decides to set a new one' do
|
132
|
-
before do
|
133
|
-
Zenflow.should_receive(:Ask).and_return('y')
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'authorizes with Github' do
|
137
|
-
Zenflow::Github.should_receive(:authorize).with('my-hub')
|
138
|
-
hubs.authorize('my-hub')
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'and the user decides not to set a new one' do
|
143
|
-
before do
|
144
|
-
Zenflow.should_receive(:Ask).and_return('n')
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'does not authorize with Github' do
|
148
|
-
Zenflow::Github.should_not_receive(:authorize)
|
149
|
-
hubs.authorize('my-hub')
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context 'when a zenflow_token is not already saved' do
|
155
|
-
before do
|
156
|
-
Zenflow::Github.should_receive(:zenflow_token).and_return(nil)
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'authorizes with Github' do
|
160
|
-
Zenflow::Github.should_receive(:authorize).with('my-hub')
|
161
|
-
hubs.authorize('my-hub')
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe '.hub_label' do
|
167
|
-
context 'hub is default hub' do
|
168
|
-
context 'hub is current hub' do
|
169
|
-
before(:each){
|
170
|
-
Zenflow::Repo.should_receive(:hub).and_return(Zenflow::Github::DEFAULT_HUB)
|
171
|
-
}
|
172
|
-
|
173
|
-
it 'returns the expected label' do
|
174
|
-
expect(hubs.hub_label(Zenflow::Github::DEFAULT_HUB)).to eq("#{Zenflow::Github::DEFAULT_HUB} [default] [current]")
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context 'hub is not current hub' do
|
179
|
-
before(:each){
|
180
|
-
Zenflow::Repo.should_receive(:hub).and_return('current-hub')
|
181
|
-
}
|
182
|
-
|
183
|
-
it 'returns the expected label' do
|
184
|
-
expect(hubs.hub_label(Zenflow::Github::DEFAULT_HUB)).to eq("#{Zenflow::Github::DEFAULT_HUB} [default]")
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'hub is not default hub' do
|
190
|
-
context 'hub is current hub' do
|
191
|
-
before(:each){
|
192
|
-
Zenflow::Repo.should_receive(:hub).and_return('current-hub')
|
193
|
-
}
|
194
|
-
|
195
|
-
it 'returns the expected label' do
|
196
|
-
expect(hubs.hub_label('current-hub')).to eq('current-hub [current]')
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context 'hub is not current hub' do
|
201
|
-
before(:each){
|
202
|
-
Zenflow::Repo.should_receive(:hub).and_return('default-hub')
|
203
|
-
}
|
204
|
-
|
205
|
-
it 'returns the expected label' do
|
206
|
-
expect(hubs.hub_label('not-current-hub')).to eq('not-current-hub')
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe '.default_hub_tag' do
|
213
|
-
context 'hub is default hub' do
|
214
|
-
it 'returns the expected tag' do
|
215
|
-
expect(hubs.default_hub_tag(Zenflow::Github::DEFAULT_HUB)).to eq(' [default]')
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context 'hub is not default hub' do
|
220
|
-
it 'returns the expected tag' do
|
221
|
-
expect(hubs.default_hub_tag('not-default-hub')).to eq('')
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe '.current_hub_tag' do
|
227
|
-
before(:each){
|
228
|
-
Zenflow::Repo.should_receive(:hub).and_return('current-hub')
|
229
|
-
}
|
230
|
-
|
231
|
-
context 'hub is current hub' do
|
232
|
-
it 'returns the expected tag' do
|
233
|
-
expect(hubs.current_hub_tag('current-hub')).to eq(' [current]')
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
context 'hub is not current hub' do
|
238
|
-
it 'returns the expected tag' do
|
239
|
-
expect(hubs.current_hub_tag('not-current-hub')).to eq('')
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe '.config_key_regex' do
|
245
|
-
it 'returns the expected regex' do
|
246
|
-
expect(hubs.config_keys_regex).to eq('(?:api\\.base\\.url|github\\.user|token|user\\.agent\\.base)')
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe '.config_api_base_url' do
|
251
|
-
context 'when a github api base url is already saved' do
|
252
|
-
before do
|
253
|
-
Zenflow::Github.should_receive(:api_base_url).and_return('api-base-url')
|
254
|
-
end
|
255
|
-
|
256
|
-
context 'and the user decides to set a new one' do
|
257
|
-
before do
|
258
|
-
Zenflow.should_receive(:Ask).and_return('n')
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'asks for an api base url' do
|
262
|
-
Zenflow::Github.should_receive(:set_api_base_url)
|
263
|
-
hubs.config_api_base_url('my-hub')
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
context 'and the user decides not to set a new one' do
|
268
|
-
before do
|
269
|
-
Zenflow.should_receive(:Ask).and_return('y')
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'does not ask for an api base url' do
|
273
|
-
Zenflow::Github.should_not_receive(:set_api_base_url)
|
274
|
-
hubs.config_api_base_url('my-hub')
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
context 'when an api base url is not already saved' do
|
280
|
-
before do
|
281
|
-
Zenflow::Github.should_receive(:api_base_url).and_return(nil)
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'asks for an api base url' do
|
285
|
-
Zenflow::Github.should_receive(:set_api_base_url)
|
286
|
-
hubs.config_api_base_url('my-hub')
|
287
|
-
end
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
describe '.config_user' do
|
292
|
-
context 'when a github user is already saved' do
|
293
|
-
before do
|
294
|
-
Zenflow::Github.should_receive(:user).and_return('user')
|
295
|
-
end
|
296
|
-
|
297
|
-
context 'and the user decides to set a new one' do
|
298
|
-
before do
|
299
|
-
Zenflow.should_receive(:Ask).and_return('n')
|
300
|
-
end
|
301
|
-
|
302
|
-
it 'asks for a user' do
|
303
|
-
Zenflow::Github.should_receive(:set_user)
|
304
|
-
hubs.config_user('my-hub')
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
context 'and the user decides not to set a new one' do
|
309
|
-
before do
|
310
|
-
Zenflow.should_receive(:Ask).and_return('y')
|
311
|
-
end
|
312
|
-
|
313
|
-
it 'does not ask for a user' do
|
314
|
-
Zenflow::Github.should_not_receive(:set_user)
|
315
|
-
hubs.config_user('my-hub')
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
context 'when a user is not already saved' do
|
321
|
-
before do
|
322
|
-
Zenflow::Github.should_receive(:user).and_return(nil)
|
323
|
-
end
|
324
|
-
|
325
|
-
it 'asks for a user' do
|
326
|
-
Zenflow::Github.should_receive(:set_user)
|
327
|
-
hubs.config_user('my-hub')
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
describe '.config_user_agent_base' do
|
333
|
-
context 'when a github user agent base is already saved' do
|
334
|
-
before do
|
335
|
-
Zenflow::Github.should_receive(:user_agent_base).and_return('user-agent-base')
|
336
|
-
end
|
337
|
-
|
338
|
-
context 'and the user decides to set a new one' do
|
339
|
-
before do
|
340
|
-
Zenflow.should_receive(:Ask).and_return('n')
|
341
|
-
end
|
342
|
-
|
343
|
-
it 'asks for a user agent base' do
|
344
|
-
Zenflow::Github.should_receive(:set_user_agent_base)
|
345
|
-
hubs.config_user_agent_base('my-hub')
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
context 'and the user decides not to set a new one' do
|
350
|
-
before do
|
351
|
-
Zenflow.should_receive(:Ask).and_return('y')
|
352
|
-
end
|
353
|
-
|
354
|
-
it 'does not ask for a user agent base' do
|
355
|
-
Zenflow::Github.should_not_receive(:set_user_agent_base)
|
356
|
-
hubs.config_user_agent_base('my-hub')
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
context 'when a user agent base is not already saved' do
|
362
|
-
before do
|
363
|
-
Zenflow::Github.should_receive(:user_agent_base).and_return(nil)
|
364
|
-
end
|
365
|
-
|
366
|
-
it 'asks for a user agent base' do
|
367
|
-
Zenflow::Github.should_receive(:set_user_agent_base)
|
368
|
-
hubs.config_user_agent_base('my-hub')
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|