cf 1.1.4 → 2.0.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.
Files changed (58) hide show
  1. data/lib/cf/cli/start/login.rb +3 -0
  2. data/lib/cf/version.rb +1 -1
  3. data/spec/cf/cli/app/base_spec.rb +2 -2
  4. data/spec/cf/cli/app/delete_spec.rb +150 -129
  5. data/spec/cf/cli/app/instances_spec.rb +56 -51
  6. data/spec/cf/cli/app/push/create_spec.rb +72 -70
  7. data/spec/cf/cli/app/push_spec.rb +46 -43
  8. data/spec/cf/cli/app/rename_spec.rb +13 -6
  9. data/spec/cf/cli/app/scale_spec.rb +9 -4
  10. data/spec/cf/cli/app/start_spec.rb +28 -23
  11. data/spec/cf/cli/app/stats_spec.rb +9 -10
  12. data/spec/cf/cli/domain/map_spec.rb +13 -10
  13. data/spec/cf/cli/domain/unmap_spec.rb +11 -11
  14. data/spec/cf/cli/organization/delete_spec.rb +10 -4
  15. data/spec/cf/cli/organization/orgs_spec.rb +15 -4
  16. data/spec/cf/cli/organization/rename_spec.rb +7 -5
  17. data/spec/cf/cli/populators/organization_spec.rb +40 -29
  18. data/spec/cf/cli/populators/space_spec.rb +51 -40
  19. data/spec/cf/cli/populators/target_spec.rb +4 -2
  20. data/spec/cf/cli/route/delete_spec.rb +6 -4
  21. data/spec/cf/cli/route/map_spec.rb +54 -35
  22. data/spec/cf/cli/route/unmap_spec.rb +21 -15
  23. data/spec/cf/cli/service/create_spec.rb +17 -12
  24. data/spec/cf/cli/service/rename_spec.rb +8 -6
  25. data/spec/cf/cli/service/services_spec.rb +15 -8
  26. data/spec/cf/cli/space/create_spec.rb +5 -9
  27. data/spec/cf/cli/space/delete_spec.rb +9 -8
  28. data/spec/cf/cli/space/rename_spec.rb +15 -8
  29. data/spec/cf/cli/space/space_spec.rb +10 -10
  30. data/spec/cf/cli/space/spaces_spec.rb +11 -5
  31. data/spec/cf/cli/space/switch_space_spec.rb +7 -7
  32. data/spec/cf/cli/start/info_spec.rb +3 -1
  33. data/spec/cf/cli/start/login_spec.rb +1 -1
  34. data/spec/cf/cli/start/logout_spec.rb +1 -1
  35. data/spec/cf/cli/start/target_spec.rb +7 -6
  36. data/spec/cf/cli/user/create_spec.rb +3 -4
  37. data/spec/cf/cli/user/passwd_spec.rb +2 -4
  38. data/spec/cf/cli/user/register_spec.rb +4 -4
  39. data/spec/cf/cli_spec.rb +1 -3
  40. data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
  41. data/spec/factories/cfoundry/v2/clients_factory.rb +4 -0
  42. data/spec/factories/cfoundry/v2/{domain_factory.rb → domains_factory.rb} +0 -0
  43. data/spec/factories/cfoundry/v2/organizations_factory.rb +12 -0
  44. data/spec/factories/cfoundry/v2/{route_factory.rb → routes_factory.rb} +0 -0
  45. data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
  46. data/spec/factories/cfoundry/v2/service_instances_factory.rb +12 -0
  47. data/spec/factories/cfoundry/v2/service_plans_factory.rb +13 -0
  48. data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
  49. data/spec/factories/cfoundry/v2/spaces_factory.rb +12 -0
  50. data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
  51. data/spec/factories/cfoundry/v2/{user_factory.rb → users_factory.rb} +0 -0
  52. data/spec/features/push_flow_spec.rb +8 -8
  53. data/spec/manifests/manifests_spec.rb +34 -51
  54. data/spec/manifests/plugin_spec.rb +17 -6
  55. data/spec/spec_helper.rb +0 -1
  56. data/spec/support/interact_helper.rb +1 -1
  57. data/spec/tunnel/tunnel_spec.rb +5 -5
  58. metadata +37 -13
