ruby_yacht 0.5.0 → 0.6.0

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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rdoc_options +8 -2
  4. data/.rspec +1 -0
  5. data/.travis.yml +17 -1
  6. data/Gemfile.lock +18 -2
  7. data/README.md +28 -10
  8. data/bin/ruby_yacht +5 -0
  9. data/doc/TODO.md +1 -20
  10. data/doc/configuration.md +104 -21
  11. data/doc/configuration_sample.rb +19 -8
  12. data/doc/contributing.md +28 -5
  13. data/doc/plugins.md +105 -45
  14. data/lib/ruby_yacht/dsl/app.rb +14 -18
  15. data/lib/ruby_yacht/dsl/configuration.rb +51 -32
  16. data/lib/ruby_yacht/dsl/database.rb +24 -8
  17. data/lib/ruby_yacht/dsl/dsl.rb +32 -4
  18. data/lib/ruby_yacht/dsl/hook.rb +182 -48
  19. data/lib/ruby_yacht/dsl/project.rb +20 -14
  20. data/lib/ruby_yacht/dsl/server_type.rb +14 -31
  21. data/lib/ruby_yacht/dsl/web_server.rb +87 -0
  22. data/lib/ruby_yacht/dsl.rb +1 -0
  23. data/lib/ruby_yacht/images/app/Dockerfile.erb +17 -6
  24. data/lib/ruby_yacht/images/app/before_startup.bash.erb +5 -3
  25. data/lib/ruby_yacht/images/app/startup.bash.erb +5 -2
  26. data/lib/ruby_yacht/images/app-dependencies/Dockerfile.erb +7 -11
  27. data/lib/ruby_yacht/images/database/Dockerfile.erb +7 -18
  28. data/lib/ruby_yacht/images/database/startup.bash.erb +1 -1
  29. data/lib/ruby_yacht/images/web/Dockerfile.erb +25 -19
  30. data/lib/ruby_yacht/plugins/mysql.rb +18 -8
  31. data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/add_app.rb +5 -5
  32. data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/add_project.rb +3 -3
  33. data/lib/ruby_yacht/plugins/nginx.rb +28 -0
  34. data/lib/ruby_yacht/plugins/rails/scripts/build_new_app.rb +10 -0
  35. data/lib/ruby_yacht/plugins/rails/scripts/update_rails_config.rb +6 -1
  36. data/lib/ruby_yacht/plugins/rails.rb +34 -19
  37. data/lib/ruby_yacht/plugins.rb +2 -1
  38. data/lib/ruby_yacht/runner/build_images.rb +87 -73
  39. data/lib/ruby_yacht/runner/checkout.rb +1 -1
  40. data/lib/ruby_yacht/runner/command.rb +13 -1
  41. data/lib/ruby_yacht/runner/create_new_project.rb +91 -0
  42. data/lib/ruby_yacht/runner/help.rb +1 -1
  43. data/lib/ruby_yacht/runner/run_containers.rb +17 -21
  44. data/lib/ruby_yacht/runner/runner.rb +27 -2
  45. data/lib/ruby_yacht/runner/services.rb +15 -10
  46. data/lib/ruby_yacht/runner/shell.rb +1 -1
  47. data/lib/ruby_yacht/runner/update_hosts.rb +16 -11
  48. data/lib/ruby_yacht/runner.rb +1 -0
  49. data/log/.gitkeep +0 -0
  50. data/ruby_yacht.gemspec +4 -2
  51. data/spec/docker/Dockerfile +19 -3
  52. data/spec/docker/install_gems.bash +5 -0
  53. data/spec/docker/run.bash +44 -0
  54. data/spec/docker/startup.bash +10 -0
  55. data/spec/dsl/app_spec.rb +66 -38
  56. data/spec/dsl/configuration_spec.rb +236 -30
  57. data/spec/dsl/database_spec.rb +103 -4
  58. data/spec/dsl/dsl_spec.rb +46 -3
  59. data/spec/dsl/hook_spec.rb +278 -57
  60. data/spec/dsl/project_spec.rb +75 -45
  61. data/spec/dsl/server_type_spec.rb +52 -12
  62. data/spec/dsl/web_server_spec.rb +160 -0
  63. data/spec/fixtures/apollo-new-project-config +20 -0
  64. data/spec/fixtures/app-dependencies-dockerfile-generic +4 -7
  65. data/spec/fixtures/app-dependencies-dockerfile-generic-with-library-install +6 -10
  66. data/spec/fixtures/app-dependencies-dockerfile-rails +9 -11
  67. data/spec/fixtures/app-dependencies-dockerfile-with-no-repository +20 -0
  68. data/spec/fixtures/database-dockerfile +1 -1
  69. data/spec/fixtures/database-dockerfile-mysql +3 -3
  70. data/spec/fixtures/database-dockerfile-rails +5 -4
  71. data/spec/fixtures/database-dockerfile-rails-with-no-repository +27 -0
  72. data/spec/fixtures/database-dockerfile-with-seed-hooks +3 -3
  73. data/spec/fixtures/database-startup-mysql +2 -1
  74. data/spec/fixtures/mars-before-startup +2 -2
  75. data/spec/fixtures/mars-before-startup-rails +5 -4
  76. data/spec/fixtures/mars-before-startup-with-before-startup-hooks +5 -4
  77. data/spec/fixtures/mars-before-startup-with-custom-file-copy +3 -3
  78. data/spec/fixtures/mars-before-startup-with-no-repository +3 -0
  79. data/spec/fixtures/mars-dockerfile +3 -2
  80. data/spec/fixtures/mars-dockerfile-rails +6 -5
  81. data/spec/fixtures/mars-dockerfile-rails-with-no-repository +32 -0
  82. data/spec/fixtures/mars-dockerfile-with-after-checkout-hooks +5 -4
  83. data/spec/fixtures/mars-dockerfile-with-before-startup-hooks +5 -4
  84. data/spec/fixtures/mars-dockerfile-with-custom-file-copy +4 -3
  85. data/spec/fixtures/mars-dockerfile-with-local-database +4 -2
  86. data/spec/fixtures/mars-dockerfile-with-no-repository +22 -0
  87. data/spec/fixtures/mars-dockerfile-with-remote-database +4 -2
  88. data/spec/fixtures/mars-startup +2 -2
  89. data/spec/fixtures/mars-startup-rails +2 -2
  90. data/spec/fixtures/mars-startup-rails-with-no-repository +5 -0
  91. data/spec/fixtures/mars-startup-with-no-repository +4 -0
  92. data/spec/fixtures/web-dockerfile +18 -11
  93. data/spec/fixtures/web-dockerfile-jupiter +28 -0
  94. data/spec/fixtures/web-dockerfile-nginx +38 -0
  95. data/spec/fixtures/web-dockerfile-with-eponymous-app +16 -10
  96. data/spec/fixtures/web-dockerfile-with-primary-app +16 -10
  97. data/spec/integration/build_images_spec.rb +210 -0
  98. data/spec/integration/build_spec.rb +23 -0
  99. data/spec/integration/checkout_spec.rb +94 -0
  100. data/spec/integration/create_new_project_spec.rb +50 -0
  101. data/spec/integration/implode_spec.rb +20 -0
  102. data/spec/integration/run.rb +93 -0
  103. data/spec/integration/run_containers_spec.rb +279 -0
  104. data/spec/integration/services_spec.rb +99 -0
  105. data/spec/integration/shell_spec.rb +31 -0
  106. data/spec/integration/update_hosts_spec.rb +35 -0
  107. data/spec/plugins/mysql_spec.rb +18 -1
  108. data/spec/plugins/nginx_spec.rb +66 -0
  109. data/spec/plugins/rails_spec.rb +61 -89
  110. data/spec/runner/build_images_spec.rb +111 -58
  111. data/spec/runner/command_spec.rb +55 -3
  112. data/spec/runner/create_new_project_spec.rb +93 -0
  113. data/spec/runner/help_spec.rb +5 -1
  114. data/spec/runner/run_containers_spec.rb +22 -10
  115. data/spec/runner/runner_spec.rb +31 -4
  116. data/spec/runner/services_spec.rb +32 -4
  117. data/spec/runner/update_hosts_spec.rb +2 -1
  118. data/spec/spec_helper.rb +16 -1
  119. data/spec/support/integration_helpers.rb +76 -0
  120. data/spec/support/test_project.rb +15 -3
  121. metadata +97 -14
  122. data/spec/docker/build.bash +0 -10
  123. data/spec/fixtures/deploy-dockerfile +0 -2
  124. data/spec/fixtures/multi-project-web-dockerfile +0 -25
  125. /data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/app_config.erb +0 -0
  126. /data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/index.html.erb +0 -0
  127. /data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/index_config.erb +0 -0
