Coder Social home page Coder Social logo

factory_girl_elixir's People

Contributors

cloudbring avatar sinetris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

factory_girl_elixir's Issues

Usage in runtime in tests instead of compilation time

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.

Can't reference a factory from another factory definition

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

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.