<commit_before># GivenFilesystem

GivenFilesystem is a set of helpers for testing code which operates on file
systems. It lets you create temporary directories and files with given content as
test data. You can write to these directories and GivenFilesystem takes care of
cleaning up after the test. It only assumes that you can set the path to your
file system data in your tests.

GivenFilesystem provides helpers for RSpec and a standalone class.

## Usage with RSpec

### Setup

To use the GivenFilesystem helpers in a RSpec test you have to include the
`GivenFileSystemSpecHelpers` module to get access to the helper methods:

```ruby
include GivenFileSystemSpecHelpers
```

To make use of the helpers you have to activate the test file system to
initialize the temporary test directory:

```ruby
use_given_filesystem
```

### Creating directories

Create a temporary directory for writing test data:

```ruby
path = given_directory
```

Use the returned path to access the directory.

Create a temporary directory with a given name for writing test data:

```ruby
path = given_directory "myname"
```

Create a directory structure:

```ruby
given_directory "mydir" do
  path = given_directory "data"
  
  do_something(path)
end
```

### Creating files

Create a temporary file with arbitrary content:

```ruby
path = given_dummy_file
```

Use the returned path to access the file.

Create a temporary file with given content:

```ruby
path = given_file "mycontent"
```

The content of the file is taken from a file stored in your `spec/data`
directory. The name of the created file is the same as the name of the file
containing the test content.

Create a temporary file with given content under a different name:

```ruby
path = given_file "myspecialdata", :from => "mycontent"
```

The content of the file is taken from the file `spec/data/mycontent` and stored
under the name `myspecialdata` in a temporary directory. You can access it under
the returned path.

### Creating structures of directories and files

You can combine `given_directory` and `given_file` to create file system
structures as input for you tests. Here is an example:

```ruby
path = given_directory "mydir" do
  given_directory "one" do
    given_file "myfile"
    given_file "myotherfile"
  end
  given_diretory "two" do
    given_file "myfile2", :from => "myfile"
  end
end
```

This will create the following file system structure and return the path to the
temporary directory, which you can then use in your tests to access the data:

```
/tmp/
  given_filesystem/
    20140216-74592/
      one/
        myfile
        myotherfile
      two/
        myfile2
```<commit_msg>Add contact<commit_after># GivenFilesystem

GivenFilesystem is a set of helpers for testing code which operates on file
systems. It lets you create temporary directories and files with given content as
test data. You can write to these directories and GivenFilesystem takes care of
cleaning up after the test. It only assumes that you can set the path to your
file system data in your tests.

GivenFilesystem provides helpers for RSpec and a standalone class.

## Usage with RSpec

### Setup

To use the GivenFilesystem helpers in a RSpec test you have to include the
`GivenFileSystemSpecHelpers` module to get access to the helper methods:

```ruby
include GivenFileSystemSpecHelpers
```

To make use of the helpers you have to activate the test file system to
initialize the temporary test directory:

```ruby
use_given_filesystem
```

### Creating directories

Create a temporary directory for writing test data:

```ruby
path = given_directory
```

Use the returned path to access the directory.

Create a temporary directory with a given name for writing test data:

```ruby
path = given_directory "myname"
```

Create a directory structure:

```ruby
given_directory "mydir" do
  path = given_directory "data"
  
  do_something(path)
end
```

### Creating files

Create a temporary file with arbitrary content:

```ruby
path = given_dummy_file
```

Use the returned path to access the file.

Create a temporary file with given content:

```ruby
path = given_file "mycontent"
```

The content of the file is taken from a file stored in your `spec/data`
directory. The name of the created file is the same as the name of the file
containing the test content.

Create a temporary file with given content under a different name:

```ruby
path = given_file "myspecialdata", :from => "mycontent"
```

The content of the file is taken from the file `spec/data/mycontent` and stored
under the name `myspecialdata` in a temporary directory. You can access it under
the returned path.

### Creating structures of directories and files

You can combine `given_directory` and `given_file` to create file system
structures as input for you tests. Here is an example:

```ruby
path = given_directory "mydir" do
  given_directory "one" do
    given_file "myfile"
    given_file "myotherfile"
  end
  given_diretory "two" do
    given_file "myfile2", :from => "myfile"
  end
end
```

This will create the following file system structure and return the path to the
temporary directory, which you can then use in your tests to access the data:

```
/tmp/
  given_filesystem/
    20140216-74592/
      one/
        myfile
        myotherfile
      two/
        myfile2
```

## Contact

If you have questions or comments about GivenFilesystem don't hesitate to get in
touch with [<NAME>](mailto:<EMAIL>).
{'fraction_non_alphanumeric': 0.06331436960910258, 'fraction_numerical': 0.0055055973573132685, 'mean_word_length': 4.1756885090218425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '30997', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1479, 'n_words': 756}