Class: HashFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_factory.rb

Class Method Summary collapse

Class Method Details

.factoriesObject



16
17
18
# File 'lib/hash_factory.rb', line 16

def self.factories
  Dir[factories_path + '/*_factory.rb']
end

.factories_pathObject



24
25
26
# File 'lib/hash_factory.rb', line 24

def self.factories_path
  "#{Rails.root}/test/factories"
end

.get_class(file) ⇒ Object



20
21
22
# File 'lib/hash_factory.rb', line 20

def self.get_class(file)
  file.split('/').last.gsub('.rb', '').classify.constantize
end

.load_in(klass) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/hash_factory.rb', line 6

def self.load_in(klass)
  require 'hash_factory_builder'
  klass.send :include, HashFactoryBuilder
  
  factories.each do |file|
    require file
    klass.send :include, get_class(file)
  end
end

.setupObject



2
3
4
# File 'lib/hash_factory.rb', line 2

def self.setup
  self.load_in(ActiveSupport::TestCase)
end