cf 1.1.3.rc1 → 1.1.4

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 (59) hide show
  1. data/lib/cf/cli.rb +2 -7
  2. data/lib/cf/cli/organization/delete.rb +4 -6
  3. data/lib/cf/cli/service/create.rb +23 -17
  4. data/lib/cf/cli/space/create.rb +43 -41
  5. data/lib/cf/cli/space/space.rb +49 -46
  6. data/lib/cf/version.rb +1 -1
  7. data/lib/console/console.rb +1 -1
  8. data/spec/cf/cli/app/delete_spec.rb +16 -28
  9. data/spec/cf/cli/app/instances_spec.rb +4 -5
  10. data/spec/cf/cli/app/push/create_spec.rb +362 -373
  11. data/spec/cf/cli/app/push_spec.rb +216 -215
  12. data/spec/cf/cli/app/rename_spec.rb +28 -31
  13. data/spec/cf/cli/app/scale_spec.rb +44 -41
  14. data/spec/cf/cli/app/start_spec.rb +194 -193
  15. data/spec/cf/cli/app/stats_spec.rb +55 -56
  16. data/spec/cf/cli/domain/map_spec.rb +105 -102
  17. data/spec/cf/cli/domain/unmap_spec.rb +60 -56
  18. data/spec/cf/cli/organization/delete_spec.rb +85 -84
  19. data/spec/cf/cli/organization/orgs_spec.rb +80 -83
  20. data/spec/cf/cli/organization/rename_spec.rb +90 -89
  21. data/spec/cf/cli/populators/organization_spec.rb +117 -119
  22. data/spec/cf/cli/populators/space_spec.rb +107 -108
  23. data/spec/cf/cli/populators/target_spec.rb +17 -12
  24. data/spec/cf/cli/route/delete_spec.rb +4 -4
  25. data/spec/cf/cli/route/map_spec.rb +106 -102
  26. data/spec/cf/cli/route/unmap_spec.rb +5 -5
  27. data/spec/cf/cli/service/create_spec.rb +74 -46
  28. data/spec/cf/cli/service/rename_spec.rb +29 -33
  29. data/spec/cf/cli/service/services_spec.rb +48 -48
  30. data/spec/cf/cli/space/base_spec.rb +39 -32
  31. data/spec/cf/cli/space/create_spec.rb +52 -53
  32. data/spec/cf/cli/space/delete_spec.rb +84 -85
  33. data/spec/cf/cli/space/rename_spec.rb +93 -94
  34. data/spec/cf/cli/space/space_spec.rb +60 -60
  35. data/spec/cf/cli/space/spaces_spec.rb +75 -80
  36. data/spec/cf/cli/space/switch_space_spec.rb +45 -48
  37. data/spec/cf/cli/start/info_spec.rb +4 -6
  38. data/spec/cf/cli/start/login_spec.rb +18 -20
  39. data/spec/cf/cli/start/logout_spec.rb +36 -37
  40. data/spec/cf/cli/start/target_spec.rb +86 -89
  41. data/spec/cf/cli/user/create_spec.rb +83 -84
  42. data/spec/cf/cli/user/passwd_spec.rb +87 -86
  43. data/spec/cf/cli/user/register_spec.rb +109 -108
  44. data/spec/cf/cli_spec.rb +305 -310
  45. data/spec/console/console_spec.rb +58 -58
  46. data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
  47. data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
  48. data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
  49. data/spec/features/org_spec.rb +11 -11
  50. data/spec/manifests/manifests_spec.rb +21 -21
  51. data/spec/manifests/plugin_spec.rb +34 -34
  52. data/spec/spec_helper.rb +1 -2
  53. data/spec/support/cli_helper.rb +5 -14
  54. data/spec/support/factory_girl.rb +6 -0
  55. data/spec/support/interact_helper.rb +5 -15
  56. data/spec/support/shared_examples/errors.rb +1 -1
  57. data/spec/tunnel/plugin_spec.rb +2 -2
  58. data/spec/tunnel/tunnel_spec.rb +5 -5
  59. metadata +36 -28
@@ -1,18 +1,23 @@
1
1
  require "spec_helper"
2
- require "webmock/rspec"
3
- require "cf/cli/populators/target"
4
2
 
