Skip to content
jeffWelling edited this page Feb 1, 2011 · 2 revisions

What is it?

MMSpecUtils is an executable script containing a pair of functions, which serves the purpose of creating a list of paths to files (such as in your download folder), for testing matches. It takes two arguments, the first is a directory to recursively scan and the second is the directory to create the fake files that were scanned in the first directory.

These fake files have no content, they were created using touch.

Usage Example

Here, we have a temp directory with a couple fake files and a dir.

[jeff@Shmee ~/Documents/Projects/MediaManager/temp (master)]$ ls --recursive

.:

total 9.8M

drwxr-xr-x 3 jeff jeff 4.0K 2011-01-30 21:17 .

drwxr-xr-x 14 jeff jeff 4.0K 2011-01-30 21:15 ..

drwxr-xr-x 2 jeff jeff 4.0K 2011-01-30 21:17 bar

-rw-r--r-- 1 jeff jeff 9.7M 2011-01-30 21:16 foo.rand

./bar:

total 18M

drwxr-xr-x 2 jeff jeff 4.0K 2011-01-30 21:17 .

drwxr-xr-x 3 jeff jeff 4.0K 2011-01-30 21:17 ..

-rw-r--r-- 1 jeff jeff 18M 2011-01-30 21:17 foobar.rand

[jeff@Shmee ~/Documents/Projects/MediaManager/temp (master)]$

Now, we go back to the project directory, and use the script to create a fake copy of the temp directory.

[jeff@Shmee ~/Documents/Projects/MediaManager/temp (master)]$ cd ..

[jeff@Shmee ~/Documents/Projects/MediaManager (master)]$ ./spec/MMSpecUtils.rb \

'temp' '/tmp/fakefilez';

Scanning temp

temp/

temp/foo.rand

temp/bar/

temp/bar/foobar.rand

[jeff@Shmee ~/Documents/Projects/MediaManager (master)]$ cd /tmp/fakefilez

[jeff@Shmee /tmp/fakefilez]$ ls

total 16K

drwxr-xr-x 4 jeff jeff 4.0K 2011-01-30 21:24 .

drwxrwxrwt 10 root root 4.0K 2011-01-30 21:24 ..

drwxr-xr-x 3 jeff jeff 4.0K 2011-01-30 21:24 temp

[jeff@Shmee /tmp/fakefilez]$

[jeff@Shmee /tmp/fakefilez]$ cd temp

[jeff@Shmee /tmp/fakefilez/temp]$ ls

total 12K

drwxr-xr-x 3 jeff jeff 4.0K 2011-01-30 21:24 .

drwxr-xr-x 4 jeff jeff 4.0K 2011-01-30 21:24 ..

drwxr-xr-x 2 jeff jeff 4.0K 2011-01-30 21:24 bar

-rw-r--r-- 1 jeff jeff 0 2011-01-30 21:24 foo.rand

[jeff@Shmee /tmp/fakefilez/temp]$

Now we can see, the files are there, but they're empty. But, now we can use this to test our pattern matching code and other parts of the code that require a more mutable test environment than your actual downloads directory.

Clone this wiki locally