module FactoryGirl

factory girl helpers

to use:

require 'factory_stacker'

in spec/spec_helper

Public Instance Methods

auto_money_sequence(column) click to toggle source

sequence with money output

# File lib/rails_model_stacker/factory_stacker.rb, line 28
def auto_money_sequence column
        auto_sequence column, :money
end
auto_monney_sequencer(columns) click to toggle source

multiple sequences with money type

# File lib/rails_model_stacker/factory_stacker.rb, line 34
def auto_monney_sequencer columns
        auto_sequencer columns, :money
end
auto_number_sequence(column) click to toggle source

integer sequence

# File lib/rails_model_stacker/factory_stacker.rb, line 40
def auto_number_sequence column
        auto_sequence column, :number
end
auto_number_sequencer(columns) click to toggle source

multiple integer sequences

# File lib/rails_model_stacker/factory_stacker.rb, line 46
def auto_number_sequencer columns
        auto_sequencer columns, :number
end
auto_sequence(column, type = :text) click to toggle source

short hand sequence

column

symbol of column name

type

symbol of type, :text or :money

# File lib/rails_model_stacker/factory_stacker.rb, line 12
def auto_sequence column, type = :text
        sequence(column) do |n|
                generate_as_text n, column.to_s, type
        end

end
auto_sequencer(columns, type) click to toggle source

short hand sequence for multiple columns

columns

array of symbols of column names

# File lib/rails_model_stacker/factory_stacker.rb, line 22
def auto_sequencer columns, type
        columns.each  { |k| sequence(k, type) }
end

Private Instance Methods

generate_as_text(index, template, type) click to toggle source

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

# File lib/rails_model_stacker/factory_stacker.rb, line 56
def generate_as_text index, template, type
        case type
        when :money
                "#{index}.#{rand(99)}"
        when :number
                index.to_s
        else
                "#{template} #{index}"
        end

end