mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
More step definitions
This commit is contained in:
parent
db6c46a101
commit
adce9df6c9
2 changed files with 27 additions and 0 deletions
|
@ -59,3 +59,18 @@ Feature: Use step definitions generated by factories
|
|||
| title | author_id |
|
||||
| a title | 123 |
|
||||
And there should be 1 user
|
||||
|
||||
Scenario: create a user without attributes
|
||||
Given a user exists
|
||||
Then there should be 1 user
|
||||
|
||||
Scenario: create several users without attributes
|
||||
Given 3 users exist
|
||||
Then there should be 3 users
|
||||
|
||||
Scenario: create several users with one attribute
|
||||
Given 3 users exist with a name of "John"
|
||||
Then there should be 3 users
|
||||
And I should find the following for the last user:
|
||||
| name |
|
||||
| John |
|
||||
|
|
|
@ -30,12 +30,24 @@ Factory.factories.values.each do |factory|
|
|||
end
|
||||
end
|
||||
|
||||
Given /^an? #{factory.human_name} exists$/ do
|
||||
Factory(factory.factory_name)
|
||||
end
|
||||
|
||||
Given /^(\d+) #{factory.human_name}s exist$/ do |count|
|
||||
count.to_i.times { Factory(factory.human_name) }
|
||||
end
|
||||
|
||||
if factory.build_class.respond_to?(:columns)
|
||||
factory.build_class.columns.each do |column|
|
||||
human_column_name = column.name.downcase.gsub('_', ' ')
|
||||
Given /^an? #{factory.human_name} exists with an? #{human_column_name} of "([^"]*)"$/i do |value|
|
||||
Factory(factory.human_name, column.name => value)
|
||||
end
|
||||
|
||||
Given /^(\d+) #{factory.human_name}s exist with an? #{human_column_name} of "([^"]*)"$/i do |count, value|
|
||||
count.to_i.times { Factory(factory.human_name, column.name => value) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue