forked from test-kitchen/test-kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkitchen_init_command.feature
226 lines (194 loc) · 6.27 KB
/
kitchen_init_command.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
Feature: Add Test Kitchen support to an existing project
In order to add Test Kitchen to a project with minimal effort
As an operator
I want to run a command to initialize my project
@spawn
Scenario: Displaying help
When I run `kitchen help init`
Then the output should contain:
"""
Usage:
kitchen init
"""
And the exit status should be 0
@spawn
Scenario: Running init with default values
Given a sandboxed GEM_HOME directory named "kitchen-init"
And I have a git repository
When I run `kitchen init`
Then the exit status should be 0
And a directory named "test/integration/default" should exist
And the file ".gitignore" should contain ".kitchen/"
And the file ".gitignore" should contain ".kitchen.local.yml"
And the file ".kitchen.yml" should contain:
"""
driver:
name: vagrant
"""
And a file named "Gemfile" should not exist
And a file named "Rakefile" should not exist
And a file named "Thorfile" should not exist
And a gem named "kitchen-vagrant" is installed
And a file named "chefignore" should exist
And the file "chefignore" should contain ".kitchen"
Scenario: Running init that creates a Gemfile
When I successfully run `kitchen init --create-gemfile`
Then the file "Gemfile" should contain "https://rubygems.org"
And the file "Gemfile" should contain:
"""
gem "test-kitchen"
"""
And the file "Gemfile" should contain:
"""
gem "kitchen-vagrant"
"""
And the output should contain "You must run `bundle install'"
Scenario: Running init with an existing Gemfile appends to the Gemfile
Given a file named "Gemfile" with:
"""
source "https://rubygems.org"
"""
When I successfully run `kitchen init`
Then the file "Gemfile" should contain exactly:
"""
source "https://rubygems.org"
gem "test-kitchen"
gem "kitchen-vagrant"
"""
And the output should contain "You must run `bundle install'"
Scenario: Running init with a Gemfile containing test-kitchen does not
re-append
Given a file named "Gemfile" with:
"""
source "https://rubygems.org"
gem 'test-kitchen'
"""
When I successfully run `kitchen init`
Then the file "Gemfile" should contain exactly:
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem "kitchen-vagrant"
"""
And the output should contain "You must run `bundle install'"
Scenario: Running init with a Gemfile containing the driver gem does not
re-append
Given a file named "Gemfile" with:
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem 'kitchen-ec2'
"""
When I successfully run `kitchen init --driver=kitchen-ec2`
Then the file "Gemfile" should contain exactly:
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem 'kitchen-ec2'
"""
And the output should not contain "You must run `bundle install'"
Scenario: Running init with multiple drivers appends to the Gemfile
Given an empty file named "Gemfile"
When I successfully run `kitchen init --driver=kitchen-bluebox kitchen-wakka`
Then the file "Gemfile" should contain:
"""
gem "kitchen-bluebox"
"""
And the file "Gemfile" should contain:
"""
gem "kitchen-wakka"
"""
And the output should contain "You must run `bundle install'"
Scenario: Running init with multiple driver sets the plugin_driver to the
first driver given
Given an empty file named "Gemfile"
When I successfully run `kitchen init --driver=kitchen-bluebox kitchen-wakka`
Then the file ".kitchen.yml" should contain:
"""
driver:
name: bluebox
"""
Scenario: Running init with no drivers sets the plugin_driver to the
dummy driver
Given an empty file named "Gemfile"
When I successfully run `kitchen init --no-driver`
Then the file ".kitchen.yml" should contain:
"""
driver:
name: dummy
"""
Scenario: Running init without a provisioner sets the default provisioner
to chef_solo in .kitchen.yml
Given an empty file named "Gemfile"
When I successfully run `kitchen init --no-driver`
Then the file ".kitchen.yml" should contain:
"""
provisioner:
name: chef_solo
"""
Scenario: Running init with a provisioner sets the provisioner in .kitchen.yml
Given an empty file named "Gemfile"
When I successfully run `kitchen init --no-driver --provisioner=chef_zero`
Then the file ".kitchen.yml" should contain:
"""
provisioner:
name: chef_zero
"""
Scenario: Running with a Rakefile file appends Kitchen tasks
Given an empty file named "Gemfile"
And an empty file named "Rakefile"
When I successfully run `kitchen init`
Then the file "Rakefile" should contain:
"""
begin
require "kitchen/rake_tasks"
Kitchen::RakeTasks.new
rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
end
"""
Scenario: Running without git doesn't make a .gitignore
When I successfully run `kitchen init`
Then the exit status should be 0
And a file named ".gitignore" should not exist
Scenario: Running with a Thorfile file appends Kitchen tasks
Given an empty file named "Gemfile"
Given an empty file named "Thorfile"
When I successfully run `kitchen init`
Then the file "Thorfile" should contain:
"""
begin
require "kitchen/thor_tasks"
Kitchen::ThorTasks.new
rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
end
"""
Scenario: Running init with a name in metadata.rb sets a run list
Given an empty file named "Gemfile"
Given a file named "metadata.rb" with:
"""
name "ntp"
license "Apache 2.0"
description "Installs and configures ntp as a client or server"
version "0.1.0"
support "ubuntu"
support "centos"
"""
When I successfully run `kitchen init`
Then the file ".kitchen.yml" should contain exactly:
"""
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: ubuntu-14.04
- name: centos-7.1
suites:
- name: default
run_list:
- recipe[ntp::default]
attributes:
"""