@@ -1,22 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RubyYacht::Hook do
4
- describe "copied_file_name" do
5
- context "with no copied_file_path" do
6
- it "is an empty string" do
7
- expect(subject.copied_file_name).to eq ""
8
- end
9
- end
10
-
11
- context "with a a copied_file_path" do
12
- before { subject.copied_file_path = "./foo/bar.rb" }
13
-
14
- it "gets the filename from the path" do
15
- expect(subject.copied_file_name).to eq "bar.rb"
16
- end
17
- end
18
- end
19
-
20
4
  describe "dsl" do
21
5
  let(:dsl) { RubyYacht::Hook::DSL.new(:before, :startup) }
22
6
  let(:hook) { dsl.run(@config_block).create_object }
@@ -25,103 +9,340 @@ describe RubyYacht::Hook do
25
9
  RubyYacht.configuration.clear
26
10
 
27
11
  RubyYacht.configure do
28
- server_type :test do
12
+ server_type :rails do
29
13
  container_type :app
30
14
  baseline_image 'ubuntu'
31
15
  end
16
+
17
+ server_type :mysql do
18
+ container_type :database
19
+ baseline_image 'ubuntu'
20
+ end
21
+
22
+ server_type :nginx do
23
+ container_type :web
24
+ baseline_image 'ubuntu'
25
+ end
32
26
  end
