mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Undef possible method before defining
Without these changes, factory_girl causes massive number of warnings: "warning: method redefined; discarding old ..." "warning: previous definition of ... was here"
This commit is contained in:
parent
f5e568e47e
commit
241e8e5fb4
2 changed files with 8 additions and 0 deletions
|
@ -64,6 +64,10 @@ module FactoryGirl
|
|||
end
|
||||
|
||||
def self.define_attribute(name, &block)
|
||||
if method_defined?(name) || private_method_defined?(name)
|
||||
undef_method(name)
|
||||
end
|
||||
|
||||
define_method(name) do
|
||||
if @cached_attributes.key?(name)
|
||||
@cached_attributes[name]
|
||||
|
|
|
@ -39,6 +39,10 @@ module FactoryGirl
|
|||
|
||||
def define_syntax_method(name, &block)
|
||||
FactoryGirl::Syntax::Methods.module_exec do
|
||||
if method_defined?(name) || private_method_defined?(name)
|
||||
undef_method(name)
|
||||
end
|
||||
|
||||
define_method(name, &block)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue