Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/camertron/repo-fixture
Build and package up git repositories as test fixtures.
https://github.com/camertron/repo-fixture
Last synced: 19 days ago
JSON representation
Build and package up git repositories as test fixtures.
- Host: GitHub
- URL: https://github.com/camertron/repo-fixture
- Owner: camertron
- Created: 2014-08-31T21:46:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-22T18:49:47.000Z (over 9 years ago)
- Last Synced: 2024-11-04T00:42:04.315Z (2 months ago)
- Language: Ruby
- Size: 160 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.txt
Awesome Lists containing this project
README
repo-fixture
============Build and package up git repositories as test fixtures.
## Installation
`gem install repo-fixture`
## Usage
```ruby
require 'repo-fixture'
```### Philosophy
Test fixtures are static files that contain data used in tests. For example, you might be writing and testing a YAML parser that needs to recognize various types of YAML data. You could test these various types by creating a number of .yml fixture files that you then feed to your parser.
RepoFixture brings this concept to git repositories. It facilitates creating and packaging the repositories into individual fixture files (currently only zip is supported). RepoFixture can also load fixture files and expand the repo's contents into your temp folder, creating a pristine test environment every time.
### Generating Fixtures
To create a new repo-based fixture:
```ruby
my_fixture = RepoFixture.create do |fixture|
fixture.copy_files(Dir.glob('path/to/files/**/**')) do |file|
file.sub('path/to/files', '') # the path in the zip file itself
endfixture.add_all
fixture.commit('Committing all files')
end
```Note that the `fixture` object in the example above responds to all the methods in [`TmpRepo`](https://github.com/camertron/tmp-repo).
Once you've put your fixture repo into the state you want, use the `export` method to generate a fixture file:
```ruby
my_fixture.export('path/to/my_fixture.zip')
```It's always a good idea to clean up after yourself as well:
```ruby
my_fixture.unlink
```### Loading Fixtures
Once you've created a fixture file, you might want to load it again:
```ruby
my_fixture = RepoFixture.load('./path/to/my_fixture.zip')
my_fixture.working_dir # => somewhere in your tmp directory
```## Requirements
No external requirements.
## Running Tests
`bundle exec rake` should do the trick.
## Authors
* Cameron C. Dutro: http://github.com/camertron