33
27
 
34
28
  @config_block = Proc.new do
35
- server_type :test
36
- command 'curl google.com'
29
+ container_type :app
30
+ app_server_type :rails
31
+ database_server_type :mysql
32
+ web_server_type :nginx
37
33
  end
38
34
  end
39
35
 
40
36
  it "can create a hook for running a command" do
41
37
  expect(hook.event_time).to eq :before
42
38
  expect(hook.event_type).to eq :startup
43
- expect(hook.server_type).to eq :test
44
- expect(hook.command).to eq 'curl google.com'
39
+ expect(hook.app_server_type).to eq :rails
40
+ expect(hook.database_server_type).to eq :mysql
41
+ expect(hook.web_server_type).to eq :nginx
42
+ expect(hook.behaviors).to eq []
43
+ end
44
+
45
+ context "with no container type" do
46
+ before do
47
+ @config_block = Proc.new do
48
+ app_server_type :rails
49
+ database_server_type :mysql
50
+ web_server_type :nginx
51
+ end
52
+ end
53
+
54
+ it "defaults to all" do
55
+ expect { hook }.to raise_exception 'Missing required attribute container_type for RubyYacht::Hook::DSL'
56
+ end
45
57
  end
46
58
 
47
- it "can create a hook for running a script" do
48
- @config_block = Proc.new do
49
- server_type :test
50
- script_folder './foo'
51
- run_script 'bar.rb'
59
+ context "with no app type" do
60
+ before do
61
+ @config_block = Proc.new do
62
+ container_type :app
63
+ database_server_type :mysql
64
+ web_server_type :nginx
65
+ end
66
+ end
67
+
68
+ it "defaults to all" do
69
+ expect(hook.app_server_type).to eq :all
52
70
  end
53
- expect(hook.event_time).to eq :before
54
- expect(hook.event_type).to eq :startup
55
- expect(hook.server_type).to eq :test
56
- expect(hook.copied_file_path).to eq './foo/bar.rb'
57
- expect(hook.command).to eq '/var/docker/bar.rb'
58
71
  end
