sinetris / factory_girl_elixir Goto Github PK
View Code? Open in Web Editor NEWMinimal implementation of Ruby's factory_girl in Elixir.
License: MIT License
Minimal implementation of Ruby's factory_girl in Elixir.
License: MIT License
It seems ambiguous if this does or does not insert into the database. I'm leaning no, but I'd love clarity / an update in the docs.
Hi,
Is the declaring of the factory module should only happen inside the test itself ? From what I gather, the declaration of the factory methods are done into a genserver which is initialized with the application at runtime.
Hi there,
perhaps it might be my fault, but it I wasn't able to reference a factory from another definition. This is a common use case, for example when you want create a record on the fly to associate to another factory.
to quickly test this, I've modified your test/factory_girl_elixir_test.exs
this way:
[...]
factory :user do
field :name, "joe"
field :password, "secret"
field :email, &("foo#{&1}@example.com")
# getting a value through another factory
field :asset_name, fn(_) ->
assets = Factory.attributes_for(:assets) |> Factory.parametrize
assets.name
end
end
factory :assets do
field :name, "bob"
end
[...]
when I run mix test
I get this:
=ERROR REPORT==== 7-Sep-2015::23:00:32 ===
** Generic server factory_girl terminating
** Last message in was {get,user,[]}
** When Server state == [{counters,[]},
{attributes,
[{assets,[{name,<<"bob">>}]},
{user,
[{asset_name,
#Fun<elixir_compiler_2.1.33695206>},
{email,#Fun<elixir_compiler_2.0.33695206>},
{password,<<"secret">>},
{name,<<"joe">>}]}]}]
** Reason for termination ==
** {{timeout,{'Elixir.GenServer',call,[factory_girl,{get,assets,[]},5000]}},
[{'Elixir.GenServer',call,3,[{file,"lib/gen_server.ex"},{line,356}]},
{elixir_compiler_2,'-__MODULE__/1-fun-1-',1,
[{file,"test/factory_girl_elixir_test.exs"},{line,12}]},
{'Elixir.FactoryGirlElixir.Worker',expand_functions,3,
[{file,"lib/factory_girl_elixir/worker.ex"},{line,60}]},
{'Elixir.FactoryGirlElixir.Worker',handle_call,3,
[{file,"lib/factory_girl_elixir/worker.ex"},{line,45}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,629}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,661}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}
of course, the tests are broken.
Any hint or workaround for this? :-P
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.