Sha256: 7f702dcddf61c910e6cf346763e6d1d39b3cea1fd20507658e7ee42e30a69855
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
#factory girl helpers # #to use: # require 'factory_stacker' #in spec/spec_helper module FactoryGirl ## #short hand sequence #+column+:: symbol of column name #+type+:: symbol of type, :text or :money def auto_sequence column, type = :text sequence(column) do |n| generate_as_text n, column.to_s, type end end ## #short hand sequence for multiple columns #+columns+:: array of symbols of column names def auto_sequencer columns, type columns.each { |k| sequence(k, type) } end ## #sequence with money output def auto_money_sequence column auto_sequence column, :money end ## #multiple sequences with money type def auto_monney_sequencer columns auto_sequencer columns, :money end private ## #makes the text for auto_sequence #+index+:: index of item #+template+:: only the prepended text atm #+type+:: symbol of type, will handle any symbol gracefully def generate_as_text index, template, type case type when :money "#{index}.#{rand(99)}" else "#{template} #{index}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_model_stacker-0.0.6 | lib/rails_model_stacker/factory_stacker.rb |