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,68 +1,67 @@
1
- require 'spec_helper'
2
- require 'stringio'
1
+ require "spec_helper"
3
2
 
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")] }
3
+ module CF
4
+ module App
5
+ describe Stats do
6
+ let(:global) { {:color => false} }
7
+ let(:inputs) { {:app => apps[0]} }
8
+ let(:given) { {} }
9
+ let(:client) { fake_client(:apps => apps) }
10
+ let(:apps) { [fake(:app, :name => "basic_app")] }
10
11
 
11
- before do
12
- any_instance_of(CF::CLI) do |cli|
13
- stub(cli).client { client }
14
- stub(cli).precondition { nil }
15
- end
16
- stub(inputs[:app]).stats do
17
- {"0" => {
18
- :state => "RUNNING",
19
- :stats => {
20
- :name => "basic_app",
21
- :uris => ["basic_app.p01.rbconsvcs.com"],
22
- :host => "172.20.183.93",
23
- :port => 61006,
24
- :uptime => 3250,
25
- :mem_quota => 301989888,
26
- :disk_quota => 268435456,
27
- :fds_quota => 256,
28
- :usage => {
29
- :time => "2013-01-04 19:53:39 +0000",
30
- :cpu => 0.0019777013519415455,
31
- :mem => 31395840,
32
- :disk => 15638528
12
+ before do
13
+ inputs[:app].stub(:stats) do
14
+ {"0" => {
15
+ :state => "RUNNING",
16
+ :stats => {
17
+ :name => "basic_app",
18
+ :uris => ["basic_app.p01.rbconsvcs.com"],
19
+ :host => "172.20.183.93",
20
+ :port => 61006,
21
+ :uptime => 3250,
22
+ :mem_quota => 301989888,
23
+ :disk_quota => 268435456,
24
+ :fds_quota => 256,
25
+ :usage => {
26
+ :time => "2013-01-04 19:53:39 +0000",
27
+ :cpu => 0.0019777013519415455,
28
+ :mem => 31395840,
29
+ :disk => 15638528
30
+ }
31
+ }
33
32
  }
34
- }
35
- }
36
- }
37
- end
38
- end
33
+ }
34
+ end
35
+ end
39
36
 
40
- subject do
41
- capture_output { Mothership.new.invoke(:stats, inputs, given, global) }
42
- end
37
+ subject do
38
+ capture_output { Mothership.new.invoke(:stats, inputs, given, global) }
39
+ end
43
40
 
44
- describe 'metadata' do
45
- let(:command) { Mothership.commands[:stats] }
41
+ describe 'metadata' do
42
+ let(:command) { Mothership.commands[:stats] }
46
43
 
47
- describe 'command' do
48
- subject { command }
49
- its(:description) { should eq "Display application instance status" }
50
- it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
51
- end
44
+ describe 'command' do
45
+ subject { command }
46
+ its(:description) { should eq "Display application instance status" }
47
+ it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
48
+ end
52
49
 
53
- include_examples 'inputs must have descriptions'
50
+ include_examples 'inputs must have descriptions'
54
51
 
55
- describe 'arguments' do
56
- subject { command.arguments }
57
- it 'has no arguments' do
58
- should eq([:name => :app, :type => :optional, :value => nil])
52
+ describe 'arguments' do
53
+ subject { command.arguments }
54
+ it 'has no arguments' do
55
+ should eq([:name => :app, :type => :optional, :value => nil])
56
+ end
57
+ end
59
58
  end
60
- end
61
- end
62
59
 
63
- it 'prints out the stats' do
64
- subject
65
- stdout.rewind
66
- expect(stdout.readlines.last).to match /.*0\s+0\.0%\s+29\.9M of 288M\s+14\.9M of 256M.*/
60
+ it 'prints out the stats' do
61
+ subject
62
+ stdout.rewind
63
+ expect(stdout.readlines.last).to match /.*0\s+0\.0%\s+29\.9M of 288M\s+14\.9M of 256M.*/
64
+ end
65
+ end
67
66
  end
68
67
  end
@@ -1,134 +1,137 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe CF::Domain::Map do
4
- before do
5
- stub_client_and_precondition
6
- end
3
+ module CF
4
+ module Domain
5
+ describe Map do
6
+ before do
7
+ stub_client_and_precondition
8
+ end
7
9
 
8
- let(:client) do
9
- fake_client(
10
- :current_organization => organization,
11
- :current_space => space,
12
- :spaces => [space],
13
- :organizations => [organization],
14
- :domains => domains)
15
- end
10
+ let(:client) do
11
+ fake_client(
12
+ :current_organization => organization,
13
+ :current_space => space,
14
+ :spaces => [space],
15
+ :organizations => [organization],
16
+ :domains => domains)
17
+ end
16
18
 
17
- let(:organization) { fake(:organization) }
18
- let(:space) { fake(:space, :organization => organization) }
19
- let(:domain) { fake(:domain, :name => domain_name) }
20
- let(:domain_name) { "some.domain.com" }
21
- let(:domains) { [domain] }
22
-
23
- shared_examples_for "binding a domain to a space" do
24
- it "adds the domain to the space's organization" do
25
- mock(space.organization).add_domain(domain)
26
- stub(space).add_domain(domain)
27
- subject
28
- end
19
+ let(:organization) { fake(:organization) }
20
+ let(:space) { fake(:space, :organization => organization) }
21
+ let(:domain) { fake(:domain, :name => domain_name) }
22
+ let(:domain_name) { "some.domain.com" }
23
+ let(:domains) { [domain] }
29
24
 
30
- it 'adds the domain to the space' do
31
- stub(space.organization).add_domain(domain)
32
- mock(space).add_domain(domain)
33
- subject
34
- end
35
- end
25
+ shared_examples_for "binding a domain to a space" do
26
+ it "adds the domain to the space's organization" do
27
+ space.organization.should_receive(:add_domain).with(domain)
28
+ space.stub(:add_domain)
29
+ subject
30
+ end
36
31
 
37
- shared_examples_for "binding a domain to an organization" do
38
- it 'does NOT add the domain to a space' do
39
- any_instance_of(space.class) do |space|
40
- dont_allow(space).add_domain(domain)
32
+ it "adds the domain to the space" do
33
+ space.organization.stub(:add_domain)
34
+ space.should_receive(:add_domain).with(domain)
35
+ subject
36
+ end
41
37
  end
42
- end
43
-
44
- it 'adds the domain to the organization' do
45
- mock(organization).add_domain(domain)
46
- subject
47
- end
48
- end
49
38
 
50
- shared_examples_for "mapping a domain to a space" do
51
- context "when the domain does NOT exist" do
52
- let(:domains) { [] }
39
+ shared_examples_for "binding a domain to an organization" do
40
+ it "does NOT add the domain to a space" do
41
+ space.class.any_instance.should_not_receive(:add_domain).with(domain)
42
+ end
53
43
 
54
- before do
55
- stub(client).domain { domain }
56
- stub(domain).create!
57
- stub(space.organization).add_domain(domain)
58
- stub(space).add_domain(domain)
44
+ it "adds the domain to the organization" do
45
+ organization.should_receive(:add_domain).with(domain)
46
+ subject
47
+ end
59
48
  end
60
49
 
61
- it 'creates the domain' do
62
- mock(domain).create!
63
- subject
64
- expect(domain.name).to eq domain_name
65
- expect(domain.owning_organization).to eq organization
66
- end
50
+ shared_examples_for "mapping a domain to a space" do
51
+ context "when the domain does NOT exist" do
52
+ let(:domains) { [] }
67
53
 
68
- include_examples "binding a domain to a space"
69
- end
54
+ before do
55
+ client.stub(:domain) { domain }
56
+ domain.stub(:create!)
57
+ end
70
58
 
71
- context "when the domain already exists" do
72
- include_examples "binding a domain to a space"
73
- end
74
- end
59
+ it "creates the domain" do
60
+ space.organization.stub(:add_domain)
61
+ space.should_receive(:add_domain).with(domain)
75
62
 
76
- context 'when a domain and a space are passed' do
77
- subject { cf %W[map-domain #{domain.name} --space #{space.name}] }
63
+ domain.should_receive(:create!)
64
+ subject
65
+ expect(domain.name).to eq domain_name
66
+ expect(domain.owning_organization).to eq organization
67
+ end
78
68
 
79
- include_examples "mapping a domain to a space"
80
- end
69
+ include_examples "binding a domain to a space"
70
+ end
81
71
 
82
- context 'when a domain and an organization are passed' do
83
- subject { cf %W[map-domain #{domain.name} --organization #{organization.name}] }
72
+ context "when the domain already exists" do
73
+ include_examples "binding a domain to a space"
74
+ end
75
+ end
84
76
 
85
- context "and the domain does NOT exist" do
86
- let(:domains) { [] }
77
+ context "when a domain and a space are passed" do
78
+ subject { cf %W[map-domain #{domain.name} --space #{space.name}] }
87
79
 
88
- before do
89
- stub(client).domain { domain }
90
- stub(domain).create!
91
- stub(organization).add_domain(domain)
80
+ include_examples "mapping a domain to a space"
92
81
  end
93
82
 
94
- include_examples "binding a domain to an organization"
83
+ context "when a domain and an organization are passed" do
84
+ subject { cf %W[map-domain #{domain.name} --organization #{organization.name}] }
95
85
 
96
- it 'creates the domain' do
97
- mock(domain).create!
98
- subject
99
- expect(domain.name).to eq domain_name
100
- end
86
+ context "and the domain does NOT exist" do
87
+ let(:domains) { [] }
101
88
 
102
- context "and the --shared option is passed" do
103
- subject { cf %W[map-domain #{domain.name} --organization #{organization.name} --shared] }
89
+ before do
90
+ client.stub(:domain) { domain }
91
+ domain.stub(:create!)
92
+ organization.stub(:add_domain)
93
+ end
104
94
 
105
- it 'adds the domain to the organization' do
106
- mock(organization).add_domain(domain)
107
- subject
95
+ include_examples "binding a domain to an organization"
96
+
97
+ it "creates the domain" do
98
+ domain.should_receive(:create!)
99
+ subject
100
+ expect(domain.name).to eq domain_name
101
+ end
102
+
103
+ context "and the --shared option is passed" do
104
+ subject { cf %W[map-domain #{domain.name} --organization #{organization.name} --shared] }
105
+
106
+ it "adds the domain to the organization" do
107
+ organization.should_receive(:add_domain).with(domain)
108
+ subject
109
+ end
110
+
111
+ it "does not add the domain to a specific organization" do
112
+ domain.stub(:create!)
113
+ subject
114
+ expect(domain.owning_organization).to be_nil
115
+ end
116
+ end
108
117
  end
109
118
 
110
- it "does not add the domain to a specific organization" do
111
- stub(domain).create!
112
- subject
113
- expect(domain.owning_organization).to be_nil
119
+ context "and the domain already exists" do
120
+ include_examples "binding a domain to an organization"
114
121
  end
115
122
  end
116
- end
117
123
 
118
- context "and the domain already exists" do
119
- include_examples "binding a domain to an organization"
120
- end
121
- end
124
+ context "when a domain, organization, and space is passed" do
125
+ subject { cf %W[map-domain #{domain.name} --space #{space.name} --organization #{organization.name}] }
122
126
 
123
- context 'when a domain, organization, and space is passed' do
124
- subject { cf %W[map-domain #{domain.name} --space #{space.name} --organization #{organization.name}] }
125
-
126
- include_examples "mapping a domain to a space"
127
- end
127
+ include_examples "mapping a domain to a space"
128
+ end
128
129
 
129
- context 'when only a domain is passed' do
130
- subject { cf %W[map-domain #{domain.name}] }
130
+ context "when only a domain is passed" do
131
+ subject { cf %W[map-domain #{domain.name}] }
131
132
 
132
- include_examples "mapping a domain to a space"
133
+ include_examples "mapping a domain to a space"
134
+ end
135
+ end
133
136
  end
134
137
  end
@@ -1,73 +1,77 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe CF::Domain::Unmap do
4
- before do
5
- stub_client_and_precondition
6
- end
3
+ module CF
4
+ module Domain
5
+ describe Unmap do
6
+ before do
7
+ stub_client_and_precondition
8
+ end
7
9
 
8
- let(:client) do
9
- fake_client(
10
- :current_organization => organization,
11
- :current_space => space,
12
- :spaces => [space],
13
- :organizations => [organization],
14
- :domains => [domain])
15
- end
10
+ let(:client) do
11
+ fake_client(
12
+ :current_organization => organization,
13
+ :current_space => space,
14
+ :spaces => [space],
15
+ :organizations => [organization],
16
+ :domains => [domain])
17
+ end
16
18
 
17
- let(:organization) { fake(:organization, :spaces => [space]) }
18
- let(:space) { fake(:space) }
19
- let(:domain) { fake(:domain, :name => "some.domain.com") }
19
+ let(:organization) { fake(:organization, :spaces => [space]) }
20
+ let(:space) { fake(:space) }
21
+ let(:domain) { fake(:domain, :name => "some.domain.com") }
20
22
 
21
- context "when the --delete flag is given" do
22
- subject { cf %W[unmap-domain #{domain.name} --delete] }
23
+ context "when the --delete flag is given" do
24
+ subject { cf %W[unmap-domain #{domain.name} --delete] }
23
25
 
24
- it "asks for a confirmation" do
25
- mock_ask("Really delete #{domain.name}?", :default => false) { false }
26
- stub(domain).delete!
27
- subject
28
- end
26
+ it "asks for a confirmation" do
27
+ mock_ask("Really delete #{domain.name}?", :default => false) { false }
28
+ domain.stub(:delete!)
29
+ subject
30
+ end
29
31
 
30
- context "and the user answers 'no' to the confirmation" do
31
- it "does NOT delete the domain" do
32
- stub_ask("Really delete #{domain.name}?", anything) { false }
33
- dont_allow(domain).delete!
34
- subject
35
- end
36
- end
32
+ context "and the user answers 'no' to the confirmation" do
33
+ it "does NOT delete the domain" do
34
+ stub_ask("Really delete #{domain.name}?", anything) { false }
35
+ domain.should_not_receive(:delete!)
36
+ subject
37
+ end
38
+ end
37
39
 
38
- context "and the user answers 'yes' to the confirmation" do
39
- it "deletes the domain" do
40
- stub_ask("Really delete #{domain.name}?", anything) { true }
41
- mock(domain).delete!
42
- subject
40
+ context "and the user answers 'yes' to the confirmation" do
41
+ it "deletes the domain" do
42
+ stub_ask("Really delete #{domain.name}?", anything) { true }
43
+ domain.should_receive(:delete!)
44
+ subject
45
+ end
46
+ end
43
47
  end
44
- end
45
- end
46
48
 
47
- context "when a space is given" do
48
- subject { cf %W[unmap-domain #{domain.name} --space #{space.name}] }
49
+ context "when a space is given" do
50
+ subject { cf %W[unmap-domain #{domain.name} --space #{space.name}] }
49
51
 
50
- it "unmaps the domain from the space" do
51
- mock(space).remove_domain(domain)
52
- subject
53
- end
54
- end
52
+ it "unmaps the domain from the space" do
53
+ space.should_receive(:remove_domain).with(domain)
54
+ subject
55
+ end
56
+ end
55
57
 
56
- context "when an organization is given" do
57
- subject { cf %W[unmap-domain #{domain.name} --organization #{organization.name}] }
58
+ context "when an organization is given" do
59
+ subject { cf %W[unmap-domain #{domain.name} --organization #{organization.name}] }
58
60
 
59
- it "unmaps the domain from the organization" do
60
- mock(organization).remove_domain(domain)
61
- subject
62
- end
63
- end
61
+ it "unmaps the domain from the organization" do
62
+ organization.should_receive(:remove_domain).with(domain)
63
+ subject
64
+ end
65
+ end
64
66
 
65
- context "when only the domain is given" do
66
- subject { cf %W[unmap-domain #{domain.name}] }
67
+ context "when only the domain is given" do
68
+ subject { cf %W[unmap-domain #{domain.name}] }
67
69
 
68
- it "unmaps the domain from the current space" do
69
- mock(client.current_space).remove_domain(domain)
70
- subject
70
+ it "unmaps the domain from the current space" do
71
+ client.current_space.should_receive(:remove_domain).with(domain)
72
+ subject
73
+ end
74
+ end
71
75
  end
72
76
  end
73
77
  end