Deprecate alternate syntaxes
This commit is contained in:
parent
d67b798195
commit
c006dd186f
|
@ -1,3 +1,4 @@
|
|||
require "active_support/deprecation"
|
||||
require "factory_girl/syntax/methods"
|
||||
require "factory_girl/syntax/default"
|
||||
require "factory_girl/syntax/vintage"
|
||||
|
|
|
@ -26,6 +26,7 @@ module FactoryGirl
|
|||
module ClassMethods #:nodoc:
|
||||
|
||||
def blueprint(&block)
|
||||
ActiveSupport::Deprecation.warn "Model.blueprint is deprecated; use the FactoryGirl.define syntax instead", caller
|
||||
instance = Factory.new(name.underscore, class: self)
|
||||
proxy = FactoryGirl::DefinitionProxy.new(instance)
|
||||
proxy.instance_eval(&block)
|
||||
|
|
|
@ -42,6 +42,7 @@ module FactoryGirl
|
|||
module ClassMethods #:nodoc:
|
||||
|
||||
def generate(overrides = {}, &block)
|
||||
ActiveSupport::Deprecation.warn "Model.generate is deprecated; use the FactoryGirl.define syntax instead", caller
|
||||
instance = FactoryRunner.new(name.underscore, Strategy::Build, [overrides]).run
|
||||
instance.save
|
||||
yield(instance) if block_given?
|
||||
|
@ -49,12 +50,14 @@ module FactoryGirl
|
|||
end
|
||||
|
||||
def generate!(overrides = {}, &block)
|
||||
ActiveSupport::Deprecation.warn "Model.generate! is deprecated; use the FactoryGirl.define syntax instead", caller
|
||||
instance = FactoryRunner.new(name.underscore, Strategy::Create, [overrides]).run
|
||||
yield(instance) if block_given?
|
||||
instance
|
||||
end
|
||||
|
||||
def spawn(overrides = {}, &block)
|
||||
ActiveSupport::Deprecation.warn "Model.spawn is deprecated; use the FactoryGirl.define syntax instead", caller
|
||||
instance = FactoryRunner.new(name.underscore, Strategy::Build, [overrides]).run
|
||||
yield(instance) if block_given?
|
||||
instance
|
||||
|
|
|
@ -28,10 +28,12 @@ module FactoryGirl
|
|||
module ClassMethods #:nodoc:
|
||||
|
||||
def make(overrides = {})
|
||||
ActiveSupport::Deprecation.warn "Model.make is deprecated; use the FactoryGirl.define syntax instead", caller
|
||||
FactoryRunner.new(name.underscore, Strategy::Build, [overrides]).run
|
||||
end
|
||||
|
||||
def make!(overrides = {})
|
||||
ActiveSupport::Deprecation.warn "Model.make! is deprecated; use the FactoryGirl.define syntax instead", caller
|
||||
FactoryRunner.new(name.underscore, Strategy::Create, [overrides]).run
|
||||
end
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ module FactoryGirl
|
|||
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
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require "active_support/deprecation"
|
||||
|
||||
module FactoryGirl
|
||||
module Syntax
|
||||
module Vintage
|
||||
|
|
|
@ -4,6 +4,8 @@ require 'factory_girl/syntax/blueprint'
|
|||
|
||||
describe "a blueprint" do
|
||||
before do
|
||||
ActiveSupport::Deprecation.silenced = true
|
||||
|
||||
define_model('User', first_name: :string, last_name: :string, email: :string)
|
||||
|
||||
FactoryGirl.define do
|
||||
|
|
|
@ -4,6 +4,8 @@ require 'factory_girl/syntax/generate'
|
|||
|
||||
describe "a factory using generate syntax" do
|
||||
before do
|
||||
ActiveSupport::Deprecation.silenced = true
|
||||
|
||||
define_model('User', first_name: :string, last_name: :string, email: :string) do
|
||||
validates_presence_of :first_name
|
||||
end
|
||||
|
|
|
@ -4,6 +4,8 @@ require 'factory_girl/syntax/make'
|
|||
|
||||
describe "a factory using make syntax" do
|
||||
before do
|
||||
ActiveSupport::Deprecation.silenced = true
|
||||
|
||||
define_model('User', first_name: :string, last_name: :string)
|
||||
|
||||
FactoryGirl.define do
|
||||
|
|
Loading…
Reference in New Issue