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.
- data/lib/cf/cli.rb +2 -7
- data/lib/cf/cli/organization/delete.rb +4 -6
- data/lib/cf/cli/service/create.rb +23 -17
- data/lib/cf/cli/space/create.rb +43 -41
- data/lib/cf/cli/space/space.rb +49 -46
- data/lib/cf/version.rb +1 -1
- data/lib/console/console.rb +1 -1
- data/spec/cf/cli/app/delete_spec.rb +16 -28
- data/spec/cf/cli/app/instances_spec.rb +4 -5
- data/spec/cf/cli/app/push/create_spec.rb +362 -373
- data/spec/cf/cli/app/push_spec.rb +216 -215
- data/spec/cf/cli/app/rename_spec.rb +28 -31
- data/spec/cf/cli/app/scale_spec.rb +44 -41
- data/spec/cf/cli/app/start_spec.rb +194 -193
- data/spec/cf/cli/app/stats_spec.rb +55 -56
- data/spec/cf/cli/domain/map_spec.rb +105 -102
- data/spec/cf/cli/domain/unmap_spec.rb +60 -56
- data/spec/cf/cli/organization/delete_spec.rb +85 -84
- data/spec/cf/cli/organization/orgs_spec.rb +80 -83
- data/spec/cf/cli/organization/rename_spec.rb +90 -89
- data/spec/cf/cli/populators/organization_spec.rb +117 -119
- data/spec/cf/cli/populators/space_spec.rb +107 -108
- data/spec/cf/cli/populators/target_spec.rb +17 -12
- data/spec/cf/cli/route/delete_spec.rb +4 -4
- data/spec/cf/cli/route/map_spec.rb +106 -102
- data/spec/cf/cli/route/unmap_spec.rb +5 -5
- data/spec/cf/cli/service/create_spec.rb +74 -46
- data/spec/cf/cli/service/rename_spec.rb +29 -33
- data/spec/cf/cli/service/services_spec.rb +48 -48
- data/spec/cf/cli/space/base_spec.rb +39 -32
- data/spec/cf/cli/space/create_spec.rb +52 -53
- data/spec/cf/cli/space/delete_spec.rb +84 -85
- data/spec/cf/cli/space/rename_spec.rb +93 -94
- data/spec/cf/cli/space/space_spec.rb +60 -60
- data/spec/cf/cli/space/spaces_spec.rb +75 -80
- data/spec/cf/cli/space/switch_space_spec.rb +45 -48
- data/spec/cf/cli/start/info_spec.rb +4 -6
- data/spec/cf/cli/start/login_spec.rb +18 -20
- data/spec/cf/cli/start/logout_spec.rb +36 -37
- data/spec/cf/cli/start/target_spec.rb +86 -89
- data/spec/cf/cli/user/create_spec.rb +83 -84
- data/spec/cf/cli/user/passwd_spec.rb +87 -86
- data/spec/cf/cli/user/register_spec.rb +109 -108
- data/spec/cf/cli_spec.rb +305 -310
- data/spec/console/console_spec.rb +58 -58
- data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
- data/spec/features/org_spec.rb +11 -11
- data/spec/manifests/manifests_spec.rb +21 -21
- data/spec/manifests/plugin_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -2
- data/spec/support/cli_helper.rb +5 -14
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/interact_helper.rb +5 -15
- data/spec/support/shared_examples/errors.rb +1 -1
- data/spec/tunnel/plugin_spec.rb +2 -2
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +36 -28
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require "cf/cli/service/rename"
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
describe CF::Service::Rename do
|
5
4
|
let(:global) { { :color => false, :quiet => true } }
|
@@ -9,29 +8,26 @@ describe CF::Service::Rename do
|
|
9
8
|
let(:service) {}
|
10
9
|
let(:new_name) { "some-new-name" }
|
11
10
|
|
11
|
+
subject { Mothership.new.invoke(:rename_service, inputs, given, global) }
|
12
|
+
|
12
13
|
before do
|
13
|
-
|
14
|
-
stub(cli).client { client }
|
15
|
-
stub(cli).precondition { nil }
|
16
|
-
end
|
14
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
17
15
|
end
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
describe 'metadata' do
|
17
|
+
describe "metadata" do
|
22
18
|
let(:command) { Mothership.commands[:rename_service] }
|
23
19
|
|
24
|
-
describe
|
20
|
+
describe "command" do
|
25
21
|
subject { command }
|
26
22
|
its(:description) { should eq "Rename a service" }
|
27
23
|
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
28
24
|
end
|
29
25
|
|
30
|
-
include_examples
|
26
|
+
include_examples "inputs must have descriptions"
|
31
27
|
|
32
|
-
describe
|
28
|
+
describe "arguments" do
|
33
29
|
subject { command.arguments }
|
34
|
-
it
|
30
|
+
it "has the correct argument order" do
|
35
31
|
should eq([
|
36
32
|
{ :type => :optional, :value => nil, :name => :service },
|
37
33
|
{ :type => :optional, :value => nil, :name => :name }
|
@@ -40,62 +36,62 @@ describe CF::Service::Rename do
|
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
43
|
-
context
|
44
|
-
context
|
39
|
+
context "when there are no services" do
|
40
|
+
context "and a service is given" do
|
45
41
|
let(:given) { { :service => "some-service" } }
|
46
42
|
it { expect { subject }.to raise_error(CF::UserError, "Unknown service 'some-service'.") }
|
47
43
|
end
|
48
44
|
|
49
|
-
context
|
45
|
+
context "and a service is not given" do
|
50
46
|
it { expect { subject }.to raise_error(CF::UserError, "No services.") }
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
54
|
-
context
|
50
|
+
context "when there are services" do
|
55
51
|
let(:client) { fake_client(:service_instances => services) }
|
56
52
|
let(:services) { fake_list(:service_instance, 2) }
|
57
53
|
let(:renamed_service) { services.first }
|
58
54
|
|
59
|
-
context
|
60
|
-
it
|
55
|
+
context "when the defaults are used" do
|
56
|
+
it "asks for the service and new name and renames" do
|
61
57
|
mock_ask("Rename which service?", anything) { renamed_service }
|
62
58
|
mock_ask("New name") { new_name }
|
63
|
-
|
64
|
-
|
59
|
+
renamed_service.should_receive(:name=).with(new_name)
|
60
|
+
renamed_service.should_receive(:update!)
|
65
61
|
subject
|
66
62
|
end
|
67
63
|
end
|
68
64
|
|
69
|
-
context
|
65
|
+
context "when no name is provided, but a service is" do
|
70
66
|
let(:given) { { :service => renamed_service.name } }
|
71
67
|
|
72
|
-
it
|
68
|
+
it "asks for the new name and renames" do
|
73
69
|
dont_allow_ask("Rename which service?", anything)
|
74
70
|
mock_ask("New name") { new_name }
|
75
|
-
|
76
|
-
|
71
|
+
renamed_service.should_receive(:name=).with(new_name)
|
72
|
+
renamed_service.should_receive(:update!)
|
77
73
|
subject
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
81
|
-
context
|
77
|
+
context "when a service is provided and a name" do
|
82
78
|
let(:inputs) { { :service => renamed_service, :name => new_name } }
|
83
79
|
|
84
|
-
it
|
85
|
-
|
80
|
+
it "renames the service" do
|
81
|
+
renamed_service.should_receive(:update!)
|
86
82
|
subject
|
87
83
|
end
|
88
84
|
|
89
|
-
it
|
85
|
+
it "displays the progress" do
|
90
86
|
mock_with_progress("Renaming to #{new_name}")
|
91
|
-
|
87
|
+
renamed_service.should_receive(:update!)
|
92
88
|
|
93
89
|
subject
|
94
90
|
end
|
95
91
|
|
96
|
-
context
|
97
|
-
it
|
98
|
-
|
92
|
+
context "and the name already exists" do
|
93
|
+
it "fails" do
|
94
|
+
renamed_service.should_receive(:update!) { raise CFoundry::ServiceInstanceNameTaken.new("Taken", 200) }
|
99
95
|
expect { subject }.to raise_error(CFoundry::ServiceInstanceNameTaken)
|
100
96
|
end
|
101
97
|
end
|
@@ -1,64 +1,63 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module CF
|
4
|
+
module Service
|
5
|
+
describe Services do
|
6
|
+
let(:command) { Mothership.commands[:services] }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
describe "metadata" do
|
9
|
+
describe "command" do
|
10
|
+
subject { command }
|
11
|
+
its(:description) { should eq "List your services" }
|
12
|
+
it { expect(Mothership::Help.group(:services)).to include(subject) }
|
13
|
+
end
|
12
14
|
|
13
|
-
|
15
|
+
include_examples "inputs must have descriptions"
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
describe "arguments" do
|
18
|
+
subject { command.arguments }
|
19
|
+
it "has no required arguments" do
|
20
|
+
should eq([])
|
21
|
+
end
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
describe "inputs" do
|
25
|
+
subject { command.inputs }
|
26
|
+
it "has the expected inputs" do
|
27
|
+
subject.keys.should =~ [:name, :service, :plan, :provider, :version, :app, :full, :space]
|
28
|
+
end
|
29
|
+
end
|
26
30
|
end
|
27
|
-
end
|
28
|
-
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
describe "listing services" do
|
33
|
+
let(:global) { {:color => false} }
|
34
|
+
let(:inputs) { {} }
|
35
|
+
let(:given) { {} }
|
36
|
+
let(:client) { fake_client(:current_space => current_space, :service_instances => service_instances) }
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
let(:service_plan) { fake(:service_plan, :service => fake(:service, :version => "service_version", :provider => "provider")) }
|
39
|
+
let(:service1) { fake(:service_instance, :service_plan => service_plan) }
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
let(:service_instances) { [service1] }
|
42
|
+
let(:current_space) { fake(:space, :name => "the space") }
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
subject do
|
45
|
+
capture_output { Mothership.new.invoke(:services, inputs, given, global) }
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
stub(cli).precondition { nil }
|
50
|
-
end
|
51
|
-
end
|
48
|
+
before do
|
49
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
it "produces a table of services" do
|
53
|
+
subject
|
54
|
+
stdout.rewind
|
55
|
+
output = stdout.read
|
57
56
|
|
58
|
-
|
57
|
+
expect(output).to match /Getting services in the space.*OK/
|
59
58
|
|
60
|
-
|
61
|
-
|
59
|
+
expect(output).to match /name\s+service\s+provider\s+version\s+plan\s+bound apps/
|
60
|
+
expect(output).to match /service_instance-.+?\s+ # name
|
62
61
|
service-.*?\s+ # service
|
63
62
|
provider.*?\s+ # provider
|
64
63
|
service_version\s+ # version
|
@@ -66,7 +65,8 @@ describe CF::Service::Services do
|
|
66
65
|
none\s+ # bound apps
|
67
66
|
/x
|
68
67
|
|
68
|
+
end
|
69
|
+
end
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
|
@@ -1,41 +1,48 @@
|
|
1
|
-
require
|
2
|
-
require "cf/cli/app/base"
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
subject { CF::Space::Base.new }
|
7
|
-
|
8
|
-
it "uses a populator to set organization" do
|
9
|
-
org = stub
|
10
|
-
mock(CF::Populators::Organization).new(instance_of(Mothership::Inputs)) { stub!.populate_and_save! { org } }
|
11
|
-
stub(subject).send()
|
12
|
-
|
13
|
-
subject.run(:some_command)
|
14
|
-
subject.org.should == org
|
15
|
-
end
|
3
|
+
module CF::Space
|
4
|
+
class Base; def fake_method; end
|
16
5
|
end
|
6
|
+
end
|
17
7
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
8
|
+
module CF
|
9
|
+
module Space
|
10
|
+
describe Base do
|
11
|
+
describe "#run" do
|
12
|
+
subject { CF::Space::Base.new }
|
25
13
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
it "uses a populator to set organization" do
|
15
|
+
organization = double
|
16
|
+
CF::Populators::Organization.should_receive(:new) { double(:populator, :populate_and_save! => organization) }
|
17
|
+
subject.run(:fake_method)
|
18
|
+
subject.org.should == organization
|
19
|
+
end
|
30
20
|
end
|
31
|
-
end
|
32
21
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
describe ".space_by_name" do
|
23
|
+
subject { CF::Space::Base.space_by_name }
|
24
|
+
let(:org) { double(:organization) }
|
25
|
+
|
26
|
+
before do
|
27
|
+
org.should_receive(:space_by_name).with("mySpace").and_return(space)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
context "with a space" do
|
32
|
+
let(:space) { double(:space) }
|
33
|
+
it "returns a space matching the name from the given org" do
|
34
|
+
CF::Space::Base.space_by_name.call("mySpace", org).should == space
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with no matching space" do
|
39
|
+
let(:space) { nil }
|
40
|
+
it "fails when no space matches the name" do
|
41
|
+
expect {
|
42
|
+
CF::Space::Base.space_by_name.call("mySpace", org)
|
43
|
+
}.to raise_exception
|
44
|
+
end
|
45
|
+
end
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
@@ -1,69 +1,68 @@
|
|
1
|
-
require
|
2
|
-
require "cf/cli/space/create"
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module CF
|
4
|
+
module Space
|
5
|
+
describe Create do
|
6
|
+
describe "metadata" do
|
7
|
+
let(:command) { Mothership.commands[:create_space] }
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
describe "command" do
|
10
|
+
subject { command }
|
11
|
+
its(:description) { should eq "Create a space in an organization" }
|
12
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
include_examples "inputs must have descriptions"
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
describe "arguments" do
|
18
|
+
subject { command.arguments }
|
19
|
+
it "has the correct argument order" do
|
20
|
+
should eq([
|
21
|
+
{:type => :optional, :value => nil, :name => :name},
|
22
|
+
{:type => :optional, :value => nil, :name => :organization}
|
23
|
+
])
|
24
|
+
end
|
25
|
+
end
|
23
26
|
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "running the command" do
|
28
|
-
let(:new_space) { fake :space, :name => new_name }
|
29
|
-
let(:new_name) { "some-new-name" }
|
30
27
|
|
31
|
-
|
32
|
-
|
28
|
+
describe "running the command" do
|
29
|
+
let(:new_space) { fake(:space, :name => new_name) }
|
30
|
+
let(:new_name) { "some-new-name" }
|
33
31
|
|
34
|
-
|
32
|
+
let(:spaces) { [new_space] }
|
33
|
+
let(:organization) { fake(:organization, :spaces => spaces) }
|
35
34
|
|
36
|
-
|
37
|
-
stub(client).space { new_space }
|
38
|
-
stub(new_space).create!
|
39
|
-
stub(new_space).add_manager
|
40
|
-
stub(new_space).add_developer
|
41
|
-
stub(new_space).add_auditor
|
42
|
-
any_instance_of described_class do |cli|
|
43
|
-
stub(cli).client { client }
|
35
|
+
let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
|
44
36
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
37
|
+
before do
|
38
|
+
client.stub(:space).and_return(new_space)
|
39
|
+
new_space.stub(:create!)
|
40
|
+
new_space.stub(:add_manager)
|
41
|
+
new_space.stub(:add_developer)
|
42
|
+
new_space.stub(:add_auditor)
|
43
|
+
described_class.any_instance.stub(:client).and_return(client)
|
44
|
+
described_class.any_instance.stub(:precondition).and_return(nil)
|
45
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
46
|
+
CF::Populators::Organization.any_instance.stub(:choices).and_return([organization])
|
47
|
+
end
|
50
48
|
|
51
|
-
|
52
|
-
|
49
|
+
context "when --target is given" do
|
50
|
+
subject { cf %W[create-space #{new_space.name} --target] }
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
52
|
+
it "switches them to the new space" do
|
53
|
+
mock_invoke :target, :organization => organization, :space => new_space
|
54
|
+
subject
|
55
|
+
end
|
56
|
+
end
|
60
57
|
|
61
|
-
|
62
|
-
|
58
|
+
context "when --target is NOT given" do
|
59
|
+
subject { cf %W[create-space #{new_space.name}] }
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
it "tells the user how they can switch to the new space" do
|
62
|
+
subject
|
63
|
+
expect(output).to say("Space created! Use `cf switch-space #{new_space.name}` to target it.")
|
64
|
+
end
|
65
|
+
end
|
67
66
|
end
|
68
67
|
end
|
69
68
|
end
|