Fix step definitions with case sensitive factory name and attributes

Closes #95
This commit is contained in:
Brice Stacey 2010-11-05 12:02:38 -04:00 committed by Joshua Clayton
parent 2f053fdbcb
commit 87712252ac
2 changed files with 36 additions and 3 deletions

View File

@ -149,3 +149,36 @@ Feature: Use step definitions generated by factories
| category_group_id |
| 456 |
Scenario: factory name and attributes should not be case sensitive
Given the following category exists:
| name | category group |
| fiction | Name: books |
Then there should be 1 category
Given the following Category exists:
| name | category group |
| science | Name: books |
Then there should be 2 categories
Scenario: factory name and attributes should not be case sensitive
Given a user exists
Then there should be 1 user
Given a User exists
Then there should be 2 Users
Scenario: factory name and attributes should not be case sensitive
Given 3 users exist
Then there should be 3 users
Given 3 Users exist
Then there should be 6 Users
Scenario: factory name and attributes should not be case sensitive
Given a category exists with a name of "fiction"
Then there should be 1 category
Given a Category exists with a name of "science"
Then there should be 2 Categories
Scenario: factory name and attributes should not be case sensitive
Given 3 categories exist with a name of "fiction"
Then there should be 3 categories
Given 3 Categories exist with a name of "science"
Then there should be 6 Categories

View File

@ -29,18 +29,18 @@ end
World(FactoryGirlStepHelpers)
FactoryGirl.factories.each do |factory|
Given /^the following (?:#{factory.human_name}|#{factory.human_name.pluralize}) exists?:$/ do |table|
Given /^the following (?:#{factory.human_name}|#{factory.human_name.pluralize}) exists?:$/i do |table|
table.hashes.each do |human_hash|
attributes = convert_human_hash_to_attribute_hash(human_hash, factory.associations)
factory.run(FactoryGirl::Proxy::Create, attributes)
end
end
Given /^an? #{factory.human_name} exists$/ do
Given /^an? #{factory.human_name} exists$/i do
FactoryGirl.create(factory.name)
end
Given /^(\d+) #{factory.human_name.pluralize} exist$/ do |count|
Given /^(\d+) #{factory.human_name.pluralize} exist$/i do |count|
count.to_i.times { FactoryGirl.create(factory.name) }
end