fig 2.0.0.pre.alpha.4 → 2.0.0.pre.alpha.5

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fig/spec_utils.rb +312 -0
  3. data/lib/fig/version.rb +1 -1
  4. data/spec/application_configuration_spec.rb +73 -0
  5. data/spec/command/clean_spec.rb +62 -0
  6. data/spec/command/command_line_vs_package_spec.rb +32 -0
  7. data/spec/command/dump_package_definition_spec.rb +104 -0
  8. data/spec/command/environment_variables_spec.rb +62 -0
  9. data/spec/command/grammar_asset_spec.rb +391 -0
  10. data/spec/command/grammar_command_spec.rb +88 -0
  11. data/spec/command/grammar_environment_variable_spec.rb +384 -0
  12. data/spec/command/grammar_retrieve_spec.rb +74 -0
  13. data/spec/command/grammar_spec.rb +87 -0
  14. data/spec/command/grammar_spec_helper.rb +23 -0
  15. data/spec/command/include_file_spec.rb +73 -0
  16. data/spec/command/listing_spec.rb +1574 -0
  17. data/spec/command/miscellaneous_spec.rb +145 -0
  18. data/spec/command/publish_local_and_updates_spec.rb +32 -0
  19. data/spec/command/publishing_retrieval_spec.rb +423 -0
  20. data/spec/command/publishing_spec.rb +596 -0
  21. data/spec/command/running_commands_spec.rb +354 -0
  22. data/spec/command/suppress_includes_spec.rb +65 -0
  23. data/spec/command/suppress_warning_include_statement_missing_version_spec.rb +134 -0
  24. data/spec/command/update_lock_response_spec.rb +47 -0
  25. data/spec/command/usage_errors_spec.rb +481 -0
  26. data/spec/command_options_spec.rb +184 -0
  27. data/spec/command_spec.rb +49 -0
  28. data/spec/deparser/v1_spec.rb +64 -0
  29. data/spec/environment_variables_spec.rb +91 -0
  30. data/spec/figrc_spec.rb +144 -0
  31. data/spec/parser_spec.rb +398 -0
  32. data/spec/repository_spec.rb +117 -0
  33. data/spec/runtime_environment_spec.rb +357 -0
  34. data/spec/spec_helper.rb +1 -0
  35. data/spec/split_repo_url_spec.rb +190 -0
  36. data/spec/statement/asset_spec.rb +203 -0
  37. data/spec/statement/configuration_spec.rb +41 -0
  38. data/spec/support/formatters/seed_spitter.rb +12 -0
  39. data/spec/working_directory_maintainer_spec.rb +102 -0
  40. metadata +42 -5