59
72
 
60
- context "with no command" do
73
+ context "with an app type that is not defined" do
61
74
  before do
62
75
  @config_block = Proc.new do
63
- server_type :test
76
+ container_type :app
77
+ app_server_type :invalid
78
+ database_server_type :mysql
79
+ web_server_type :nginx
64
80
  end
65
81
  end
66
82
 
67
83
  it "raises an exception" do
68
- expect { hook }.to raise_exception 'Missing required attribute command for RubyYacht::Hook::DSL'
84
+ expect { hook }.to raise_exception 'RubyYacht::Hook::DSL has invalid app server type `invalid`'
69
85
  end
70
86
  end
71
87
 
72
- context "with a script name and no script path" do
88
+ context 'with an app type that is really a database type' do
73
89
  before do
74
90
  @config_block = Proc.new do
75
- server_type :test
76
- run_script 'bar.rb'
91
+ container_type :app
92
+ app_server_type :mysql
93
+ database_server_type :mysql
94
+ web_server_type :nginx
77
95
  end
78
96
  end
97
+
98
+ it "raises an exception" do
99
+ expect { hook }.to raise_exception 'RubyYacht::Hook::DSL has invalid app server type `mysql`'
100
+ end
101
+ end
79
102
 
80
- it "creates a hook with with the script relative to the current folder" do
81
- expect(hook.copied_file_path).to eq './bar.rb'
82
- expect(hook.command).to eq '/var/docker/bar.rb'
103
+ context "with no database server type" do
104
+ before do
105
+ @config_block = Proc.new do
106
+ container_type :app
107
+ app_server_type :rails
108
+ web_server_type :nginx
109
+ end
110
+ end
111
+
112
+ it "defaults to all" do
113
+ expect(hook.database_server_type).to eq :all
83
114
  end
84
115
  end
85
-
86
- context "with a custom command for copying a file" do
116
+
117
+ context 'with a database server type that is not defined' do
87
118
  before do
88
119
  @config_block = Proc.new do
89
- server_type :test
90
- script_folder './foo'
91
- copy_file 'test.txt'
92
- command 'scp /var/docker/test.txt test.com:test.txt'
120
+ container_type :app
121
+ app_server_type :rails
122
+ database_server_type :invalid
123
+ web_server_type :nginx
93
124
  end
94
125
  end
126
+
127
+ it "raises an exception" do
128
+ expect { hook }.to raise_exception 'RubyYacht::Hook::DSL has invalid database server type `invalid`'
129
+ end
130
+ end
95
131
 
96
- it "uses that file as the copied_file_path" do
97
- expect(hook.copied_file_path).to eq './foo/test.txt'
98
- expect(hook.command).to eq 'scp /var/docker/test.txt test.com:test.txt'
132
+ context 'with a database server type that is really an app type' do
133
+ before do
134
+ @config_block = Proc.new do
135
+ container_type :app
136
+ app_server_type :rails
137
+ database_server_type :rails
138
+ web_server_type :nginx
139
+ end
140
+ end
141
+
142
+ it "raises an exception" do
143
+ expect { hook }.to raise_exception 'RubyYacht::Hook::DSL has invalid database server type `rails`'
99
144
  end
100
145
  end
101
146
 
102
- context "with no app type" do
147
+ context "with no web server type" do
103
148
  before do
104
149
  @config_block = Proc.new do
105
- script_folder './foo'
106
- run_script 'bar.rb'
150
+ container_type :app
151
+ app_server_type :rails
152
+ database_server_type :mysql
153
+ end
154
+ end
155
+
156
+ it "defaults to all" do
157
+ expect(hook.web_server_type).to eq :all
158
+ end
159
+ end
160
+
161
+ context 'with a web server type that is not defined' do
162
+ before do
163
+ @config_block = Proc.new do
164
+ container_type :app
165
+ app_server_type :rails
166
+ database_server_type :mysql
167
+ web_server_type :invalid
107
168
  end
108
169
  end
109
170
 
