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,155 +1,153 @@
1
1
  require "spec_helper"
2
- require "webmock/rspec"
3
- require "cf/cli/populators/organization"
4
-
5
- describe CF::Populators::Organization do
6
- stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
7
-
8
- describe "#populate_and_save!" do
9
- let(:tokens_file_path) { CF::TOKENS_FILE }
10
- let(:user) { stub! }
11
- let(:organizations) do
12
- [
13
- fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]),
14
- fake(:organization, :guid => "organization-id-2")
15
- ]
16
- end
17
- let(:organization) { organizations.first }
18
- let(:client) { fake_client :organizations => organizations }
19
-
20
- let(:input) { {:organization => organization} }
21
- let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
22
- let(:populator) { populator = CF::Populators::Organization.new(Mothership::Inputs.new(nil, nil, input)) }
23
-
24
- before do
25
- stub(client).current_user { user }
26
- stub(client).organization { organization }
27
- stub(client).current_organization { organization }
28
- stub(client).target { 'https://api.some-domain.com' }
29
- any_instance_of(described_class) do |instance|
30
- stub(instance).client { client }
31
- end
32
2
 
33
- write_token_file({:organization => "organization-id-1"})
34
- end
3
+ module CF
4
+ module Populators
5
+ describe Organization do
6
+ stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
7
+
8
+ describe "#populate_and_save!" do
9
+ let(:tokens_file_path) { CF::TOKENS_FILE }
10
+ let(:user) { build(:user) }
11
+ let(:organizations) do
12
+ [
13
+ double(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]),
14
+ double(:organization, :name => "Other Org", :guid => "organization-id-2")
15
+ ]
16
+ end
17
+ let(:organization) { organizations.first }
18
+ let(:client) { fake_client :organizations => organizations }
35
19
 
36
- subject do
37
- capture_output { populator.populate_and_save! }
38
- end
20
+ let(:input) { {:organization => organization} }
21
+ let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
22
+ let(:populator) { populator = CF::Populators::Organization.new(Mothership::Inputs.new(nil, nil, input)) }
39
23
 
40
- it "updates the client with the new organization" do
41
- write_token_file({:organization => "organization-id-2"})
42
- any_instance_of(described_class) do |instance|
43
- stub.proxy(instance).client
44
- end
45
- populator.client.current_organization.guid.should == "organization-id-2"
24
+ before do
25
+ client.stub(:current_user).and_return(user)
26
+ client.stub(:organization).and_return(organization)
27
+ client.stub(:current_organization).and_return(organization)
28
+ client.stub(:target).and_return('https://api.some-domain.com')
29
+ described_class.any_instance.stub(:client).and_return(client)
46
30
 
47
- subject
31
+ write_token_file({:organization => "organization-id-1"})
32
+ end
48
33
 
49
- populator.client.current_organization.guid.should == "organization-id-1"
50
- end
34
+ subject do
35
+ capture_output { populator.populate_and_save! }
36
+ end
51
37
 
52
- it "returns the organization" do
53
- subject.should == organization
54
- end
38
+ it "updates the client with the new organization" do
39
+ write_token_file({:organization => "organization-id-2"})
40
+ described_class.any_instance.unstub(:client)
41
+ populator.client.current_organization.guid.should == "organization-id-2"
55
42
 
56
- context "with an organization in the input" do
57
- let(:input) { {:organization => organization} }
58
- before { write_token_file({:organization => "organization-id-2"}) }
43
+ subject
59
44
 
60
- it "uses that organization" do
61
- subject.should == organization
62
- end
45
+ populator.client.current_organization.guid.should == "organization-id-1"
46
+ end
63
47
 
64
- it "should not reprompt for organization" do
65
- dont_allow_ask("Organization", anything)
66
- subject
67
- end
48
+ it "returns the organization" do
49
+ subject.should == organization
50
+ end
68
51
 
69
- it "sets the organization in the token file" do
70
- subject
71
- expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
72
- end
52
+ context "with an organization in the input" do
53
+ let(:input) { {:organization => organization} }
54
+ before { write_token_file({:organization => "organization-id-2"}) }
73
55
 
74
- it "prints out that it is switching to that organization" do
75
- subject
76
- expect(output).to say("Switching to organization #{organization.name}")
77
- end
56
+ it "uses that organization" do
57
+ subject.should == organization
58
+ end
78
59
 
