af 0.3.22 → 0.5.0.beta.1

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 (157) hide show
  1. checksums.yaml +14 -6
  2. data/LICENSE +1277 -24
  3. data/Rakefile +24 -87
  4. data/bin/af +7 -2
  5. data/lib/af/version.rb +3 -0
  6. data/lib/vmc.rb +7 -2
  7. data/lib/vmc/cli.rb +475 -0
  8. data/lib/vmc/cli/app/app.rb +45 -0
  9. data/lib/vmc/cli/app/apps.rb +105 -0
  10. data/lib/vmc/cli/app/base.rb +82 -0
  11. data/lib/vmc/cli/app/crashes.rb +46 -0
  12. data/lib/vmc/cli/app/delete.rb +95 -0
  13. data/lib/vmc/cli/app/deprecated.rb +11 -0
  14. data/lib/vmc/cli/app/env.rb +78 -0
  15. data/lib/vmc/cli/app/files.rb +137 -0
  16. data/lib/vmc/cli/app/health.rb +26 -0
  17. data/lib/vmc/cli/app/instances.rb +53 -0
  18. data/lib/vmc/cli/app/logs.rb +76 -0
  19. data/lib/vmc/cli/app/push.rb +107 -0
  20. data/lib/vmc/cli/app/push/create.rb +150 -0
  21. data/lib/vmc/cli/app/push/interactions.rb +100 -0
  22. data/lib/vmc/cli/app/push/sync.rb +64 -0
  23. data/lib/vmc/cli/app/rename.rb +39 -0
  24. data/lib/vmc/cli/app/restart.rb +20 -0
  25. data/lib/vmc/cli/app/scale.rb +71 -0
  26. data/lib/vmc/cli/app/start.rb +93 -0
  27. data/lib/vmc/cli/app/stats.rb +67 -0
  28. data/lib/vmc/cli/app/stop.rb +27 -0
  29. data/lib/vmc/cli/domain/base.rb +12 -0
  30. data/lib/vmc/cli/domain/domains.rb +40 -0
  31. data/lib/vmc/cli/domain/map.rb +55 -0
  32. data/lib/vmc/cli/domain/unmap.rb +56 -0
  33. data/lib/vmc/cli/help.rb +16 -0
  34. data/lib/vmc/cli/interactive.rb +105 -0
  35. data/lib/vmc/cli/organization/base.rb +14 -0
  36. data/lib/vmc/cli/organization/create.rb +32 -0
  37. data/lib/vmc/cli/organization/delete.rb +73 -0
  38. data/lib/vmc/cli/organization/org.rb +45 -0
  39. data/lib/vmc/cli/organization/orgs.rb +35 -0
  40. data/lib/vmc/cli/organization/rename.rb +36 -0
  41. data/lib/vmc/cli/route/base.rb +12 -0
  42. data/lib/vmc/cli/route/map.rb +80 -0
  43. data/lib/vmc/cli/route/routes.rb +26 -0
  44. data/lib/vmc/cli/route/unmap.rb +94 -0
  45. data/lib/vmc/cli/service/base.rb +8 -0
  46. data/lib/vmc/cli/service/bind.rb +44 -0
  47. data/lib/vmc/cli/service/create.rb +126 -0
  48. data/lib/vmc/cli/service/delete.rb +86 -0
  49. data/lib/vmc/cli/service/rename.rb +35 -0
  50. data/lib/vmc/cli/service/service.rb +42 -0
  51. data/lib/vmc/cli/service/services.rb +115 -0
  52. data/lib/vmc/cli/service/unbind.rb +38 -0
  53. data/lib/vmc/cli/space/base.rb +21 -0
  54. data/lib/vmc/cli/space/create.rb +56 -0
  55. data/lib/vmc/cli/space/delete.rb +95 -0
  56. data/lib/vmc/cli/space/rename.rb +39 -0
  57. data/lib/vmc/cli/space/space.rb +64 -0
  58. data/lib/vmc/cli/space/spaces.rb +55 -0
  59. data/lib/vmc/cli/space/take.rb +16 -0
  60. data/lib/vmc/cli/start/base.rb +80 -0
  61. data/lib/vmc/cli/start/colors.rb +13 -0
  62. data/lib/vmc/cli/start/info.rb +122 -0
  63. data/lib/vmc/cli/start/login.rb +92 -0
  64. data/lib/vmc/cli/start/logout.rb +13 -0
  65. data/lib/vmc/cli/start/target.rb +64 -0
  66. data/lib/vmc/cli/start/target_interactions.rb +37 -0
  67. data/lib/vmc/cli/start/targets.rb +16 -0
  68. data/lib/vmc/cli/user/base.rb +29 -0
  69. data/lib/vmc/cli/user/create.rb +39 -0
  70. data/lib/vmc/cli/user/delete.rb +25 -0
  71. data/lib/vmc/cli/user/passwd.rb +50 -0
  72. data/lib/vmc/cli/user/register.rb +42 -0
  73. data/lib/vmc/cli/user/users.rb +32 -0
  74. data/lib/vmc/constants.rb +13 -0
  75. data/lib/vmc/detect.rb +134 -0
  76. data/lib/vmc/errors.rb +17 -0
  77. data/lib/vmc/plugin.rb +56 -0
  78. data/lib/vmc/spacing.rb +89 -0
  79. data/lib/vmc/spec_helper.rb +1 -0
  80. data/lib/vmc/test_support.rb +4 -0
  81. data/lib/vmc/test_support/command_helper.rb +32 -0
  82. data/lib/vmc/test_support/common_input_examples.rb +14 -0
  83. data/lib/vmc/test_support/fake_home_dir.rb +16 -0
  84. data/lib/vmc/test_support/interact_helper.rb +29 -0
  85. data/lib/vmc/version.rb +3 -0
  86. data/spec/assets/hello-sinatra/Gemfile +3 -0
  87. data/spec/assets/hello-sinatra/main.rb +6 -0
  88. data/spec/features/new_user_flow_spec.rb +71 -0
  89. data/spec/spec_helper.rb +63 -0
  90. data/spec/vmc/cli/app/base_spec.rb +17 -0
  91. data/spec/vmc/cli/app/delete_spec.rb +188 -0
  92. data/spec/vmc/cli/app/instances_spec.rb +65 -0
  93. data/spec/vmc/cli/app/push/create_spec.rb +571 -0
  94. data/spec/vmc/cli/app/push_spec.rb +369 -0
  95. data/spec/vmc/cli/app/rename_spec.rb +104 -0
  96. data/spec/vmc/cli/app/scale_spec.rb +81 -0
  97. data/spec/vmc/cli/app/stats_spec.rb +62 -0
  98. data/spec/vmc/cli/domain/map_spec.rb +140 -0
  99. data/spec/vmc/cli/domain/unmap_spec.rb +73 -0
  100. data/spec/vmc/cli/organization/orgs_spec.rb +108 -0
  101. data/spec/vmc/cli/organization/rename_spec.rb +113 -0
  102. data/spec/vmc/cli/route/map_spec.rb +138 -0
  103. data/spec/vmc/cli/route/unmap_spec.rb +215 -0
  104. data/spec/vmc/cli/service/bind_spec.rb +25 -0
  105. data/spec/vmc/cli/service/delete_spec.rb +22 -0
  106. data/spec/vmc/cli/service/rename_spec.rb +105 -0
  107. data/spec/vmc/cli/service/service_spec.rb +23 -0
  108. data/spec/vmc/cli/service/unbind_spec.rb +25 -0
  109. data/spec/vmc/cli/space/rename_spec.rb +102 -0
  110. data/spec/vmc/cli/space/spaces_spec.rb +104 -0
  111. data/spec/vmc/cli/start/info_spec.rb +153 -0
  112. data/spec/vmc/cli/start/login_spec.rb +71 -0
  113. data/spec/vmc/cli/user/create_spec.rb +54 -0
  114. data/spec/vmc/cli/user/passwd_spec.rb +102 -0
  115. data/spec/vmc/cli/user/register_spec.rb +148 -0
  116. data/spec/vmc/cli_spec.rb +448 -0
  117. data/spec/vmc/detect_spec.rb +54 -0
  118. metadata +231 -124
  119. data/README.md +0 -155
  120. data/caldecott_helper/Gemfile +0 -10
  121. data/caldecott_helper/Gemfile.lock +0 -48
  122. data/caldecott_helper/server.rb +0 -43
  123. data/config/clients.yml +0 -17
  124. data/config/micro/offline.conf +0 -2
  125. data/config/micro/paths.yml +0 -22
  126. data/config/micro/refresh_ip.rb +0 -20
  127. data/lib/cli.rb +0 -48
  128. data/lib/cli/commands/admin.rb +0 -81
  129. data/lib/cli/commands/apps.rb +0 -1358
  130. data/lib/cli/commands/base.rb +0 -233
  131. data/lib/cli/commands/manifest.rb +0 -56
  132. data/lib/cli/commands/micro.rb +0 -115
  133. data/lib/cli/commands/misc.rb +0 -147
  134. data/lib/cli/commands/services.rb +0 -217
  135. data/lib/cli/commands/user.rb +0 -70
  136. data/lib/cli/config.rb +0 -176
  137. data/lib/cli/console_helper.rb +0 -163
  138. data/lib/cli/core_ext.rb +0 -122
  139. data/lib/cli/errors.rb +0 -19
  140. data/lib/cli/file_helper.rb +0 -123
  141. data/lib/cli/frameworks.rb +0 -265
  142. data/lib/cli/manifest_helper.rb +0 -316
  143. data/lib/cli/runner.rb +0 -633
  144. data/lib/cli/services_helper.rb +0 -104
  145. data/lib/cli/tunnel_helper.rb +0 -336
  146. data/lib/cli/usage.rb +0 -129
  147. data/lib/cli/version.rb +0 -7
  148. data/lib/cli/zip_util.rb +0 -102
  149. data/lib/vmc/client.rb +0 -574
  150. data/lib/vmc/const.rb +0 -27
  151. data/lib/vmc/micro.rb +0 -56
  152. data/lib/vmc/micro/switcher/base.rb +0 -97
  153. data/lib/vmc/micro/switcher/darwin.rb +0 -19
  154. data/lib/vmc/micro/switcher/dummy.rb +0 -15
  155. data/lib/vmc/micro/switcher/linux.rb +0 -16
  156. data/lib/vmc/micro/switcher/windows.rb +0 -31
  157. data/lib/vmc/micro/vmrun.rb +0 -158