110
171
  it "raises an exception" do
111
- expect { hook }.to raise_exception 'Missing required attribute server_type for RubyYacht::Hook::DSL'
172
+ expect { hook }.to raise_exception 'RubyYacht::Hook::DSL has invalid web server type `invalid`'
112
173
  end
113
174
  end
114
175
 
115
- context "with an invalid app type" do
176
+ context 'with a web server type that is really an app type' do
116
177
  before do
117
178
  @config_block = Proc.new do
118
- server_type :invalid
119
- command 'whoami'
179
+ container_type :app
180
+ app_server_type :rails
181
+ database_server_type :mysql
182
+ web_server_type :rails
120
183
  end
121
184
  end
122
185
 
123
186
  it "raises an exception" do
124
- expect { hook }.to raise_exception 'Hook has invalid app type `invalid`'
187
+ expect { hook }.to raise_exception 'RubyYacht::Hook::DSL has invalid web server type `rails`'
188
+ end
189
+ end
190
+
191
+ describe 'behaviors' do
192
+ describe 'command' do
193
+ before do
194
+ @config_block = Proc.new do
195
+ container_type :app
196
+ app_server_type :rails
197
+ database_server_type :mysql
198
+ command 'curl google.com'
199
+ end
200
+ end
201
+
202
+ it 'adds a behavior for running the command' do
203
+ expect(hook.behaviors.count).to eq 1
204
+ expect(hook.behaviors[0].dockerfile_command).to eq 'RUN curl google.com'
205
+ end
206
+ end
207
+
208
+ describe "run_script" do
209
+ context 'with a script folder' do
210
+ before do
211
+ @config_block = Proc.new do
212
+ container_type :app
213
+ app_server_type :rails
214
+ database_server_type :mysql
215
+ script_folder './foo'
216
+ run_script :ruby, 'bar.rb'
217
+ end
218
+ end
219
+
220
+ it 'adds behaviors for copying the file, making it executable, and running it' do
221
+ expect(hook.behaviors.count).to eq 2
222
+ expect(hook.behaviors[0].dockerfile_command).to eq 'COPY bar.rb /var/docker/'
223
+ expect(hook.behaviors[0].file_path).to eq './foo/bar.rb'
224
+ expect(hook.behaviors[1].dockerfile_command).to eq 'RUN ruby /var/docker/bar.rb'
225
+ end
226
+ end
227
+
228
+ context "with no script folder" do
229
+ before do
230
+ @config_block = Proc.new do
231
+ container_type :app
232
+ app_server_type :rails
233
+ database_server_type :mysql
234
+ run_script :bash, 'bar.bash'
235
+ end
236
+ end
237
+
238
+ it "copies the file from the working directory" do
239
+ expect(hook.behaviors.count).to eq 2
240
+ expect(hook.behaviors[0].file_path).to eq './bar.bash'
241
+ expect(hook.behaviors[1].dockerfile_command).to eq 'RUN bash /var/docker/bar.bash'
242
+ end
243
+ end
244
+ end
245
+
246
+ describe 'copy_file' do
247
+ before do
248
+ @config_block = Proc.new do
249
+ container_type :app
250
+ app_server_type :rails
251
+ database_server_type :mysql
252
+ script_folder './foo'
253
+ copy_file 'test.txt'
254
+ end
255
+ end
256
+
257
+ it "adds a behavior for copying the file" do
258
+ expect(hook.behaviors.count).to eq 1
259
+ expect(hook.behaviors[0].dockerfile_command).to eq 'COPY test.txt /var/docker/'
260
+ expect(hook.behaviors[0].file_path).to eq './foo/test.txt'
261
+ end
262
+ end
263
+
264
+ describe 'set_environment_variable' do
265
+ context 'with a literal value' do
266
+ before do
267
+ @config_block = Proc.new do
268
+ container_type :app
269
+ app_server_type :rails
270
+ database_server_type :mysql
271
+ set_environment_variable 'RAILS_ENV', 'development'
272
+ end
273
+ end
274
+
275
+ it 'adds a behavior for setting the environment variable' do
276
+ expect(hook.behaviors.count).to eq 1
277
+ expect(hook.behaviors[0].dockerfile_command).to eq 'ENV RAILS_ENV development'
278
+ end
279
+ end
280
+
281
+ context 'with a proc value' do
282
+ before do
283
+ @config_block = Proc.new do
284
+ container_type :app
285
+ app_server_type :rails
286
+ database_server_type :mysql
287
+ set_environment_variable('RAILS_ENV') { 'production' }
288
+ end
289
+ end
290
+
291
+ it 'adds a behavior for setting the environment variable' do
292
+ expect(hook.behaviors.count).to eq 1
293
+ expect(hook.behaviors[0].dockerfile_command).to eq 'ENV RAILS_ENV production'
294
+ end
295
+ end
296
+ end
297
+ end
298
+ end
299
+
300
+ describe "behaviors" do
301
+ describe 'default behavior' do
302
+ let(:behavior) { RubyYacht::Hook::Behavior.new }
303
+ it 'has no commands' do
304
+ expect(behavior.dockerfile_command).to eq ''
305
+ expect(behavior.shell_command).to eq ''
306
+ end
307
+ end
308
+
309
+ describe "command behavior" do
310
+ let(:behavior) { RubyYacht::Hook::CommandBehavior.new('curl google.com') }
311
+
312
+ it "runs the command as its docker command" do
313
+ expect(behavior.dockerfile_command).to eq "RUN curl google.com"
314
+ end
315
+
316
+ it "runs the command as its shell command" do
317
+ expect(behavior.shell_command).to eq "curl google.com"
318
+ end
319
+ end
320
+
321
+ describe "copy file behavior" do
322
+ let(:behavior) { RubyYacht::Hook::CopyFileBehavior.new('./files/script.rb') }
323
+
324
+ it "makes the full path accessible through the file_path" do
325
+ expect(behavior.file_path).to eq './files/script.rb'
326
+ end
327
+
328
+ it "copies the file as its docker command" do
329
+ expect(behavior.dockerfile_command).to eq "COPY script.rb /var/docker/"
330
+ end
331
+
332
+ it "has no shell command" do
333
+ expect(behavior.shell_command).to eq ""
334
+ end
335
+ end
336
+
337
+ describe "environment variable behavior" do
338
+ let(:behavior) { RubyYacht::Hook::EnvironmentVariableBehavior.new('SECRET_KEY_BASE', Proc.new { 'abc'}) }
339
+
340
+ it 'sets the environment variable as its docker command' do
341
+ expect(behavior.dockerfile_command).to eq 'ENV SECRET_KEY_BASE abc'
342
+ end
343
+
344
+ it 'sets the environment variable as its shell command' do
345
+ expect(behavior.shell_command).to eq 'export SECRET_KEY_BASE="abc"'
125
346
  end
