olag 0.1.15 → 0.1.16
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.
- data/ChangeLog +1 -0
- data/codnar.html +102 -6
- data/doc/system.markdown +11 -0
- data/lib/olag/test/with_tempdir.rb +31 -0
- data/lib/olag/test/with_tempfile.rb +2 -1
- data/lib/olag/version.rb +1 -1
- metadata +6 -5
data/ChangeLog
CHANGED
data/codnar.html
CHANGED
@@ -679,8 +679,7 @@ Olag using monkey-patching.
|
|
679
679
|
<p>
|
680
680
|
Finally, Olag::Rake sets up the following tasks (as reported by <code>rake -T</code>):
|
681
681
|
</p>
|
682
|
-
<pre>
|
683
|
-
<code>rake all # Version, verify, document, package
|
682
|
+
<pre><code>rake all # Version, verify, document, package
|
684
683
|
rake analyze # Analyze source code
|
685
684
|
rake changelog # Update ChangeLog from Git
|
686
685
|
rake clean # Remove any temporary products.
|
@@ -710,9 +709,7 @@ rake second_commit # Perform the 2nd (amend) Git commit
|
|
710
709
|
rake test # Run tests for test
|
711
710
|
rake verify # Test, coverage, analyze code
|
712
711
|
rake version # Update version file from Git
|
713
|
-
</code>
|
714
|
-
</pre>
|
715
|
-
</li>
|
712
|
+
</code></pre></li>
|
716
713
|
</ul>
|
717
714
|
|
718
715
|
|
@@ -2028,7 +2025,7 @@ number of Git commits by running <tt>rake version</tt>.
|
|
2028
2025
|
</tr>
|
2029
2026
|
</table>
|
2030
2027
|
<pre class='ruby code syntax'>
|
2031
|
-
<span class="Type">VERSION</span> = <span class="Special">"</span><span class="Constant">0.1.
|
2028
|
+
<span class="Type">VERSION</span> = <span class="Special">"</span><span class="Constant">0.1.16</span><span class="Special">"</span>
|
2032
2029
|
|
2033
2030
|
end
|
2034
2031
|
</pre>
|
@@ -3305,6 +3302,7 @@ Here is a mix-in that helps writing tests using temporary files and folders:
|
|
3305
3302
|
<div class="chunk html">
|
3306
3303
|
<pre class='ruby code syntax'>
|
3307
3304
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">fileutils</span><span class="Special">"</span>
|
3305
|
+
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">tempfile</span><span class="Special">"</span>
|
3308
3306
|
|
3309
3307
|
<span class="PreProc">module</span> <span class="Type">Test</span>
|
3310
3308
|
|
@@ -3423,8 +3421,106 @@ Automatically clean up the temporary files when the test is done.
|
|
3423
3421
|
<span class="PreProc">end</span>
|
3424
3422
|
|
3425
3423
|
end
|
3424
|
+
end
|
3425
|
+
|
3426
|
+
end
|
3427
|
+
|
3428
|
+
end
|
3429
|
+
</pre>
|
3430
|
+
</div>
|
3431
|
+
</div>
|
3432
|
+
</p>
|
3433
|
+
<h3>Testing with a temporary directory</h3>
|
3434
|
+
<p>
|
3435
|
+
When running external programs, or sometimes even Ruby programs, it is useful
|
3436
|
+
to have a temporary directory to stuff everything into, which is automatically
|
3437
|
+
removed when the test is done. The <code>WithTempfile</code> module does provide the
|
3438
|
+
<code>create_tempdir</code> function, which we can use; but it is easier to also include
|
3439
|
+
the <code>WithTempdir</code> module, which does this automatically in the <code>setup</code> function
|
3440
|
+
for us, and precomputes up the standard I/O file names as well.
|
3441
|
+
</p>
|
3442
|
+
<p>
|
3443
|
+
<div class="named_with_containers chunk">
|
3444
|
+
<div class="chunk name">
|
3445
|
+
<a name="lib-olag-test-with-tempdir-rb">
|
3446
|
+
<span>lib/olag/test/with_tempdir.rb</span>
|
3447
|
+
</a>
|
3448
|
+
</div>
|
3449
|
+
<div class="chunk html">
|
3450
|
+
<pre class='ruby code syntax'>
|
3451
|
+
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">olag/test/with_tempfile</span><span class="Special">"</span>
|
3452
|
+
|
3453
|
+
<span class="PreProc">module</span> <span class="Type">Test</span>
|
3454
|
+
|
3455
|
+
</pre>
|
3456
|
+
<table class='layout'>
|
3457
|
+
<tr>
|
3458
|
+
<td class='indentation'>
|
3459
|
+
<pre> </pre>
|
3460
|
+
</td>
|
3461
|
+
<td class='html'>
|
3462
|
+
<div class='rdoc comment markup'>
|
3463
|
+
<p>
|
3464
|
+
Mix-in for tests that run applications in a temporary directory. This
|
3465
|
+
assumes that the test class has already mixed-in the WithTempfile mix-in.
|
3466
|
+
</p>
|
3467
|
+
</div>
|
3468
|
+
</td>
|
3469
|
+
</tr>
|
3470
|
+
</table>
|
3471
|
+
<pre class='ruby code syntax'>
|
3472
|
+
<span class="PreProc">module</span> <span class="Type">WithTempdir</span>
|
3473
|
+
|
3474
|
+
</pre>
|
3475
|
+
<table class='layout'>
|
3476
|
+
<tr>
|
3477
|
+
<td class='indentation'>
|
3478
|
+
<pre> </pre>
|
3479
|
+
</td>
|
3480
|
+
<td class='html'>
|
3481
|
+
<div class='rdoc comment markup'>
|
3482
|
+
<p>
|
3483
|
+
Aliasing methods needs to be deferred to when the module is included and be
|
3484
|
+
executed in the context of the class.
|
3485
|
+
</p>
|
3486
|
+
</div>
|
3487
|
+
</td>
|
3488
|
+
</tr>
|
3489
|
+
</table>
|
3490
|
+
<pre class='ruby code syntax'>
|
3491
|
+
<span class="PreProc">def</span> <span class="Constant">self</span>.<span class="Identifier">included</span>(base)
|
3492
|
+
base.class_eval <span class="Statement">do</span>
|
3493
|
+
|
3494
|
+
alias_method <span class="Constant">:tempdir_original_setup</span>, <span class="Constant">:setup</span>
|
3426
3495
|
|
3496
|
+
</pre>
|
3497
|
+
<table class='layout'>
|
3498
|
+
<tr>
|
3499
|
+
<td class='indentation'>
|
3500
|
+
<pre> </pre>
|
3501
|
+
</td>
|
3502
|
+
<td class='html'>
|
3503
|
+
<div class='rdoc comment markup'>
|
3504
|
+
<p>
|
3505
|
+
Create a temporary directory for the run and percompute the standard I/O
|
3506
|
+
file names in it.
|
3507
|
+
</p>
|
3508
|
+
</div>
|
3509
|
+
</td>
|
3510
|
+
</tr>
|
3511
|
+
</table>
|
3512
|
+
<pre class='ruby code syntax'>
|
3513
|
+
<span class="PreProc">def</span> <span class="Identifier">setup</span>
|
3514
|
+
tempdir_original_setup
|
3515
|
+
<span class="Identifier">@tempdir</span> = create_tempdir
|
3516
|
+
<span class="Identifier">@stdout</span> = <span class="Identifier">@tempdir</span> + <span class="Special">"</span><span class="Constant">/stdout</span><span class="Special">"</span>
|
3517
|
+
<span class="Identifier">@stdin</span> = <span class="Identifier">@tempdir</span> + <span class="Special">"</span><span class="Constant">/stdin</span><span class="Special">"</span>
|
3518
|
+
<span class="Identifier">@stderr</span> = <span class="Identifier">@tempdir</span> + <span class="Special">"</span><span class="Constant">/stderr</span><span class="Special">"</span>
|
3519
|
+
<span class="PreProc">end</span>
|
3520
|
+
|
3521
|
+
end
|
3427
3522
|
end
|
3523
|
+
|
3428
3524
|
end
|
3429
3525
|
|
3430
3526
|
end
|
data/doc/system.markdown
CHANGED
@@ -242,6 +242,17 @@ Here is a mix-in that helps writing tests using temporary files and folders:
|
|
242
242
|
|
243
243
|
[[lib/olag/test/with_tempfile.rb|named_chunk_with_containers]]
|
244
244
|
|
245
|
+
### Testing with a temporary directory ###
|
246
|
+
|
247
|
+
When running external programs, or sometimes even Ruby programs, it is useful
|
248
|
+
to have a temporary directory to stuff everything into, which is automatically
|
249
|
+
removed when the test is done. The `WithTempfile` module does provide the
|
250
|
+
`create_tempdir` function, which we can use; but it is easier to also include
|
251
|
+
the `WithTempdir` module, which does this automatically in the `setup` function
|
252
|
+
for us, and precomputes up the standard I/O file names as well.
|
253
|
+
|
254
|
+
[[lib/olag/test/with_tempdir.rb|named_chunk_with_containers]]
|
255
|
+
|
245
256
|
### Testing Rake tasks ###
|
246
257
|
|
247
258
|
Testing Rake tasks is tricky because tests may be run in the context of Rake.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "olag/test/with_tempfile"
|
2
|
+
|
3
|
+
module Test
|
4
|
+
|
5
|
+
# Mix-in for tests that run applications in a temporary directory. This
|
6
|
+
# assumes that the test class has already mixed-in the WithTempfile mix-in.
|
7
|
+
module WithTempdir
|
8
|
+
|
9
|
+
# Aliasing methods needs to be deferred to when the module is included and
|
10
|
+
# be executed in the context of the class.
|
11
|
+
def self.included(base)
|
12
|
+
base.class_eval do
|
13
|
+
|
14
|
+
alias_method :tempdir_original_setup, :setup
|
15
|
+
|
16
|
+
# Create a temporary directory for the run and percompute the standard
|
17
|
+
# I/O file names in it.
|
18
|
+
def setup
|
19
|
+
tempdir_original_setup
|
20
|
+
@tempdir = create_tempdir
|
21
|
+
@stdout = @tempdir + "/stdout"
|
22
|
+
@stdin = @tempdir + "/stdin"
|
23
|
+
@stderr = @tempdir + "/stderr"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/olag/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: olag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 16
|
10
|
+
version: 0.1.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Oren Ben-Kiki
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: Saikuro
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/olag/test/with_errors.rb
|
181
181
|
- lib/olag/test/with_fakefs.rb
|
182
182
|
- lib/olag/test/with_rake.rb
|
183
|
+
- lib/olag/test/with_tempdir.rb
|
183
184
|
- lib/olag/test/with_tempfile.rb
|
184
185
|
- lib/olag/test.rb
|
185
186
|
- lib/olag/update_version.rb
|
@@ -202,7 +203,7 @@ licenses: []
|
|
202
203
|
post_install_message:
|
203
204
|
rdoc_options:
|
204
205
|
- --title
|
205
|
-
- Olag 0.1.
|
206
|
+
- Olag 0.1.16
|
206
207
|
- --main
|
207
208
|
- README.rdoc
|
208
209
|
- --line-numbers
|