Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Deprecate FactoryGirl step definitions

  • Loading branch information...
commit 154346b01b36568a2b9b8d9a491790ea8af056cd 1 parent f97ed2d
@joshuaclayton joshuaclayton authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/factory_girl/step_definitions.rb
View
12 lib/factory_girl/step_definitions.rb
@@ -1,3 +1,5 @@
+require 'active_support/deprecation'
+
# @api private
module FactoryGirlStepHelpers
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
@@ -109,6 +111,8 @@ 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)
@@ -116,10 +120,14 @@ def initialize(human_hash_to_attributes_hash, key, value)
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
@@ -127,10 +135,14 @@ def initialize(human_hash_to_attributes_hash, key, value)
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

5 comments on commit 154346b

@betelgeuse

It would be nice if the NEWS file and the messages documented what you should use instead.

@jmuheim

Yes, I would also be interested in that.

@joshuaclayton

@betelgeuse @sientia-jmu We typically keep the "why" out of the NEWS file; for big changes like this, I'll write a blog post on robots.thoughtbot.com. Here's the post about why we deprecated the steps: http://robots.thoughtbot.com/post/25650434584/writing-better-cucumber-scenarios-or-why-were

@betelgeuse

@joshuaclayton how about linking to the blog post in the commit message at least?

@joshuaclayton

@betelgeuse The post wasn't written yet; I wanted to publish after 3.5.0 was released so devs upgrading would have seen it

Please sign in to comment.
Something went wrong with that request. Please try again.