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,108 +1,107 @@
1
- require 'spec_helper'
2
- require "cf/cli/space/delete"
3
-
4
- describe CF::Space::Delete do
5
- describe 'metadata' do
6
- let(:command) { Mothership.commands[:delete_space] }
7
-
8
- describe 'command' do
9
- subject { command }
10
- its(:description) { should eq "Delete a space and its contents" }
11
- it { expect(Mothership::Help.group(:spaces)).to include(subject) }
12
- end
13
-
14
- include_examples 'inputs must have descriptions'
15
- end
16
-
17
- describe "running the command" do
18
- let(:space) { fake :space, :name => "some_space_name" }
19
- let(:organization) { fake(:organization, :spaces => [space], :name => "MyOrg") }
20
- let(:client) { fake_client(:current_organization => organization, :spaces => [space]) }
21
-
22
- subject { capture_output { cf %W[delete-space some_space_name --quiet --force] } }
23
-
24
- before do
25
- any_instance_of described_class do |cli|
26
- stub(cli).client { client }
1
+ require "spec_helper"
2
+
3
+ module CF
4
+ module Space
5
+ describe Delete do
6
+ describe "metadata" do
7
+ let(:command) { Mothership.commands[:delete_space] }
8
+
9
+ describe "command" do
10
+ subject { command }
11
+ its(:description) { should eq "Delete a space and its contents" }
12
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
13
+ end
27
14
 
28
- stub(cli).check_logged_in
29
- stub(cli).check_target
30
- any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
15
+ include_examples "inputs must have descriptions"
31
16
  end
32
- stub(space).delete!
33
- end
34
17
 
18
+ describe "running the command" do
19
+ let(:space) { fake :space, :name => "some_space_name" }
20
+ let(:organization) { fake(:organization, :spaces => [space], :name => "MyOrg") }
21
+ let(:client) { fake_client(:current_organization => organization, :spaces => [space]) }
35
22
 
36
- context "without the force parameter when prompting" do
37
- subject { cf %W[delete-space some_space_name --quiet] }
38
- context "when the user responds 'y'" do
39
- it "deletes the space, exits cleanly" do
40
- mock(space).delete!
41
- mock_ask("Really delete #{space.name}?", {:default => false}) { true }
23
+ subject { capture_output { cf %W[delete-space some_space_name --quiet --force] } }
42
24
 
43
- subject
44
- @status.should == 0
25
+ before do
26
+ described_class.any_instance.stub(:client) { client }
27
+ described_class.any_instance.stub(:precondition)
28
+ CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
29
+ space.stub(:delete!)
45
30
  end
46
- end
47
31
 
48
- context "when the user responds 'n'" do
49
- it "exits cleanly without deleting the space" do
50
- dont_allow(space).delete!
51
- mock_ask("Really delete #{space.name}?", {:default => false}) { false }
52
32
 
53
- subject
54
- @status.should == 0
55
- end
56
- end
57
- end
33
+ context "without the force parameter when prompting" do
34
+ subject { cf %W[delete-space some_space_name --quiet] }
35
+ context "when the user responds 'y'" do
36
+ it "deletes the space, exits cleanly" do
37
+ space.should_receive(:delete!)
38
+ mock_ask("Really delete #{space.name}?", {:default => false}) { true }
58
39
 
59
- context "when deleting the current space" do
60
- before do
61
- stub(client).current_space { space }
62
- end
40
+ subject
41
+ @status.should == 0
42
+ end
43
+ end
63
44
 
64
- it "warns the user what they've done" do
65
- subject
66
- expect(output).to say("The space that you were targeting has now been deleted. Please use `cf target -s SPACE_NAME` to target a different one.")
67
- end
45
+ context "when the user responds 'n'" do
46
+ it "exits cleanly without deleting the space" do
47
+ space.should_not_receive(:delete!)
48
+ mock_ask("Really delete #{space.name}?", {:default => false}) { false }
68
49
 
