Sha256: 7fb14800818ebe5a07e00fc18af9ee67120fba470a576d786f9a54441fa092d0

Contents?: true

Size: 1.93 KB

Versions: 54

Compression:

Stored size: 1.93 KB

Contents

module FactoryGirl
  module Syntax
    module Methods
      # Builds and returns multiple instances from this factory as an array. Attributes can be
      # individually overridden by passing in a Hash of attribute => value pairs.
      #
      # Arguments:
      # * name: +Symbol+ or +String+
      #   The name of the factory to be used.
      # * amount: +Integer+
      #   number of instances to be built.
      # * traits_and_overrides: +Array+
      #   [+*Array+] Traits to be applied
      #   [+Hash+] Attributes to overwrite for this instance.
      #
      # Returns: +Array+
      # An array of instances of the class this factory generates, with generated attributes
      # assigned.
      def build_list(name, amount, *traits_and_overrides)
        amount.times.map { build(name, *traits_and_overrides) }
      end

      # Creates and returns multiple instances from this factory as an array. Attributes can be
      # individually overridden by passing in a Hash of attribute => value pairs.
      #
      # Arguments:
      # * name: +Symbol+ or +String+
      #   The name of the factory to be used.
      # * amount: +Integer+
      #   number of instances to be created.
      # * traits_and_overrides: +Array+
      #   [+*Array+] Traits to be applied
      #   [+Hash+] Attributes to overwrite for this instance.
      #
      # Returns: +Array+
      # An array of instances of the class this factory generates, with generated attributes
      # assigned.
      def create_list(name, amount, *traits_and_overrides)
        amount.times.map { create(name, *traits_and_overrides) }
      end

      # Generates and returns the next value in a sequence.
      #
      # Arguments:
      #   name: (Symbol)
      #     The name of the sequence that a value should be generated for.
      #
      # Returns:
      #   The next value in the sequence. (Object)
      def generate(name)
        FactoryGirl.sequence_by_name(name).next
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.7.4 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.7.3 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.7.2 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.7.1 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.7.0 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.9 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.8 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.7 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.6 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.5 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.4 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.3 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.2 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.1 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.6.0 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.5.17 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.5.16 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.5.15 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb
classiccms-0.5.14 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/methods.rb