@@ -0,0 +1,391 @@
1
+ # coding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/grammar_spec_helper')
3
+
4
+ require 'cgi'
5
+
6
+ require 'fig/operating_system'
7
+
8
+ # I do not understand the scoping rules for RSpec at all.
9
+
10
+ # Block is supposed to publish the package given a URL.
11
+ def test_published_asset_with_url_with_symbol(
12
+ asset_type, symbol, quote, version
13
+ )
14
+ file_name = "with#{symbol}symbol.zip"
15
+ escaped_file = CGI.escape file_name
16
+ quoted_url =
17
+ "#{quote}file://#{CURRENT_DIRECTORY}/#{escaped_file}#{quote}"
18
+
19
+ it %Q<with URL «#{quoted_url}» (contains a «#{symbol}»)> do
20
+ IO.write "#{CURRENT_DIRECTORY}/#{file_name}", ''
21
+
22
+ yield quoted_url
23
+
24
+ check_published_grammar_version(version)
25
+
26
+ out, err =
27
+ fig(%w< foo/1.2.3 --dump-package-definition-text >, :fork => false)
28
+
29
+ # Test that the statement gets rewritten without the URL.
30
+ #
31
+ # Assumes that all grammar versions don't put non-whitespace before the
32
+ # asset statement.
33
+ out.should =~ /
34
+ ^ \s*
35
+ #{asset_type}
36
+ \s+
37
+ ['"]? # Don't worry about what the grammar does with quoting.
38
+ #{Regexp.escape file_name}
39
+ \b
40
+ /x
41
+ end
42
+
43
+ return
44
+ end
45
+
46
+ def test_published_command_line_asset_with_url_with_symbol(
47
+ asset_type, symbol, quote, version
48
+ )
49
+ test_published_asset_with_url_with_symbol(
50
+ asset_type, symbol, quote, version
51
+ ) do
52
+ |quoted_url|
53
+
54
+ fig(
55
+ [ %w< --publish foo/1.2.3 --set x=y >, "--#{asset_type}", quoted_url ],
56
+ :fork => false
57
+ )
58
+ end
59
+
60
+ return
61
+ end
62
+
63
+ def test_published_file_asset_with_url_with_symbol(
64
+ asset_type, symbol, quote, version
65
+ )
66
+ test_published_asset_with_url_with_symbol(
67
+ asset_type, symbol, quote, version
68
+ ) do
69
+ |quoted_url|
70
+
71
+ input = <<-"END"
72
+ grammar v1
73
+
74
+ #{asset_type} #{quoted_url}
75
+
76
+ config default
77
+ end
78
+ END
79
+ fig %w< --publish foo/1.2.3 >, input, :fork => false
80
+ end
81
+
82
+ return
83
+ end
84
+
85
+ def test_published_asset_with_file_with_symbol(
86
+ asset_type, symbol, quote, version
87
+ )
88
+ file_name = "with#{symbol}symbol.zip"
89
+ quoted_name = "#{quote}#{file_name}#{quote}"
90
+
91
+ it %Q<with file «#{quoted_name}»> do
92
+ IO.write "#{CURRENT_DIRECTORY}/#{file_name}", ''
93
+
94
+ yield quoted_name
95
+
96
+ check_published_grammar_version(version)
97
+ end
98
+
99
+ return
100
+ end
101
+
102
+ def test_published_command_line_asset_with_file_with_symbol(
103
+ asset_type, symbol, quote, version
104
+ )
105
+ test_published_asset_with_file_with_symbol(
106
+ asset_type, symbol, quote, version
107
+ ) do
108
+ |quoted_name|
109
+
110
+ fig(
111
+ [ %w< --publish foo/1.2.3 --set x=y >, "--#{asset_type}", quoted_name ],
112
+ :fork => false
113
+ )
114
+ end
115
+
116
+ return
117
+ end
118
+
119
+ def test_published_file_asset_with_file_with_symbol(
120
+ asset_type, symbol, quote, version
121
+ )
122
+ test_published_asset_with_file_with_symbol(
123
+ asset_type, symbol, quote, version
124
+ ) do
125
+ |quoted_url|
126
+
127
+ input = <<-"END"
128
+ grammar v1
129
+
130
+ #{asset_type} #{quoted_url}
131
+
132
+ config default
133
+ end
134
+ END
135
+ fig %w< --publish foo/1.2.3 >, input, :fork => false
136
+ end
137
+
138
+ return
139
+ end
140
+
141
+ def full_glob_characters() return %w< * ? [ ] { } >; end
142
+ def testable_glob_characters()
143
+ return full_glob_characters() -
144
+ Fig::OperatingSystem.file_name_illegal_characters
145
+ end
146
+
147
+ def v1_special_characters() return full_glob_characters + %w[ # ]; end
148
+ def v1_non_special_characters() return %w[ < > | ]; end
149
+ def v0_special_characters()
150
+ return v1_special_characters + v1_non_special_characters
151
+ end
152
+ def testable_v1_special_characters()
153
+ return v1_special_characters() -
154
+ Fig::OperatingSystem.file_name_illegal_characters
155
+ end
156
+ def testable_v1_non_special_characters()
157
+ return v1_non_special_characters() -
158
+ Fig::OperatingSystem.file_name_illegal_characters
159
+ end
160
+ def testable_v0_special_characters()
161
+ return v0_special_characters() -
162
+ Fig::OperatingSystem.file_name_illegal_characters
163
+ end
164
+
165
+ describe 'Fig' do
166
+ describe %q<uses the correct grammar version in the package definition created for publishing> do
167
+ before(:each) do
168
+ clean_up_test_environment
169
+ set_up_test_environment
170
+ end
171
+
172
+ shared_examples_for 'asset option' do
173
+ |asset_type|
174
+
175
+ ['', %q<'>, %q<">].each do
176
+ |quote|
177
+
178
+ begin
179
+ value = "#{quote}nothing-special.zip#{quote}"
180
+
181
+ it %Q<with file «#{value}»> do
182
+ IO.write "#{CURRENT_DIRECTORY}/nothing-special.zip", ''
183
+
184
+ fig(
185
+ [%w< --publish foo/1.2.3 --set x=y >, "--#{asset_type}", value],
186
+ :fork => false
187
+ )
188
+
189
+ check_published_grammar_version(0)
190
+ end
191
+ end
192
+
193
+ test_published_command_line_asset_with_url_with_symbol(
194
+ asset_type, '#', quote, 1
195
+ )
196
+ end
197
+
198
+ testable_glob_characters.each do
199
+ |symbol|
200
+
201
+ test_published_command_line_asset_with_url_with_symbol(
202
+ asset_type, symbol, %q<'>, 1
203
+ )
204
+
205
+ ['', %q<">].each do
206
+ |quote|
207
+
208
+ test_published_command_line_asset_with_url_with_symbol(
209
+ asset_type, symbol, quote, 0
210
+ )
211
+ end
212
+ end
213
+ end
214
+
215
+ describe 'for --archive' do
216
+ ['', %q<'>, %q<">].each do
217
+ |quote|
218
+
219
+ testable_v1_special_characters.each do
220
+ |symbol|
221
+
222
+ test_published_command_line_asset_with_file_with_symbol(
223
+ 'archive', symbol, quote, 1
224
+ )
225
+ end
226
+
227
+ testable_v1_non_special_characters.each do
228
+ |symbol|
229
+
230
+ test_published_command_line_asset_with_file_with_symbol(
231
+ 'archive', symbol, quote, 1
232
+ )
233
+ end
234
+ end
235
+
236
+ it_behaves_like 'asset option', 'archive'
237
+ end
238
+
239
+ describe 'for --resource' do
240
+ ['', %q<'>, %q<">].each do
241
+ |quote|
242
+
243
+ testable_v0_special_characters.each do
244
+ |symbol|
245
+
246
+ test_published_command_line_asset_with_file_with_symbol(
247
+ 'resource', symbol, quote, 0
248
+ )
249
+ end
250
+ end
251
+
252
+ it_behaves_like 'asset option', 'resource'
253
+ end
254
+
255
+ shared_examples_for 'asset statement' do
256
+ |asset_type|
257
+
258
+ ['', %q<'>, %q<">].each do
259
+ |quote|
260
+
261
+ begin
262
+ value = "#{quote}nothing-special.zip#{quote}"
263
+
264
+ it %Q<with file «#{value}»> do
265
+ IO.write "#{CURRENT_DIRECTORY}/nothing-special.zip", ''
266
+
267
+ input = <<-"END"
268
+ grammar v1
269
+
270
+ #{asset_type} #{value}
271
+
272
+ config default
273
+ end
274
+ END
275
+ fig %w< --publish foo/1.2.3 >, input, :fork => false
276
+
277
+ check_published_grammar_version(0)
278
+ end
279
+ end
280
+
281
+ test_published_file_asset_with_url_with_symbol(
282
+ asset_type, '#', quote, 1
283
+ )
284
+ end
285
+
286
+ testable_glob_characters.each do
287
+ |symbol|
288
+
289
+ test_published_file_asset_with_url_with_symbol(
290
+ asset_type, symbol, %q<'>, 1
291
+ )
292
+
293
+ ['', %q<">].each do
294
+ |quote|
295
+
296
+ test_published_file_asset_with_url_with_symbol(
297
+ asset_type, symbol, quote, 0
298
+ )
299
+ end
300
+ end
301
+ end
302
+
303
+ describe 'for archive statement' do
304
+ ['', %q<'>, %q<">].each do
305
+ |quote|
306
+
307
+ (testable_v1_special_characters - %w<#>).each do
308
+ |symbol|
309
+
310
+ test_published_file_asset_with_file_with_symbol(
311
+ 'archive', symbol, quote, 1
312
+ )
313
+ end
314
+
315
+ testable_v1_non_special_characters.each do
316
+ |symbol|
317
+
318
+ test_published_file_asset_with_file_with_symbol(
319
+ 'archive', symbol, quote, 1
320
+ )
321
+ end
322
+ end
323
+
324
+ [%q<'>, %q<">].each do
325
+ |quote|
326
+
327
+ test_published_file_asset_with_file_with_symbol(
328
+ 'archive', '#', quote, 1
329
+ )
330
+ end
331
+
332
+ it_behaves_like 'asset statement', 'archive'
333
+ end
334
+
335
+ describe 'for resource statement' do
336
+ ['', %q<'>, %q<">].each do
337
+ |quote|
338
+
339
+ (testable_v0_special_characters - %w<#>).each do
340
+ |symbol|
341
+
342
+ test_published_file_asset_with_file_with_symbol(
343
+ 'resource', symbol, quote, 0
344
+ )
345
+ end
346
+ end
347
+
348
+ [%q<'>, %q<">].each do
349
+ |quote|
350
+
351
+ test_published_file_asset_with_file_with_symbol(
352
+ 'resource', '#', quote, 0
353
+ )
354
+ end
355
+
356
+ it_behaves_like 'asset statement', 'resource'
357
+ end
358
+ end
359
+
360
+ describe %q<uses the correct grammar version in the package definition after parsing> do
361
+ before(:each) do
362
+ clean_up_test_environment
363
+ set_up_test_environment
364
+ end
365
+
366
+ %w< archive resource >.each do
367
+ |asset_type|
368
+
369
+ describe "#{asset_type} statement" do
370
+ [%q<'>, %q<">].each do
371
+ |quote|
372
+
373
+ value = "#{quote}contains#octothorpe#{quote}"
374
+ it %Q<with input containing «#{value}»> do
375
+ input = <<-"END"
376
+ grammar v1
377
+ #{asset_type} #{value}
378
+ END
379
+
380
+ out, err =
381
+ fig ['--dump-package-definition-parsed'], input, :fork => false
382
+ out.should =~ /\b grammar [ ] v1 \b/x
383
+ err.should == ''
384
+ end
385
+ end
386
+ end
387
+ end
388
+ end
389
+ end
390
+
391
+ # vim: set fileencoding=utf8 :
@@ -0,0 +1,88 @@
1
+ # coding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/grammar_spec_helper')
3
+
4
+ describe 'Fig' do
5
+ describe %q<uses the correct grammar version in the package definition created for publishing> do
6
+ before(:each) do
7
+ clean_up_test_environment
8
+ set_up_test_environment
9
+ end
10
+
11
+ it 'from unversioned file input with a simple command statement' do
12
+ check_published_grammar_version 0, <<-'END'
13
+ config default
14
+ command "echo foo"
15
+ end
16
+ END
17
+ end
18
+
19
+ it 'from v1 file input with a simple command statement' do
20
+ check_published_grammar_version 0, <<-'END'
21
+ grammar v1
22
+ config default
23
+ command "echo foo" end
24
+ end
25
+ END
26
+ end
27
+
28
+ it 'from v1 file input with a multi-component, mixed-quoting command statement' do
29
+ check_published_grammar_version 1, <<-'END'
30
+ grammar v1
31
+ config default
32
+ command echo "foo" 'bar baz' end
33
+ end
34
+ END
35
+ end
36
+
37
+ it 'from v1 file input with a command statement containing all keywords' do
38
+ check_published_grammar_version 1, <<-'END'
39
+ grammar v1
40
+ config default
41
+ command
42
+ add
43
+ append
44
+ archive
45
+ command
46
+ config
47
+ 'end' # Have to quote this one
48
+ include
49
+ override
50
+ path
51
+ resource
52
+ retrieve
53
+ set
54
+ end
55
+ end
56
+ END
57
+ end
58
+
59
+ it 'from v1 file input with a single-quoted command statement' do
60
+ check_published_grammar_version 0, <<-'END'
61
+ grammar v1
62
+ config default
63
+ command 'bar baz' end
64
+ end
65
+ END
66
+ end
67
+
68
+ it 'from v1 file input with a command statement containing an octothorpe' do
69
+ check_published_grammar_version 1, <<-'END'
70
+ grammar v1
71
+ config default
72
+ command "bar#baz" end
73
+ end
74
+ END
75
+ end
76
+
77
+ it 'from v1 file input with a command statement containing a double quote' do
78
+ check_published_grammar_version 1, <<-'END'
79
+ grammar v1
80
+ config default
81
+ command bar\"baz end
82
+ end
83
+ END
84
+ end
85
+ end
86
+ end
87
+
88
+ # vim: set fileencoding=utf8 :