create_valid 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/create_valid.gemspec +1 -1
- data/lib/create_valid.rb +17 -0
- data/rails/init.rb +2 -12
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/create_valid.gemspec
CHANGED
data/lib/create_valid.rb
CHANGED
@@ -122,6 +122,23 @@ module CreateValid
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
module TestIntegration
|
126
|
+
def self.included(base)
|
127
|
+
base.send(:include, InstanceMethods)
|
128
|
+
base.alias_method_chain :method_missing, :create_valid
|
129
|
+
end
|
130
|
+
|
131
|
+
module InstanceMethods
|
132
|
+
def method_missing_with_create_valid(method, *args)
|
133
|
+
if method.to_s =~ ::CreateValid::MAGIC_METHOD
|
134
|
+
::CreateValid::Factory.new(self).send(method, *args)
|
135
|
+
else
|
136
|
+
method_missing_without_create_valid(method, *args)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
125
142
|
class KludgyEvalContext
|
126
143
|
include GlobalHelpers
|
127
144
|
end
|
data/rails/init.rb
CHANGED
@@ -1,16 +1,6 @@
|
|
1
1
|
if defined?(RAILS_ENV) && RAILS_ENV == 'test'
|
2
|
-
|
3
|
-
|
4
|
-
if method.to_s =~ ::CreateValid::MAGIC_METHOD
|
5
|
-
::CreateValid::Factory.new(self).send(method, *args)
|
6
|
-
else
|
7
|
-
method_missing_without_create_valid(method, *args)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
alias_method_chain :method_missing, :create_valid
|
11
|
-
end
|
12
|
-
|
13
|
-
Kernel.send(:include, ::CreateValid::GlobalHelpers)
|
2
|
+
require 'test/unit'
|
3
|
+
::ActiveSupport::TestCase.send(:include, ::CreateValid::TestIntegration)
|
14
4
|
|
15
5
|
if File.exists?(RAILS_ROOT + '/test/factory.rb')
|
16
6
|
::CreateValid::KludgyEvalContext.new.instance_eval(File.read(RAILS_ROOT + '/test/factory.rb'))
|