79
- context "and a different organization and space in the token file" do
80
- let(:input) { {:organization => organizations.last} }
60
+ it "should not reprompt for organization" do
61
+ dont_allow_ask("Organization", anything)
62
+ subject
63
+ end
81
64
 
82
- before do
83
- write_token_file({:organization => "organization-id-1", :space => "should-be-removed"})
84
- end
65
+ it "sets the organization in the token file" do
66
+ subject
67
+ expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
68
+ end
85
69
 
86
- it "removes the space from the token file" do
87
- subject
88
- refreshed_tokens = YAML.load_file(File.expand_path(tokens_file_path))
89
- expect(refreshed_tokens["https://api.some-domain.com"][:space]).to be_nil
90
- end
70
+ it "prints out that it is switching to that organization" do
71
+ subject
72
+ expect(output).to say("Switching to organization #{organization.name}")
73
+ end
91
74
 
92
- end
75
+ context "and a different organization and space in the token file" do
76
+ let(:input) { {:organization => organizations.last} }
93
77
 
94
- context "and the same organization and a space in the token file" do
95
- before do
96
- write_token_file({:organization => "organization-id-1", :space => "should-not-be-removed"})
97
- end
78
+ before do
79
+ write_token_file({:organization => "organization-id-1", :space => "should-be-removed"})
80
+ end
98
81
 
99
- it "does not remove the space from the token file" do
100
- subject
101
- expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "should-not-be-removed"
102
- end
103
- end
82
+ it "removes the space from the token file" do
83
+ subject
84
+ refreshed_tokens = YAML.load_file(File.expand_path(tokens_file_path))
85
+ expect(refreshed_tokens["https://api.some-domain.com"][:space]).to be_nil
86
+ end
104
87
 
105
- end
88
+ end
106
89
 
107
- context "without an organization in the input" do
108
- let(:input) { {} }
90
+ context "and the same organization and a space in the token file" do
91
+ before do
92
+ write_token_file({:organization => "organization-id-1", :space => "should-not-be-removed"})
93
+ end
109
94
 
110
- context "with an organization in the config file" do
111
- it "should not reprompt for organization" do
112
- dont_allow_ask("Organization", anything)
113
- subject
114
- end
95
+ it "does not remove the space from the token file" do
96
+ subject
97
+ expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "should-not-be-removed"
98
+ end
99
+ end
115
100
 
116
- it "sets the organization in the token file" do
117
- subject
118
- expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
119
101
  end
120
102
 
121
- context "but that organization doesn't exist anymore (not valid)" do
122
- before { stub(organization).users { raise CFoundry::APIError } }
103
+ context "without an organization in the input" do
104
+ let(:input) { {} }
123
105
 
124
- it "asks the user for an organization" do
125
- mock_ask("Organization", anything) { organization }
126
- subject
106
+ context "with an organization in the config file" do
107
+ it "should not reprompt for organization" do
108
+ dont_allow_ask("Organization", anything)
109
+ subject
110
+ end
111
+
112
+ it "sets the organization in the token file" do
113
+ subject
114
+ expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
115
+ end
116
+
117
+ context "but that organization doesn't exist anymore (not valid)" do
118
+ before { organization.stub(:users).and_raise(CFoundry::APIError) }
119
+
120
+ it "asks the user for an organization" do
121
+ mock_ask("Organization", anything) { organization }
122
+ subject
123
+ end
124
+ end
127
125
  end
128
- end
129
- end
130
126
 
131
- context "without an organization in the config file" do
132
- before { write_token_file({}) }
127
+ context "without an organization in the config file" do
128
+ before { write_token_file({}) }
133
129
 
134
- it "prompts for the organization" do
135
- mock_ask("Organization", anything) { organization }
136
- subject
130
+ it "prompts for the organization" do
131
+ mock_ask("Organization", anything) { organization }
132
+ subject
137
133
 
138
- expect(output).to say("Switching to organization #{organization.name}")
139
- end
134
+ expect(output).to say("Switching to organization #{organization.name}")
135
+ end
140
136
 
141
- it "sets the organization in the token file" do
142
- mock_ask("Organization", anything) { organization }
137
+ it "sets the organization in the token file" do
138
+ mock_ask("Organization", anything) { organization }
143
139
 
144
- subject
145
- expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
146
- end
140
+ subject
141
+ expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
142
+ end
147
143
 
148
- context "when the user has no organizations" do
149
- let(:client) { fake_client :organizations => [] }
144
+ context "when the user has no organizations" do
145
+ let(:client) { fake_client :organizations => [] }
150
146
 
