mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Deprecate FactoryGirl step definitions
This commit is contained in:
parent
f97ed2dd73
commit
154346b01b
1 changed files with 12 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
require 'active_support/deprecation'
|
||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
module FactoryGirlStepHelpers
|
module FactoryGirlStepHelpers
|
||||||
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
|
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
|
||||||
|
@ -109,6 +111,8 @@ FactoryGirl.factories.each do |factory|
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^the following (?:#{human_name}|#{human_name.pluralize}) exists?:?$/i do |table|
|
Given /^the following (?:#{human_name}|#{human_name.pluralize}) exists?:?$/i do |table|
|
||||||
|
ActiveSupport::Deprecation.warn %{The step 'Given the following #{human_name} exists:' is deprecated and will be removed in 4.0}
|
||||||
|
|
||||||
table.hashes.each do |human_hash|
|
table.hashes.each do |human_hash|
|
||||||
attributes = convert_human_hash_to_attribute_hash(human_hash, factory.associations)
|
attributes = convert_human_hash_to_attribute_hash(human_hash, factory.associations)
|
||||||
FactoryGirl.create(factory.name, attributes)
|
FactoryGirl.create(factory.name, attributes)
|
||||||
|
@ -116,10 +120,14 @@ FactoryGirl.factories.each do |factory|
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^an? #{human_name} exists$/i do
|
Given /^an? #{human_name} exists$/i do
|
||||||
|
ActiveSupport::Deprecation.warn %{The step 'Given a #{human_name} exists' is deprecated and will be removed in 4.0}
|
||||||
|
|
||||||
FactoryGirl.create(factory.name)
|
FactoryGirl.create(factory.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^(\d+) #{human_name.pluralize} exist$/i do |count|
|
Given /^(\d+) #{human_name.pluralize} exist$/i do |count|
|
||||||
|
ActiveSupport::Deprecation.warn %{The step 'Given #{count} #{human_name.pluralize} exist' is deprecated and will be removed in 4.0}
|
||||||
|
|
||||||
FactoryGirl.create_list(factory.name, count.to_i)
|
FactoryGirl.create_list(factory.name, count.to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -127,10 +135,14 @@ FactoryGirl.factories.each do |factory|
|
||||||
human_column_name = attribute_name.downcase.gsub('_', ' ')
|
human_column_name = attribute_name.downcase.gsub('_', ' ')
|
||||||
|
|
||||||
Given /^an? #{human_name} exists with an? #{human_column_name} of "([^"]*)"$/i do |value|
|
Given /^an? #{human_name} exists with an? #{human_column_name} of "([^"]*)"$/i do |value|
|
||||||
|
ActiveSupport::Deprecation.warn %{The step 'Given a #{human_name} exists with a #{human_column_name} of "#{value}"' is deprecated and will be removed in 4.0}
|
||||||
|
|
||||||
FactoryGirl.create(factory.name, attribute_name => value)
|
FactoryGirl.create(factory.name, attribute_name => value)
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^(\d+) #{human_name.pluralize} exist with an? #{human_column_name} of "([^"]*)"$/i do |count, value|
|
Given /^(\d+) #{human_name.pluralize} exist with an? #{human_column_name} of "([^"]*)"$/i do |count, value|
|
||||||
|
ActiveSupport::Deprecation.warn %{The step 'Given #{count} #{human_name.pluralize} exists with a #{human_column_name} of "#{value}"' is deprecated and will be removed in 4.0}
|
||||||
|
|
||||||
FactoryGirl.create_list(factory.name, count.to_i, attribute_name => value)
|
FactoryGirl.create_list(factory.name, count.to_i, attribute_name => value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue