Skip to content

Commit

Permalink
Deprecate FactoryGirl step definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Jun 22, 2012
1 parent f97ed2d commit 154346b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/factory_girl/step_definitions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/deprecation'

# @api private
module FactoryGirlStepHelpers
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
Expand Down Expand Up @@ -109,28 +111,38 @@ def initialize(human_hash_to_attributes_hash, key, value)
end

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|
attributes = convert_human_hash_to_attribute_hash(human_hash, factory.associations)
FactoryGirl.create(factory.name, attributes)
end
end

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)
end

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)
end

attribute_names_for_model.each do |attribute_name|
human_column_name = attribute_name.downcase.gsub('_', ' ')

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)
end

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)
end
end
Expand Down

0 comments on commit 154346b

Please sign in to comment.