@@ -35,8 +35,11 @@ module CF::Start
35
35
  authenticated = false
36
36
  failed = false
37
37
  remaining_attempts = 3
38
+
38
39
  until authenticated || remaining_attempts <= 0
39
40
  remaining_attempts -= 1
41
+ failed = false
42
+
40
43
  unless force?
41
44
  ask_prompts(credentials, prompts)
42
45
  end
data/lib/cf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "1.1.4".freeze
2
+ VERSION = "2.0.0".freeze
3
3
  end
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
  require "cf/cli/app/base"
3
3
 
4
4
  describe CF::App::Base do
5
- describe '#human_size' do
5
+ describe "#human_size" do
6
6
  let(:base) { CF::App::Base.new }
7
7
 
8
8
  it { base.human_size(1_023).should == "1023.0B" }
@@ -1,174 +1,195 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
  require "cf/cli/app/delete"
3
3
 
4
- describe CF::App::Delete do
5
- let(:global) { { :color => false, :quiet => true } }
6
- let(:inputs) { {} }
7
- let(:given) { {} }
8
- let(:client) { fake_client }
9
- let(:app) {}
10
- let(:new_name) { "some-new-name" }
11
-
12
- before do
13
- CF::CLI.any_instance.stub(:client).and_return(client)
14
- CF::CLI.any_instance.stub(:precondition).and_return(nil)
15
- end
4
+ module CF
5
+ module App
6
+ describe Delete do
7
+ let(:global) { {:color => false, :quiet => true} }
8
+ let(:inputs) { {} }
9
+ let(:given) { {} }
10
+ let(:client) { build(:client) }
11
+
12
+ before do
13
+ CF::CLI.any_instance.stub(:client).and_return(client)
14
+ CF::CLI.any_instance.stub(:precondition).and_return(nil)
15
+ end
16
16
 
17
- subject { Mothership.new.invoke(:delete, inputs, given, global) }
17
+ subject { Mothership.new.invoke(:delete, inputs, given, global) }
18
18
 
19
- describe 'metadata' do
20
- let(:command) { Mothership.commands[:delete] }
19
+ describe "metadata" do
20
+ let(:command) { Mothership.commands[:delete] }
21
21
 
22
- describe 'command' do
23
- subject { command }
24
- its(:description) { should eq "Delete an application" }
25
- it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
26
- end
22
+ describe "command" do
23
+ subject { command }
24
+ its(:description) { should eq "Delete an application" }
25
+ it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
26
+ end
27
27
 
28
- include_examples 'inputs must have descriptions'
28
+ include_examples "inputs must have descriptions"
29
29
 
30
- describe 'arguments' do
31
- subject { command.arguments }
32
- it 'has the correct argument order' do
33
- should eq([{ :type => :splat, :value => nil, :name => :apps }])
30
+ describe "arguments" do
31
+ subject { command.arguments }
32
+ it "has the correct argument order" do
33
+ should eq([{:type => :splat, :value => nil, :name => :apps}])
34
+ end
35
+ end
34
36
  end
35
- end
36
- end
37
37
 
38
- context 'when there are no apps' do
39
- context 'and an app is given' do
40
- let(:given) { { :app => "some-app" } }
41
- it { expect { subject }.to raise_error(CF::UserError, "Unknown app 'some-app'.") }
42
- end
38
+ context "when there are no apps" do
39
+ before do
40
+ client.stub(:apps).and_return([])
41
+ end
43
42
 
44
- context 'and an app is not given' do
45
- it { expect { subject }.to raise_error(CF::UserError, "No applications.") }
46
- end
47
- end
43
+ context "and an app is given" do
44
+ let(:given) { {:app => "some-app"} }
48
45
 