126
347
  end
127
348
  end
@@ -15,27 +15,31 @@ describe RubyYacht::Project do
15
15
  container_type :database
16
16
  baseline_image 'ubuntu'
17
17
  end
18
+ server_type :apache do
19
+ container_type :web
20
+ baseline_image 'ubuntu'
21
+ end
18
22
  end
19
23
  end
20
24
 
21
25
  it "can create a project with all the fields" do
22
26
  @builder = Proc.new do
23
27
  system_prefix :a
24
- domain "a.test.com"
25
28
  repository "github.com"
26
29
 
27
- app :app1, :generic do
30
+ app :generic, :app1 do
28
31
  repository_name 'brownleej/test1'
29
32
  end
30
33
 
31
- app :app2, :generic do
34
+ app :generic, :app2 do
32
35
  repository_name 'brownleej/test2'
33
36
  end
34
37
 
35
- database :project1, :sqlite do
38
+ database :sqlite, :project1 do
36
39
  host "localhost"
37
40
  username "test"
38
41
  password "test"
42
+ port 1234
39
43
  container_label :sqlite
40
44
  end
41
45
 
@@ -43,41 +47,47 @@ describe RubyYacht::Project do
43
47
  server '8.10.1.1'
44
48
  end
45
49
 
50
+ web_server :apache, :web do
51
+ domain 'test.com'
52
+ end
53
+
46
54
  primary_app :app1
