Coder Social home page Coder Social logo

tacos's Introduction

Tacos

A fixture library for Elixir

Features

  • JSON fixutre support
  • YAML fixture support
  • Mix task for generating (empty) fixtures from Ecto models

Instructions

Installation

Add to your mix.exs

{:tacos, github: "simble-app/tacos", tag: "v0.0.1"}

Setup

Setup a directory for your tacos (fixtures). The default is test/tacos

$ mix tacos.setup

Optionally, you can configure tacos in your config/*.exs files, configure where to find tacos.

# Ex. Configuration for the test environment
# config/test.exs

config :tacos, :tacos,
  tacos_path: "tacos/test",
  format: "json"

# Ex. All environments not "test"
# config/config.exs
config :tacos, :tacos,
  tacos_path: "tacos/data",
  format: "json"

If you do this, you'll need to generate tacos individually for each environment by setting MIX_ENV.

Usage

Tacos#tacos

Fairly straightforward, examples below are from the tests. Tacos tolerates string(s), atom(s), or keyword list with string, or atom, values.

# Fixtures can be retrieved one at a time
#
# tacos/test/spike.json
spike = Tacos.tacos("spike")

# Fixtures can be retrieved as a list
#
# tacos/test/spike.json
# tacos/test/faye.json
[spike, faye] = Tacos.tacos([:spike, :faye])
# Fixtures can be grouped (using directories)
#
# tacos/test/users/ein.json
[ein] = Tacos.tacos(users: :ein)

# Fixtures can be grouped (using directories)
#
# tacos/test/users/ein.json
# tacos/test/users/jet.json
[ein, jet] = Tacos.tacos(users: ["ein", "jet"])

# Fixtures can be deeply nested
#
# tacos/test/users/active/admin/ed.json
[edward] = Tacos.tacos(users: [active: [admin: [:ed]]])

Mix Tasks

Initial Setup

Create the default directories for tacos (tacos/data and tacos/test)

$ mix tacos.setup

Ecto and/or Vex Integration

Tacos has a mix task to generate fixtures from Ecto models, or structs/maps using Vex [1,2].

#  Simple
$ mix tacos.gen.model TheBebop.Crew

# Specify the base path (relative to the application root)
$ TACOS_PATH="delicious_tacos" mix tacos.gen.model TheBebop.Crew

1 It actually works with any struct (filters out :__struct__) or map.
2 The reason it "works" with Ecto and/or Vex models is because it also filters out: :__meta__, :__id__, :inserted_at, :updated_at, :errors, :_vex

Misc

Known Limitations Issues

  • No support for YAML fixture generation because I couldn't find an Elixir/Erlang libary to do (serialize) it.
  • It automatically strips some keys, see Ecto/Vex Integration for specifics. If someone needs this configurable, create an issue or PR.

Possible Features

  • JSON-Schema support
  • Rich fixture generation from JSON-Schema support

Why?

  1. There aren't any other fixture libraries for Elixir
  2. It seemed easy enough to do? ¯\(ツ)
  3. I don't like factories, nay... I hate factories
  4. Community profit?
  5. Tacos are delicious

Pull Requests

  1. Pull requests must pass tests and add full coverage.
  2. You only need to add coverage to publicly available methods.

License

Tacos is released under the MIT License.

tacos's People

Contributors

tehprofessor avatar hackervera avatar

Watchers

Moxley Stratton avatar James Cloos avatar May Matyi 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.