Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally disable duplicate assignment of attributes in initialize_with
By setting: FactoryGirl.duplicate_attribute_assignment_from_initialize_with = false This turns off duplicate assignment of attributes accessed from initialize_with. This means any attributes accessed from the factory and assigned in the initialize_with block won't be subsequently set after the object has been instantiated. This will be the default functionality in 4.0. Closes #345
- Loading branch information
1 parent
64e50a3
commit a5b3a97
Showing
10 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module FactoryGirl | ||
class Decorator < BasicObject | ||
undef_method :== | ||
|
||
def initialize(component) | ||
@component = component | ||
end | ||
|
||
def method_missing(name, *args, &block) | ||
@component.send(name, *args, &block) | ||
end | ||
|
||
def send(symbol, *args) | ||
__send__(symbol, *args) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module FactoryGirl | ||
class Decorator | ||
class InvocationIgnorer < Decorator | ||
def __invoked_methods__ | ||
[] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module FactoryGirl | ||
class Decorator | ||
class InvocationTracker < Decorator | ||
def initialize(component) | ||
super | ||
@invoked_methods = [] | ||
end | ||
|
||
def method_missing(name, *args, &block) | ||
@invoked_methods << name | ||
super | ||
end | ||
|
||
def __invoked_methods__ | ||
@invoked_methods.uniq | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters