ruby on rails - FactoryGirl clean up code -



ruby on rails - FactoryGirl clean up code -

here's ride factory:

factorygirl.define mill :ride departure_address "#{faker::address.street_address}, #{faker::address.city} #{faker::address.country}" end end

how clean ugly code? "#{faker::address.street_address}, #{faker::address.city} #{faker::address.country}"

i'd create fake_full_address method within test/helpers , phone call factory. how it?

under /lib can set helper module:

module myhelper def self.full_address "#{faker::address.street_address}, #{faker::address.city} #{faker::address.country}" end end

the in mill can including helper:

require 'my_helper.rb' factorygirl.define mill :ride departure_address myhelper.full_address end end

i did on project , works well, can check these options too...

how include module in factory_girl factory?

https://github.com/thoughtbot/factory_girl/issues/564

ruby-on-rails factory-girl faker

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -