forked from thoughtbot/factory_bot
/
factory_girl_steps.feature
125 lines (109 loc) · 4.08 KB
/
factory_girl_steps.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Feature: Use step definitions generated by factories
Scenario: create a post and verify its attributes
Given the following post exists:
| Title | Body |
| a fun title | here is the content |
Then I should find the following for the last post:
| title | body |
| a fun title | here is the content |
Scenario: create a post without a table and verify its attributes
Given a post exists with a title of "a fun title"
Then I should find the following for the last post:
| title |
| a fun title |
Scenario: flexible English when creating posts
Given an post exists with an title of "a fun title"
Then I should find the following for the last post:
| title |
| a fun title |
Scenario: create a post with an underscore in an attribute name
Given a post exists with an author ID of "5"
Then I should find the following for the last post:
| author_id |
| 5 |
Scenario: create several posts
Given the following posts exist:
| Title | Body |
| one | first |
| two | second |
| three | third |
Then I should find the following for the last post:
| title | body |
| three | third |
And there should be 3 posts
Scenario: create a post with a new author
Given the following post exists:
| Title | Author |
| a title | ID: 123 |
Then I should find the following for the last post:
| title | author_id |
| a title | 123 |
And I should find the following for the last user:
| id |
| 123 |
Scenario: create a post with an existing author
Given the following user exists:
| ID | Name |
| 123 | Joe |
And the following post exists:
| Title | Author |
| a title | Name: Joe |
Then I should find the following for the last post:
| title | author_id |
| a title | 123 |
And there should be 1 user
Scenario: create post with and without a category association
Given the following users exist:
| ID | Name |
| 123 | Joe |
And the following posts exist:
| Title | Author | Category |
| a title | Name: Joe | Name: programming |
| a title without a category | Name: Joe | |
Then I should find the following for the last post:
| title | category_id |
| a title without a category | |
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 |
Scenario: create instances of a factory with an underscore in its name
Given an admin user exists with a name of "John"
Then I should find the following for the last user:
| name | admin |
| John | true |
Scenario: create a several instances of a factory with an underscore in its name
Given 3 admin users exist
Then I should find the following for the last user:
| admin |
| true |
Scenario: use true values when creating instances
Given the following user exists:
| name | admin |
| Bill | true |
Then I should find the following for the last user:
| name | admin |
| Bill | true |
Scenario: use false values when creating instances
Given the following user exists:
| name | admin |
| Mike | false |
Then I should find the following for the last user:
| name | admin |
| Mike | false |
Scenario: Properly pluralize words
Given the following categories exist:
| name |
| Bed |
| Test Drive |
And 2 categories exist
And 2 categories exist with a name of "Future"
Then there should be 6 categories