public
Description: replacement for fixtures in rails tests. sweet metaprogramming to build/create valid/default models and attribute hashes.
Homepage: http://blog.internautdesign.com/2008/6/4/factories-and-workers-plugin
Clone URL: git://github.com/dfl/factories-and-workers.git
dfl (author)
Wed Dec 10 12:28:54 -0800 2008
commit  cfec04c879181dadb5a8e715549eb1fb8462cc6e
tree    db9932c9e0ba29a46b956d2114495ae928286223
parent  c2984ee99c66c71691b59e9d02631d014d05e3ab
100644 27 lines (19 sloc) 0.92 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if defined?(RAILS_ENV) && __FILE__ =~ %r{vendor/plugins} # are we running as a rails plugin?
 
  # Modify the variable below to specify in which environments this plugin should be loaded.
  load_plugin_in = {
    'test' => true,
    'development' => true, # NOTE: often comes in handy in the console
    'production' => false,
  }
 
  if load_plugin_in[ RAILS_ENV ]
    require "factories-and-workers"
    require File.dirname(__FILE__)+"/rails/init.rb"
  end
 
 
else # bootstrap the gem
 
  require "factories-and-workers"
  require File.dirname(__FILE__)+"/rails/init.rb" if defined?(RAILS_ENV)
 
  # NOTE: if using as a gem with Rails and you want similar behaviour as above, do something like this in environment.rb :
  # config.after_initialize do
  # config.gem 'dfl-factories-and-workers', :lib => 'factories-and-workers', :source => 'http://gems.github.com' unless RAILS_ENV=='production'
  # end
 
end