151
- it "tells the user to create one by raising a UserFriendlyError" do
152
- expect { subject }.to raise_error(CF::UserFriendlyError, /There are no organizations/)
147
+ it "tells the user to create one by raising a UserFriendlyError" do
148
+ expect { subject }.to raise_error(CF::UserFriendlyError, /There are no organizations/)
149
+ end
150
+ end
153
151
  end
154
152
  end
155
153
  end
@@ -1,142 +1,141 @@
1
1
  require "spec_helper"
2
- require "webmock/rspec"
3
- require "cf/cli/populators/space"
4
-
5
- describe CF::Populators::Space do
6
- stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
7
-
8
- describe "#populate_and_save!" do
9
- let(:tokens_file_path) { "~/.cf/tokens.yml" }
10
- let(:spaces) {
11
- [fake(:space, :name => "Development", :guid => "space-id-1", :developers => [user]),
12
- fake(:space, :name => "Staging", :guid => "space-id-2")]
13
- }
14
-
15
- let(:user) { stub! }
16
- let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => spaces) }
17
- let(:space) { spaces.first }
18
- let(:client) do
19
- fake_client :organizations => [organization]
20
- end
21
-
22
- let(:input_hash) { {:space => space} }
23
- let(:inputs) { Mothership::Inputs.new(nil, nil, input_hash) }
24
- let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
25
- let(:populator) { CF::Populators::Space.new(inputs, organization) }
26
2
 
27
- before do
28
- stub(client).current_user { user }
29
- stub(client).space { space }
30
- any_instance_of(described_class) do |instance|
31
- stub(instance).client { client }
32
- end
3
+ module CF
4
+ module Populators
33
5
 
34
- write_token_file({:space => "space-id-1", :organization => "organization-id-1"})
35
- end
6
+ describe Space do
7
+ stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
36
8
 
37
- subject do
38
- capture_output { populator.populate_and_save! }
39
- end
9
+ describe "#populate_and_save!" do
10
+ let(:tokens_file_path) { "~/.cf/tokens.yml" }
11
+ let(:spaces) {
12
+ [double(:space, :name => "Development", :guid => "space-id-1", :developers => [user]),
13
+ double(:space, :name => "Staging", :guid => "space-id-2")]
14
+ }
40
15
 
41
- it "updates the client with the new space" do
42
- write_token_file({:space => "space-id-2"})
43
- any_instance_of(described_class) do |instance|
44
- stub.proxy(instance).client
45
- end
46
- populator.client.current_space.guid.should == "space-id-2"
16
+ let(:user) { build(:user) }
17
+ let(:organization) { double(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => spaces) }
18
+ let(:space) { spaces.first }
19
+ let(:client) do
20
+ fake_client :organizations => [organization]
21
+ end
47
22
 
48
- subject
23
+ let(:input_hash) { {:space => space} }
24
+ let(:inputs) { Mothership::Inputs.new(nil, nil, input_hash) }
25
+ let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
26
+ let(:populator) { CF::Populators::Space.new(inputs, organization) }
49
27
 
50
- populator.client.current_space.guid.should == "space-id-1"
51
- end
28
+ before do
29
+ client.stub(:current_user).and_return(user)
30
+ client.stub(:space).and_return(space)
31
+ described_class.any_instance.stub(:client).and_return(client)
52
32
 
53
- it "returns the space" do
54
- subject.should == space
55
- end
33
+ write_token_file({:space => "space-id-1", :organization => "organization-id-1"})
34
+ end
56
35
 
57
- describe "mothership input arguments" do
58
- let(:inputs) do
59
- Mothership::Inputs.new(nil, nil, input_hash).tap do |input|
60
- mock(input).[](:space, organization) { space }
61
- stub(input).[](anything) { space }
36
+ subject do
37
+ capture_output { populator.populate_and_save! }
62
38
  end
63
- end
64
39
 
65
- it "passes through extra arguments to the input call" do
66
- subject
67
- end
68
- end
40
+ it "updates the client with the new space" do
41
+ write_token_file({:space => "space-id-2"})
42
+ described_class.any_instance.unstub(:client)
43
+ populator.client.current_space.guid.should == "space-id-2"
69
44
 
70
- context "with a space in the input" do
71
- let(:input_hash) { {:space => space} }
72
- before { write_token_file({:space => "space-id-2"}) }
45
+ subject
73
46
 