69
- context "when the current space has dependent objects" do
70
- before do
71
- stub(space).delete! { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
50
+ subject
51
+ @status.should == 0
52
+ end
53
+ end
72
54
  end
73
55
 
74
- it "does not print a success message" do
75
- subject
76
- expect(output).to_not say("The space that you were targeting has now been deleted")
56
+ context "when deleting the current space" do
57
+ before do
58
+ client.stub(:current_space) { space }
59
+ end
60
+
61
+ it "warns the user what they've done" do
62
+ subject
63
+ expect(output).to say("The space that you were targeting has now been deleted. Please use `cf target -s SPACE_NAME` to target a different one.")
64
+ end
65
+
66
+ context "when the current space has dependent objects" do
67
+ before do
68
+ space.stub(:delete!) { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
69
+ end
70
+
71
+ it "does not print a success message" do
72
+ subject
73
+ expect(output).to_not say("The space that you were targeting has now been deleted")
74
+ end
75
+ end
77
76
  end
78
- end
79
- end
80
77
 
81
- context "when a space fails to delete" do
82
- before do
83
- stub(space).delete! { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
84
- subject
85
- end
78
+ context "when a space fails to delete" do
79
+ before do
80
+ space.stub(:delete!) { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
81
+ subject
82
+ end
86
83
 
87
- it "shows the error message" do
88
- expect(output).to say "We don't delete children."
89
- end
84
+ it "shows the error message" do
85
+ expect(output).to say "We don't delete children."
86
+ end
90
87
 
91
- it "informs the user of how to recursively delete" do
92
- expect(output).to say "If you want to delete the space along with all dependent objects, rerun the command with the '--recursive' flag."
93
- end
88
+ it "informs the user of how to recursively delete" do
89
+ expect(output).to say "If you want to delete the space along with all dependent objects, rerun the command with the '--recursive' flag."
90
+ end
94
91
 
95
- it "returns a non-zero exit code" do
96
- @status.should_not == 0
97
- end
98
- end
92
+ it "returns a non-zero exit code" do
93
+ @status.should_not == 0
94
+ end
95
+ end
99
96
 
100
- context "when deleting with --recursive" do
101
- subject { cf %W[delete-space some_space_name --recursive --force] }
97
+ context "when deleting with --recursive" do
98
+ subject { cf %W[delete-space some_space_name --recursive --force] }
102
99
 
103
- it "sends recursive true in its delete request" do
104
- mock(space).delete!(:recursive => true)
105
- subject
100
+ it "sends recursive true in its delete request" do
101
+ space.should_receive(:delete!).with(:recursive => true)
102
+ subject
103
+ end
104
+ end
106
105
  end
107
106
  end
108
107
  end
@@ -1,103 +1,102 @@
1
- require 'spec_helper'
2
- require "cf/cli/space/rename"
3
-
4
- describe CF::Space::Rename do
5
- let(:spaces) { fake_list(:space, 3) }
6
- let(:organization) { fake(:organization, :spaces => spaces) }
7
- let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
8
- let(:new_name) { "some-new-name" }
9
-
10
- before do
11
- any_instance_of described_class do |cli|
12
- stub(cli).client { client }
13
-
14
- stub(cli).check_logged_in
15
- stub(cli).check_target
16
- any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
17
- end
18
- end
19
-
20
- describe 'metadata' do
21
- let(:command) { Mothership.commands[:rename_space] }
22
-
23
- describe 'command' do
24
- subject { command }
25
- its(:description) { should eq "Rename a space" }
26
- it { expect(Mothership::Help.group(:spaces)).to include(subject) }
27
- end
28
-
29
- include_examples 'inputs must have descriptions'
30
-
31
- describe 'arguments' do
32
- subject { command.arguments }
33
- it 'has the correct argument order' do
34
- should eq([
35
- {:type => :optional, :value => nil, :name => :space},
36
- {:type => :optional, :value => nil, :name => :name}
37
- ])
38
- end
39
- end
40
- end
41
-
42
- context 'when there are no spaces' do
43
- let(:spaces) { [] }
44
-
45
- context 'and a space is given' do
46
- subject { cf %W[rename-space --space some-invalid-space --no-force --no-quiet] }
47
- it 'prints out an error message' do
48
- subject
49
- expect(stderr.string).to include "Unknown space 'some-invalid-space'."
1
+ require "spec_helper"
2
+
3
+ module CF
4
+ module Space
5
+ describe Rename do
6
+ let(:spaces) { fake_list(:space, 3) }
7
+ let(:organization) { fake(:organization, :spaces => spaces) }
8
+ let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
9
+ let(:new_name) { "some-new-name" }
10
+
11
+ before do
12
+ described_class.any_instance.stub(:client) { client }
13
+ described_class.any_instance.stub(:precondition)
14
+ CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
50
15
  end
51
- end
52
-
53
- context 'and a space is not given' do
54
- subject { cf %W[rename-space --no-force] }
55
- it 'prints out an error message' do
56
- subject
57
- expect(stderr.string).to include "No spaces."
58
- end
59
- end
60
- end
61
-
62
- context 'when there are spaces' do
63
- let(:renamed_space) { spaces.first }
64
- subject { cf %W[rename-space --no-force --no-quiet] }
65
-
66
- context 'when the defaults are used' do
67
- it 'asks for the space and new name and renames' do
68
- mock_ask("Rename which space?", anything) { renamed_space }
69
- mock_ask("New name") { new_name }
70
- mock(renamed_space).name=(new_name)
71
- mock(renamed_space).update!
72
- subject
73
- end
74
- end
75
-
76
- context 'when no name is provided, but a space is' do
77
- subject { cf %W[rename-space --space #{renamed_space.name} --no-force] }
78
16
 
79
- it 'asks for the new name and renames' do
80
- dont_allow_ask("Rename which space?", anything)
81
- mock_ask("New name") { new_name }
82
- mock(renamed_space).name=(new_name)
83
- mock(renamed_space).update!
84
- subject
17
+ describe "metadata" do
18
+ let(:command) { Mothership.commands[:rename_space] }
19
+
20
+ describe "command" do
21
+ subject { command }
22
+ its(:description) { should eq "Rename a space" }
23
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
24
+ end
25
+
26
+ include_examples "inputs must have descriptions"
27
+
28
+ describe "arguments" do
29
+ subject { command.arguments }
30
+ it "has the correct argument order" do
31
+ should eq([
32
+ {:type => :optional, :value => nil, :name => :space},
33
+ {:type => :optional, :value => nil, :name => :name}
34
+ ])
35
+ end
36
+ end
85
37
  end
86
- end
87
-
88
- context 'when a space is provided and a name' do
89
- subject { cf %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
90
38
 
91
- it 'renames the space' do
92
- mock(renamed_space).update!
93
- subject
39
+ context "when there are no spaces" do
40
+ let(:spaces) { [] }
41
+
42
+ context "and a space is given" do
43
+ subject { cf %W[rename-space --space some-invalid-space --no-force --no-quiet] }
44
+ it "prints out an error message" do
45
+ subject
46
+ expect(stderr.string).to include "Unknown space 'some-invalid-space'."
47
+ end
48
+ end
49
+
50
+ context "and a space is not given" do
51
+ subject { cf %W[rename-space --no-force] }
52
+ it "prints out an error message" do
53
+ subject
54
+ expect(stderr.string).to include "No spaces."
55
+ end
56
+ end
94
57
  end
95
58
 
96
- it 'displays the progress' do
97
- mock_with_progress("Renaming to #{new_name}")
98
- mock(renamed_space).update!
99
-
100
- subject
59
+ context "when there are spaces" do
60
+ let(:renamed_space) { spaces.first }
61
+ subject { cf %W[rename-space --no-force --no-quiet] }
62
+
63
+ context "when the defaults are used" do
64
+ it "asks for the space and new name and renames" do
65
+ mock_ask("Rename which space?", anything) { renamed_space }
66
+ mock_ask("New name") { new_name }
67
+ renamed_space.should_receive(:name=).with(new_name)
68
+ renamed_space.should_receive(:update!)
69
+ subject
70
+ end
71
+ end
72
+
73
+ context "when no name is provided, but a space is" do
74
+ subject { cf %W[rename-space --space #{renamed_space.name} --no-force] }
75
+
76
+ it "asks for the new name and renames" do
77
+ dont_allow_ask("Rename which space?", anything)
78
+ mock_ask("New name") { new_name }
79
+ renamed_space.should_receive(:name=).with(new_name)
80
+ renamed_space.should_receive(:update!)
81
+ subject
82
+ end
83
+ end
84
+
85
+ context "when a space is provided and a name" do
86
+ subject { cf %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
87
+
88
+ it "renames the space" do
89
+ renamed_space.should_receive(:update!)
90
+ subject
91
+ end
92
+
93
+ it "displays the progress" do
94
+ mock_with_progress("Renaming to #{new_name}")
95
+ renamed_space.should_receive(:update!)
96
+
97
+ subject
98
+ end
99
+ end
101
100
  end
102
101
  end
103
102
  end
@@ -1,79 +1,79 @@
1
- require 'spec_helper'
2
- require 'stringio'
1
+ require "spec_helper"
3
2
 
4
- describe CF::Space::Space do
5
- describe 'metadata' do
6
- let(:command) { Mothership.commands[:space] }
3
+ module CF
4
+ module Space
5
+ describe Space do
6
+ describe "metadata" do
7
+ let(:command) { Mothership.commands[:space] }
7
8
 
8
- describe 'command' do
9
- subject { command }
10
- its(:description) { should eq "Show space information" }
11
- it { expect(Mothership::Help.group(:spaces)).to include(subject) }
12
- end
9
+ describe "command" do
10
+ subject { command }
11
+ its(:description) { should eq "Show space information" }
12
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
13
+ end
13
14
 
14
- include_examples 'inputs must have descriptions'
15
+ include_examples "inputs must have descriptions"
15
16
 
16
- describe 'arguments' do
17
- subject { command.arguments }
18
- it 'has the correct argument order' do
19
- should eq([
20
- { :type => :optional, :value => nil, :name => :space }
21
- ])
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 => :space}
22
+ ])
23
+ end
24
+ end
22
25
  end
23
- end
24
- end
25
26
 
26
- describe "running the command" do
27
- let(:apps) { fake_list(:app, 2) }
28
- let(:domains) { fake_list(:domain, 2) }
29
- let(:services) { fake_list(:service_instance, 2) }
30
- let!(:space_1) { fake(:space, :name => "some_space_name", :apps => apps, :service_instances => services, :domains => domains) }
31
- let(:spaces) { [space_1] }
32
- let(:organization) { fake(:organization, :name => "Spacey Org", :spaces => spaces) }
33
- let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
27
+ describe "running the command" do
28
+ let(:apps) { fake_list(:app, 2) }
29
+ let(:domains) { fake_list(:domain, 2) }
30
+ let(:services) { fake_list(:service_instance, 2) }
31
+ let!(:space_1) { fake(:space, :name => "some_space_name", :apps => apps, :service_instances => services, :domains => domains) }
32
+ let(:spaces) { [space_1] }
33
+ let(:organization) { fake(:organization, :name => "Spacey Org", :spaces => spaces) }
34
+ let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
34
35
 
35
- before do
36
- any_instance_of described_class do |cli|
37
- stub(cli).client { client }
38
- stub(cli).check_logged_in
39
- stub(cli).check_target
40
- any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
41
- any_instance_of(CF::Populators::Space, :populate_and_save! => space_1)
42
- end
43
- end
36
+ before do
37
+ CF::Space::Base.any_instance.stub(:client) { client }
38
+ CF::Space::Base.any_instance.stub(:precondition)
39
+ CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
40
+ CF::Populators::Space.any_instance.stub(:populate_and_save!).and_return(space_1)
41
+ end
44
42
 
45
- context "with --quiet" do
46
- subject { cf %W[space some_space_name --quiet] }
43
+ context "with --quiet" do
44
+ subject { cf %W[space some_space_name --quiet] }
47
45
 
48
- it "shows only the name" do
49
- subject
50
- expect(stdout.read).to eq("some_space_name\n")
51
- end
52
- end
46
+ it "shows only the name" do
47
+ subject
48
+ expect(stdout.read).to eq("some_space_name\n")
49
+ end
50
+ end
53
51
 
54
- context "with --no-quiet" do
55
- subject { cf %W[space some_space_name --no-quiet] }
52
+ context "with --no-quiet" do
53
+ subject { cf %W[space some_space_name --no-quiet] }
56
54
 
57
- before { subject }
55
+ before { subject }
58
56
 
59
- it "shows the space's name" do
60
- expect(stdout.read).to include("some_space_name:")
61
- end
57
+ it "shows the space's name" do
58
+ expect(stdout.read).to include("some_space_name:")
59
+ end
62
60
 
63
- it "shows the space's org" do
64
- expect(stdout.read).to include("organization: Spacey Org")
65
- end
61
+ it "shows the space's org" do
62
+ expect(stdout.read).to include("organization: Spacey Org")
63
+ end
66
64
 
67
- it "shows apps" do
68
- expect(stdout.read).to include("apps: #{apps.first.name}, #{apps.last.name}")
69
- end
65
+ it "shows apps" do
66
+ expect(stdout.read).to include("apps: #{apps.first.name}, #{apps.last.name}")
67
+ end
70
68
 
71
- it "shows services" do
72
- expect(stdout.read).to include("services: #{services.first.name}, #{services.last.name}")
73
- end
69
+ it "shows services" do
70
+ expect(stdout.read).to include("services: #{services.first.name}, #{services.last.name}")
71
+ end
74
72
 
75
- it "shows domains" do
76
- expect(stdout.read).to include("domains: #{domains.first.name}, #{domains.last.name}")
73
+ it "shows domains" do
74
+ expect(stdout.read).to include("domains: #{domains.first.name}, #{domains.last.name}")
75
+ end
76
+ end
77
77
  end
78
78
  end
79
79
  end