49
- context 'when there are apps' do
50
- let(:client) { fake_client(:apps => apps) }
51
- let(:apps) { [basic_app, app_with_orphans, app_without_orphans] }
52
- let(:service_1) { fake :service_instance }
53
- let(:service_2) { fake :service_instance }
54
- let(:basic_app) { fake(:app, :name => "basic_app") }
55
- let(:app_with_orphans) {
56
- fake :app,
57
- :name => "app_with_orphans",
58
- :service_bindings => [
59
- fake(:service_binding, :service_instance => service_1),
60
- fake(:service_binding, :service_instance => service_2)
61
- ]
62
- }
63
- let(:app_without_orphans) {
64
- fake :app,
65
- :name => "app_without_orphans",
66
- :service_bindings => [
67
- fake(:service_binding, :service_instance => service_1)
68
- ]
69
- }
70
-
71
- context 'and no app is given' do
72
- it 'asks for the app' do
73
- mock_ask("Delete which application?", anything) { basic_app }
74
- stub_ask { true }
75
- basic_app.stub(:delete!)
76
- subject
46
+ it { expect { subject }.to raise_error(CF::UserError, "Unknown app 'some-app'.") }
47
+ end
48
+
49
+ context "and an app is not given" do
50
+ it { expect { subject }.to raise_error(CF::UserError, "No applications.") }
51
+ end
77
52
  end
78
- end
79
53
 
80
- context 'and a basic app is given' do
81
- let(:deleted_app) { basic_app }
82
- let(:given) { { :app => deleted_app.name } }
54
+ context "when there are apps" do
55
+ let(:service_1) { build(:service_instance, :name => "service-instance-name-1") }
56
+ let(:service_2) { build(:service_instance, :name => "service-instance-name-2") }
57
+
58
+ let(:service_binding_1) { build(:service_binding, :service_instance => service_1) }
59
+ let(:service_binding_2) { build(:service_binding, :service_instance => service_2) }
60
+
61
+ let(:basic_app) { build(:app, :name => "basic-app-name", :guid => "basic-app-guid-1") }
62
+
63
+ let(:app_with_orphans) {
64
+ build(:app,
65
+ :name => "app_with_orphans",
66
+ :service_bindings => [service_binding_1, service_binding_2]
67
+ )
68
+ }
69
+ let(:app_without_orphans) {
70
+ build(:app,
71
+ :name => "app_without_orphans",
72
+ :service_bindings => [service_binding_1]
73
+ )
74
+ }
75
+
76
+ let(:apps) { [basic_app, app_with_orphans, app_without_orphans] }
77
+
78
+ before do
79
+ basic_app.stub(:service_bindings).and_return([])
80
+ client.stub(:apps).and_return(apps)
81
+ end
82
+
83
+ context "and no app is given" do
84
+ it "asks for the app" do
85
+ basic_app.stub(:delete!)
86
+
87
+ should_ask("Delete which application?", anything) { basic_app }
88
+ stub_ask { true }
83
89
 
84
- context 'and it asks for confirmation' do
85
- context 'and the user answers no' do
86
- it 'does not delete the application' do
87
- mock_ask("Really delete #{deleted_app.name}?", anything) { false }
88
- deleted_app.should_not_receive(:delete!)
89
90
  subject
90
91
  end
91
92
  end
92
93
 
93
- context 'and the user answers yes' do
94
- it 'deletes the application' do
95
- mock_ask("Really delete #{deleted_app.name}?", anything) { true }
96
- deleted_app.should_receive(:delete!)
97
- subject
94
+ context "and a basic app is given" do
95
+ let(:deleted_app) { basic_app }
96
+ let(:given) { {:app => deleted_app.name} }
97
+
98
+ context "and it asks for confirmation" do
99
+ context "and the user answers no" do
100
+ it "does not delete the application" do
101
+ should_ask("Really delete #{deleted_app.name}?", anything) { false }
102
+ deleted_app.should_not_receive(:delete!)
103
+ subject
104
+ end
105
+ end
106
+
107
+ context "and the user answers yes" do
108
+ it "deletes the application" do
109
+ should_ask("Really delete #{deleted_app.name}?", anything) { true }
110
+ deleted_app.should_receive(:delete!)
111
+ subject
112
+ end
113
+ end
98
114
  end
99
- end
100
- end
101
115
 
102
- context 'and --force is given' do
103
- let(:global) { { :force => true, :color => false, :quiet => true } }
116
+ context "and --force is given" do
117
+ let(:global) { {:force => true, :color => false, :quiet => true} }
104
118
 
105
- it 'deletes the application without asking to confirm' do
106
- dont_allow_ask
107
- deleted_app.should_receive(:delete!)
108
- subject
119
+ it "deletes the application without asking to confirm" do
120
+ dont_allow_ask
121
+ deleted_app.should_receive(:delete!)
122
+ subject
123
+ end
124
+ end
109
125
  end
