Sha256: 8b222a3ce4e78d8e79995de475f3c478df80e91e61930e2df60c75ae7a92b101

Contents?: true

Size: 1.37 KB

Versions: 54

Compression:

Stored size: 1.37 KB

Contents

module FactoryGirl
  module Syntax

    # Adds a Sham module, which provides an alternate interface to
    # FactoryGirl::Sequence.
    #
    # Usage:
    #
    #   require 'factory_girl/syntax/sham'
    #
    #   Sham.email {|n| "somebody#{n}@example.com" }
    #
    #   FactoryGirl.define do
    #     factory :user do
    #       email
    #     end
    #   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, *args, &block)
          if block_given?
            ActiveSupport::Deprecation.warn "Sham.sequence is deprecated; use the FactoryGirl.define syntax instead", caller
            start_value = args.first
            FactoryGirl.register_sequence(Sequence.new(name, start_value || 1, &block))
          else
            FactoryGirl.sequence_by_name(name).next
          end
        end

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

include FactoryGirl::Syntax::Sham

Version data entries

54 entries across 54 versions & 4 rubygems

Version Path
classiccms-0.5.13 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.12 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.11 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.10 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.9 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.8 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.7 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.6 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.5 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.2 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.1 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.5.0 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.4.2 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.4.1 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.4.0 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
classiccms-0.3.9 vendor/bundle/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/factory_girl-3.2.0/lib/factory_girl/syntax/sham.rb