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,105 +1,100 @@
1
- require 'spec_helper'
2
- require 'stringio'
3
-
4
- describe CF::Space::Spaces do
5
- let(:full) { false }
6
- let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
7
- let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
8
- let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
9
- let(:spaces) { [space_1, space_2, space_3]}
10
- let(:organization) { fake(:organization, :spaces => spaces, :name => 'foo') }
11
- let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
12
-
13
- before do
14
- any_instance_of described_class do |cli|
15
- stub(cli).client { client }
16
- stub(cli).check_logged_in
17
- stub(cli).check_target
18
- any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
19
- end
20
- end
1
+ require "spec_helper"
2
+
3
+ module CF
4
+ module Space
5
+ describe Spaces do
6
+ let(:full) { false }
7
+ let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
8
+ let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
9
+ let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
10
+ let(:spaces) { [space_1, space_2, space_3] }
11
+ let(:organization) { fake(:organization, :spaces => spaces, :name => "foo") }
12
+ let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
13
+
14
+ before do
15
+ stub_client_and_precondition
16
+ CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
17
+ end
21
18
 
22
- describe 'metadata' do
23
- let(:command) { Mothership.commands[:spaces] }
19
+ describe "metadata" do
20
+ let(:command) { Mothership.commands[:spaces] }
24
21
 
25
- describe 'command' do
26
- subject { command }
27
- its(:description) { should eq "List spaces in an organization" }
28
- it { expect(Mothership::Help.group(:spaces)).to include(subject) }
29
- end
22
+ describe "command" do
23
+ subject { command }
24
+ its(:description) { should eq "List spaces in an organization" }
25
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
26
+ end
30
27
 
31
- include_examples 'inputs must have descriptions'
28
+ include_examples "inputs must have descriptions"
32
29
 
33
- describe 'arguments' do
34
- subject { command.arguments }
35
- it 'has the correct argument order' do
36
- should eq([{ :type => :optional, :value => nil, :name => :organization }])
30
+ describe "arguments" do
31
+ subject { command.arguments }
32
+ it "has the correct argument order" do
33
+ should eq([{:type => :optional, :value => nil, :name => :organization}])
34
+ end
35
+ end
37
36
  end
38
- end
39
- end
40
37
 
41
- subject { cf %W[spaces --#{bool_flag(:full)} --no-quiet] }
38
+ subject { cf %W[spaces --#{bool_flag(:full)} --no-quiet] }
42
39
 
43
- it 'outputs that it is getting spaces' do
44
- subject
40
+ it "outputs that it is getting spaces" do
41
+ subject
45
42
 
46
- stdout.rewind
47
- expect(stdout.readline).to match /Getting spaces.*OK/
48
- expect(stdout.readline).to eq "\n"
49
- end
43
+ stdout.rewind
44
+ expect(stdout.readline).to match /Getting spaces.*OK/
45
+ expect(stdout.readline).to eq "\n"
46
+ end
50
47
 
51
- context 'when there are no spaces' do
52
- let(:spaces) { [] }
48
+ context "when there are no spaces" do
49
+ let(:spaces) { [] }
53
50
 
54
- context 'and the full flag is given' do
55
- let(:full) { true }
51
+ context "and the full flag is given" do
52
+ let(:full) { true }
56
53
 
57
- it 'displays yaml-style output with all space details' do
58
- any_instance_of CF::Space::Spaces do |spaces|
59
- dont_allow(spaces).invoke
54
+ it "displays yaml-style output with all space details" do
55
+ CF::Space::Spaces.any_instance.should_not_receive(:invoke)
56
+ subject
57
+ end
60
58
  end
61
- subject
62
- end
63
- end
64
59
 
65
- context 'and the full flag is not given (default is false)' do
66
- it 'should show only the progress' do
67
- subject
60
+ context "and the full flag is not given (default is false)" do
61
+ it "should show only the progress" do
62
+ subject
68
63
 
69
- stdout.rewind
70
- expect(stdout.readline).to match /Getting spaces.*OK/
71
- expect(stdout).to be_eof
64
+ stdout.rewind
65
+ expect(stdout.readline).to match /Getting spaces.*OK/
66
+ expect(stdout).to be_eof
67
+ end
68
+ end
72
69
  end
73
- end
74
- end
75
70
 
76
- context 'when there are spaces' do
77
- context 'and the full flag is given' do
78
- let(:full) { true }
71
+ context "when there are spaces" do
72
+ context "and the full flag is given" do
73
+ let(:full) { true }
79
74
 
80
- it 'displays yaml-style output with all space details' do
81
- any_instance_of CF::Space::Spaces do |spaces|
82
- mock(spaces).invoke(:space, :space => space_2, :full => true).ordered
83
- mock(spaces).invoke(:space, :space => space_1, :full => true).ordered
84
- mock(spaces).invoke(:space, :space => space_3, :full => true).ordered
75
+ it "displays yaml-style output with all space details" do
76
+ CF::Space::Spaces.any_instance.should_receive(:invoke).with(:space, :space => space_2, :full => true)
77
+ CF::Space::Spaces.any_instance.should_receive(:invoke).with(:space, :space => space_1, :full => true)
78
+ CF::Space::Spaces.any_instance.should_receive(:invoke).with(:space, :space => space_3, :full => true)
79
+ subject
80
+ end
85
81
  end
86
- subject
87
- end
88
- end
89
82
 
90
- context 'and the full flag is not given (default is false)' do
91
- it 'displays tabular output with names, spaces and domains' do
92
- subject
83
+ context "and the full flag is not given (default is false)" do
84
+ it "displays tabular output with names, spaces and domains" do
85
+ subject
93
86
 
94
- stdout.rewind
95
- stdout.readline
96
- stdout.readline
87
+ stdout.rewind
88
+ stdout.readline
89
+ stdout.readline
97
90
 
98
- expect(stdout.readline).to match /name\s+apps\s+services/
99
- spaces.sort_by(&:name).each do |space|
100
- expect(stdout.readline).to match /#{space.name}\s+#{name_list(space.apps)}\s+#{name_list(space.service_instances)}/
91
+ expect(stdout.readline).to match /name\s+apps\s+services/
92
+ spaces.sort_by(&:name).each do |space|
93
+ expect(stdout.readline).to match /#{space.name}\s+#{name_list(space.apps)}\s+#{name_list(space.service_instances)}/
94
+ end
95
+ expect(stdout).to be_eof
96
+ end
101
97
  end
102
- expect(stdout).to be_eof
103
98
  end
104
99
  end
105
100
  end
@@ -1,60 +1,57 @@
1
- require 'spec_helper'
2
- require "cf/cli/space/switch"
3
-
4
- describe CF::Space::Switch do
5
- let(:space_to_switch_to) { spaces.last }
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
-
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
1
+ require "spec_helper"
2
+
3
+ module CF
4
+ module Space
5
+ describe Switch do
6
+ let(:space_to_switch_to) { spaces.last }
7
+ let(:spaces) { fake_list(:space, 3) }
8
+ let(:organization) { fake(:organization, :spaces => spaces) }
9
+ let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
10
+
11
+ before do
12
+ CF::Space::Base.any_instance.stub(:client) { client }
13
+ CF::Space::Base.any_instance.stub(:precondition)
14
+ CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
15
+ end
19
16
 
20
- describe 'metadata' do
21
- let(:command) { Mothership.commands[:switch_space] }
17
+ describe "metadata" do
18
+ let(:command) { Mothership.commands[:switch_space] }
22
19
 
23
- describe 'command' do
24
- subject { command }
25
- its(:description) { should eq "Switch to a space" }
26
- it { expect(Mothership::Help.group(:spaces)).to include(subject) }
27
- end
20
+ describe "command" do
21
+ subject { command }
22
+ its(:description) { should eq "Switch to a space" }
23
+ it { expect(Mothership::Help.group(:spaces)).to include(subject) }
24
+ end
28
25
 
29
- include_examples 'inputs must have descriptions'
26
+ include_examples "inputs must have descriptions"
30
27
 
31
- describe 'arguments' do
32
- subject { command.arguments }
33
- it 'has the correct argument order' do
34
- should eq([{:type => :normal, :value => nil, :name => :name}])
28
+ describe "arguments" do
29
+ subject { command.arguments }
30
+ it "has the correct argument order" do
31
+ should eq([{:type => :normal, :value => nil, :name => :name}])
32
+ end
33
+ end
35
34
  end
36
- end
37
- end
38
35
 
39
- subject { cf %W[--no-quiet switch-space #{space_to_switch_to.name} --no-color] }
36
+ subject { cf %W[--no-quiet switch-space #{space_to_switch_to.name} --no-color] }
40
37
 
41
- context "when the space exists" do
42
- before do
43
- any_instance_of(Mothership) do |m|
44
- mock(m).invoke(:target, {:space => space_to_switch_to})
45
- end
46
- end
38
+ context "when the space exists" do
39
+ before do
40
+ Mothership.any_instance.should_receive(:invoke).with(:target, {:space => space_to_switch_to})
41
+ end
47
42
 
48
- it "switches to that space" do
49
- subject
50
- end
51
- end
43
+ it "switches to that space" do
44
+ subject
45
+ end
46
+ end
52
47
 
53
- context "when the space does not exist" do
54
- let(:space_to_switch_to) { fake(:space, :name => "unique-name") }
48
+ context "when the space does not exist" do
49
+ let(:space_to_switch_to) { fake(:space, :name => "unique-name") }
55
50
 
56
- it_behaves_like "an error that gets passed through",
57
- :with_exception => CF::UserError,
58
- :with_message => "The space unique-name does not exist, please create the space first."
51
+ it_behaves_like "an error that gets passed through",
52
+ :with_exception => CF::UserError,
53
+ :with_message => "The space unique-name does not exist, please create the space first."
54
+ end
55
+ end
59
56
  end
60
57
  end
@@ -16,9 +16,7 @@ describe CF::Start::Info do
16
16
  end
17
17
 
18
18
  before do
19
- any_instance_of described_class do |cli|
20
- stub(cli).client { client }
21
- end
19
+ described_class.any_instance.stub(:client).and_return(client)
22
20
  end
23
21
 
24
22
  describe 'metadata' do
@@ -50,7 +48,7 @@ describe CF::Start::Info do
50
48
 
51
49
  context 'when given no flags' do
52
50
  it "displays target information" do
53
- mock(client).info { target_info }
51
+ client.should_receive(:info).and_return(target_info)
54
52
 
55
53
  subject
56
54
 
@@ -67,7 +65,7 @@ describe CF::Start::Info do
67
65
  let(:services) { true }
68
66
 
69
67
  it 'does not grab /info' do
70
- dont_allow(client).info
68
+ client.should_not_receive(:info)
71
69
  subject
72
70
  end
73
71
 
@@ -89,7 +87,7 @@ describe CF::Start::Info do
89
87
  let(:all) { true }
90
88
 
91
89
  it 'runs as --services' do
92
- mock(client).info { target_info }
90
+ client.should_receive(:info).and_return(target_info)
93
91
 
94
92
  subject
95
93
 
@@ -1,24 +1,24 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe CF::Start::Login do
4
4
  let(:client) { fake_client }
5
5
 
6
- describe 'metadata' do
6
+ describe "metadata" do
7
7
  before do
8
8
  stub_client_and_precondition
9
9
  end
10
10
 
11
11
  let(:command) { Mothership.commands[:login] }
12
12
 
13
- describe 'command' do
13
+ describe "command" do
14
14
  subject { command }
15
15
  its(:description) { should eq "Authenticate with the target" }
16
16
  specify { expect(Mothership::Help.group(:start)).to include(subject) }
17
17
  end
18
18
 
19
- include_examples 'inputs must have descriptions'
19
+ include_examples "inputs must have descriptions"
20
20
 
21
- describe 'flags' do
21
+ describe "flags" do
22
22
  subject { command.flags }
23
23
 
24
24
  its(["-o"]) { should eq :organization }
@@ -27,9 +27,9 @@ describe CF::Start::Login do
27
27
  its(["-s"]) { should eq :space }
28
28
  end
29
29
 
30
- describe 'arguments' do
30
+ describe "arguments" do
31
31
  subject(:arguments) { command.arguments }
32
- it 'have the correct commands' do
32
+ it "have the correct commands" do
33
33
  expect(arguments).to eq [{:type => :optional, :value => :email, :name => :username}]
34
34
  end
35
35
  end
@@ -44,26 +44,25 @@ describe CF::Start::Login do
44
44
 
45
45
  let(:auth_token) { CFoundry::AuthToken.new("bearer some-new-access-token", "some-new-refresh-token") }
46
46
  let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
47
- let(:tokens_file_path) { '~/.cf/tokens.yml' }
47
+ let(:tokens_file_path) { "~/.cf/tokens.yml" }
48
48
 
49
49
  before do
50
- stub(client).login("my-username", "my-password") { auth_token }
51
- stub(client).login_prompts do
52
- {
53
- :username => ["text", "Username"],
54
- :password => ["password", "8-digit PIN"]
55
- }
56
- end
50
+ client.stub(:login).with("my-username", "my-password") { auth_token }
51
+ client.stub(:login_prompts).and_return(
52
+ {
53
+ :username => ["text", "Username"],
54
+ :password => ["password", "8-digit PIN"]
55
+ })
57
56
 
58
57
  stub_ask("Username", {}) { "my-username" }
59
58
  stub_ask("8-digit PIN", {:echo => "*", :forget => true}) { "my-password" }
60
- any_instance_of(CF::Populators::Target, :populate_and_save! => true)
61
59
  end
62
60
 
63
61
  subject { cf ["login"] }
64
62
 
65
63
  context "when there is a target" do
66
64
  before do
65
+ CF::Populators::Target.any_instance.stub(:populate_and_save!)
67
66
  stub_precondition
68
67
  end
69
68
 
@@ -75,13 +74,13 @@ describe CF::Start::Login do
75
74
  end
76
75
 
77
76
  it "calls use a PopulateTarget to ensure that an organization and space is set" do
78
- mock(CF::Populators::Target).new(is_a(Mothership::Inputs)) { mock!.populate_and_save! }
77
+ CF::Populators::Target.should_receive(:new) { double(:target, :populate_and_save! => true) }
79
78
  subject
80
79
  end
81
80
 
82
81
  context "when the user logs in with invalid credentials" do
83
82
  before do
84
- stub(client).login("my-username", "my-password") { raise CFoundry::Denied }
83
+ client.should_receive(:login).with("my-username", "my-password").and_raise(CFoundry::Denied)
85
84
  end
86
85
 
87
86
  it "informs the user gracefully" do
@@ -92,9 +91,8 @@ describe CF::Start::Login do
92
91
  end
93
92
 
94
93
  context "when there is no target" do
95
- let(:client) { nil }
96
-
97
94
  it "tells the user to select a target" do
95
+ client.stub(:target) { nil }
98
96
  subject
99
97
  expect(error_output).to say("Please select a target with 'cf target'.")
100
98
  end
@@ -1,50 +1,49 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe CF::Start::Logout do
4
- let(:client) { fake_client }
3
+ module CF
4
+ module Start
5
+ describe Logout do
6
+ let(:client) { fake_client }
5
7
 
6
- before do
7
- any_instance_of described_class do |cli|
8
- stub(cli).client { client }
9
- end
10
- end
8
+ before do
9
+ described_class.any_instance.stub(:client) { client }
10
+ end
11
11
 
12
- describe 'metadata' do
13
- let(:command) { Mothership.commands[:logout] }
12
+ describe "metadata" do
13
+ let(:command) { Mothership.commands[:logout] }
14
14
 
15
- describe 'command' do
16
- subject { command }
17
- its(:description) { should eq "Log out from the target" }
18
- it { expect(Mothership::Help.group(:start)).to include(subject) }
19
- end
20
- end
15
+ describe "command" do
16
+ subject { command }
17
+ its(:description) { should eq "Log out from the target" }
18
+ it { expect(Mothership::Help.group(:start)).to include(subject) }
19
+ end
20
+ end
21
21
 
22
- describe "running the command" do
23
- subject { cf ["logout"] }
22
+ describe "running the command" do
23
+ subject { cf ["logout"] }
24
24
 
25
- context "when there is a target" do
26
- let(:info) { { client.target => "x", "abc" => "x" } }
25
+ context "when there is a target" do
26
+ let(:info) { {client.target => "x", "abc" => "x"} }
27
27
 
28
- before do
29
- any_instance_of CF::CLI do |cli|
30
- stub(cli).targets_info { info }
31
- stub(cli).client_target { client.target }
28
+ before do
29
+ CF::CLI.any_instance.stub(:targets_info) { info }
30
+ CF::CLI.any_instance.stub(:client_target) { client.target }
31
+ end
32
+
33
+ it "removes the target info from the tokens file" do
34
+ expect {
35
+ subject
36
+ }.to change { info }.to("abc" => "x")
37
+ end
32
38
  end
33
- end
34
39
 
35
- it "removes the target info from the tokens file" do
36
- expect {
37
- subject
38
- }.to change { info }.to("abc" => "x")
40
+ context "when there is no target" do
41
+ let(:client) { nil }
42
+ it_behaves_like "an error that gets passed through",
43
+ :with_exception => CF::UserError,
44
+ :with_message => "Please select a target with 'cf target'."
45
+ end
39
46
  end
40
47
  end
41
-
42
- context "when there is no target" do
43
- let(:client) { nil }
44
- it_behaves_like "an error that gets passed through",
45
- :with_exception => CF::UserError,
46
- :with_message => "Please select a target with 'cf target'."
47
- end
48
48
  end
49
49
  end
50
-