cucumber_scaffold 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +2 -1
- data/README.rdoc +100 -57
- data/Rakefile +1 -1
- data/cucumber_scaffold.gemspec +4 -4
- data/lib/generators/cucumber_scaffold/feature/feature_generator.rb +58 -45
- data/lib/generators/cucumber_scaffold/feature/templates/feature.feature +111 -112
- data/lib/generators/cucumber_scaffold/feature/templates/steps.rb +10 -8
- data/lib/generators/cucumber_scaffold/install/install_generator.rb +2 -1
- data/lib/generators/cucumber_scaffold/install/templates/{shared → step_definitions}/web_steps_additional.rb +23 -3
- data/lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb +20 -0
- metadata +8 -6
data/Manifest
CHANGED
@@ -9,4 +9,5 @@ lib/generators/cucumber_scaffold/feature/templates/feature.feature
|
|
9
9
|
lib/generators/cucumber_scaffold/feature/templates/steps.rb
|
10
10
|
lib/generators/cucumber_scaffold/install/USAGE
|
11
11
|
lib/generators/cucumber_scaffold/install/install_generator.rb
|
12
|
-
lib/generators/cucumber_scaffold/install/templates/
|
12
|
+
lib/generators/cucumber_scaffold/install/templates/step_definitions/web_steps_additional.rb
|
13
|
+
lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb
|
data/README.rdoc
CHANGED
@@ -4,14 +4,29 @@
|
|
4
4
|
|
5
5
|
== Usage
|
6
6
|
|
7
|
+
Install the support files (you should also do this when updating the gem):
|
8
|
+
|
7
9
|
$ rails generate cucumber_scaffold:install
|
8
|
-
|
10
|
+
|
11
|
+
Run the built-in Rails scaffold generator:
|
12
|
+
|
13
|
+
$ rails generate scaffold Post name:string body:text rating:integer published:boolean
|
14
|
+
|
15
|
+
Then run the cucumber_scaffold generator with the same parameters:
|
16
|
+
|
17
|
+
$ rails generate cucumber_scaffold:feature Post name:string body:text rating:integer published:boolean
|
18
|
+
|
19
|
+
== Notes
|
20
|
+
|
21
|
+
* By default the generated features are targeted at the Rails scaffold generator
|
22
|
+
* Only tested with Rails 3 and Capybara (not webrat)
|
23
|
+
* Only supports string, text, integer and boolean fields at present
|
9
24
|
|
10
25
|
== Sample Output
|
11
26
|
|
12
27
|
# Generated by cucumber_scaffold - http://github.com/andyw8/cucumber_scaffold
|
13
28
|
|
14
|
-
Feature: Manage
|
29
|
+
Feature: Manage posts
|
15
30
|
In order to [goal]
|
16
31
|
[stakeholder]
|
17
32
|
wants [behaviour]
|
@@ -19,64 +34,77 @@
|
|
19
34
|
@index
|
20
35
|
Scenario: List all posts
|
21
36
|
Given the following posts:
|
22
|
-
| name
|
23
|
-
| name 1 | body 1 |
|
24
|
-
| name 2 | body 2 |
|
25
|
-
| name 3 | body 3 |
|
37
|
+
| name | body | rating | published |
|
38
|
+
| name 1 | body 1 | 11 | true |
|
39
|
+
| name 2 | body 2 | 12 | true |
|
40
|
+
| name 3 | body 3 | 13 | true |
|
26
41
|
When I go to the posts page
|
27
42
|
Then I should see the following posts:
|
28
|
-
| Name
|
29
|
-
| name 1 | body 1 |
|
30
|
-
| name 2 | body 2 |
|
31
|
-
| name 3 | body 3 |
|
43
|
+
| Name | Body | Rating | Published |
|
44
|
+
| name 1 | body 1 | 11 | true |
|
45
|
+
| name 2 | body 2 | 12 | true |
|
46
|
+
| name 3 | body 3 | 13 | true |
|
32
47
|
|
33
48
|
@show
|
34
49
|
Scenario: View a post
|
35
50
|
Given the following post:
|
36
|
-
| name | name
|
37
|
-
| body | body
|
51
|
+
| name | name 10 |
|
52
|
+
| body | body 10 |
|
53
|
+
| rating | 20 |
|
54
|
+
| published | true |
|
38
55
|
When I go to the page for that post
|
39
56
|
Then I should see the following post:
|
40
|
-
| Name: | name
|
41
|
-
| Body: | body
|
57
|
+
| Name: | name 10 |
|
58
|
+
| Body: | body 10 |
|
59
|
+
| Rating: | 20 |
|
60
|
+
| Published: | true |
|
42
61
|
|
43
62
|
@edit
|
44
63
|
Scenario: Edit a post
|
45
64
|
Given the following post:
|
46
|
-
| name | name
|
47
|
-
| body | body
|
65
|
+
| name | name 10 |
|
66
|
+
| body | body 10 |
|
67
|
+
| rating | 20 |
|
68
|
+
| published | true |
|
48
69
|
When I go to the edit page for that post
|
49
70
|
Then I should see the following form field values:
|
50
|
-
| Name | name
|
51
|
-
| Body | body
|
71
|
+
| Name | name 10 |
|
72
|
+
| Body | body 10 |
|
73
|
+
| Rating | 20 |
|
74
|
+
| Published | [x] |
|
52
75
|
|
53
76
|
@index @destroy
|
54
77
|
Scenario: Delete a post via the index page
|
55
78
|
Given the following posts:
|
56
|
-
| name
|
57
|
-
| name 1 | body 1 |
|
58
|
-
| name 2 | body 2 |
|
59
|
-
| name 3 | body 3 |
|
79
|
+
| name | body | rating | published |
|
80
|
+
| name 1 | body 1 | 11 | true |
|
81
|
+
| name 2 | body 2 | 12 | true |
|
82
|
+
| name 3 | body 3 | 13 | true |
|
60
83
|
When I go to the posts page
|
61
84
|
And I click "Destroy" in the 2nd row
|
62
85
|
Then I should see the following posts:
|
63
|
-
| Name
|
64
|
-
| name 1 | body 1 |
|
65
|
-
| name 3 | body 3 |
|
86
|
+
| Name | Body | Rating | Published |
|
87
|
+
| name 1 | body 1 | 11 | true |
|
88
|
+
| name 3 | body 3 | 13 | true |
|
66
89
|
And I should be on the posts page
|
90
|
+
|
67
91
|
|
68
92
|
@new @create @show
|
69
93
|
Scenario: Create a new post
|
70
94
|
Pending
|
71
95
|
# Given I am on the new post page
|
72
|
-
# When I fill in the
|
73
|
-
# | Name
|
74
|
-
# | Body | body
|
96
|
+
# When I fill in the form with:
|
97
|
+
# | Name | name 10 |
|
98
|
+
# | Body | body 10 |
|
99
|
+
# | Rating | 20 |
|
100
|
+
# | Published | [x] |
|
75
101
|
# And I press "Create"
|
76
102
|
# Then I should see "Post was successfully created."
|
77
103
|
# And I should see the following post:
|
78
|
-
# | Name: | name
|
79
|
-
# | Body: | body
|
104
|
+
# | Name: | name 10 |
|
105
|
+
# | Body: | body 10 |
|
106
|
+
# | Rating: | 20 |
|
107
|
+
# | Published: | true |
|
80
108
|
#
|
81
109
|
# In order to confirm that the user is redirected to the correct page
|
82
110
|
# after create, you'll need to add an entry to paths.rb to uniquely
|
@@ -101,18 +129,21 @@
|
|
101
129
|
Pending
|
102
130
|
# You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required
|
103
131
|
# Given I am on the new post page
|
104
|
-
# When I fill in the
|
105
|
-
# | Name
|
106
|
-
# | Body | body
|
132
|
+
# When I fill in the form with:
|
133
|
+
# | Name | name 10 |
|
134
|
+
# | Body | body 10 |
|
135
|
+
# | Rating | 20 |
|
136
|
+
# | Published | [x] |
|
107
137
|
# And I press "Create"
|
108
138
|
# Then I should see "prohibited this post from being saved:"
|
109
139
|
#
|
110
140
|
# [You should add checks for specific errors here. It may be appropriate to add extra scenarios.]
|
111
141
|
#
|
112
|
-
# And I should be on the posts page
|
113
142
|
# And I should see the following form field values:
|
114
|
-
# | Name
|
115
|
-
# | Body
|
143
|
+
# | Name | name 10 |
|
144
|
+
# | Body | body 10 |
|
145
|
+
# | Rating | 20 |
|
146
|
+
# | Published | [x] |
|
116
147
|
|
117
148
|
@edit @update
|
118
149
|
Scenario: Attempt to update a post with invalid input
|
@@ -120,32 +151,43 @@
|
|
120
151
|
# You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required
|
121
152
|
# Given a post exists
|
122
153
|
# When I go to the edit page for that post
|
123
|
-
# And I fill in the
|
124
|
-
# | Name
|
125
|
-
# | Body | body
|
154
|
+
# And I fill in the form with:
|
155
|
+
# | Name | name 10 |
|
156
|
+
# | Body | body 10 |
|
157
|
+
# | Rating | 20 |
|
158
|
+
# | Published | [x] |
|
126
159
|
# And I press "Update"
|
127
160
|
# Then I should see "prohibited this post from being saved:"
|
128
161
|
#
|
129
162
|
# [You should add checks for specific errors here. It may be appropriate to add extra scenarios.]
|
130
163
|
#
|
131
|
-
# And I should be on the page for that post
|
132
164
|
# And I should see the following form field values:
|
133
|
-
# | Name
|
134
|
-
# | Body
|
165
|
+
# | Name | name 10 |
|
166
|
+
# | Body | body 10 |
|
167
|
+
# | Rating | 20 |
|
168
|
+
# | Published | [x] |
|
135
169
|
|
136
170
|
@edit @update @show
|
137
171
|
Scenario: Update a post
|
138
|
-
Given
|
172
|
+
Given the following post:
|
173
|
+
| name | name 10 |
|
174
|
+
| body | body 10 |
|
175
|
+
| rating | 20 |
|
176
|
+
| published | true |
|
139
177
|
When I go to the edit page for that post
|
140
|
-
And I fill in the
|
141
|
-
| Name | name
|
142
|
-
| Body | body
|
178
|
+
And I fill in the form with:
|
179
|
+
| Name | name 10 updated |
|
180
|
+
| Body | body 10 updated |
|
181
|
+
| Rating | -20 |
|
182
|
+
| Published | [ ] |
|
143
183
|
And I press "Update"
|
144
184
|
Then I should be on the page for that post
|
145
185
|
And I should see "Post was successfully updated."
|
146
186
|
And I should see the following post:
|
147
|
-
| Name: | name
|
148
|
-
| Body: | body
|
187
|
+
| Name: | name 10 updated |
|
188
|
+
| Body: | body 10 updated |
|
189
|
+
| Rating: | -20 |
|
190
|
+
| Published: | false |
|
149
191
|
|
150
192
|
@index @new
|
151
193
|
Scenario: Navigate from the posts page to the new post page
|
@@ -156,10 +198,10 @@
|
|
156
198
|
@index @show
|
157
199
|
Scenario: Navigate from posts page to the show post page
|
158
200
|
Given the following posts:
|
159
|
-
| name
|
160
|
-
| name 1 | body 1 |
|
161
|
-
| name 2 | body 2 |
|
162
|
-
| name 3 | body 3 |
|
201
|
+
| name | body | rating | published |
|
202
|
+
| name 1 | body 1 | 11 | true |
|
203
|
+
| name 2 | body 2 | 12 | true |
|
204
|
+
| name 3 | body 3 | 13 | true |
|
163
205
|
When I go to the posts page
|
164
206
|
And I click "Show" in the 2nd row
|
165
207
|
Then I should be on the page for the 2nd post
|
@@ -167,10 +209,10 @@
|
|
167
209
|
@index @edit
|
168
210
|
Scenario: Navigate from posts page to the edit post page
|
169
211
|
Given the following posts:
|
170
|
-
| name
|
171
|
-
| name 1 | body 1 |
|
172
|
-
| name 2 | body 2 |
|
173
|
-
| name 3 | body 3 |
|
212
|
+
| name | body | rating | published |
|
213
|
+
| name 1 | body 1 | 11 | true |
|
214
|
+
| name 2 | body 2 | 12 | true |
|
215
|
+
| name 3 | body 3 | 13 | true |
|
174
216
|
When I go to the posts page
|
175
217
|
And I click "Edit" in the 2nd row
|
176
218
|
Then I should be on the edit page for the 2nd post
|
@@ -213,7 +255,7 @@
|
|
213
255
|
Scenario: Posts page title
|
214
256
|
When I go to the posts page
|
215
257
|
Then the heading should be "Listing posts"
|
216
|
-
|
258
|
+
|
217
259
|
@new
|
218
260
|
Scenario: New post page title
|
219
261
|
When I go to the new post page
|
@@ -224,3 +266,4 @@
|
|
224
266
|
Given a post exists
|
225
267
|
When I go to the edit page for that post
|
226
268
|
Then the heading should be "Editing post"
|
269
|
+
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('cucumber_scaffold', '0.1.
|
5
|
+
Echoe.new('cucumber_scaffold', '0.1.3') do |p|
|
6
6
|
p.description = "Generate scaffolding for Cucumber features and steps definitions"
|
7
7
|
p.url = "http://github.com/andyw8/cucumber_scaffold"
|
8
8
|
p.author = "Andy Waite"
|
data/cucumber_scaffold.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cucumber_scaffold}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Andy Waite"]
|
9
|
-
s.date = %q{2010-11-
|
9
|
+
s.date = %q{2010-11-13}
|
10
10
|
s.description = %q{Generate scaffolding for Cucumber features and steps definitions}
|
11
11
|
s.email = %q{andy@andywaite.com}
|
12
|
-
s.extra_rdoc_files = ["README.rdoc", "TODO", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/
|
13
|
-
s.files = ["Manifest", "README.rdoc", "Rakefile", "TODO", "cucumber_scaffold.gemspec", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "TODO", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/step_definitions/web_steps_additional.rb", "lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb"]
|
13
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "TODO", "cucumber_scaffold.gemspec", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/step_definitions/web_steps_additional.rb", "lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb"]
|
14
14
|
s.homepage = %q{http://github.com/andyw8/cucumber_scaffold}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cucumber_scaffold", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -28,17 +28,17 @@ module CucumberScaffold
|
|
28
28
|
template('steps.rb', "features/step_definitions/#{singular}_steps.rb")
|
29
29
|
|
30
30
|
extra_paths = <<EOF
|
31
|
-
when /edit page for that #{singular}/
|
31
|
+
when /edit page for that #{singular.humanize.downcase}/
|
32
32
|
edit_#{singular}_path(@#{singular})
|
33
|
-
when /page for that #{singular}/
|
34
|
-
raise 'no #{singular}' unless @#{singular}
|
33
|
+
when /page for that #{singular.humanize.downcase}/
|
34
|
+
raise 'no #{singular.humanize.downcase}' unless @#{singular}
|
35
35
|
#{singular}_path(@#{singular})
|
36
|
-
when /edit page for the (\\d+)(?:st|nd|rd|th) #{singular}/
|
37
|
-
raise 'no #{plural}' unless @#{plural}
|
36
|
+
when /edit page for the (\\d+)(?:st|nd|rd|th) #{singular.humanize.downcase}/
|
37
|
+
raise 'no #{plural.humanize.downcase}' unless @#{plural}
|
38
38
|
nth_#{singular} = @#{plural}[$1.to_i - 1]
|
39
39
|
edit_#{singular}_path(nth_#{singular})
|
40
|
-
when /page for the (\\d+)(?:st|nd|rd|th) #{singular}/
|
41
|
-
raise 'no #{plural}' unless @#{plural}
|
40
|
+
when /page for the (\\d+)(?:st|nd|rd|th) #{singular.humanize.downcase}/
|
41
|
+
raise 'no #{plural.humanize.downcase}' unless @#{plural}
|
42
42
|
nth_#{singular} = @#{plural}[$1.to_i - 1]
|
43
43
|
#{singular}_path(nth_#{singular})
|
44
44
|
EOF
|
@@ -69,11 +69,11 @@ EOF
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def singular_title
|
72
|
-
singular.
|
72
|
+
singular.humanize
|
73
73
|
end
|
74
74
|
|
75
75
|
def plural_title
|
76
|
-
plural.
|
76
|
+
plural.humanize
|
77
77
|
end
|
78
78
|
|
79
79
|
def activerecord_table_header_row
|
@@ -81,103 +81,116 @@ EOF
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def html_table_header_row
|
84
|
-
make_row(attribute_names.map(&:
|
84
|
+
make_row(attribute_names.map(&:humanize))
|
85
85
|
end
|
86
86
|
|
87
87
|
def attribute_names
|
88
|
-
@attributes.collect {|a| a.first[0]}
|
88
|
+
@attributes.collect {|a| a.first[0].gsub('_', ' ')}
|
89
89
|
end
|
90
90
|
|
91
|
-
def html_single_resource(
|
91
|
+
def html_single_resource(options={})
|
92
92
|
lines = []
|
93
93
|
@attributes.each do |pair|
|
94
94
|
attribute_name = pair.first[0]
|
95
|
-
|
96
|
-
|
95
|
+
attribute_type = pair.first[1]
|
96
|
+
default_value = default_value(:attribute_name => attribute_name, :attribute_type => attribute_type, :updated => options[:updated])
|
97
|
+
|
98
|
+
lines << "| #{attribute_name.humanize}: | #{default_value} |"
|
97
99
|
end
|
98
|
-
lines.join(commented ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
100
|
+
lines.join(options[:commented] ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
99
101
|
end
|
100
102
|
|
101
103
|
def form_single_resource_commented
|
102
|
-
form_single_resource(
|
104
|
+
form_single_resource(:commented => true)
|
103
105
|
end
|
104
106
|
|
105
107
|
def html_single_resource_commented
|
106
|
-
html_single_resource(
|
108
|
+
html_single_resource(:commented => true)
|
107
109
|
end
|
108
110
|
|
109
|
-
def form_single_resource(
|
111
|
+
def form_single_resource(options = {})
|
110
112
|
lines = []
|
111
113
|
@attributes.each do |pair|
|
112
114
|
attribute_name = pair.first[0]
|
113
|
-
|
114
|
-
lines << "| #{attribute_name.
|
115
|
+
attribute_type = pair.first[1]
|
116
|
+
lines << "| #{attribute_name.humanize} | #{default_value(:attribute_name => attribute_name, :attribute_type => attribute_type, :updated => options[:updated], :form => true)} |"
|
115
117
|
end
|
116
|
-
result = lines.join(commented ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
118
|
+
result = lines.join(options[:commented] ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
117
119
|
end
|
118
120
|
|
119
|
-
def activerecord_single_resource(
|
121
|
+
def activerecord_single_resource(options={})
|
120
122
|
lines = []
|
121
123
|
@attributes.each do |pair|
|
122
124
|
attribute_name = pair.first[0]
|
123
|
-
|
124
|
-
lines << "| #{attribute_name} | #{default_value(attribute_name,
|
125
|
+
attribute_type = pair.first[1]
|
126
|
+
lines << "| #{attribute_name} | #{default_value(:attribute_name => attribute_name, :attribute_type => attribute_type, :updated =>options[:updated])} |"
|
125
127
|
end
|
126
128
|
lines.join(LINE_BREAK_WITH_INDENT)
|
127
129
|
end
|
128
130
|
|
129
131
|
def html_resources
|
130
132
|
[html_table_header_row,
|
131
|
-
html_table_row(1),
|
132
|
-
html_table_row(2),
|
133
|
-
html_table_row(3)].join(LINE_BREAK_WITH_INDENT)
|
133
|
+
html_table_row(:index => 1),
|
134
|
+
html_table_row(:index => 2),
|
135
|
+
html_table_row(:index => 3)].join(LINE_BREAK_WITH_INDENT)
|
134
136
|
end
|
135
137
|
|
136
138
|
def activerecord_resources
|
137
139
|
[activerecord_table_header_row,
|
138
|
-
activerecord_table_row(1),
|
139
|
-
activerecord_table_row(2),
|
140
|
-
activerecord_table_row(3)].join(LINE_BREAK_WITH_INDENT)
|
140
|
+
activerecord_table_row(:index => 1),
|
141
|
+
activerecord_table_row(:index => 2),
|
142
|
+
activerecord_table_row(:index => 3)].join(LINE_BREAK_WITH_INDENT)
|
141
143
|
end
|
142
144
|
|
143
145
|
def activerecord_single_resource_updated
|
144
|
-
activerecord_single_resource(true)
|
146
|
+
activerecord_single_resource(:updated => true)
|
145
147
|
end
|
146
148
|
|
147
149
|
def form_single_resource_updated
|
148
|
-
form_single_resource(true)
|
150
|
+
form_single_resource(:updated => true)
|
149
151
|
end
|
150
152
|
|
151
153
|
def html_single_resource_updated
|
152
|
-
html_single_resource(true)
|
154
|
+
html_single_resource(:updated => true)
|
153
155
|
end
|
154
156
|
|
155
|
-
def default_value(attribute_name, attribute_type, updated=false, index=1
|
157
|
+
def default_value(options={}) # attribute_name, attribute_type, updated=false, index=1
|
156
158
|
# TODO use an options hash instead of all these arguments
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
result =
|
162
|
-
result
|
159
|
+
|
160
|
+
options[:index] ||= 10
|
161
|
+
|
162
|
+
if ['string', 'text'].include?(options[:attribute_type])
|
163
|
+
result = "#{options[:attribute_name].humanize.downcase} #{options[:index]}"
|
164
|
+
result += ' updated' if options[:updated]
|
165
|
+
elsif options[:attribute_type] == 'integer'
|
166
|
+
result = 10 + options[:index]
|
167
|
+
result = -result if options[:updated]
|
168
|
+
elsif options[:attribute_type] == 'boolean'
|
169
|
+
if options[:form]
|
170
|
+
result = '[x]'
|
171
|
+
result = '[ ]' if options[:updated]
|
172
|
+
else
|
173
|
+
result = true
|
174
|
+
result = false if options[:updated]
|
175
|
+
end
|
163
176
|
else
|
164
|
-
raise "Cannot create default value for attribute type '#{attribute_type}'"
|
177
|
+
raise "Cannot create default value for attribute type '#{options[:attribute_type]}'"
|
165
178
|
end
|
166
179
|
result
|
167
180
|
end
|
168
181
|
|
169
|
-
def activerecord_table_row(
|
182
|
+
def activerecord_table_row(options)
|
170
183
|
data = []
|
171
184
|
@attributes.each do |attribute|
|
172
185
|
attribute_name = attribute.first[0]
|
173
186
|
attribute_type = attribute.first[1]
|
174
|
-
data << default_value(attribute_name, attribute_type
|
187
|
+
data << default_value(:attribute_name => attribute_name, :attribute_type => attribute_type, :index => options[:index])
|
175
188
|
end
|
176
189
|
make_row(data)
|
177
190
|
end
|
178
191
|
|
179
|
-
def html_table_row(
|
180
|
-
activerecord_table_row(
|
192
|
+
def html_table_row(options)
|
193
|
+
activerecord_table_row(options)
|
181
194
|
end
|
182
195
|
|
183
196
|
def tags(tags)
|
@@ -25,257 +25,256 @@ else
|
|
25
25
|
edit_heading = "Editing #{singular}"
|
26
26
|
new_heading = "New #{singular}"
|
27
27
|
back_to_all = 'Back'
|
28
|
-
problems_intro = "prohibited this
|
28
|
+
problems_intro = "prohibited this #{singular} from being saved:"
|
29
29
|
end
|
30
30
|
|
31
31
|
pending_explanation_1 = "You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required"
|
32
32
|
pending_explanation_2 = "[You should add checks for specific errors here. It may be appropriate to add extra scenarios.]"
|
33
33
|
-%>
|
34
34
|
|
35
|
-
Feature: Manage <%= plural_title %>
|
35
|
+
Feature: Manage <%= plural_title.humanize.downcase %>
|
36
36
|
In order to [goal]
|
37
37
|
[stakeholder]
|
38
38
|
wants [behaviour]
|
39
39
|
|
40
40
|
<%= tags('@index') %>
|
41
|
-
Scenario: List all <%= plural %>
|
42
|
-
Given the following <%= plural %>:
|
41
|
+
Scenario: List all <%= plural.humanize.downcase %>
|
42
|
+
Given the following <%= plural.humanize.downcase %>:
|
43
43
|
<%= activerecord_table_header_row %>
|
44
|
-
<%= activerecord_table_row(1) %>
|
45
|
-
<%= activerecord_table_row(2) %>
|
46
|
-
<%= activerecord_table_row(3) %>
|
47
|
-
When I go to the <%= plural %> page
|
48
|
-
Then I should see the following <%= plural %>:
|
44
|
+
<%= activerecord_table_row(:index => 1) %>
|
45
|
+
<%= activerecord_table_row(:index => 2) %>
|
46
|
+
<%= activerecord_table_row(:index => 3) %>
|
47
|
+
When I go to the <%= plural.humanize.downcase %> page
|
48
|
+
Then I should see the following <%= plural.humanize.downcase %>:
|
49
49
|
<%= html_table_header_row %>
|
50
|
-
<%= html_table_row(1) %>
|
51
|
-
<%= html_table_row(2) %>
|
52
|
-
<%= html_table_row(3) %>
|
50
|
+
<%= html_table_row(:index => 1) %>
|
51
|
+
<%= html_table_row(:index => 2) %>
|
52
|
+
<%= html_table_row(:index => 3) %>
|
53
53
|
|
54
54
|
<%= tags('@show') %>
|
55
|
-
Scenario: View a <%= singular %>
|
56
|
-
Given the following <%= singular %>:
|
55
|
+
Scenario: View a <%= singular.humanize.downcase %>
|
56
|
+
Given the following <%= singular.humanize.downcase %>:
|
57
57
|
<%= activerecord_single_resource %>
|
58
|
-
When I go to the page for that <%= singular %>
|
59
|
-
Then I should see the following <%= singular %>:
|
58
|
+
When I go to the page for that <%= singular.humanize.downcase %>
|
59
|
+
Then I should see the following <%= singular.humanize.downcase %>:
|
60
60
|
<%= html_single_resource %>
|
61
61
|
|
62
62
|
<%= tags('@edit') %>
|
63
|
-
Scenario: Edit a <%= singular %>
|
64
|
-
Given the following <%= singular %>:
|
63
|
+
Scenario: Edit a <%= singular.humanize.downcase %>
|
64
|
+
Given the following <%= singular.humanize.downcase %>:
|
65
65
|
<%= activerecord_single_resource %>
|
66
|
-
When I go to the edit page for that <%= singular %>
|
66
|
+
When I go to the edit page for that <%= singular.humanize.downcase %>
|
67
67
|
Then I should see the following form field values:
|
68
68
|
<%= form_single_resource %>
|
69
69
|
|
70
70
|
<%= tags('@index @destroy') %>
|
71
|
-
Scenario: Delete a <%= singular %> via the index page
|
72
|
-
Given the following <%= plural %>:
|
71
|
+
Scenario: Delete a <%= singular.humanize.downcase %> via the index page
|
72
|
+
Given the following <%= plural.humanize.downcase %>:
|
73
73
|
<%= activerecord_table_header_row %>
|
74
|
-
<%= activerecord_table_row(1) %>
|
75
|
-
<%= activerecord_table_row(2) %>
|
76
|
-
<%= activerecord_table_row(3) %>
|
77
|
-
When I go to the <%= plural %> page
|
74
|
+
<%= activerecord_table_row(:index => 1) %>
|
75
|
+
<%= activerecord_table_row(:index => 2) %>
|
76
|
+
<%= activerecord_table_row(:index => 3) %>
|
77
|
+
When I go to the <%= plural.humanize.downcase %> page
|
78
78
|
And I click "Destroy" in the 2nd row
|
79
|
-
Then I should see the following <%= plural %>:
|
79
|
+
Then I should see the following <%= plural.humanize.downcase %>:
|
80
80
|
<%= html_table_header_row %>
|
81
|
-
<%= activerecord_table_row(1) %>
|
82
|
-
<%= activerecord_table_row(3) %>
|
83
|
-
And I should be on the <%= plural %> page
|
81
|
+
<%= activerecord_table_row(:index => 1) %>
|
82
|
+
<%= activerecord_table_row(:index => 3) %>
|
83
|
+
And I should be on the <%= plural.humanize.downcase %> page
|
84
84
|
<% if successful_destroy_message %>
|
85
85
|
And I should see "<%= successful_destroy_message %>"
|
86
86
|
<% end -%>
|
87
87
|
|
88
88
|
<% if nifty? %>
|
89
89
|
<%= tags('@show @destroy @index') %>
|
90
|
-
Scenario: Delete a <%= singular %> via the show page
|
91
|
-
Given the following <%= plural %>:
|
90
|
+
Scenario: Delete a <%= singular.humanize.downcase %> via the show page
|
91
|
+
Given the following <%= plural.humanize.downcase %>:
|
92
92
|
<%= activerecord_table_header_row %>
|
93
|
-
<%= activerecord_table_row(1) %>
|
94
|
-
<%= activerecord_table_row(2) %>
|
95
|
-
<%= activerecord_table_row(3) %>
|
93
|
+
<%= activerecord_table_row(:index => 1) %>
|
94
|
+
<%= activerecord_table_row(:index => 2) %>
|
95
|
+
<%= activerecord_table_row(:index => 3) %>
|
96
96
|
When I go to the page for the 2nd post
|
97
97
|
And I follow "Destroy"
|
98
|
-
Then I should see the following <%= plural %>:
|
98
|
+
Then I should see the following <%= plural.humanize.downcase %>:
|
99
99
|
<%= html_table_header_row %>
|
100
|
-
<%= activerecord_table_row(1) %>
|
101
|
-
<%= activerecord_table_row(3) %>
|
102
|
-
And I should be on the <%= plural %> page
|
100
|
+
<%= activerecord_table_row(:index => 1) %>
|
101
|
+
<%= activerecord_table_row(:index => 3) %>
|
102
|
+
And I should be on the <%= plural.humanize.downcase %> page
|
103
103
|
And I should see "<%= successful_destroy_message %>"
|
104
104
|
<% end -%>
|
105
105
|
|
106
106
|
<%= tags('@new @create @show') %>
|
107
|
-
Scenario: Create a new <%= singular %>
|
107
|
+
Scenario: Create a new <%= singular.humanize.downcase %>
|
108
108
|
Pending
|
109
|
-
# Given I am on the new <%= singular %> page
|
110
|
-
# When I fill in the
|
109
|
+
# Given I am on the new <%= singular.humanize.downcase %> page
|
110
|
+
# When I fill in the form with:
|
111
111
|
# <%= form_single_resource_commented %>
|
112
112
|
# And I press "<%= create_button_title %>"
|
113
113
|
# Then I should see "<%= successful_create_message %>"
|
114
|
-
# And I should see the following <%= singular %>:
|
114
|
+
# And I should see the following <%= singular.humanize.downcase %>:
|
115
115
|
# <%= html_single_resource_commented %>
|
116
116
|
#
|
117
117
|
# In order to confirm that the user is redirected to the correct page
|
118
118
|
# after create, you'll need to add an entry to paths.rb to uniquely
|
119
|
-
# find a <%= singular %>, e.g.:
|
119
|
+
# find a <%= singular.humanize.downcase %>, e.g.:
|
120
120
|
#
|
121
|
-
# when /page for the <%= singular %> with name "([^"]*)"$/
|
121
|
+
# when /page for the <%= singular.humanize.downcase %> with name "([^"]*)"$/
|
122
122
|
# conditions = { :conditions => {:name => $1} }
|
123
|
-
# matches = <%=
|
123
|
+
# matches = <%= singular.camelcase %>.all(conditions)
|
124
124
|
# if matches.size == 0
|
125
|
-
# raise "Could not find any <%= plural %> using criteria #{conditions.inspect}"
|
125
|
+
# raise "Could not find any <%= plural.humanize.downcase %> using criteria #{conditions.inspect}"
|
126
126
|
# elsif matches.size > 1
|
127
|
-
# raise "Could not find a unique <%= singular %> using criteria #{conditions.inspect} (#{matches.size} matches)"
|
127
|
+
# raise "Could not find a unique <%= singular.humanize.downcase %> using criteria #{conditions.inspect} (#{matches.size} matches)"
|
128
128
|
# end
|
129
129
|
# <%= singular %>_path(matches.first)
|
130
130
|
#
|
131
131
|
# Then add a step such as this to the scenario:
|
132
132
|
#
|
133
|
-
# And I should be on the page for the <%= singular %> with name "..."
|
133
|
+
# And I should be on the page for the <%= singular.humanize.downcase %> with name "..."
|
134
134
|
|
135
135
|
<%= tags('@new @create') %>
|
136
|
-
Scenario: Attempt to create a new <%= singular %> with invalid input
|
136
|
+
Scenario: Attempt to create a new <%= singular.humanize.downcase %> with invalid input
|
137
137
|
Pending
|
138
138
|
# <%= pending_explanation_1 %>
|
139
|
-
# Given I am on the new <%= singular %> page
|
140
|
-
# When I fill in the
|
139
|
+
# Given I am on the new <%= singular.humanize.downcase %> page
|
140
|
+
# When I fill in the form with:
|
141
141
|
# <%= form_single_resource_commented %>
|
142
142
|
# And I press "<%= create_button_title %>"
|
143
143
|
# Then I should see "<%= problems_intro %>"
|
144
144
|
#
|
145
145
|
# <%= pending_explanation_2 %>
|
146
146
|
#
|
147
|
-
# And I should be on the <%= plural %> page
|
148
147
|
# And I should see the following form field values:
|
149
|
-
# <%=
|
148
|
+
# <%= form_single_resource_commented %>
|
150
149
|
|
151
150
|
<%= tags('@edit @update') %>
|
152
|
-
Scenario: Attempt to update a <%= singular %> with invalid input
|
151
|
+
Scenario: Attempt to update a <%= singular.humanize.downcase %> with invalid input
|
153
152
|
Pending
|
154
153
|
# <%= pending_explanation_1 %>
|
155
|
-
# Given a <%= singular %> exists
|
156
|
-
# When I go to the edit page for that <%= singular %>
|
157
|
-
# And I fill in the
|
154
|
+
# Given a <%= singular.humanize.downcase %> exists
|
155
|
+
# When I go to the edit page for that <%= singular.humanize.downcase %>
|
156
|
+
# And I fill in the form with:
|
158
157
|
# <%= form_single_resource_commented %>
|
159
158
|
# And I press "<%= update_button_title %>"
|
160
159
|
# Then I should see "<%= problems_intro %>"
|
161
160
|
#
|
162
161
|
# <%= pending_explanation_2 %>
|
163
162
|
#
|
164
|
-
# And I should be on the page for that <%= singular %>
|
165
163
|
# And I should see the following form field values:
|
166
|
-
# <%=
|
164
|
+
# <%= form_single_resource_commented %>
|
167
165
|
|
168
166
|
<%= tags('@edit @update @show') %>
|
169
|
-
Scenario: Update a <%= singular %>
|
170
|
-
Given
|
171
|
-
|
172
|
-
|
167
|
+
Scenario: Update a <%= singular.humanize.downcase %>
|
168
|
+
Given the following <%= singular.humanize.downcase %>:
|
169
|
+
<%= activerecord_single_resource %>
|
170
|
+
When I go to the edit page for that <%= singular.humanize.downcase %>
|
171
|
+
And I fill in the form with:
|
173
172
|
<%= form_single_resource_updated %>
|
174
173
|
And I press "<%= update_button_title %>"
|
175
|
-
Then I should be on the page for that <%= singular %>
|
174
|
+
Then I should be on the page for that <%= singular.humanize.downcase %>
|
176
175
|
And I should see "<%= successful_update_message %>"
|
177
|
-
And I should see the following <%= singular %>:
|
176
|
+
And I should see the following <%= singular.humanize.downcase %>:
|
178
177
|
<%= html_single_resource_updated %>
|
179
178
|
|
180
179
|
<%= tags('@index @new') %>
|
181
|
-
Scenario: Navigate from the <%= plural %> page to the new <%= singular %> page
|
182
|
-
Given I am on the <%= plural %> page
|
180
|
+
Scenario: Navigate from the <%= plural.humanize.downcase %> page to the new <%= singular.humanize.downcase %> page
|
181
|
+
Given I am on the <%= plural.humanize.downcase %> page
|
183
182
|
When I follow "New <%= singular_title %>"
|
184
|
-
Then I should be on the new <%= singular %> page
|
183
|
+
Then I should be on the new <%= singular.humanize.downcase %> page
|
185
184
|
|
186
185
|
<%= tags('@index @show') %>
|
187
|
-
Scenario: Navigate from <%= plural %> page to the show <%= singular %> page
|
188
|
-
Given the following <%= plural %>:
|
186
|
+
Scenario: Navigate from <%= plural.humanize.downcase %> page to the show <%= singular.humanize.downcase %> page
|
187
|
+
Given the following <%= plural.humanize.downcase %>:
|
189
188
|
<%= activerecord_table_header_row %>
|
190
|
-
<%= activerecord_table_row(1) %>
|
191
|
-
<%= activerecord_table_row(2) %>
|
192
|
-
<%= activerecord_table_row(3) %>
|
193
|
-
When I go to the <%= plural %> page
|
189
|
+
<%= activerecord_table_row(:index => 1) %>
|
190
|
+
<%= activerecord_table_row(:index => 2) %>
|
191
|
+
<%= activerecord_table_row(:index => 3) %>
|
192
|
+
When I go to the <%= plural.humanize.downcase %> page
|
194
193
|
And I click "Show" in the 2nd row
|
195
|
-
Then I should be on the page for the 2nd <%= singular %>
|
194
|
+
Then I should be on the page for the 2nd <%= singular.humanize.downcase %>
|
196
195
|
|
197
196
|
<%= tags('@index @edit') %>
|
198
|
-
Scenario: Navigate from <%= plural %> page to the edit <%= singular %> page
|
199
|
-
Given the following <%= plural %>:
|
197
|
+
Scenario: Navigate from <%= plural.humanize.downcase %> page to the edit <%= singular.humanize.downcase %> page
|
198
|
+
Given the following <%= plural.humanize.downcase %>:
|
200
199
|
<%= activerecord_table_header_row %>
|
201
|
-
<%= activerecord_table_row(1) %>
|
202
|
-
<%= activerecord_table_row(2) %>
|
203
|
-
<%= activerecord_table_row(3) %>
|
204
|
-
When I go to the <%= plural %> page
|
200
|
+
<%= activerecord_table_row(:index => 1) %>
|
201
|
+
<%= activerecord_table_row(:index => 2) %>
|
202
|
+
<%= activerecord_table_row(:index => 3) %>
|
203
|
+
When I go to the <%= plural.humanize.downcase %> page
|
205
204
|
And I click "Edit" in the 2nd row
|
206
|
-
Then I should be on the edit page for the 2nd <%= singular %>
|
205
|
+
Then I should be on the edit page for the 2nd <%= singular.humanize.downcase %>
|
207
206
|
|
208
207
|
<%= tags('@new @index') %>
|
209
|
-
Scenario: Navigate from new <%= singular %> page to <%= plural %> page
|
210
|
-
Given I am on the new <%= singular %> page
|
208
|
+
Scenario: Navigate from new <%= singular.humanize.downcase %> page to <%= plural.humanize.downcase %> page
|
209
|
+
Given I am on the new <%= singular.humanize.downcase %> page
|
211
210
|
When I follow "<%= back_to_all %>"
|
212
|
-
Then I should be on the <%= plural %> page
|
211
|
+
Then I should be on the <%= plural.humanize.downcase %> page
|
213
212
|
|
214
213
|
<%= tags('@edit @show') %>
|
215
|
-
Scenario: Navigate from the edit <%= singular %> page to the show <%= singular %> page
|
216
|
-
Given a <%= singular %> exists
|
217
|
-
When I go to the edit page for that <%= singular %>
|
214
|
+
Scenario: Navigate from the edit <%= singular.humanize.downcase %> page to the show <%= singular.humanize.downcase %> page
|
215
|
+
Given a <%= singular.humanize.downcase %> exists
|
216
|
+
When I go to the edit page for that <%= singular.humanize.downcase %>
|
218
217
|
And I follow "Show"
|
219
|
-
Then I should be on the page for that <%= singular %>
|
218
|
+
Then I should be on the page for that <%= singular.humanize.downcase %>
|
220
219
|
|
221
220
|
<%= tags('@edit @index') %>
|
222
|
-
Scenario: Navigate from edit <%= singular %> page to the <%= plural %> page
|
223
|
-
Given a <%= singular %> exists
|
224
|
-
When I go to the edit page for that <%= singular %>
|
221
|
+
Scenario: Navigate from edit <%= singular.humanize.downcase %> page to the <%= plural.humanize.downcase %> page
|
222
|
+
Given a <%= singular.humanize.downcase %> exists
|
223
|
+
When I go to the edit page for that <%= singular.humanize.downcase %>
|
225
224
|
And I follow "<%= back_to_all %>"
|
226
|
-
Then I should be on the <%= plural %> page
|
225
|
+
Then I should be on the <%= plural.humanize.downcase %> page
|
227
226
|
|
228
227
|
<%= tags('@show @edit') %>
|
229
|
-
Scenario: Navigate from show <%= singular %> page to edit <%= singular %> page
|
230
|
-
Given a <%= singular %> exists
|
231
|
-
When I go to the page for that <%= singular %>
|
228
|
+
Scenario: Navigate from show <%= singular.humanize.downcase %> page to edit <%= singular.humanize.downcase %> page
|
229
|
+
Given a <%= singular.humanize.downcase %> exists
|
230
|
+
When I go to the page for that <%= singular.humanize.downcase %>
|
232
231
|
And I follow "Edit"
|
233
|
-
Then I should be on the edit page for that <%= singular %>
|
232
|
+
Then I should be on the edit page for that <%= singular.humanize.downcase %>
|
234
233
|
|
235
234
|
<%= tags('@show @index') %>
|
236
|
-
Scenario: Navigate from show <%= singular %> page to <%= plural %> page
|
237
|
-
Given a <%= singular %> exists
|
238
|
-
|
235
|
+
Scenario: Navigate from show <%= singular.humanize.downcase %> page to <%= plural.humanize.downcase %> page
|
236
|
+
Given a <%= singular.humanize.downcase %> exists
|
237
|
+
When I go to the page for that <%= singular.humanize.downcase %>
|
239
238
|
<% if nifty? %>
|
240
239
|
And I follow "View All"
|
241
240
|
<% else %>
|
242
241
|
And I follow "Back"
|
243
242
|
<% end %>
|
244
|
-
Then I should be on the <%= plural %> page
|
243
|
+
Then I should be on the <%= plural.humanize.downcase %> page
|
245
244
|
|
246
245
|
<%= tags('@index') %>
|
247
246
|
Scenario: <%= plural_title %> page title
|
248
|
-
When I go to the <%= plural %> page
|
247
|
+
When I go to the <%= plural.humanize.downcase %> page
|
249
248
|
Then the heading should be "<%= index_heading %>"
|
250
249
|
<% if index_title %>
|
251
250
|
And the title should be "<%= index_title %>"
|
252
251
|
<% end -%>
|
253
252
|
|
254
|
-
<%= tags('@show') %>
|
255
253
|
<% if show_heading || index_title %>
|
254
|
+
<%= tags('@show') %>
|
256
255
|
Scenario: <%= singular_title %> page title
|
257
|
-
Given a <%= singular %> exists
|
256
|
+
Given a <%= singular.humanize.downcase %> exists
|
258
257
|
When I go to the page for that <%= singular %>
|
259
|
-
<% if show_heading
|
258
|
+
<% if show_heading -%>
|
260
259
|
Then the heading should be "<%= show_heading %>"
|
261
|
-
<% end
|
262
|
-
<% if index_title
|
260
|
+
<% end -%>
|
261
|
+
<% if index_title -%>
|
263
262
|
And the title should be "<%= show_title %>"
|
264
263
|
<% end -%>
|
265
264
|
<% end -%>
|
266
265
|
|
267
266
|
<%= tags('@new') %>
|
268
|
-
Scenario: New <%= singular %> page title
|
269
|
-
When I go to the new <%= singular %> page
|
267
|
+
Scenario: New <%= singular.humanize.downcase %> page title
|
268
|
+
When I go to the new <%= singular.humanize.downcase %> page
|
270
269
|
Then the heading should be "<%= new_heading %>"
|
271
270
|
<% if index_title %>
|
272
271
|
And the title should be "<%= new_title %>"
|
273
272
|
<% end -%>
|
274
273
|
|
275
274
|
<%= tags('@edit') %>
|
276
|
-
Scenario: Edit <%= singular %> page title
|
277
|
-
Given a <%= singular %> exists
|
278
|
-
When I go to the edit page for that <%= singular %>
|
275
|
+
Scenario: Edit <%= singular.humanize.downcase %> page title
|
276
|
+
Given a <%= singular.humanize.downcase %> exists
|
277
|
+
When I go to the edit page for that <%= singular.humanize.downcase %>
|
279
278
|
Then the heading should be "<%= edit_heading %>"
|
280
279
|
<% if index_title %>
|
281
280
|
And the title should be "<%= edit_title %>"
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<%= generated_by %>
|
2
2
|
|
3
|
-
Given /^a <%= singular %> exists$/ do
|
4
|
-
@<%= singular %> = <%=
|
3
|
+
Given /^a <%= singular.humanize.downcase %> exists$/ do
|
4
|
+
@<%= singular %> = <%= singular.camelcase %>.create!(valid_<%= singular %>_attributes)
|
5
5
|
end
|
6
6
|
|
7
|
-
Then /^I should see the following <%= singular %>:$/ do |expected_table|
|
7
|
+
Then /^I should see the following <%= singular.humanize.downcase %>:$/ do |expected_table|
|
8
8
|
|
9
9
|
<% if nifty? %>
|
10
10
|
show_fields_css_query = 'body p strong'
|
@@ -22,16 +22,18 @@ Then /^I should see the following <%= singular %>:$/ do |expected_table|
|
|
22
22
|
assert_equal actual, expected_table.rows_hash
|
23
23
|
end
|
24
24
|
|
25
|
-
Then /^I should see the following <%= plural %>:$/ do |expected_table|
|
25
|
+
Then /^I should see the following <%= plural.humanize.downcase %>:$/ do |expected_table|
|
26
26
|
expected_table.diff!(tableish('table tr', 'td,th'))
|
27
27
|
end
|
28
28
|
|
29
|
-
Given /^the following <%= plural %>:$/ do |table|
|
30
|
-
|
29
|
+
Given /^the following <%= plural.humanize.downcase %>:$/ do |table|
|
30
|
+
hashes = replace_spaces_with_underscores_in_keys(table.hashes)
|
31
|
+
@<%= plural %> = <%= singular.camelcase %>.create!(hashes)
|
31
32
|
end
|
32
33
|
|
33
|
-
Given /^the following <%= singular %>:$/ do |table|
|
34
|
-
|
34
|
+
Given /^the following <%= singular.humanize.downcase %>:$/ do |table|
|
35
|
+
hashes = replace_spaces_with_underscores_in_keys(table.rows_hash)
|
36
|
+
@<%= singular %> = <%= singular.camelcase %>.create!(hashes)
|
35
37
|
end
|
36
38
|
|
37
39
|
def valid_<%= singular %>_attributes
|
@@ -5,7 +5,8 @@ module CucumberScaffold
|
|
5
5
|
|
6
6
|
def do_it
|
7
7
|
|
8
|
-
template('
|
8
|
+
template('step_definitions/web_steps_additional.rb', 'features/step_definitions/web_steps_additional.rb')
|
9
|
+
template('support/table_helpers.rb', 'features/support/table_helpers.rb')
|
9
10
|
|
10
11
|
end
|
11
12
|
|
@@ -26,13 +26,33 @@ end
|
|
26
26
|
def form_field_for_label(label)
|
27
27
|
input_tags = label.parent.css('input,textarea')
|
28
28
|
return if input_tags.size == 0
|
29
|
-
|
29
|
+
# rails renders a hidden input alongside each checkbox
|
30
|
+
input_tag = input_tags.last
|
31
|
+
if input_tags.size > 1 && input_tag['type'] != 'checkbox'
|
30
32
|
raise "Wrong number of input tags while parsing form (found #{input_tags.size})"
|
31
33
|
end
|
32
|
-
input_tag = input_tags.first
|
33
34
|
if input_tag.name == 'textarea'
|
34
35
|
input_tag.inner_html
|
35
36
|
elsif input_tag.name == 'input'
|
36
|
-
input_tag['
|
37
|
+
if input_tag['type'] == 'checkbox'
|
38
|
+
input_tag['checked'] == 'checked' ? '[x]' : '[ ]'
|
39
|
+
else
|
40
|
+
input_tag['value']
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
44
|
+
|
45
|
+
When /^(?:|I )fill in the form with(?: within "([^"]*)")?:$/ do |selector, fields|
|
46
|
+
with_scope(selector) do
|
47
|
+
fields.rows_hash.each do |name, value|
|
48
|
+
# assume it's a checkbox
|
49
|
+
if value == '[x]'
|
50
|
+
When %{I check "#{name}"}
|
51
|
+
elsif value == '[ ]'
|
52
|
+
When %{I uncheck "#{name}"}
|
53
|
+
else
|
54
|
+
When %{I fill in "#{name}" with "#{value}"}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
def replace_spaces_with_underscores_in_keys(hashes)
|
2
|
+
# hashes will either be a single hash or an array of hashes
|
3
|
+
if hashes.class == Hash
|
4
|
+
result = {}
|
5
|
+
hashes.each_pair do |key, value|
|
6
|
+
new_key = key.gsub(' ', '_')
|
7
|
+
result[new_key] = value
|
8
|
+
end
|
9
|
+
else
|
10
|
+
result = []
|
11
|
+
hashes.each do |record|
|
12
|
+
result << {}
|
13
|
+
record.each_pair do |key, value|
|
14
|
+
new_key = key.gsub(' ', '_')
|
15
|
+
result.last[new_key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
result
|
20
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Waite
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-13 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -34,7 +34,8 @@ extra_rdoc_files:
|
|
34
34
|
- lib/generators/cucumber_scaffold/feature/templates/steps.rb
|
35
35
|
- lib/generators/cucumber_scaffold/install/USAGE
|
36
36
|
- lib/generators/cucumber_scaffold/install/install_generator.rb
|
37
|
-
- lib/generators/cucumber_scaffold/install/templates/
|
37
|
+
- lib/generators/cucumber_scaffold/install/templates/step_definitions/web_steps_additional.rb
|
38
|
+
- lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb
|
38
39
|
files:
|
39
40
|
- Manifest
|
40
41
|
- README.rdoc
|
@@ -47,7 +48,8 @@ files:
|
|
47
48
|
- lib/generators/cucumber_scaffold/feature/templates/steps.rb
|
48
49
|
- lib/generators/cucumber_scaffold/install/USAGE
|
49
50
|
- lib/generators/cucumber_scaffold/install/install_generator.rb
|
50
|
-
- lib/generators/cucumber_scaffold/install/templates/
|
51
|
+
- lib/generators/cucumber_scaffold/install/templates/step_definitions/web_steps_additional.rb
|
52
|
+
- lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb
|
51
53
|
has_rdoc: true
|
52
54
|
homepage: http://github.com/andyw8/cucumber_scaffold
|
53
55
|
licenses: []
|