74
- it "uses that space" do
75
- subject.should == space
76
- end
47
+ populator.client.current_space.guid.should == "space-id-1"
48
+ end
77
49
 
78
- it "should not reprompt for space" do
79
- dont_allow_ask("Space", anything)
80
- subject
81
- end
50
+ it "returns the space" do
51
+ subject.should == space
52
+ end
82
53
 
83
- it "sets the space in the token file" do
84
- subject
85
- expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
86
- end
54
+ describe "mothership input arguments" do
55
+ let(:inputs) do
56
+ Mothership::Inputs.new(nil, nil, input_hash).tap do |input|
57
+ input.should_receive(:[]).with(:space, organization).and_return(space)
58
+ input.stub(:[]).and_return(space)
59
+ end
60
+ end
87
61
 
88
- it "prints out that it is switching to that space" do
89
- subject
90
- expect(output).to say("Switching to space #{space.name}")
91
- end
92
- end
62
+ it "passes through extra arguments to the input call" do
63
+ subject
64
+ end
65
+ end
93
66
 
94
- context "without a space in the input" do
95
- let(:input_hash) { {} }
67
+ context "with a space in the input" do
68
+ let(:input_hash) { {:space => space} }
69
+ before { write_token_file({:space => "space-id-2"}) }
96
70
 
97
- context "with a space in the config file" do
98
- it "should not reprompt for space" do
99
- dont_allow_ask("Space", anything)
100
- subject
101
- end
71
+ it "uses that space" do
72
+ subject.should == space
73
+ end
102
74
 
103
- it "sets the space in the token file" do
104
- subject
105
- expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
106
- end
75
+ it "should not reprompt for space" do
76
+ dont_allow_ask("Space", anything)
77
+ subject
78
+ end
107
79
 
108
- context "but that space doesn't exist anymore (not valid)" do
109
- before { stub(space).developers { raise CFoundry::APIError } }
80
+ it "sets the space in the token file" do
81
+ subject
82
+ expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
83
+ end
110
84
 
111
- it "asks the user for an space" do
112
- mock_ask("Space", anything) { space }
85
+ it "prints out that it is switching to that space" do
113
86
  subject
87
+ expect(output).to say("Switching to space #{space.name}")
114
88
  end
115
89
  end
116
- end
117
90
 
118
- context "without a space in the config file" do
119
- before { write_token_file({}) }
91
+ context "without a space in the input" do
92
+ let(:input_hash) { {} }
120
93
 
121
- it "prompts for the space" do
122
- mock_ask("Space", anything) { space }
123
- subject
94
+ context "with a space in the config file" do
95
+ it "should not reprompt for space" do
96
+ dont_allow_ask("Space", anything)
97
+ subject
98
+ end
124
99
 
125
- expect(output).to say("Switching to space #{space.name}")
126
- end
100
+ it "sets the space in the token file" do
101
+ subject
102
+ expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
103
+ end
127
104
 
128
- it "sets the space in the token file" do
129
- mock_ask("Space", anything) { space }
105
+ context "but that space doesn't exist anymore (not valid)" do
106
+ before { space.stub(:developers).and_raise(CFoundry::APIError) }
130
107
 
131
- subject
132
- expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
133
- end
108
+ it "asks the user for an space" do
109
+ mock_ask("Space", anything) { space }
110
+ subject
111
+ end
112
+ end
113
+ end
114
+
115
+ context "without a space in the config file" do
116
+ before { write_token_file({}) }
117
+
118
+ it "prompts for the space" do
119
+ mock_ask("Space", anything) { space }
120
+ subject
121
+
122
+ expect(output).to say("Switching to space #{space.name}")
123
+ end
124
+
125
+ it "sets the space in the token file" do
126
+ mock_ask("Space", anything) { space }
127
+
128
+ subject
129
+ expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
130
+ end
134
131
 
135
- context "when the user has no spaces in that organization" do
136
- let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]) }
132
+ context "when the user has no spaces in that organization" do
133
+ let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]) }
137
134
 
138
- it "tells the user to create one by raising a UserFriendlyError" do
139
- expect { subject }.to raise_error(CF::UserFriendlyError, /There are no spaces/)
135
+ it "tells the user to create one by raising a UserFriendlyError" do
136
+ expect { subject }.to raise_error(CF::UserFriendlyError, /There are no spaces/)
137
+ end
138
+ end
140
139
  end
141
140
  end
142
141
  end