cukedep 0.1.11 → 0.2.00

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +6 -14
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +10 -10
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +5 -5
  6. data/LICENSE.txt +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +30 -30
  9. data/bin/cukedep +15 -15
  10. data/lib/cukedep/application.rb +105 -112
  11. data/lib/cukedep/cli/cmd-line.rb +11 -13
  12. data/lib/cukedep/config.rb +85 -89
  13. data/lib/cukedep/constants.rb +5 -5
  14. data/lib/cukedep/cuke-runner.rb +191 -198
  15. data/lib/cukedep/customization.rb +30 -30
  16. data/lib/cukedep/feature-model.rb +43 -46
  17. data/lib/cukedep/feature-rep.rb +9 -11
  18. data/lib/cukedep/file-action.rb +11 -18
  19. data/lib/cukedep/gherkin-facade.rb +11 -6
  20. data/lib/cukedep/gherkin-listener.rb +12 -42
  21. data/lib/cukedep/hook-dsl.rb +78 -78
  22. data/lib/cukedep/sandbox.rb +15 -16
  23. data/lib/cukedep.rb +1 -2
  24. data/sample/features/step_definitions/steps.rb +2 -2
  25. data/sample/model/model.rb +19 -20
  26. data/spec/cukedep/application_spec.rb +80 -80
  27. data/spec/cukedep/cli/cmd-line_spec.rb +88 -88
  28. data/spec/cukedep/cuke-runner_spec.rb +74 -74
  29. data/spec/cukedep/customization_spec.rb +31 -31
  30. data/spec/cukedep/debug-file-action.rb +29 -29
  31. data/spec/cukedep/feature-model_spec.rb +100 -100
  32. data/spec/cukedep/feature-rep_spec.rb +2 -1
  33. data/spec/cukedep/file-action_spec.rb +365 -366
  34. data/spec/cukedep/file-parsing.rb +39 -41
  35. data/spec/cukedep/gherkin-facade_spec.rb +48 -49
  36. data/spec/cukedep/gherkin-listener_spec.rb +55 -57
  37. data/spec/cukedep/hook-dsl_spec.rb +182 -182
  38. data/spec/cukedep/sample_features/cukedep_hooks.rb +30 -30
  39. data/spec/cukedep/sample_features/standalone.feature +1 -1
  40. data/templates/rake.erb +12 -21
  41. metadata +80 -58
  42. data/sample/result.html +0 -472
  43. data/spec/cukedep/sample_features/cukedep.rake +0 -215
  44. data/spec/cukedep/sample_features/dependencies.dot +0 -38
  45. data/spec/cukedep/sample_features/feature2id.csv +0 -7