5
- describe CF::Populators::Target do
6
- describe "#populate_and_save!" do
7
- let(:input) { stub! }
8
- let(:organization) { stub! }
3
+ module CF
4
+ module Populators
5
+ describe Target do
6
+ describe "#populate_and_save!" do
7
+ let(:input) { double(:input) }
8
+ let(:organization) { double(:organization) }
9
+ let(:space) { double(:space) }
9
10
 
10
- subject { CF::Populators::Target.new(input).populate_and_save! }
11
+ subject { Target.new(input).populate_and_save! }
11
12
 
12
- it "uses a organization then a space populator" do
13
- mock(CF::Populators::Organization).new(input) { mock!.populate_and_save! { organization } }
14
- mock(CF::Populators::Space).new(input, organization) { mock!.populate_and_save! }
15
- subject
13
+ it "uses a organization then a space populator" do
14
+ organization.should_receive(:populate_and_save!).and_return(organization)
15
+ space.should_receive(:populate_and_save!)
16
+ Organization.should_receive(:new).with(input).and_return(organization)
17
+ Space.should_receive(:new).with(input, organization).and_return(space)
18
+ subject
19
+ end
20
+ end
16
21
  end
17
22
  end
18
- end
23
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe CF::Route::Delete do
4
4
  before do
5
5
  stub_client_and_precondition
6
- stub(route).delete!
6
+ route.stub(:delete!)
7
7
  end
8
8
 
9
9
  let(:route) { fake(:route, :host => host_name, :domain => domain) }
@@ -47,7 +47,7 @@ describe CF::Route::Delete do
47
47
  end
48
48
 
49
49
  it "deletes the route" do
50
- mock(route).delete!
50
+ route.should_receive(:delete!)
51
51
  command
52
52
  end
53
53
 
@@ -63,7 +63,7 @@ describe CF::Route::Delete do
63
63
  end
64
64
 
65
65
  it "does not delete the route" do
66
- dont_allow(route).delete!
66
+ route.should_not_receive(:delete!)
67
67
  command
68
68
  end
69
69
 
