Git Product home page Git Product logo

repo-fixture's Introduction

repo-fixture

Build and package up git repositories as test fixtures.

Installation

gem install repo-fixture

Usage

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:

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
  end

  fixture.add_all
  fixture.commit('Committing all files')
end

Note that the fixture object in the example above responds to all the methods in TmpRepo.

Once you've put your fixture repo into the state you want, use the export method to generate a fixture file:

my_fixture.export('path/to/my_fixture.zip')

It's always a good idea to clean up after yourself as well:

my_fixture.unlink

Loading Fixtures

Once you've created a fixture file, you might want to load it again:

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

repo-fixture's People

Contributors

camertron avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.