abstract class Avram::Factory
- Avram::Factory
- Reference
- Object
Defined in:
avram/factory.crConstant Summary
-
SEQUENCES =
{} of String => Int32
Class Method Summary
- .build_attributes(&)
- .build_attributes
- .create
- .create(&)
-
.create_pair
Returns an array with 2 instances of the model from the Factory.
-
.create_pair(&)
Similar to
.create_pair
, but accepts a block which yields the factory instance.
Instance Method Summary
- #create
- #operation
-
#sequence(value : String) : String
Returns a value with a number to use for unique values.
Macro Summary
Instance methods inherited from class Object
blank_for_validates_required? : Bool
blank_for_validates_required?
Class Method Detail
def self.create_pair
#
Returns an array with 2 instances of the model from the Factory.
Usage:
tags = TagFactory.create_pair
typeof(tags) # => Array(Tag)
tags.size # => 2
def self.create_pair(&)
#
Similar to .create_pair
, but accepts a block which yields the factory instance.
Both factories receive the same argument values.
Usage:
TagFactory.create_pair do |factory|
# set both factories name to "test"
factory.name("test")
end
Instance Method Detail
Returns a value with a number to use for unique values.
Usage:
class UserFactory < Avram::Factory
def initialize
username sequence("username") # => username-1, username-2, etc.
email "#{sequence("email")}@example.com" # => [email protected], [email protected], etc.
end
end