47
55
  end
48
56
 
49
57
  expect(project.name).to eq :test_project
50
58
  expect(project.system_prefix).to eq :a
51
- expect(project.domain).to eq "a.test.com"
52
59
  expect(project.repository).to eq "github.com"
53
60
  expect(project.primary_app).to eq :app1
54
61
 
55
62
  expect(project.apps.map(&:name)).to eq [:app1, :app2]
56
63
  expect(project.databases.map(&:name)).to eq [:project1]
64
+ expect(project.web_servers.map(&:name)).to eq [:web]
57
65
 
58
66
  expect(project.dns_server.servers).to eq ['8.10.1.1']
59
67
  end
60
68
 
61
69
  it "requires the system prefix" do
62
70
  @builder = Proc.new do
63
- domain "a.test.com"
64
- repository "github.com"
65
-
66
- app :app1, :generic do
71
+ app :generic, :app1 do
67
72
  repository_name 'brownleej/test1'
68
73
  end
69
74
 
70
- app :app2, :generic do
75
+ app :generic, :app2 do
71
76
  repository_name 'brownleej/test2'
72
77
  end
73
78
 
74
- database :project1, :sqlite do
79
+ database :sqlite, :project1 do
75
80
  host "localhost"
76
81
  username "test"
77
82
  password "test"
83
+ port 1234
78
84
  container_label :sqlite
79
85
  end
80
86
 
87
+ web_server :apache, :web do
88
+ domain 'test.com'
89
+ end
90
+
81
91
  dns_server do
82
92
  server '8.10.1.1'
83
93
  end
@@ -88,26 +98,30 @@ describe RubyYacht::Project do
88
98
  expect { project }.to raise_exception "Missing required attribute system_prefix for RubyYacht::Project::DSL"
89
99
  end
90
100
 
91
- it "requires the domain" do
101
+ it "requires the repository" do
92
102
  @builder = Proc.new do
93
103
  system_prefix :a
94
- repository "github.com"
95
104
 
96
- app :app1, :generic do
105
+ app :generic, :app1 do
97
106
  repository_name 'brownleej/test1'
98
107
  end
99
108
 
100
- app :app2, :generic do
109
+ app :generic, :app2 do
101
110
  repository_name 'brownleej/test2'
102
111
  end
103
112
 
104
- database :project1, :sqlite do
113
+ database :sqlite, :project1 do
105
114
  host "localhost"
106
115
  username "test"
107
116
  password "test"
117
+ port 1234
108
118
  container_label :sqlite
109
119
  end
110
120
 
121
+ web_server :apache, :web do
122
+ domain 'test.com'
123
+ end
124
+
111
125
  dns_server do
112
126
  server '8.10.1.1'
113
127
  end
@@ -115,29 +129,26 @@ describe RubyYacht::Project do
115
129
  primary_app :app1
116
130
  end
117
131
 
118
- expect { project }.to raise_exception "Missing required attribute domain for RubyYacht::Project::DSL"
132
+ expect { project }.to raise_exception "Missing required attribute repository for RubyYacht::Project::DSL"
119
133
  end
120
134
 
121
- it "requires the repository" do
135
+ it "does not require any apps" do
122
136
  @builder = Proc.new do
123
137
  system_prefix :a
124
- domain "a.test.com"
125
-
126
- app :app1, :generic do
127
- repository_name 'brownleej/test1'
128
- end
129
-
130
- app :app2, :generic do
131
- repository_name 'brownleej/test2'
132
- end
138
+ repository "github.com"
133
139
 
134
- database :project1, :sqlite do
140
+ database :sqlite, :project1 do
135
141
  host "localhost"
136
142
  username "test"
137
143
  password "test"
144
+ port 1234
138
145
  container_label :sqlite
139
146
  end
140
147
 
148
+ web_server :apache, :web do
149
+ domain 'test.com'
150
+ end
151
+
141
152
  dns_server do