@@ -1,366 +1,365 @@
1
- # File: file-action_spec.rb
2
- require_relative '../spec_helper'
3
-
4
- # Load the class under testing
5
- require_relative '../../lib/cukedep/file-action'
6
-
7
- module Cukedep # Open module to get rid of long qualified names
8
- # Test the behaviour of the superclass
9
- describe FileAction do
10
- let(:some_patterns) { %w(README.* *tests.feature) }
11
- let(:subpath) { './some-dir' }
12
-
13
- subject { FileAction.new(some_patterns, subpath) }
14
-
15
- context 'Creation & initialization:' do
16
- it 'should be created with file patterns and a subdirectory argument' do
17
- # Case 1: empty instance
18
- expect { FileAction.new([], '') }.not_to raise_error
19
-
20
- # Case 2: stuffed instance
21
- expect { FileAction.new(some_patterns, subpath) }.not_to raise_error
22
- end
23
-
24
- it 'should know its file patterns' do
25
- expect(subject.patterns).to eq(some_patterns)
26
- end
27
-
28
- it "should know the target's subdirectory" do
29
- expect(subject.delta).to eq(subpath)
30
- end
31
- end # context
32
-
33
-
34
- context 'Basic services:' do
35
- it 'should know whether it is equal to another instance' do
36
- # Case 1: comparing with itself
37
- expect(subject).to eq(subject)
38
-
39
- # Case 2: comparing with instance with same attribute values
40
- expect(subject).to eq(subject.dup)
41
-
42
- # Case 3: comparing with instances having different attribute values
43
- another = FileAction.new(some_patterns, '')
44
- expect(subject).not_to eq(another)
45
- another = FileAction.new(['*.feature'], subpath)
46
- expect(subject).not_to eq(another)
47
- end
48
- end # context
49
- end # describe
50
-
51
-
52
- describe CopyAction do
53
- let(:source_dir) do
54
- child = '/sample_features/files_to_copy'
55
- File.join(File.dirname(__FILE__), child)
56
- end
57
-
58
- let(:subdir) do
59
- './sample_features/saved_files'
60
- end
61
-
62
-
63
- def clean_dir(aDirectory)
64
- terminator = DeleteAction.new(['*.*'])
65
- terminator.run!(aDirectory)
66
- end
67
-
68
-
69
- before(:all) do
70
- # Clean stuffed dirs
71
- path_suffix = '/sample_features/saved_files'
72
- target_dir = File.join(File.dirname(__FILE__), path_suffix)
73
- if Dir.exist?(target_dir)
74
- clean_dir(target_dir)
75
- else
76
- Dir.mkdir(target_dir)
77
- end
78
- end
79
-
80
-
81
- before(:each) do
82
- # Store the working dir before starting
83
- @original_work_dir = Dir.getwd
84
- end
85
-
86
-
87
- after(:each) do
88
- # Restore the original working dir
89
- Dir.chdir(@original_work_dir)
90
- end
91
-
92
-
93
- context 'Copying files' do
94
- it 'should copy files matching the patterns' do
95
- my_dir = File.dirname(__FILE__)
96
-
97
- # Case: one file pattern
98
- instance1 = CopyAction.new(['*.md'], subdir)
99
- expect { instance1.run!(source_dir, my_dir) }.not_to raise_error
100
-
101
- Dir.chdir(my_dir)
102
- # Control the result...
103
- copied_files = Dir.glob(subdir + '/' + '*.*')
104
- expect(copied_files.size).to eq(1)
105
-
106
- # Case: two file patterns
107
- instance2 = CopyAction.new(['file1.txt', 'file2.txt'], subdir)
108
- expect { instance2.run!(source_dir, my_dir) }.not_to raise_error
109
-
110
- # Control the result...
111
- copied_files = Dir.glob(subdir + '/' + '*.*')
112
- expect(copied_files.size).to eq(3)
113
- end
114
- end # context
115
- end # describe
116
-
117
-
118
- describe DeleteAction do
119
- let(:subdir) do
120
- './sample_features/saved_files'
121
- end
122
-
123
- let(:target_dir) do
124
- File.join(File.dirname(__FILE__), subdir)
125
- end
126
-
127
-
128
- before(:each) do
129
- # Store the working dir before starting
130
- @original_work_dir = Dir.getwd
131
- end
132
-
133
-
134
- after(:each) do
135
- # Restore the original working dir
136
- Dir.chdir(@original_work_dir)
137
- end
138
-
139
-
140
- context 'Deleting files' do
141
- it 'should delete files matching the patterns' do
142
- my_dir = File.dirname(__FILE__)
143
-
144
- # Case: one file pattern and a subdir
145
- instance1 = DeleteAction.new(['*.md'], subdir)
146
- expect { instance1.run!(my_dir) }.not_to raise_error
147
- Dir.chdir(my_dir)
148
-
149
- # Control the result...
150
- remaining_files = Dir.glob(subdir + '/' + '*.*')
151
- expect(remaining_files.size).to eq(2)
152
-
153
- # Case: multiple file patterns and no subdir
154
- instance2 = DeleteAction.new(['file1.txt', 'file3.txt'])
155
- expect { instance2.run!(target_dir) }.not_to raise_error
156
-
157
- # Control the result...
158
- remaining_files = Dir.glob(subdir + '/' + '*.*')
159
- expect(remaining_files.size).to eq(1)
160
-
161
- # Delete all files
162
- instance3 = DeleteAction.new(['*.*'])
163
- expect { instance3.run!(target_dir) }.not_to raise_error
164
-
165
- # Control the result...
166
- remaining_files = Dir.glob(subdir + '/' + '*.*')
167
- expect(remaining_files.size).to eq(0)
168
- end
169
- end # context
170
- end # describe
171
-
172
-
173
- describe ActionTriplet do
174
- def saved_files_dir()
175
- my_dir = File.dirname(__FILE__)
176
- return my_dir + '/sample_features/saved_files'
177
- end
178
-
179
- # File patterns
180
- def all_files()
181
- return ['*.*']
182
- end
183
-
184
-
185
- def txt_only()
186
- return ['*.txt']
187
- end
188
-
189
- let(:empty_config) do
190
- {
191
- save_patterns: [],
192
- save_subdir: '',
193
- delete_patterns: [],
194
- delete_subdir: '',
195
- copy_patterns: [],
196
- copy_subdir: ''
197
- }
198
- end
199
-
200
- let(:sample_config) do
201
- {
202
- save_patterns: txt_only,
203
- save_subdir: saved_files_dir,
204
- delete_patterns: all_files,
205
- delete_subdir: '',
206
- copy_patterns: txt_only,
207
- copy_subdir: ''
208
- }
209
- end
210
-
211
- context 'Creation & initialization:' do
212
- it 'should be created with Hash-like arguments' do
213
- # Case 1: empty instance
214
- expect { ActionTriplet.new(empty_config) }.not_to raise_error
215
-
216
- # Case 2: stuffed instance
217
- expect { ActionTriplet.new(sample_config) }.not_to raise_error
218
- end
219
- end # context
220
-
221
- context 'Basic services:' do
222
- subject { ActionTriplet.new(sample_config) }
223
-
224
- it 'should compare with other instances' do
225
- # Case 1: comparing with itself
226
- expect(subject).to eq(subject)
227
-
228
- # Case 2: comparing with instance with same attribute values
229
- expect(subject).to eq(subject.dup)
230
-
231
- # Case 3: comparing with instance with different attribute values
232
- other_config = sample_config.dup
233
- other_config[:copy_patterns] = all_files
234
- another = ActionTriplet.new(other_config)
235
- expect(subject).not_to eq(another)
236
- end
237
- end # context
238
-
239
-
240
- context 'Actions on files:' do
241
- before(:each) do
242
- # Store the working dir before starting
243
- @original_work_dir = Dir.getwd
244
- end
245
-
246
-
247
- after(:each) do
248
- # Restore the original working dir
249
- Dir.chdir(@original_work_dir)
250
- end
251
-
252
- after(:all) do
253
- # Clean stuffed dirs
254
- clean_dir(saved_files_dir)
255
- clean_dir(proj_dir)
256
- end
257
-
258
- # Directories
259
- def proj_dir()
260
- my_dir = File.join(File.dirname(__FILE__), '/dummy_project')
261
-
262
- if Dir.exist?(my_dir)
263
- clean_dir(my_dir)
264
- else
265
- Dir.mkdir(my_dir)
266
- end
267
-
268
- return my_dir
269
- end
270
-
271
- def files_to_copy_dir()
272
- child = '/sample_features/files_to_copy'
273
- File.join(File.dirname(__FILE__), child)
274
- end
275
-
276
- def clean_dir(aDirectory)
277
- # Create an instance with just delete file items
278
- instance = DeleteAction.new(all_files, '')
279
-
280
- # Clean the directory
281
- instance.run!(aDirectory)
282
- end
283
-
284
-
285
- it 'should be able to delete all files in the specified dir' do
286
- # Clean project dir
287
- clean_dir(proj_dir)
288
- Dir.chdir(proj_dir)
289
- expect(Dir['*.*']).to be_empty
290
- end
291
-
292
- it 'should copy files to specified dir' do
293
- # Case 1: an instance with just one copy file pattern
294
- copy_config = empty_config.dup
295
- copy_config[:copy_patterns] = txt_only
296
- instance = ActionTriplet.new(copy_config)
297
-
298
- # Current dir is the directory containing the files to copy
299
- Dir.chdir(files_to_copy_dir)
300
- project_dir = proj_dir
301
- instance.run!(Dir.getwd, project_dir)
302
-
303
- # Check that the project dir contain the requested files
304
- Dir.chdir(project_dir)
305
- actuals = Dir['*.*']
306
- expect(actuals.size).to eq(3)
307
- expect(actuals.sort).to eq(%w(file1.txt file2.txt file3.txt))
308
-
309
- # Clean project dir
310
- clean_dir(project_dir)
311
-
312
- # Case 2: an instance with just two copy file patterns
313
- copy_config[:copy_patterns] << 'README.md'
314
- instance = ActionTriplet.new(copy_config)
315
-
316
- # Current dir is the directory containing the files to copy
317
- Dir.chdir(files_to_copy_dir)
318
- instance.run!(Dir.getwd, project_dir)
319
-
320
- actuals = Dir['*.*']
321
- expect(actuals.size).to eq(4)
322
- (txt_files, md_files) = actuals.partition { |f| f =~ /\.txt/ }
323
- expect(txt_files.sort).to eq(%w(file1.txt file2.txt file3.txt))
324
- expect(md_files).to eq(%w(README.md))
325
- end
326
-
327
- =begin
328
- it 'should save files to the specified folder' do
329
- # Clean saved_files dir
330
- saved = saved_files_dir
331
- Dir.chdir(saved)
332
- pp Dir.getwd
333
- expect(Dir['*.*']).to be_empty
334
-
335
- save_config = empty_config.dup
336
- save_config[:save_patterns] = ['README.md']
337
- project_dir = proj_dir
338
-
339
- # Case 1: the save dir is absolute
340
- instance = ActionTriplet.new(save_config)
341
- instance.run!(Dir.getwd, project_dir)
342
- actuals = Dir['*.*']
343
- expect(actuals.size).to eq(1)
344
- expect(actuals).to eq(['README.md'])
345
-
346
- # Clean again saved_files dir
347
- clean_dir(saved)
348
- my_dir = File.dirname(__FILE__)
349
- save_config[:save_patterns] = txt_only
350
- save_config[:save_subdir] = './sample_features/saved_files'
351
-
352
- instance = ActionTriplet.new(save_config)
353
- Dir.chdir(my_dir)
354
- instance.run!(my_dir, project_dir)
355
-
356
- Dir.chdir(saved_files_dir)
357
- actuals = Dir['*.*']
358
- expect(actuals.size).to eq(3)
359
- expect(actuals.sort).to eq(%w[file1.txt file2.txt file3.txt])
360
- end
361
- =end
362
- end # context
363
- end # describe
364
- end # module
365
-
366
- # End of file
1
+ # File: file-action_spec.rb
2
+ require_relative '../spec_helper'
3
+
4
+ # Load the class under testing
5
+ require_relative '../../lib/cukedep/file-action'
6
+
7
+ module Cukedep # Open module to get rid of long qualified names
8
+ # Test the behaviour of the superclass
9
+ describe FileAction do
10
+ let(:some_patterns) { %w(README.* *tests.feature) }
11
+ let(:subpath) { './some-dir' }
12
+
13
+ subject { FileAction.new(some_patterns, subpath) }
14
+
15
+ context 'Creation & initialization:' do
16
+ it 'should be created with file patterns and a subdirectory argument' do
17
+ # Case 1: empty instance
18
+ expect { FileAction.new([], '') }.not_to raise_error
19
+
20
+ # Case 2: stuffed instance
21
+ expect { FileAction.new(some_patterns, subpath) }.not_to raise_error
22
+ end
23
+
24
+ it 'should know its file patterns' do
25
+ expect(subject.patterns).to eq(some_patterns)
26
+ end
27
+
28
+ it "should know the target's subdirectory" do
29
+ expect(subject.delta).to eq(subpath)
30
+ end
31
+ end # context
32
+
33
+
34
+ context 'Basic services:' do
35
+ it 'should know whether it is equal to another instance' do
36
+ # Case 1: comparing with itself
37
+ expect(subject).to eq(subject)
38
+
39
+ # Case 2: comparing with instance with same attribute values
40
+ expect(subject).to eq(subject.dup)
41
+
42
+ # Case 3: comparing with instances having different attribute values
43
+ another = FileAction.new(some_patterns, '')
44
+ expect(subject).not_to eq(another)
45
+ another = FileAction.new(['*.feature'], subpath)
46
+ expect(subject).not_to eq(another)
47
+ end
48
+ end # context
49
+ end # describe
50
+
51
+
52
+ describe CopyAction do
53
+ let(:source_dir) do
54
+ child = '/sample_features/files_to_copy'
55
+ File.join(File.dirname(__FILE__), child)
56
+ end
57
+
58
+ let(:subdir) do
59
+ './sample_features/saved_files'
60
+ end
61
+
62
+
63
+ def clean_dir(aDirectory)
64
+ terminator = DeleteAction.new(['*.*'])
65
+ terminator.run!(aDirectory)
66
+ end
67
+
68
+
69
+ before(:all) do
70
+ # Clean stuffed dirs
71
+ path_suffix = '/sample_features/saved_files'
72
+ target_dir = File.join(File.dirname(__FILE__), path_suffix)
73
+ if Dir.exist?(target_dir)
74
+ clean_dir(target_dir)
75
+ else
76
+ Dir.mkdir(target_dir)
77
+ end
78
+ end
79
+
80
+
81
+ before(:each) do
82
+ # Store the working dir before starting
83
+ @original_work_dir = Dir.getwd
84
+ end
85
+
86
+
87
+ after(:each) do
88
+ # Restore the original working dir
89
+ Dir.chdir(@original_work_dir)
90
+ end
91
+
92
+
93
+ context 'Copying files' do
94
+ it 'should copy files matching the patterns' do
95
+ my_dir = File.dirname(__FILE__)
96
+
97
+ # Case: one file pattern
98
+ instance1 = CopyAction.new(['*.md'], subdir)
99
+ expect { instance1.run!(source_dir, my_dir) }.not_to raise_error
100
+
101
+ Dir.chdir(my_dir)
102
+ # Control the result...
103
+ copied_files = Dir.glob(subdir + '/' + '*.*')
104
+ expect(copied_files.size).to eq(1)
105
+
106
+ # Case: two file patterns
107
+ instance2 = CopyAction.new(['file1.txt', 'file2.txt'], subdir)
108
+ expect { instance2.run!(source_dir, my_dir) }.not_to raise_error
109
+
110
+ # Control the result...
111
+ copied_files = Dir.glob(subdir + '/' + '*.*')
112
+ expect(copied_files.size).to eq(3)
113
+ end
114
+ end # context
115
+ end # describe
116
+
117
+
118
+ describe DeleteAction do
119
+ let(:subdir) do
120
+ './sample_features/saved_files'
121
+ end
122
+
123
+ let(:target_dir) do
124
+ File.join(File.dirname(__FILE__), subdir)
125
+ end
126
+
127
+
128
+ before(:each) do
129
+ # Store the working dir before starting
130
+ @original_work_dir = Dir.getwd
131
+ end
132
+
133
+
134
+ after(:each) do
135
+ # Restore the original working dir
136
+ Dir.chdir(@original_work_dir)
137
+ end
138
+
139
+
140
+ context 'Deleting files' do
141
+ it 'should delete files matching the patterns' do
142
+ my_dir = File.dirname(__FILE__)
143
+
144
+ # Case: one file pattern and a subdir
145
+ instance1 = DeleteAction.new(['*.md'], subdir)
146
+ expect { instance1.run!(my_dir) }.not_to raise_error
147
+ Dir.chdir(my_dir)
148
+
149
+ # Control the result...
150
+ remaining_files = Dir.glob(subdir + '/' + '*.*')
151
+ expect(remaining_files.size).to eq(2)
152
+
153
+ # Case: multiple file patterns and no subdir
154
+ instance2 = DeleteAction.new(['file1.txt', 'file3.txt'])
155
+ expect { instance2.run!(target_dir) }.not_to raise_error
156
+
157
+ # Control the result...
158
+ remaining_files = Dir.glob(subdir + '/' + '*.*')
159
+ expect(remaining_files.size).to eq(1)
160
+
161
+ # Delete all files
162
+ instance3 = DeleteAction.new(['*.*'])
163
+ expect { instance3.run!(target_dir) }.not_to raise_error
164
+
165
+ # Control the result...
166
+ remaining_files = Dir.glob(subdir + '/' + '*.*')
167
+ expect(remaining_files.size).to eq(0)
168
+ end
169
+ end # context
170
+ end # describe
171
+
172
+
173
+ describe ActionTriplet do
174
+ def saved_files_dir
175
+ my_dir = File.dirname(__FILE__)
176
+ return my_dir + '/sample_features/saved_files'
177
+ end
178
+
179
+ # File patterns
180
+ def all_files
181
+ return ['*.*']
182
+ end
183
+
184
+ def txt_only
185
+ return ['*.txt']
186
+ end
187
+
188
+ let(:empty_config) do
189
+ {
190
+ save_patterns: [],
191
+ save_subdir: '',
192
+ delete_patterns: [],
193
+ delete_subdir: '',
194
+ copy_patterns: [],
195
+ copy_subdir: ''
196
+ }
197
+ end
198
+
199
+ let(:sample_config) do
200
+ {
201
+ save_patterns: txt_only,
202
+ save_subdir: saved_files_dir,
203
+ delete_patterns: all_files,
204
+ delete_subdir: '',
205
+ copy_patterns: txt_only,
206
+ copy_subdir: ''
207
+ }
208
+ end
209
+
210
+ context 'Creation & initialization:' do
211
+ it 'should be created with Hash-like arguments' do
212
+ # Case 1: empty instance
213
+ expect { ActionTriplet.new(empty_config) }.not_to raise_error
214
+
215
+ # Case 2: stuffed instance
216
+ expect { ActionTriplet.new(sample_config) }.not_to raise_error
217
+ end
218
+ end # context
219
+
220
+ context 'Basic services:' do
221
+ subject { ActionTriplet.new(sample_config) }
222
+
223
+ it 'should compare with other instances' do
224
+ # Case 1: comparing with itself
225
+ expect(subject).to eq(subject)
226
+
227
+ # Case 2: comparing with instance with same attribute values
228
+ expect(subject).to eq(subject.dup)
229
+
230
+ # Case 3: comparing with instance with different attribute values
231
+ other_config = sample_config.dup
232
+ other_config[:copy_patterns] = all_files
233
+ another = ActionTriplet.new(other_config)
234
+ expect(subject).not_to eq(another)
235
+ end
236
+ end # context
237
+
238
+
239
+ context 'Actions on files:' do
240
+ before(:each) do
241
+ # Store the working dir before starting
242
+ @original_work_dir = Dir.getwd
243
+ end
244
+
245
+
246
+ after(:each) do
247
+ # Restore the original working dir
248
+ Dir.chdir(@original_work_dir)
249
+ end
250
+
251
+ after(:all) do
252
+ # Clean stuffed dirs
253
+ clean_dir(saved_files_dir)
254
+ clean_dir(proj_dir)
255
+ end
256
+
257
+ # Directories
258
+ def proj_dir
259
+ my_dir = File.join(File.dirname(__FILE__), '/dummy_project')
260
+
261
+ if Dir.exist?(my_dir)
262
+ clean_dir(my_dir)
263
+ else
264
+ Dir.mkdir(my_dir)
265
+ end
266
+
267
+ return my_dir
268
+ end
269
+
270
+ def files_to_copy_dir
271
+ child = '/sample_features/files_to_copy'
272
+ File.join(File.dirname(__FILE__), child)
273
+ end
274
+
275
+ def clean_dir(aDirectory)
276
+ # Create an instance with just delete file items
277
+ instance = DeleteAction.new(all_files, '')
278
+
279
+ # Clean the directory
280
+ instance.run!(aDirectory)
281
+ end
282
+
283
+
284
+ it 'should be able to delete all files in the specified dir' do
285
+ # Clean project dir
286
+ clean_dir(proj_dir)
287
+ Dir.chdir(proj_dir)
288
+ expect(Dir['*.*']).to be_empty
289
+ end
290
+
291
+ it 'should copy files to specified dir' do
292
+ # Case 1: an instance with just one copy file pattern
293
+ copy_config = empty_config.dup
294
+ copy_config[:copy_patterns] = txt_only
295
+ instance = ActionTriplet.new(copy_config)
296
+
297
+ # Current dir is the directory containing the files to copy
298
+ Dir.chdir(files_to_copy_dir)
299
+ project_dir = proj_dir
300
+ instance.run!(Dir.getwd, project_dir)
301
+
302
+ # Check that the project dir contain the requested files
303
+ Dir.chdir(project_dir)
304
+ actuals = Dir['*.*']
305
+ expect(actuals.size).to eq(3)
306
+ expect(actuals.sort).to eq(%w(file1.txt file2.txt file3.txt))
307
+
308
+ # Clean project dir
309
+ clean_dir(project_dir)
310
+
311
+ # Case 2: an instance with just two copy file patterns
312
+ copy_config[:copy_patterns] << 'README.md'
313
+ instance = ActionTriplet.new(copy_config)
314
+
315
+ # Current dir is the directory containing the files to copy
316
+ Dir.chdir(files_to_copy_dir)
317
+ instance.run!(Dir.getwd, project_dir)
318
+
319
+ actuals = Dir['*.*']
320
+ expect(actuals.size).to eq(4)
321
+ (txt_files, md_files) = actuals.partition { |f| f =~ /\.txt/ }
322
+ expect(txt_files.sort).to eq(%w(file1.txt file2.txt file3.txt))
323
+ expect(md_files).to eq(%w(README.md))
324
+ end
325
+
326
+ =begin
327
+ it 'should save files to the specified folder' do
328
+ # Clean saved_files dir
329
+ saved = saved_files_dir
330
+ Dir.chdir(saved)
331
+ pp Dir.getwd
332
+ expect(Dir['*.*']).to be_empty
333
+
334
+ save_config = empty_config.dup
335
+ save_config[:save_patterns] = ['README.md']
336
+ project_dir = proj_dir
337
+
338
+ # Case 1: the save dir is absolute
339
+ instance = ActionTriplet.new(save_config)
340
+ instance.run!(Dir.getwd, project_dir)
341
+ actuals = Dir['*.*']
342
+ expect(actuals.size).to eq(1)
343
+ expect(actuals).to eq(['README.md'])
344
+
345
+ # Clean again saved_files dir
346
+ clean_dir(saved)
347
+ my_dir = File.dirname(__FILE__)
348
+ save_config[:save_patterns] = txt_only
349
+ save_config[:save_subdir] = './sample_features/saved_files'
350
+
351
+ instance = ActionTriplet.new(save_config)
352
+ Dir.chdir(my_dir)
353
+ instance.run!(my_dir, project_dir)
354
+
355
+ Dir.chdir(saved_files_dir)
356
+ actuals = Dir['*.*']
357
+ expect(actuals.size).to eq(3)
358
+ expect(actuals.sort).to eq(%w[file1.txt file2.txt file3.txt])
359
+ end
360
+ =end
361
+ end # context
362
+ end # describe
363
+ end # module
364
+
365
+ # End of file