110
- end
111
- end
112
126
 
113
- context 'and an app with orphaned services is given' do
114
- let(:deleted_app) { app_with_orphans }
115
- let(:inputs) { { :app => deleted_app } }
127
+ context "and an app with orphaned services is given" do
128
+ let(:deleted_app) { app_with_orphans }
129
+ let(:inputs) { {:app => deleted_app} }
116
130
 
117
- context 'and it asks for confirmation' do
118
- context 'and the user answers yes' do
119
- it 'asks to delete orphaned services' do
120
- stub_ask("Really delete #{deleted_app.name}?", anything) { true }
121
- deleted_app.stub(:delete!)
131
+ before do
132
+ app_with_orphans.stub(:service_bindings).and_return([service_binding_1, service_binding_2])
133
+ app_with_orphans.stub(:service_instances).and_return([service_1, service_2])
134
+ end
122
135
 
123
- service_2.stub(:invalidate!)
136
+ context "and it asks for confirmation" do
137
+ context "and the user answers yes" do
138
+ it "asks to delete orphaned services" do
139
+ stub_ask("Really delete #{deleted_app.name}?", anything) { true }
140
+ deleted_app.stub(:delete!)
124
141
 
125
- mock_ask("Delete orphaned service #{service_2.name}?", anything) { true }
142
+ service_2.stub(:invalidate!)
126
143
 
127
- CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
144
+ should_ask("Delete orphaned service #{service_2.name}?", anything) { true }
128
145
 
129
- subject
130
- end
131
- end
146
+ CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
132
147
 
133
- context 'and the user answers no' do
134
- it 'does not ask to delete orphaned serivces, or delete them' do
135
- stub_ask("Really delete #{deleted_app.name}?", anything) { false }
136
- deleted_app.should_not_receive(:delete!)
148
+ subject
149
+ end
150
+ end
137
151
 
138
- service_2.stub(:invalidate!)
152
+ context "and the user answers no" do
153
+ it "does not ask to delete orphaned serivces, or delete them" do
154
+ stub_ask("Really delete #{deleted_app.name}?", anything) { false }
155
+ deleted_app.should_not_receive(:delete!)
139
156
 
140
- dont_allow_ask("Delete orphaned service #{service_2.name}?")
157
+ service_2.stub(:invalidate!)
141
158
 
142
- CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
159
+ dont_allow_ask("Delete orphaned service #{service_2.name}?")
143
160
 
144
- subject
161
+ CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
162
+
163
+ subject
164
+ end
165
+ end
145
166
  end
146
- end
147
- end
148
167
 
149
- context 'and --force is given' do
150
- let(:global) { { :force => true, :color => false, :quiet => true } }
168
+ context "and --force is given" do
169
+ let(:global) { {:force => true, :color => false, :quiet => true} }
151
170
 
152
- it 'does not delete orphaned services' do
153
- dont_allow_ask
154
- deleted_app.stub(:delete!)
171
+ it "does not delete orphaned services" do
172
+ dont_allow_ask
173
+ deleted_app.stub(:delete!)
155
174
 
156
- CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
175
+ CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
157
176
 
158
- subject
159
- end
160
- end
177
+ subject
178
+ end
179
+ end
161
180
 
162
- context 'and --delete-orphaned is given' do
163
- let(:inputs) { { :app => deleted_app, :delete_orphaned => true } }
181
+ context "and --delete-orphaned is given" do
182
+ let(:inputs) { {:app => deleted_app, :delete_orphaned => true} }
164
183
 
165
- it 'deletes the orphaned services' do
166
- stub_ask("Really delete #{deleted_app.name}?", anything) { true }
167
- deleted_app.stub(:delete!)
184
+ it "deletes the orphaned services" do
185
+ stub_ask("Really delete #{deleted_app.name}?", anything) { true }
186
+ deleted_app.stub(:delete!)
168
187
 
169
- CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
188
+ CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
170
189
 
171
- subject
190
+ subject
191
+ end
192
+ end
172
193
  end
173
194
  end
174
195
  end
