cf 1.1.3.rc1 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
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,5 +1,4 @@
1
- require 'spec_helper'
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
- any_instance_of(CF::CLI) do |cli|
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
- subject { Mothership.new.invoke(:rename_service, inputs, given, global) }
20
-
21
- describe 'metadata' do
17
+ describe "metadata" do
22
18
  let(:command) { Mothership.commands[:rename_service] }
23
19
 
24
- describe 'command' do
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 'inputs must have descriptions'
26
+ include_examples "inputs must have descriptions"
31
27
 
32
- describe 'arguments' do
28
+ describe "arguments" do
33
29
  subject { command.arguments }
34
- it 'has the correct argument order' do
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 'when there are no services' do
44
- context 'and a service is given' do
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 'and a service is not given' do
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 'when there are services' do
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 'when the defaults are used' do
60
- it 'asks for the service and new name and renames' do
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
- mock(renamed_service).name=(new_name)
64
- mock(renamed_service).update!
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 'when no name is provided, but a service is' do
65
+ context "when no name is provided, but a service is" do
70
66
  let(:given) { { :service => renamed_service.name } }
71
67
 
72
- it 'asks for the new name and renames' do
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
- mock(renamed_service).name=(new_name)
76
- mock(renamed_service).update!
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 'when a service is provided and a name' do
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 'renames the service' do
85
- mock(renamed_service).update!
80
+ it "renames the service" do
81
+ renamed_service.should_receive(:update!)
86
82
  subject
87
83
  end
88
84
 
89
- it 'displays the progress' do
85
+ it "displays the progress" do
90
86
  mock_with_progress("Renaming to #{new_name}")
91
- mock(renamed_service).update!
87
+ renamed_service.should_receive(:update!)
92
88
 
93
89
  subject
94
90
  end
95
91
 
96
- context 'and the name already exists' do
97
- it 'fails' do
98
- mock(renamed_service).update! { raise CFoundry::ServiceInstanceNameTaken.new("Taken", 200) }
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 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe CF::Service::Services do
4
- let(:command) { Mothership.commands[:services] }
3
+ module CF
4
+ module Service
5
+ describe Services do
6
+ let(:command) { Mothership.commands[:services] }
5
7
 
6
- describe 'metadata' do
7
- describe 'command' do
8
- subject { command }
9
- its(:description) { should eq "List your services" }
10
- it { expect(Mothership::Help.group(:services)).to include(subject) }
11
- end
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
- include_examples 'inputs must have descriptions'
15
+ include_examples "inputs must have descriptions"
14
16
 
15
- describe 'arguments' do
16
- subject { command.arguments }
17
- it 'has no required arguments' do
18
- should eq([])
19
- end
20
- end
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
- describe 'inputs' do
23
- subject { command.inputs }
24
- it 'has the expected inputs' do
25
- subject.keys.should =~ [:name, :service, :plan, :provider, :version, :app, :full, :space]
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
- describe 'listing services' do
31
- let(:global) { { :color => false } }
32
- let(:inputs) { {} }
33
- let(:given) { {} }
34
- let(:client) { fake_client(:current_space => current_space, :service_instances => service_instances) }
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
- let(:service_plan) { fake(:service_plan, :service => fake(:service, :version => 'service_version', :provider => 'provider') ) }
37
- let(:service1) { fake(:service_instance, :service_plan => service_plan ) }
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
- let(:service_instances) { [service1] }
40
- let(:current_space) { fake(:space, :name => 'the space' ) }
41
+ let(:service_instances) { [service1] }
42
+ let(:current_space) { fake(:space, :name => "the space") }
41
43
 
42
- subject do
43
- capture_output { Mothership.new.invoke(:services, inputs, given, global) }
44
- end
44
+ subject do
45
+ capture_output { Mothership.new.invoke(:services, inputs, given, global) }
46
+ end
45
47
 
46
- before do
47
- any_instance_of(CF::CLI) do |cli|
48
- stub(cli).client { client }
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
- it 'produces a table of services' do
54
- subject
55
- stdout.rewind
56
- output = stdout.read
52
+ it "produces a table of services" do
53
+ subject
54
+ stdout.rewind
55
+ output = stdout.read
57
56
 
58
- expect(output).to match /Getting services in the space.*OK/
57
+ expect(output).to match /Getting services in the space.*OK/
59
58
 
60
- expect(output).to match /name\s+service\s+provider\s+version\s+plan\s+bound apps/
61
- expect(output).to match /service_instance-.+?\s+ # name
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 'spec_helper'
2
- require "cf/cli/app/base"
1
+ require "spec_helper"
3
2
 
4
- describe CF::Space::Base do
5
- describe '#run' do
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
- describe '.space_by_name' do
19
- subject { CF::Space::Base::space_by_name }
20
- let(:org) do
21
- Object.new.tap do |o|
22
- mock(o).space_by_name("mySpace").returns(space)
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
- context "with a space" do
27
- let(:space) { mock }
28
- it "returns a space matching the name from the given org" do
29
- subject.call("mySpace", org).should == space
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
- context "with no matching space" do
34
- let(:space) { nil }
35
- it "fails when no space matches the name" do
36
- expect {
37
- subject.call("mySpace", org)
38
- }.to raise_exception
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 'spec_helper'
2
- require "cf/cli/space/create"
1
+ require "spec_helper"
3
2
 
4
- describe CF::Space::Create do
5
- describe 'metadata' do
6
- let(:command) { Mothership.commands[:create_space] }
3
+ module CF
4
+ module Space
5
+ describe Create do
6
+ describe "metadata" do
7
+ let(:command) { Mothership.commands[:create_space] }
7
8
 
8
- describe 'command' do
9
- subject { command }
10
- its(:description) { should eq "Create a space in an organization" }
11
- it { expect(Mothership::Help.group(:spaces)).to include(subject) }
12
- end
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
- 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 => :name },
21
- { :type => :optional, :value => nil, :name => :organization }
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
- let(:spaces) { [new_space] }
32
- let(:organization) { fake(:organization, :spaces => spaces) }
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
- let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
32
+ let(:spaces) { [new_space] }
33
+ let(:organization) { fake(:organization, :spaces => spaces) }
35
34
 
36
- before do
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
- stub(cli).check_logged_in
46
- stub(cli).check_target
47
- any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
48
- end
49
- end
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
- context "when --target is given" do
52
- subject { cf %W[create-space #{new_space.name} --target] }
49
+ context "when --target is given" do
50
+ subject { cf %W[create-space #{new_space.name} --target] }
53
51
 
54
- it "switches them to the new space" do
55
- mock_invoke :target, :organization => organization,
56
- :space => new_space
57
- subject
58
- end
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
- context "when --target is NOT given" do
62
- subject { cf %W[create-space #{new_space.name}] }
58
+ context "when --target is NOT given" do
59
+ subject { cf %W[create-space #{new_space.name}] }
63
60
 
64
- it "tells the user how they can switch to the new space" do
65
- subject
66
- expect(output).to say("Space created! Use `cf switch-space #{new_space.name}` to target it.")
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