Sha256: 068f45baa656c9f1d7ae1e192b00e13b774bc2701617ebbce1d53692c8d4382c
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 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 ## #integer sequence def auto_number_sequence column auto_sequence column, :number end ## #multiple integer sequences def auto_number_sequencer columns auto_sequencer columns, :number 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)}" when :number index.to_s else "#{template} #{index}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_model_stacker-0.0.7 | lib/rails_model_stacker/factory_stacker.rb |