@@ -0,0 +1,81 @@
1
+ require "spec_helper"
2
+ require "webmock/rspec"
3
+
4
+ describe VMC::App::Scale do
5
+ let(:global) { { :color => false } }
6
+ let(:given) { {} }
7
+ let(:client) { fake_client }
8
+ let!(:cli) { described_class.new }
9
+
10
+ before do
11
+ stub(cli).client { client }
12
+ stub_output(cli)
13
+ end
14
+
15
+ subject { invoke_cli(cli, :scale, inputs, given, global) }
16
+
17
+ context "when the --disk flag is given" do
18
+ let(:before_value) { 512 }
19
+ let(:app) { fake :app, :disk_quota => before_value }
20
+ let(:inputs) { { :app => app, :disk => "1G" } }
21
+
22
+ it "changes the application's disk quota" do
23
+ mock(app).update!
24
+ expect { subject }.to change(app, :disk_quota).from(before_value).to(1024)
25
+ end
26
+ end
27
+
28
+ context "when the --memory flag is given" do
29
+ let(:before_value) { 512 }
30
+ let(:app) { fake :app, :memory => before_value }
31
+ let(:inputs) { { :app => app, :memory => "1G" } }
32
+
33
+ it "changes the application's memory" do
34
+ mock(app).update!
35
+ expect { subject }.to change(app, :memory).from(before_value).to(1024)
36
+ end
37
+
38
+ context "if --restart is true" do
39
+ it "restarts the application" do
40
+ stub(app).update!
41
+ stub(app).started? { true }
42
+ mock(cli).invoke :restart, :app => app
43
+ subject
44
+ end
45
+ end
46
+ end
47
+
48
+ context "when the --instances flag is given" do
49
+ let(:before_value) { 3 }
50
+ let(:app) { fake :app, :total_instances => before_value }
51
+
52
+ let(:inputs) { { :app => app, :instances => 5 } }
53
+
54
+ it "changes the application's number of instances" do
55
+ mock(app).update!
56
+ expect { subject }.to change(app, :total_instances).from(before_value).to(5)
57
+ end
58
+ end
59
+
60
+ context "when the --plan flag is given" do
61
+ context "when the plan name begins with a 'p'" do
62
+ let(:app) { fake :app, :production => false }
63
+ let(:inputs) { { :app => app, :plan => "P100" } }
64
+
65
+ it "changes the application's 'production' flag to true" do
66
+ mock(app).update!
67
+ expect { subject }.to change(app, :production).from(false).to(true)
68
+ end
69
+ end
70
+
71
+ context "when the plan name does not begin with a 'p'" do
72
+ let(:app) { fake :app, :production => true }
73
+ let(:inputs) { { :app => app, :plan => "D100" } }
74
+
75
+ it "changes the application's 'production' flag to false" do
76
+ mock(app).update!
77
+ expect { subject }.to change(app, :production).from(true).to(false)
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe VMC::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")] }
10
+
11
+ before do
12
+ any_instance_of(VMC::CLI) do |cli|
13
+ stub(cli).client { client }
14
+ stub(cli).precondition { nil }
15
+ end
16
+ stub(client).base.stub!.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 => {:time => "2013-01-04 19:53:39 +0000", :cpu => 0.0019777013519415455, :mem => 31395840, :disk => 15638528}
29
+ }
30
+ }}
31
+ end
32
+ end
33
+
34
+ subject do
35
+ capture_output { Mothership.new.invoke(:stats, inputs, given, global) }
36
+ end
37
+
38
+ describe 'metadata' do
39
+ let(:command) { Mothership.commands[:stats] }
40
+
41
+ describe 'command' do
42
+ subject { command }
43
+ its(:description) { should eq "Display application instance status" }
44
+ it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
45
+ end
46
+
47
+ include_examples 'inputs must have descriptions'
48
+
49
+ describe 'arguments' do
50
+ subject { command.arguments }
51
+ it 'has no arguments' do
52
+ should eq([:name=>:app, :type=>:normal, :value=>nil])
53
+ end
54
+ end
55
+ end
56
+
57
+ it 'prints out the stats' do
58
+ subject
59
+ stdout.rewind
60
+ expect(stdout.readlines.last).to match /.*0\s+0\.0%\s+29\.9M of 288M\s+14\.9M of 256M.*/
61
+ end
62
+ end
@@ -0,0 +1,140 @@
1
+ require 'spec_helper'
2
+
3
+ describe VMC::Domain::Map do
4
+ let(:global) { { :color => false } }
5
+ let(:given) { {} }
6
+ let(:client) { fake_client :current_organization => organization, :current_space => space }
7
+ let!(:cli) { described_class.new }
8
+
9
+ before do
10
+ stub(cli).client { client }
11
+ stub_output(cli)
12
+ end
13
+
14
+ let(:organization) { fake(:organization) }
15
+ let(:space) { fake(:space) }
16
+ let(:domain) { fake(:domain, :name => domain_name) }
17
+ let(:domain_name) { "some.domain.com" }
18
+
19
+ subject { invoke_cli(cli, :map_domain, inputs, given, global) }
20
+
21
+ shared_examples "binding a domain to a space" do
22
+ it "adds the domain to the space's organization" do
23
+ mock(space.organization).add_domain(domain)
24
+ stub(space).add_domain(domain)
25
+ subject
26
+ end
27
+
28
+ it 'adds the domain to the space' do
29
+ stub(space.organization).add_domain(domain)
30
+ mock(space).add_domain(domain)
31
+ subject
32
+ end
33
+ end
34
+
35
+ shared_examples "binding a domain to an organization" do
36
+ it 'does NOT add the domain to a space' do
37
+ any_instance_of(space.class) do |space|
38
+ dont_allow(space).add_domain(domain)
39
+ end
40
+ end
41
+
42
+ it 'adds the domain to the organization' do
43
+ mock(organization).add_domain(domain)
44
+ subject
45
+ end
46
+ end
47
+
48
+ shared_examples "mapping a domain to a space" do
49
+ context "when the domain does NOT exist" do
50
+ before do
51
+ stub(client).domain { domain }
52
+ stub(domain).create!
53
+ stub(space.organization).add_domain(domain)
54
+ stub(space).add_domain(domain)
55
+ end
56
+
57
+ it 'creates the domain' do
58
+ mock(domain).create!
59
+ subject
60
+ expect(domain.name).to eq domain_name
61
+ expect(domain.owning_organization).to eq organization
62
+ end
63
+
64
+ include_examples "binding a domain to a space"
65
+ end
66
+
67
+ context "when the domain already exists" do
68
+ let(:client) {
69
+ fake_client :domains => [domain],
70
+ :current_organization => organization,
71
+ :current_space => space
72
+ }
73
+
74
+ include_examples "binding a domain to a space"
75
+ end
76
+ end
77
+
78
+ context 'when a domain and a space are passed' do
79
+ let(:inputs) { { :space => space, :name => domain_name } }
80
+
81
+ include_examples "mapping a domain to a space"
82
+ end
83
+
84
+ context 'when a domain and an organization are passed' do
85
+ let(:inputs) { { :organization => organization, :name => domain_name } }
86
+
87
+ context "and the domain does NOT exist" do
88
+ before do
89
+ stub(client).domain { domain }
90
+ stub(domain).create!
91
+ stub(organization).add_domain(domain)
92
+ end
93
+
94
+ include_examples "binding a domain to an organization"
95
+
96
+ it 'adds the domain to the organization' do
97
+ mock(organization).add_domain(domain)
98
+ subject
99
+ end
100
+
101
+ context "and the --shared option is passed" do
102
+ let(:inputs) { { :organization => organization, :name => domain_name, :shared => true } }
103
+
104
+ it 'adds the domain to the organization' do
105
+ mock(domain).create!
106
+ subject
107
+ expect(domain.name).to eq domain_name
108
+ end
109
+
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
114
+ end
115
+ end
116
+ end
117
+
118
+ context "and the domain already exists" do
119
+ let(:client) {
120
+ fake_client :domains => [domain],
121
+ :current_organization => organization,
122
+ :current_space => space
123
+ }
124
+
125
+ include_examples "binding a domain to an organization"
126
+ end
127
+ end
128
+
129
+ context 'when a domain, organization, and space is passed' do
130
+ let(:inputs) { { :name => domain_name, :organization => organization, :space => space } }
131
+
132
+ include_examples "mapping a domain to a space"
133
+ end
134
+
135
+ context 'when only a domain is passed' do
136
+ let(:inputs) { { :name => domain_name } }
137
+
138
+ include_examples "mapping a domain to a space"
139
+ end
140
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe VMC::Domain::Unmap do
4
+ let(:global) { { :color => false } }
5
+ let(:given) { {} }
6
+ let(:client) { fake_client :current_organization => organization, :current_space => space }
7
+ let!(:cli) { described_class.new }
8
+
9
+ before do
10
+ stub(cli).client { client }
11
+ stub_output(cli)
12
+ end
13
+
14
+ let(:organization) { fake(:organization) }
15
+ let(:space) { fake(:space) }
16
+ let(:domain) { fake(:domain, :name => domain_name) }
17
+ let(:domain_name) { "some.domain.com" }
18
+
19
+ subject { invoke_cli(cli, :unmap_domain, inputs, given, global) }
20
+
21
+ context "when the --delete flag is given" do
22
+ let(:inputs) { { :domain => domain, :delete => true } }
23
+
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
29
+
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
37
+
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
43
+ end
44
+ end
45
+ end
46
+
47
+ context "when a space is given" do
48
+ let(:inputs) { { :domain => domain, :space => space } }
49
+
50
+ it "unmaps the domain from the space" do
51
+ mock(space).remove_domain(domain)
52
+ subject
53
+ end
54
+ end
55
+
56
+ context "when an organization is given" do
57
+ let(:inputs) { { :domain => domain, :organization => organization } }
58
+
59
+ it "unmaps the domain from the organization" do
60
+ mock(organization).remove_domain(domain)
61
+ subject
62
+ end
63
+ end
64
+
65
+ context "when only the domain is given" do
66
+ let(:inputs) { { :domain => domain } }
67
+
68
+ it "unmaps the domain from the current space" do
69
+ mock(client.current_space).remove_domain(domain)
70
+ subject
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe VMC::Organization::Orgs do
5
+ let(:global) { { :color => false } }
6
+ let(:inputs) { {} }
7
+ let(:given) { {} }
8
+ let(:output) { StringIO.new }
9
+
10
+ let(:client) { fake_client(:organizations => organizations) }
11
+ let!(:org_1) { fake(:organization, :name => "bb_second", :spaces => fake_list(:space, 2), :domains => [fake(:domain)]) }
12
+ let!(:org_2) { fake(:organization, :name => "aa_first", :spaces => [fake(:space)], :domains => fake_list(:domain, 3)) }
13
+ let!(:org_3) { fake(:organization, :name => "cc_last", :spaces => fake_list(:space, 2), :domains => fake_list(:domain, 2)) }
14
+ let(:organizations) { [org_1, org_2, org_3]}
15
+
16
+ before do
17
+ any_instance_of(VMC::CLI) do |cli|
18
+ stub(cli).client { client }
19
+ stub(cli).precondition { nil }
20
+ end
21
+ end
22
+
23
+ subject do
24
+ capture_output { Mothership.new.invoke(:orgs, inputs, given, global) }
25
+ end
26
+
27
+ describe 'metadata' do
28
+ let(:command) { Mothership.commands[:orgs] }
29
+
30
+ describe 'command' do
31
+ subject { command }
32
+ its(:description) { should eq "List available organizations" }
33
+ it { expect(Mothership::Help.group(:organizations)).to include(subject) }
34
+ end
35
+
36
+ include_examples 'inputs must have descriptions'
37
+
38
+ describe 'arguments' do
39
+ subject { command.arguments }
40
+ it 'has no arguments' do
41
+ should be_empty
42
+ end
43
+ end
44
+ end
45
+
46
+ it 'should have the correct first two lines' do
47
+ subject
48
+ stdout.rewind
49
+ expect(stdout.readline).to match /Getting organizations.*OK/
50
+ expect(stdout.readline).to eq "\n"
51
+ end
52
+
53
+ context 'when there are no orgnaizations' do
54
+ let(:organizations) { [] }
55
+
56
+ context 'and the full flag is given' do
57
+ let(:inputs) { {:full => true} }
58
+
59
+ it 'displays yaml-style output with all organization details' do
60
+ any_instance_of VMC::Organization::Orgs do |orgs|
61
+ dont_allow(orgs).invoke
62
+ end
63
+ subject
64
+ end
65
+ end
66
+
67
+ context 'and the full flag is not given (default is false)' do
68
+ it 'should show only the progress' do
69
+ subject
70
+
71
+ stdout.rewind
72
+ expect(stdout.readline).to match /Getting organizations.*OK/
73
+ expect(stdout).to be_eof
74
+ end
75
+ end
76
+ end
77
+
78
+ context 'when there are organizations' do
79
+ context 'and the full flag is given' do
80
+ let(:inputs) { {:full => true} }
81
+
82
+ it 'displays yaml-style output with all organization details' do
83
+ any_instance_of VMC::Organization::Orgs do |orgs|
84
+ mock(orgs).invoke(:org, :organization => org_2, :full => true).ordered
85
+ mock(orgs).invoke(:org, :organization => org_1, :full => true).ordered
86
+ mock(orgs).invoke(:org, :organization => org_3, :full => true).ordered
87
+ end
88
+ subject
89
+ end
90
+ end
91
+
92
+ context 'and the full flag is not given (default is false)' do
93
+ it 'displays tabular output with names, spaces and domains' do
94
+ subject
95
+
96
+ stdout.rewind
97
+ stdout.readline
98
+ stdout.readline
99
+
100
+ expect(stdout.readline).to match /name\s+spaces\s+domains/
101
+ organizations.sort_by(&:name).each do |org|
102
+ expect(stdout.readline).to match /#{org.name}\s+#{name_list(org.spaces)}\s+#{name_list(org.domains)}/
103
+ end
104
+ expect(stdout).to be_eof
105
+ end
106
+ end
107
+ end
108
+ end