dfl-factories-and-workers 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -0
- data/init.rb +1 -3
- data/rails/init.rb +20 -18
- metadata +1 -1
data/CHANGELOG
CHANGED
data/init.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
if defined?(RAILS_ENV) && __FILE__ =~ %r{vendor/plugins} # are we running as a rails plugin?
|
2
2
|
|
3
|
-
# Modify the variable below to specify in which environments this plugin should be loaded.
|
3
|
+
# Modify the variable below to specify in which environments this plugin should be loaded.
|
4
4
|
load_plugin_in = {
|
5
5
|
'test' => true,
|
6
6
|
'development' => true, # NOTE: often comes in handy in the console
|
@@ -24,5 +24,3 @@ else # bootstrap the gem
|
|
24
24
|
# end
|
25
25
|
|
26
26
|
end
|
27
|
-
|
28
|
-
|
data/rails/init.rb
CHANGED
@@ -2,26 +2,28 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
config.after_initialize do
|
4
4
|
|
5
|
-
# if
|
6
|
-
|
5
|
+
unless $*.grep(/db:*/) # prevent the plugin from loading if we are simply running rake db:migrate, etc.
|
6
|
+
|
7
|
+
# if script_console_running = defined?(::IRB) && ::IRB.conf[:LOAD_MODULES] && ::IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
|
8
|
+
# # mixin to Object if we are running in ./script/console
|
7
9
|
obj = Object
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
# else # otherwise just mix into Test::Unit to play it safe
|
11
|
+
# obj = Test::Unit::TestCase
|
12
|
+
# end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# load factory and worker definition files if they exist
|
17
|
-
%w(spec/factories.rb spec/factory_workers.rb test/factories.rb test/factory_workers.rb).each do |file|
|
18
|
-
path = File.join(Dir.pwd, file)
|
19
|
-
require path if File.exists?(path)
|
20
|
-
end
|
14
|
+
# mixin plugin
|
15
|
+
obj.send :include, FactoriesAndWorkers::Factory
|
16
|
+
obj.send :include, FactoriesAndWorkers::Worker
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
# load factory and worker definition files if they exist
|
19
|
+
%w(spec/factories.rb spec/factory_workers.rb test/factories.rb test/factory_workers.rb).each do |file|
|
20
|
+
path = File.join(Dir.pwd, file)
|
21
|
+
require path if File.exists?(path)
|
22
|
+
end
|
26
23
|
|
24
|
+
# mixin factory and worker definitions
|
25
|
+
obj.send :include, ::TestFactories if defined?(TestFactories)
|
26
|
+
obj.send :include, ::FactoryWorkers if defined?(FactoryWorkers)
|
27
|
+
end
|
27
28
|
|
29
|
+
end
|