@@ -78,7 +78,7 @@ describe CF::Route::Delete do
78
78
  let(:command) { cf %W[delete-route #{url} --force] }
79
79
 
80
80
  it "deletes the route" do
81
- mock(route).delete!
81
+ route.should_receive(:delete!)
82
82
  command
83
83
  end
84
84
 
@@ -1,125 +1,129 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe CF::Route::Map do
4
- before do
5
- stub_client_and_precondition
6
- end
7
-
8
- let(:client) { fake_client(:apps => apps, :routes => routes) }
9
-
10
- let(:app) { fake(:app, :space => space, :name => "app-name") }
11
- let(:space) { fake(:space, :domains => space_domains) }
12
- let(:domain) { fake(:domain) }
13
-
14
- let(:apps) { [app] }
15
- let(:routes) { [] }
16
- let(:domains) { [domain] }
3
+ module CF
4
+ module Route
5
+ describe Map do
6
+ before do
7
+ stub_client_and_precondition
8
+ end
17
9
 
18
- let(:space_domains) { domains }
10
+ let(:client) { fake_client(:apps => apps, :routes => routes) }
11
+
12
+ let(:app) { fake(:app, :space => space, :name => "app-name") }
13
+ let(:space) { fake(:space, :domains => space_domains).as_null_object }
14
+ let(:domain) { fake(:domain, :name => "domain-name-1").as_null_object }
15
+
16
+ let(:apps) { [app] }
17
+ let(:routes) { [] }
18
+ let(:domains) { [domain] }
19
+
20
+ let(:space_domains) { domains }
21
+
22
+ let(:host_name) { "some-host" }
23
+
24
+ shared_examples "mapping the route to the app" do
25
+ context "and the domain is mapped to the space" do
26
+ let(:space_domains) { [domain] }
27
+
28
+ context "and the route is mapped to the space" do
29
+ let(:routes) { [route] }
30
+ let(:route) do
31
+ fake(:route, :space => space, :host => host_name,
32
+ :domain => domain)
33
+ end
34
+
35
+ it "binds the route to the app" do
36
+ app.should_receive(:add_route).with(route)
37
+ subject
38
+ end
39
+ end
40
+
41
+ context "and the route is not mapped to the space" do
42
+ let(:new_route) { fake(:route) }
43
+
44
+ before do
45
+ client.stub(:route).and_return(new_route)
46
+ app.stub(:add_route)
47
+ new_route.stub(:create!)
48
+ end
49
+
50
+ it "indicates that it is creating a route" do
51
+ subject
52
+ expect(output).to say("Creating route #{host_name}.#{domain.name}")
53
+ end
54
+
55
+ it "creates the route in the app's space" do
56
+ new_route.should_receive(:create!)
57
+ subject
58
+ expect(new_route.host).to eq host_name
59
+ expect(new_route.domain).to eq domain
60
+ expect(new_route.space).to eq space
61
+ end
62
+
63
+ it "indicates that it is binding the route" do
64
+ subject
65
+ expect(output).to say("Binding #{host_name}.#{domain.name} to #{app.name}")
66
+ end
67
+
68
+ it "binds the route to the app" do
69
+ app.should_receive(:add_route).with(new_route)
70
+ subject
71
+ end
72
+ end
73
+ end
74
+ end
19
75
 
20
- let(:host_name) { "some-host" }
76
+ context "when an app is specified" do
77
+ subject { cf(%W[map #{app.name} #{host_name} #{domain.name}]) }
21
78
 
22
- shared_examples "mapping the route to the app" do
23
- context 'and the domain is mapped to the space' do
24
- let(:space_domains) { [domain] }
79
+ context "and the domain is not already mapped to the space" do
80
+ let(:space_domains) { [] }
25
81
 
26
- context 'and the route is mapped to the space' do
27
- let(:routes) { [route] }
28
- let(:route) do
29
- fake(:route, :space => space, :host => host_name,
30
- :domain => domain)
82
+ it "indicates that the domain is invalid" do
83
+ subject
84
+ expect(error_output).to say("Unknown domain")
85
+ end
31
86
  end
32
87
 
33
- it 'binds the route to the app' do
34
- mock(app).add_route(route)
35
- subject
36
- end
88
+ include_examples "mapping the route to the app"
37
89
  end
38
90
 
39
- context 'and the route is not mapped to the space' do
40
- let(:new_route) { fake(:route) }
41
-
42
- before do
43
- stub(client).route { new_route }
44
- stub(app).add_route
45
- stub(new_route).create!
46
- end
47
-
48
- it 'indicates that it is creating a route' do
49
- subject
50
- expect(output).to say("Creating route #{host_name}.#{domain.name}")
51
- end
91
+ context "when an app is not specified" do
92
+ let(:space_domains) { [domain] }
93
+ let(:new_route) { double(:route).as_null_object }
52
94
 
53
- it "creates the route in the app's space" do
54
- mock(new_route).create!
55
- subject
56
- expect(new_route.host).to eq host_name
57
- expect(new_route.domain).to eq domain
58
- expect(new_route.space).to eq space
59
- end
95
+ subject { cf %W[map --host #{host_name} #{domain.name}] }
60
96
 
61
- it 'indicates that it is binding the route' do
62
- subject
63
- expect(output).to say("Binding #{host_name}.#{domain.name} to #{app.name}")
64
- end
97
+ before { stub_ask("Which application?", anything) { app } }
65
98
 
66
- it 'binds the route to the app' do
67
- mock(app).add_route(new_route)
99
+ it "asks for an app" do
100
+ client.stub(:route).and_return(new_route)
101
+ app.stub(:add_route)
102
+ new_route.stub(:create!)
103
+ mock_ask("Which application?", anything) { app }
68
104
  subject
69
105
  end
70
- end
71
- end
72
- end
73
-
74
- context 'when an app is specified' do
75
- subject { cf %W[map #{app.name} #{host_name} #{domain.name}] }
76
106
 
77
- context 'and the domain is not already mapped to the space' do
78
- let(:space_domains) { [] }
79
-
80
- it 'indicates that the domain is invalid' do
81
- subject
82
- expect(error_output).to say("Unknown domain")
107
+ include_examples "mapping the route to the app"
83
108
  end
84
- end
85
-
86
- include_examples "mapping the route to the app"
87
- end
88
-
89
- context 'when an app is not specified' do
90
- let(:space_domains) { [domain] }
91
- let(:new_route) { fake(:route) }
92
-
93
- subject { cf %W[map --host #{host_name} #{domain.name}] }
94
-
95
- before { stub_ask("Which application?", anything) { app } }
96
109
 
97
- it 'asks for an app' do
98
- stub(client).route { new_route }
99
- stub(app).add_route
100
- stub(new_route).create!
101
- mock_ask("Which application?", anything) { app }
102
- subject
103
- end
104
-
105
- include_examples "mapping the route to the app"
106
- end
110
+ context "when a host is not specified" do
111
+ let(:new_route) { build(:route) }
107
112
 
108
- context "when a host is not specified" do
109
- let(:new_route) { fake(:route) }
113
+ subject { cf %W[map #{app.name} #{domain.name}] }
110
114
 
111
- subject { cf %W[map #{app.name} #{domain.name}] }
112
-
113
- before do
114
- stub(client).route { new_route }
115
- stub(app).add_route
116
- stub(new_route).create!
117
- end
115
+ before do
116
+ client.stub(:route).and_return(new_route)
117
+ app.stub(:add_route)
118
+ new_route.stub(:create!)
119
+ end
118
120
 
119
- it "creates a route with an empty string as its host" do
120
- mock(new_route).create!
121
- subject
122
- expect(new_route.host).to eq ""
121
+ it "creates a route with an empty string as its host" do
122
+ new_route.should_receive(:create!)
123
+ subject
124
+ expect(new_route.host).to eq ""
125
+ end
126
+ end
123
127
  end
124
128
  end
125
129
  end
@@ -42,7 +42,7 @@ describe CF::Route::Unmap do
42
42
  let(:route) { fake(:route, :space => space, :host => host_name, :domain => domain) }
43
43
 
44
44
  it "unmaps the url from the app" do
45
- mock(app).remove_route(route)
45
+ app.should_receive(:remove_route).with(route)
46
46
  subject
47
47
  end
48
48
  end
@@ -68,14 +68,14 @@ describe CF::Route::Unmap do
68
68
  route
69
69
  end
70
70
 
71
- stub(app).remove_route(anything)
71
+ app.stub(:remove_route)
72
72
 
73
73
  subject
74
74
  end
75
75
 
76
76
  it "unmaps the selected url from the app" do
77
77
  stub_ask("Which URL?", anything) { route }
78
- mock(app).remove_route(route)
78
+ app.should_receive(:remove_route).with(route)
79
79
  subject
80
80
  end
81
81
  end
@@ -88,8 +88,8 @@ describe CF::Route::Unmap do
88
88
  subject { cf %W[unmap --all --app #{app.name}] }
89
89
 
90
90
  it "unmaps all routes from the given app" do
91
- mock(app).remove_route(route)
92
- mock(app).remove_route(other_route)
91
+ app.should_receive(:remove_route).with(route)
92
+ app.should_receive(:remove_route).with(other_route)
93
93
  subject
94
94
  end
95
95
  end
@@ -1,65 +1,93 @@
1
1
  require "spec_helper"
2
2
 
3
- module CF::Service
4
- describe Create do
5
- before do
6
- any_instance_of(CF::CLI) do |cli|
7
- stub(cli).client { client }
8
- end
9
- end
3
+ module CF
4
+ module Service
5
+ describe Create do
6
+ describe "metadata" do
7
+ let(:command) { Mothership.commands[:create_service] }
10
8
 
11
- describe "metadata" do
12
- let(:command) { Mothership.commands[:create_service] }
9
+ describe "command" do
10
+ subject { command }
11
+ its(:description) { should eq "Create a service" }
12
+ it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
13
+ end
13
14
 
14
- describe "command" do
15
- subject { command }
16
- its(:description) { should eq "Create a service" }
17
- it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
15
+ include_examples "inputs must have descriptions"
16
+
17
+ describe "arguments" do
18
+ subject { command.arguments }
19
+ it "has the correct argument order" do
20
+ should eq([{:type => :optional, :value => nil, :name => :offering}, {:type => :optional, :value => nil, :name => :name}])
21
+ end
22
+ end
18
23
  end
19
24
 
20
- include_examples "inputs must have descriptions"
25
+ context "when there are services" do
26
+ let(:service_plan) { fake(:service_plan, :name => "F20") }
27
+ let(:selected_service) { fake(:service, :label => "Foo Service", :service_plans => [service_plan]) }
28
+ let(:command) { Mothership.new.invoke(:create_service, params, {}) }
29
+ let(:client) { fake_client(:services => services) }
30
+ let(:params) { {} }
21
31
 
22
- describe "arguments" do
23
- subject { command.arguments }
24
- it "has the correct argument order" do
25
- should eq([{:type => :optional, :value => nil, :name => :offering}, {:type => :optional, :value => nil, :name => :name}])
32
+ before do
33
+ CF::CLI.any_instance.stub(:client).and_return(client)
26
34
  end
27
- end
28
- end
29
35
 
30
- context "when there are services" do
31
- let(:service_plan) { fake(:service_plan, :name => "F20") }
32
- let(:selected_service) { fake(:service, :label => "Foo Service", :service_plans => [service_plan]) }
33
- let(:command) { Mothership.new.invoke(:create_service, {}, {}) }
34
- let(:client) { fake_client(:services => services) }
35
-
36
- describe "when there is at least one service" do
37
- let(:services) { [selected_service] }
38
-
39
- it "asks for the service" do
40
- mock_ask("What kind?", anything) { selected_service }
41
- mock_ask("Name?", anything) { selected_service.label }
42
- mock_ask("Which plan?", anything) { service_plan }
43
- any_instance_of(CFoundry::V2::ServiceInstance) do |service_instance|
44
- stub(service_instance).create!
36
+ describe "when there is at least one service" do
37
+ let(:services) { [selected_service] }
38
+
39
+ it "asks for the service" do
40
+ mock_ask("What kind?", anything) { selected_service }
41
+ mock_ask("Name?", anything) { selected_service.label }
42
+ mock_ask("Which plan?", anything) { service_plan }
43
+ CFoundry::V2::ServiceInstance.any_instance.stub(:create!)
44
+
45
+ capture_output { command }
45
46
  end
47
+ end
48
+
49
+ describe "when there are more than one services" do
50
+ let(:services) { [selected_service, fake(:service), fake(:service)] }
46
51
 
47
- capture_output { command }
52
+ it "asks for the service" do
53
+ mock_ask("What kind?", anything) { selected_service }
54
+ mock_ask("Name?", anything) { selected_service.label }
55
+ mock_ask("Which plan?", anything) { service_plan }
56
+ CFoundry::V2::ServiceInstance.any_instance.stub(:create!)
57
+
58
+ capture_output { command }
59
+ end
48
60
  end
49
- end
50
61
 
51
- describe "when there are more than one services" do
52
- let(:services) { [selected_service, fake(:service), fake(:service)] }
62
+ describe "when the service plan is specified by an object, not a string" do
63
+ let(:services) { [selected_service] }
64
+ let(:params) { {
65
+ :name => "my-service-name",
66
+ :offering => selected_service,
67
+ :plan => service_plan,
68
+ } }
53
69
 
54
- it "asks for the service" do
55
- mock_ask("What kind?", anything) { selected_service }
56
- mock_ask("Name?", anything) { selected_service.label }
57
- mock_ask("Which plan?", anything) { service_plan }
58
- any_instance_of(CFoundry::V2::ServiceInstance) do |service_instance|
59
- stub(service_instance).create!
70
+ it "creates the specified service" do
71
+ CFoundry::V2::ServiceInstance.any_instance.should_receive(:service_plan=).with(service_plan)
72
+ CFoundry::V2::ServiceInstance.any_instance.should_receive(:create!)
73
+ capture_output { command }
60
74
  end
75
+ end
61
76
 
62
- capture_output { command }
77
+ describe "when entering command line options" do
78
+ let(:service_plan) { fake(:service_plan, :name => "f20") }
79
+ let(:params) { {
80
+ :name => "my-service-name",
81
+ :offering => selected_service,
82
+ :plan => "F20",
83
+ } }
84
+ let(:services) { [selected_service] }
85
+
86
+ it "uses case insensitive match" do
87
+ CFoundry::V2::ServiceInstance.any_instance.should_receive(:service_plan=).with(service_plan)
88
+ CFoundry::V2::ServiceInstance.any_instance.should_receive(:create!)
89
+ capture_output { command }
90
+ end
63
91
  end
64
92
  end
65
93
  end