@@ -1,64 +1,69 @@
1
- require 'spec_helper'
2
- require 'stringio'
1
+ require "spec_helper"
2
+ require "stringio"
3
3
 
4
- describe CF::App::Stats do
5
- let(:global) { { :color => false } }
6
- let(:inputs) { { :app => apps[0] } }
7
- let(:given) { {} }
8
- let(:client) { fake_client(:apps => apps) }
9
- let(:apps) { [fake(:app, :name => "basic_app")] }
10
- let(:time) { Time.local(2012, 11, 1, 2, 30) }
4
+ module CF
5
+ module App
6
+ describe Stats do
7
+ let(:global) { {:color => false} }
8
+ let(:inputs) { {:app => apps[0]} }
9
+ let(:given) { {} }
10
+ let(:client) { build(:client) }
11
+ let(:apps) { [build(:app, :client => client, :name => "basic-app-name")] }
12
+ let(:time) { Time.local(2012, 11, 1, 2, 30) }
11
13
 
12
- before do
13
- CF::CLI.any_instance.stub(:client).and_return(client)
14
- CF::CLI.any_instance.stub(:precondition).and_return(nil)
14
+ before do
15
+ client.stub(:apps).and_return(apps)
16
+ CF::CLI.any_instance.stub(:client).and_return(client)
17
+ CF::CLI.any_instance.stub(:precondition).and_return(nil)
15
18
 
16
- client.base.stub(:instances).with(anything) do
17
- {
18
- "12" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
19
- "1" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
20
- "2" => {:state => "STARTED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"}
21
- }
22
- end
23
- end
19
+ client.base.stub(:instances).with(anything) do
20
+ {
21
+ "12" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
22
+ "1" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
23
+ "2" => {:state => "STARTED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"}
24
+ }
25
+ end
26
+ end
24
27
 
25
- subject do
26
- capture_output do
27
- Mothership.new.invoke(:instances, inputs, given, global)
28
- end
29
- end
28
+ subject do
29
+ capture_output do
30
+ Mothership.new.invoke(:instances, inputs, given, global)
31
+ end
32
+ end
30
33
 
31
- describe 'metadata' do
32
- let(:command) { Mothership.commands[:instances] }
34
+ describe "metadata" do
35
+ let(:command) { Mothership.commands[:instances] }
33
36
 
34
- describe 'command' do
35
- subject { command }
36
- its(:description) { should eq "List an app's instances" }
37
- it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
38
- end
37
+ describe "command" do
38
+ subject { command }
39
+ its(:description) { should eq "List an app's instances" }
40
+ it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
41
+ end
39
42
 
40
- include_examples 'inputs must have descriptions'
43
+ include_examples "inputs must have descriptions"
41
44
 
42
- describe 'arguments' do
43
- subject { command.arguments }
44
- it 'has no arguments' do
45
- should eq([{:type=>:splat, :value=>nil, :name=>:apps}])
45
+ describe "arguments" do
46
+ subject { command.arguments }
47
+ it "has no arguments" do
48
+ should eq([{:type => :splat, :value => nil, :name => :apps}])
49
+ end
50
+ end
46
51
  end
47
- end
48
- end
49
52
 
50
- it 'prints out the instances in the correct order' do
51
- subject
52
- expect(output).to say("instance #1")
53
- expect(output).to say("instance #2")
54
- expect(output).to say("instance #12")
55
- end
53
+ it "prints out the instances in the correct order" do
54
+ subject
55
+ expect(output).to say("instance #1")
56
+ expect(output).to say("instance #2")
57
+ expect(output).to say("instance #12")
58
+ end
56
59
 
57
- it 'prints out one of the instances correctly' do
58
- subject
59
- expect(output).to say("instance #2: started")
60
- expect(output).to say(" started: #{time.strftime("%F %r")}")
61
- expect(output).to say(" debugger: port bar at foo")
62
- expect(output).to say(" console: port qux at baz")
60
+ it "prints out one of the instances correctly" do
61
+ subject
62
+ expect(output).to say("instance #2: started")
63
+ expect(output).to say(" started: #{time.strftime("%F %r")}")
64
+ expect(output).to say(" debugger: port bar at foo")
65
+ expect(output).to say(" console: port qux at baz")
66
+ end
67
+ end
63
68
  end
64
69
  end