Sha256: 48f89a8c1acbea8578d8fcb060e2f7062e7184b3f65ad924e4c26387f7acc1bd

Contents?: true

Size: 1.12 KB

Versions: 35

Compression:

Stored size: 1.12 KB

Contents

class Factory
  module Syntax

    # Adds a Sham module, which provides an alternate interface to
    # Factory::Sequence.
    #
    # Usage:
    #
    #   require 'factory_girl/syntax/sham'
    #
    #   Sham.email {|n| "somebody#{n}@example.com" }
    #
    #   Factory.define :user do |factory|
    #     factory.email { Sham.email }
    #   end
    #
    # Note that you can also use Faker, but it is recommended that you simply
    # use a sequence as in the above example, as factory_girl does not provide
    # protection against duplication in randomized sequences, and a randomized
    # value does not provide any tangible benefits over an ascending sequence.
    #
    # This syntax was derived from Pete Yandell's machinist.
    module Sham
      module Sham #:nodoc:
        def self.method_missing(name, &block)
          if block_given?
            Factory.sequence(name, &block)
          else
            Factory.next(name)
          end
        end

        # overrides name on Module
        def self.name(&block)
          method_missing('name', &block)
        end
      end
    end
  end
end

include Factory::Syntax::Sham

Version data entries

35 entries across 35 versions & 14 rubygems

Version Path
BrettRasmussen-factory_girl-1.2.2 lib/factory_girl/syntax/sham.rb
BrettRasmussen-factory_girl-1.2.3 lib/factory_girl/syntax/sham.rb
agibralter-factory_girl-1.2.1 lib/factory_girl/syntax/sham.rb
lacomartincik-factory_girl-1.2.1.1 lib/factory_girl/syntax/sham.rb
masa-iwasaki-factory_girl-1.2.1.1 lib/factory_girl/syntax/sham.rb
qrush-factory_girl-1.2.1.1 lib/factory_girl/syntax/sham.rb
thoughtbot-factory_girl-1.2.0 lib/factory_girl/syntax/sham.rb
thoughtbot-factory_girl-1.2.1 lib/factory_girl/syntax/sham.rb
thoughtbot-factory_girl-1.2.2 lib/factory_girl/syntax/sham.rb
ttilley-factory_girl-1.2.2.1 lib/factory_girl/syntax/sham.rb
ttilley-factory_girl-1.2.2.2 lib/factory_girl/syntax/sham.rb
ttilley-factory_girl-1.2.2 lib/factory_girl/syntax/sham.rb
vitalish-factory_girl-1.2.10 lib/factory_girl/syntax/sham.rb
factory_girl-1.3.3 lib/factory_girl/syntax/sham.rb
vitalish-factory_girl-1.2.9 lib/factory_girl/syntax/sham.rb
vitalish-factory_girl-1.2.8 lib/factory_girl/syntax/sham.rb
vitalish-factory_girl-1.2.7 lib/factory_girl/syntax/sham.rb
vitalish-factory_girl-1.2.6 lib/factory_girl/syntax/sham.rb
factory_girl-1.3.2 lib/factory_girl/syntax/sham.rb
factory_girl-1.3.1 lib/factory_girl/syntax/sham.rb