petermueller / ex_junk

Junk is a module for generating Junk data in your tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Junk

Junk is a module for generating Junk data in your tests. For when you don't care about the content, just that it has the right 'shape'. It is inspired by Dave Brady's rspec-junklet

Build Status

Installation

The package can be installed by adding ex_junk to your list of dependencies in mix.exs:

def deps do
  [{:ex_junk, "~> 0.1.0", only: :test}]
end

Example

defmodule ExampleTest do
  import Junk 

  test "example test" do
    thing = %{
      name:    junk, # defaults to junk(String)
      some_id: junk(Integer, size: 9)
    }
    struct(SomeThing, thing)
    |> SomeThing.push

    assert SomeThing.pop == thing
  end
end

Usage

Junk.junk                          # "w8eY_L2UHZsPBBSq"
Junk.junk(String)                  # same
Junk.junk(String,  byte_size: 10)  # similar, but shorter
Junk.junk(String,  prefix: "yarp") # "yarp-w8eY_L2UHZsPBBSq..."
Junk.junk(Integer, size: 10)       # 9593685924

Links

Hex - https://hex.pm/packages/ex_junk

About

Junk is a module for generating Junk data in your tests

License:MIT License


Languages

Language:Elixir 100.0%