142
153
  server '8.10.1.1'
143
154
  end
@@ -145,19 +156,27 @@ describe RubyYacht::Project do
145
156
  primary_app :app1
146
157
  end
147
158
 
148
- expect { project }.to raise_exception "Missing required attribute repository for RubyYacht::Project::DSL"
159
+ expect(project.apps.count).to eq 0
149
160
  end
150
-
151
- it "does not require any apps" do
161
+
162
+ it "does not require any web servers" do
152
163
  @builder = Proc.new do
153
164
  system_prefix :a
154
- domain "a.test.com"
155
165
  repository "github.com"
156
166
 
157
- database :project1, :sqlite do
167
+ app :generic, :app1 do
168
+ repository_name 'brownleej/test1'
169
+ end
170
+
171
+ app :generic, :app2 do
172
+ repository_name 'brownleej/test2'
173
+ end
174
+
175
+ database :sqlite, :project1 do
158
176
  host "localhost"
159
177
  username "test"
160
178
  password "test"
179
+ port 1234
161
180
  container_label :sqlite
162
181
  end
163
182
 
@@ -168,23 +187,26 @@ describe RubyYacht::Project do
168
187
  primary_app :app1
169
188
  end
170
189
 
171
- expect(project.apps.count).to eq 0
190
+ expect(project.web_servers.count).to eq 0
172
191
  end
173
192
 
174
193
  it "does not require the database config" do
175
194
  @builder = Proc.new do
176
195
  system_prefix :a
177
- domain "a.test.com"
178
196
  repository "github.com"
179
197
 
180
- app :app1, :generic do
198
+ app :generic, :app1 do
181
199
  repository_name 'brownleej/test1'
182
200
  end
183
201
 
184
- app :app2, :generic do
202
+ app :generic, :app2 do
185
203
  repository_name 'brownleej/test2'
186
204
  end
187
205
 
206
+ web_server :apache, :web do
207
+ domain 'test.com'
208
+ end
209
+
188
210
  dns_server do
189
211
  server '8.10.1.1'
190
212
  end
@@ -198,24 +220,28 @@ describe RubyYacht::Project do
198
220
  it "does not require the DNS server config" do
199
221
  @builder = Proc.new do
200
222
  system_prefix :a
201
- domain "a.test.com"
202
223
  repository "github.com"
203
224
 
204
- app :app1, :generic do
225
+ app :generic, :app1 do
205
226
  repository_name 'brownleej/test1'
206
227
  end
207
228
 
208
- app :app2, :generic do
229
+ app :generic, :app2 do
209
230
  repository_name 'brownleej/test2'
210
231
  end
211
232
 
212
- database :project1, :sqlite do
233
+ database :sqlite, :project1 do
213
234
  host "localhost"
214
235
  username "test"
215
236
  password "test"
237
+ port 1234
216
238
  container_label :sqlite
217
239
  end
218
240
 
241
+ web_server :apache, :web do
242
+ domain 'test.com'
243
+ end
244
+
219
245
  primary_app :app1
220
246
  end
221
247
 
@@ -225,24 +251,28 @@ describe RubyYacht::Project do
225
251
  it "does not require the primary_app field" do
226
252
  @builder = Proc.new do
227
253
  system_prefix :a
228
- domain "a.test.com"
229
254
  repository "github.com"
230
255
 
231
- app :app1, :generic do
256
+ app :generic, :app1 do
232
257
  repository_name 'brownleej/test1'
233
258
  end
234
259
 
235
- app :app2, :generic do
260
+ app :generic, :app2 do
236
261
  repository_name 'brownleej/test2'
237
262
  end
238
263
 
239
- database :project1, :sqlite do
264
+ database :sqlite, :project1 do
240
265
  host "localhost"
241
266
  username "test"
242
267
  password "test"
268
+ port 1234
243
269
  container_label :sqlite
244
270
  end
245
271
 
272
+ web_server :apache, :web do
273
+ domain 'test.com'
274
+ end
275
+
246
276
  dns_server do
247
277
  server '8.10.1.1'
248
278
  end