CouchFactory.Factory
Factory Girl like generator with doc persistence in database for ExUnit testing.
Couch Factory have a dependency on Couchbeam.
This module have the macros to be used in a factory definition.
##Example
defmodule MyFactory do
use CouchFactory.Factory
factory :doc_name,
property_a: "value_a",
property_b: "value_b",
prperty_c: "value_c"
factory :other_doc,
property: "a value",
other_property: [1,2,3]
Once the file is loaded included for compilation in the test_helper
file.
You can call this functions:
MyFactory.build(:other_doc)
MyFactory.create(:doc_name)
It will also create a function with the name of the factory, that returns a dictionary:
MaFactory.doc_name() # => [property_a: "value_a", property_b: "value_b", property_c: "value_c"]
Summary
Macros
Implements :couchbeam.save_doc/2 function but accepts a single argument,
which is a list of tupples {[{"key", "value"}]}
, as cuchbeam format documents
This will generate a function per named factory
Macros
Implements :couchbeam.save_doc/2 function but accepts a single argument,
which is a list of tupples {[{"key", "value"}]}
, as cuchbeam format documents.