dockerspec 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/LICENSE +1 -1
- data/README.md +190 -24
- data/Rakefile +60 -6
- data/TODO.md +3 -2
- data/lib/dockerspec.rb +1 -2
- data/lib/dockerspec/builder.rb +13 -6
- data/lib/dockerspec/builder/config_helpers.rb +8 -3
- data/lib/dockerspec/builder/logger/ci.rb +2 -2
- data/lib/dockerspec/builder/matchers.rb +32 -51
- data/lib/dockerspec/configuration.rb +188 -0
- data/lib/dockerspec/docker_exception_parser.rb +2 -2
- data/lib/dockerspec/engine/base.rb +156 -0
- data/lib/dockerspec/engine/infrataster.rb +87 -0
- data/lib/dockerspec/engine/specinfra.rb +130 -0
- data/lib/dockerspec/engine/specinfra/backend.rb +163 -0
- data/lib/dockerspec/{serverspec/specinfra_hack.rb → engine/specinfra/backend_hack.rb} +17 -3
- data/lib/dockerspec/engine_list.rb +150 -0
- data/lib/dockerspec/exceptions.rb +13 -0
- data/lib/dockerspec/helper/multiple_sources_description.rb +3 -3
- data/lib/dockerspec/helper/rspec_example_helpers.rb +86 -6
- data/lib/dockerspec/infrataster.rb +26 -0
- data/lib/dockerspec/rspec.rb +21 -0
- data/lib/dockerspec/{rspec_configuration.rb → rspec/configuration.rb} +1 -1
- data/lib/dockerspec/rspec/resources.rb +602 -0
- data/lib/dockerspec/rspec/resources/its_container.rb +110 -0
- data/lib/dockerspec/{rspec_settings.rb → rspec/settings.rb} +5 -1
- data/lib/dockerspec/runner.rb +2 -357
- data/lib/dockerspec/runner/base.rb +367 -0
- data/lib/dockerspec/runner/compose.rb +322 -0
- data/lib/dockerspec/runner/docker.rb +302 -0
- data/lib/dockerspec/runner/serverspec.rb +21 -0
- data/lib/dockerspec/runner/serverspec/base.rb +185 -0
- data/lib/dockerspec/runner/serverspec/compose.rb +106 -0
- data/lib/dockerspec/runner/serverspec/docker.rb +116 -0
- data/lib/dockerspec/runner/serverspec/rspec.rb +20 -0
- data/lib/dockerspec/{serverspec/rspec_settings.rb → runner/serverspec/rspec/settings.rb} +1 -1
- data/lib/dockerspec/serverspec.rb +12 -2
- data/lib/dockerspec/version.rb +1 -1
- data/spec/spec_helper.rb +6 -2
- metadata +84 -15
- data/lib/dockerspec/rspec_assertions.rb +0 -54
- data/lib/dockerspec/rspec_resources.rb +0 -203
- data/lib/dockerspec/serverspec/rspec_resources.rb +0 -179
- data/lib/dockerspec/serverspec/runner.rb +0 -305
- data/lib/dockerspec/serverspec/specinfra_backend.rb +0 -128
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00c000093e65be525764d4adb1a19c986747a1f2
|
4
|
+
data.tar.gz: 31ffe0b3521f66c09dffb9994e0d5de0a7895ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf7da409ef3be6b88a6720bab01736e9badb61fc12b6ed494fee7efc47df18ca51aa09ad11a1703230aee29912e0dd62788d2653463048f8bfcea457a3fb4297
|
7
|
+
data.tar.gz: 769fd611bd5c3e1bb8b97e8d37f65adb9572a2fe810e26af03e85d41ec7dac8af7fc543ba8575c7afef6fccc2cace7455404f8a0e20d9c0caa14deb5fca248b5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,40 @@
|
|
2
2
|
|
3
3
|
This file is used to list changes made in each version of `dockerspec` Ruby Gem.
|
4
4
|
|
5
|
+
## 0.3.0 (2016-02-28)
|
6
|
+
|
7
|
+
### Breaking Changes on 0.3.0
|
8
|
+
|
9
|
+
* Enable `options[:rm]` by default.
|
10
|
+
|
11
|
+
### New Features on 0.3.0
|
12
|
+
|
13
|
+
* Add Docker Compose support.
|
14
|
+
* Add Infrataster and Capybara support.
|
15
|
+
* Add `:wait` option to `docker_run` and `docker_compose`.
|
16
|
+
* Add `described_image` helper for `docker_run`.
|
17
|
+
* Support integer values with `have_expose` matcher.
|
18
|
+
* Make `require 'dockerspec'` optional.
|
19
|
+
|
20
|
+
### Fixes on 0.3.0
|
21
|
+
|
22
|
+
* Fix `:env` in `docker_run` with Serverspec.
|
23
|
+
* Fix *Must have id* error when building images from IDs with tags.
|
24
|
+
|
25
|
+
### Improvements on 0.3.0
|
26
|
+
|
27
|
+
* Update RuboCop to `0.37`, fix new offenses.
|
28
|
+
* `Runner` classes split into `Engine::Base` and `Runner::Base`.
|
29
|
+
* Add support for multiple testing engines.
|
30
|
+
* Add a `Configuration` class to setup the internal modularization.
|
31
|
+
* Rename many classes.
|
32
|
+
|
33
|
+
### Documentation Changes on 0.3.0
|
34
|
+
|
35
|
+
* README:
|
36
|
+
* Move the documentation below examples.
|
37
|
+
* Add many examples.
|
38
|
+
|
5
39
|
## 0.2.0 (2015-12-11)
|
6
40
|
|
7
41
|
### New Features on 0.2.0
|
data/LICENSE
CHANGED
@@ -175,7 +175,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
175
175
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
177
177
|
|
178
|
-
Copyright 2015 Xabier de Zuazo
|
178
|
+
Copyright 2015-2016 Xabier de Zuazo
|
179
179
|
|
180
180
|
Licensed under the Apache License, Version 2.0 (the "License");
|
181
181
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -6,14 +6,14 @@
|
|
6
6
|
[](https://rubygems.org/gems/dockerspec)
|
7
7
|
[](https://gemnasium.com/zuazo/dockerspec)
|
8
8
|
[](https://codeclimate.com/github/zuazo/dockerspec)
|
9
|
-
[](https://travis-ci.org/zuazo/dockerspec)
|
10
10
|
[](https://circleci.com/gh/zuazo/dockerspec/tree/master)
|
11
|
-
[](https://coveralls.io/r/zuazo/dockerspec?branch=0.3.0)
|
12
12
|
[](http://inch-ci.org/github/zuazo/dockerspec)
|
13
13
|
|
14
14
|
## Description
|
15
15
|
|
16
|
-
A small Ruby Gem to run RSpec
|
16
|
+
A small Ruby Gem to run RSpec, [Serverspec](http://serverspec.org/), [Infrataster](https://github.com/ryotarai/infrataster) and [Capybara](http://jnicklas.github.io/capybara/) tests against Dockerfiles or Docker images easily.
|
17
17
|
|
18
18
|
This gem is designed to work out of the box on [Travis CI](https://travis-ci.org/), [CircleCI](https://circleci.com/) and other similar CI environments.
|
19
19
|
|
@@ -33,7 +33,7 @@ $ gem install dockerspec
|
|
33
33
|
Or you can add this line to the *Gemfile* of your application:
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
gem 'dockerspec', '~> 0.
|
36
|
+
gem 'dockerspec', '~> 0.3.0'
|
37
37
|
```
|
38
38
|
|
39
39
|
And then execute:
|
@@ -44,30 +44,22 @@ $ bundle
|
|
44
44
|
|
45
45
|
**Warning:** As the gem is in its early development stages, [the API is very likely to break between minor versions](http://semver.org/).
|
46
46
|
|
47
|
-
## Documentation
|
48
|
-
|
49
|
-
- [`docker_build`](http://www.rubydoc.info/gems/dockerspec/Dockerspec/RSpecResources#docker_build-instance_method)
|
50
|
-
- [*Docker Build* helpers](http://www.rubydoc.info/gems/dockerspec/Dockerspec/Builder/ConfigHelpers)
|
51
|
-
- [`docker_run`](http://www.rubydoc.info/gems/dockerspec/Dockerspec/Serverspec/RSpecResources#docker_run-instance_method)
|
52
|
-
- [*Docker Run* Serverspec resource types](http://serverspec.org/resource_types.html)
|
53
|
-
|
54
47
|
## Usage Examples
|
55
48
|
|
56
49
|
### Run Tests Against a Dockerfile in the Current Directory
|
57
50
|
|
58
51
|
```ruby
|
59
|
-
require 'dockerspec'
|
60
52
|
require 'dockerspec/serverspec'
|
61
53
|
|
62
54
|
describe 'My Dockerfile' do
|
63
|
-
describe docker_build('.'
|
55
|
+
describe docker_build('.') do
|
64
56
|
|
65
57
|
it { should have_maintainer /John Doe/ }
|
66
58
|
it { should have_cmd ['/bin/dash'] }
|
67
59
|
it { should have_expose '80' }
|
68
60
|
it { should have_user 'nobody' }
|
69
61
|
|
70
|
-
describe docker_run(
|
62
|
+
describe docker_run(described_image) do
|
71
63
|
describe file('/etc/httpd.conf') do
|
72
64
|
it { should be_file }
|
73
65
|
it { should contain 'ServerName www.example.jp' }
|
@@ -78,15 +70,195 @@ describe 'My Dockerfile' do
|
|
78
70
|
it { should be_running }
|
79
71
|
end
|
80
72
|
end
|
73
|
+
|
81
74
|
end
|
82
75
|
end
|
83
76
|
```
|
84
77
|
|
85
78
|
See the documentation above for more examples.
|
86
79
|
|
80
|
+
### Run Tests Against Docker Compose
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
require 'dockerspec/serverspec'
|
84
|
+
|
85
|
+
describe docker_compose('.', wait: 30) do
|
86
|
+
|
87
|
+
its_container(:myapp) do
|
88
|
+
describe process('apache2') do
|
89
|
+
it { should be_running }
|
90
|
+
its(:args) { should match(/-DFOREGROUND/) }
|
91
|
+
end
|
92
|
+
# [...]
|
93
|
+
end
|
94
|
+
|
95
|
+
its_container(:db) do
|
96
|
+
describe process('mysqld') do
|
97
|
+
it { should be_running }
|
98
|
+
end
|
99
|
+
# [...]
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
**Important Warning:** The `docker_compose` resource uses the [`docker-compose-api`](https://rubygems.org/gems/docker-compose-api) Ruby gem to emulate Docker Compose. So, some *docker-compose.yml* configuration options may not be supported yet or may not work exactly the same. Let us know if you find any bug or you need a missing feature. And thanks to [Mauricio Klein](https://github.com/mauricioklein) for all his work by the way!
|
106
|
+
|
107
|
+
### Run HTTP Tests Using Infrataster
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# require 'dockerspec/serverspec' # Only if you want to run both types of tests
|
111
|
+
require 'dockerspec/infrataster'
|
112
|
+
|
113
|
+
describe docker_run('nginx') do
|
114
|
+
describe server(described_container) do # Infrataster
|
115
|
+
|
116
|
+
describe http('/') do
|
117
|
+
it 'responds content including "Welcome to nginx!"' do
|
118
|
+
expect(response.body).to include 'Welcome to nginx!'
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'responds as "nginx" server' do
|
122
|
+
expect(response.headers['server']).to match(/nginx/i)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
See the [Infrataster Resources documentation](http://www.rubydoc.info/gems/infrataster#Resources) for more information.
|
130
|
+
|
131
|
+
### Run HTTP Tests Using Capybara
|
132
|
+
|
133
|
+
In the following example we set the *admin* password and log in in a hypothetical web application:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
require 'dockerspec/infrataster'
|
137
|
+
|
138
|
+
describe docker_build('.', tag: 'mywebapp') do
|
139
|
+
describe docker_run('mywebapp') do
|
140
|
+
|
141
|
+
describe server(described_container) do
|
142
|
+
describe capybara('/') do
|
143
|
+
let(:password) { '4dm1nP4ssw0rd' }
|
144
|
+
|
145
|
+
describe 'on /setup' do
|
146
|
+
before { visit '/setup' }
|
147
|
+
|
148
|
+
it 'contains "Configure the password"' do
|
149
|
+
expect(page).to have_content 'Configure the password'
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'sets the admin password' do
|
153
|
+
fill_in 'Password', with: password
|
154
|
+
fill_in 'Confirm Password', with: password
|
155
|
+
click_button 'Set password'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe 'on /login' do
|
160
|
+
before { visit '/login' }
|
161
|
+
|
162
|
+
it 'logs in as admin' do
|
163
|
+
expect(page).to have_content 'sign in'
|
164
|
+
fill_in 'User name', with: 'admin'
|
165
|
+
fill_in 'Password', with: password
|
166
|
+
click_button 'Sig in'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe 'on /' do
|
171
|
+
before { visit '/' }
|
172
|
+
|
173
|
+
it 'is logged id' do
|
174
|
+
expect(page).to have_content 'Welcome admin!'
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|
183
|
+
```
|
184
|
+
|
185
|
+
See the [Capybara DSL documentation](http://www.rubydoc.info/gems/capybara#The_DSL) for more information.
|
186
|
+
|
187
|
+
### Run Database Tests Using `infrataster-plugin-mysql` Gem with Docker Compose
|
188
|
+
|
189
|
+
You need to include the `infrataster-plugin-mysql` gem in your *Gemfile*:
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
# Gemfile
|
193
|
+
|
194
|
+
# gem [...]
|
195
|
+
gem 'infrataster-plugin-mysql', '~> 0.2.0'
|
196
|
+
```
|
197
|
+
|
198
|
+
A *docker-compose.yml* file example with a database:
|
199
|
+
|
200
|
+
```yaml
|
201
|
+
myapp:
|
202
|
+
image: myapp
|
203
|
+
links:
|
204
|
+
- db:mysql
|
205
|
+
ports:
|
206
|
+
- 8080:80
|
207
|
+
|
208
|
+
db:
|
209
|
+
image: mariadb
|
210
|
+
environment:
|
211
|
+
- MYSQL_ROOT_PASSWORD=example
|
212
|
+
```
|
213
|
+
|
214
|
+
The file with the tests:
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
require 'dockerspec/infrataster'
|
218
|
+
require 'infrataster-plugin-mysql'
|
219
|
+
|
220
|
+
describe docker_compose('docker-compose.yml', wait: 60) do
|
221
|
+
|
222
|
+
its_container(:db, mysql: { user: 'root', password: 'example' }) do
|
223
|
+
describe server(described_container) do # Infrataster
|
224
|
+
|
225
|
+
describe mysql_query('SHOW STATUS') do
|
226
|
+
it 'returns positive uptime' do
|
227
|
+
row = results.find { |r| r['Variable_name'] == 'Uptime' }
|
228
|
+
expect(row['Value'].to_i).to be > 0
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe mysql_query('SHOW DATABASES') do
|
233
|
+
it 'includes `myapp` database' do
|
234
|
+
databases = results.map { |r| r['Database'] }
|
235
|
+
expect(databases).to include('myapp')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
```
|
243
|
+
|
244
|
+
## Documentation
|
245
|
+
|
246
|
+
- [`docker_build`](http://www.rubydoc.info/gems/dockerspec/Dockerspec/RSpec/Resources#docker_build-instance_method)
|
247
|
+
- [*Docker Build* helpers](http://www.rubydoc.info/gems/dockerspec/Dockerspec/Builder/ConfigHelpers)
|
248
|
+
- [`docker_run`](http://www.rubydoc.info/gems/dockerspec/Dockerspec/RSpec/Resources#docker_run-instance_method)
|
249
|
+
- [*Docker Run* Serverspec resource types](http://serverspec.org/resource_types.html)
|
250
|
+
- [Infrataster Resources](http://www.rubydoc.info/gems/infrataster#Resources)
|
251
|
+
- [Capybara DSL](http://www.rubydoc.info/gems/capybara#The_DSL)
|
252
|
+
- [`docker_compose`](http://www.rubydoc.info/gems/dockerspec/Dockerspec/RSpec/Resources#docker_compose-instance_method)
|
253
|
+
- [`its_container`](http://www.rubydoc.info/gems/dockerspec/Dockerspec/RSpec/Resources#its_container-instance_method)
|
254
|
+
|
87
255
|
### Real-world Examples
|
88
256
|
|
89
257
|
* [`alpine-tor`](https://github.com/zuazo/alpine-tor-docker) image ([*spec/*](https://github.com/zuazo/alpine-tor-docker/tree/master/spec), [*Gemfile*](https://github.com/zuazo/alpine-tor-docker/tree/master/Gemfile), [*.travis.yml*](https://github.com/zuazo/alpine-tor-docker/tree/master/.travis.yml)).
|
258
|
+
* [`chef-local`](https://github.com/zuazo/chef-local-docker) image ([*spec/*](https://github.com/zuazo/chef-local-docker/tree/master/spec), [*Gemfile*](https://github.com/zuazo/chef-local-docker/tree/master/Gemfile), [*.travis.yml*](https://github.com/zuazo/chef-local-docker/tree/master/.travis.yml)): Runs the same tests against multiple tags.
|
259
|
+
* [`keywhiz`](https://github.com/zuazo/keywhiz-docker) image ([*spec/*](https://github.com/zuazo/keywhiz-docker/tree/master/spec), [*Gemfile*](https://github.com/zuazo/keywhiz-docker/tree/master/Gemfile), [*.travis.yml*](https://github.com/zuazo/keywhiz-docker/tree/master/.travis.yml)).
|
260
|
+
* [`irssi-tor`](https://github.com/zuazo/irssi-tor-docker) image ([*spec/*](https://github.com/zuazo/irssi-tor-docker/tree/master/spec), [*Gemfile*](https://github.com/zuazo/irssi-tor-docker/tree/master/Gemfile), [*.travis.yml*](https://github.com/zuazo/irssi-tor-docker/tree/master/.travis.yml)).
|
261
|
+
* [`dradis`](https://github.com/zuazo/dradis-docker) image ([*spec/*](https://github.com/zuazo/dradis-docker/tree/master/spec), [*Gemfile*](https://github.com/zuazo/dradis-docker/tree/master/Gemfile), [*.travis.yml*](https://github.com/zuazo/dradis-docker/tree/master/.travis.yml)): Runs some Capybara HTTP tests.
|
90
262
|
|
91
263
|
### Prepare Your Ruby Environment
|
92
264
|
|
@@ -99,7 +271,7 @@ If you are new to Ruby, you can follow these steps:
|
|
99
271
|
|
100
272
|
source 'https://rubygems.org'
|
101
273
|
|
102
|
-
gem 'dockerspec', '~> 0.
|
274
|
+
gem 'dockerspec', '~> 0.3.0'
|
103
275
|
```
|
104
276
|
|
105
277
|
#### 2. Create the *spec/* directory:
|
@@ -113,13 +285,12 @@ $ mkdir spec
|
|
113
285
|
```ruby
|
114
286
|
# spec/myapp_spec.rb
|
115
287
|
|
116
|
-
require 'dockerspec'
|
117
288
|
require 'dockerspec/serverspec'
|
118
289
|
|
119
290
|
describe 'My Dockerfile' do
|
120
|
-
describe docker_build('.'
|
291
|
+
describe docker_build('.') do
|
121
292
|
# [...]
|
122
|
-
describe docker_run(
|
293
|
+
describe docker_run(described_image) do
|
123
294
|
# [...]
|
124
295
|
end
|
125
296
|
end
|
@@ -145,11 +316,6 @@ $ bundle exec rspec
|
|
145
316
|
```yaml
|
146
317
|
language: ruby
|
147
318
|
|
148
|
-
rvm:
|
149
|
-
- 2.0.0
|
150
|
-
- 2.1
|
151
|
-
- 2.2
|
152
|
-
|
153
319
|
sudo: required
|
154
320
|
|
155
321
|
services: docker
|
@@ -192,7 +358,7 @@ See [TODO.md](https://github.com/zuazo/dockerspec/blob/master/TODO.md).
|
|
192
358
|
| | |
|
193
359
|
|:---------------------|:-----------------------------------------|
|
194
360
|
| **Author:** | [Xabier de Zuazo](https://github.com/zuazo) (<xabier@zuazo.org>)
|
195
|
-
| **Copyright:** | Copyright (c) 2015 Xabier de Zuazo
|
361
|
+
| **Copyright:** | Copyright (c) 2015-2016 Xabier de Zuazo
|
196
362
|
| **License:** | Apache License, Version 2.0
|
197
363
|
|
198
364
|
Licensed under the Apache License, Version 2.0 (the "License");
|
data/Rakefile
CHANGED
@@ -2,7 +2,22 @@
|
|
2
2
|
# -*- mode: ruby -*-
|
3
3
|
# vi: set ft=ruby :
|
4
4
|
|
5
|
+
#
|
6
|
+
# Available Rake tasks:
|
7
|
+
#
|
8
|
+
# $ rake -T
|
9
|
+
# rake clean # Clean some generated files
|
10
|
+
# rake integration # Run the integration tests
|
11
|
+
# rake integration:infrataster # Infrataster engine integration tests
|
12
|
+
# rake integration:serverspec # Serverspec engine integration tests
|
13
|
+
# rake rubocop # Run RuboCop style checks
|
14
|
+
# rake style # Run all style checks
|
15
|
+
# rake test # Run all the tests
|
16
|
+
# rake unit # Run the unit tests
|
17
|
+
# rake yard # Generate Ruby documentation
|
18
|
+
#
|
5
19
|
# More info at https://github.com/ruby/rake/blob/master/doc/rakefile.rdoc
|
20
|
+
#
|
6
21
|
|
7
22
|
require 'bundler'
|
8
23
|
Bundler::GemHelper.install_tasks
|
@@ -43,15 +58,54 @@ task style: %w(rubocop)
|
|
43
58
|
|
44
59
|
require 'rspec/core/rake_task'
|
45
60
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
61
|
+
#
|
62
|
+
# Gest the tests directory name to use.
|
63
|
+
#
|
64
|
+
# @param name [String] The task name.
|
65
|
+
#
|
66
|
+
# @return [String] Subdirectory name inside *spec/*.
|
67
|
+
#
|
68
|
+
def rake_dir_from_name(name)
|
69
|
+
if %w(serverspec infrataster).include?(name.to_s)
|
70
|
+
'integration'
|
71
|
+
else
|
72
|
+
name.to_s == 'test' ? '{unit,integration}' : name
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Generates RakeTask to run the tests.
|
78
|
+
#
|
79
|
+
# @param name [String] The task name.
|
80
|
+
#
|
81
|
+
# @param env [Hash] The environment variables to set.
|
82
|
+
#
|
83
|
+
# @return [RSpec::Core::RakeTask] The Generated RakeTask.
|
84
|
+
#
|
85
|
+
def rake_task(name, env = {})
|
86
|
+
dir = rake_dir_from_name(name)
|
87
|
+
RSpec::Core::RakeTask.new(name) do |t|
|
88
|
+
env.each { |k, v| ENV[k.to_s.upcase] = v.to_s }
|
52
89
|
t.pattern = "spec/#{dir}/**{,/*/**}/*_spec.rb"
|
53
90
|
t.verbose = true
|
54
91
|
end
|
55
92
|
end
|
56
93
|
|
94
|
+
desc 'Run the unit tests'
|
95
|
+
rake_task(:unit)
|
96
|
+
|
97
|
+
namespace :integration do
|
98
|
+
desc 'Serverspec engine integration tests'
|
99
|
+
rake_task(:serverspec, serverspec: true)
|
100
|
+
|
101
|
+
desc 'Infrataster engine integration tests'
|
102
|
+
rake_task(:infrataster, infrataster: true)
|
103
|
+
end
|
104
|
+
|
105
|
+
desc 'Run all the integration tests'
|
106
|
+
rake_task(:integration)
|
107
|
+
|
108
|
+
desc 'Run all the tests'
|
109
|
+
rake_task(:test)
|
110
|
+
|
57
111
|
task default: %w(style test)
|
data/TODO.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# TODO for Dockerspec
|
2
2
|
|
3
3
|
* [ ] Integrate with [Inspec](https://www.chef.io/inspec/).
|
4
|
-
* [ ]
|
5
|
-
* [ ]
|
4
|
+
* [ ] Test resources for built images supported inside `docker_compose`.
|
5
|
+
* [ ] Add `docker_context`, `docker_describe` to avoid starting all containers at the same time.
|
6
6
|
* [ ] Add a Runner logger.
|
7
|
+
* [ ] Create `stub_*` methods for unit tests.
|