Skip to content

Commit d98ec7a

Browse files
committed
gsubing generated widget files to test validation
prepare valid and invalid attributes for widgets
1 parent 3f0212f commit d98ec7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

example_app_generator/generate_stuff.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,17 @@ def using_source_path(path)
167167
gsub_file 'spec/controllers/uploads_controller_spec.rb',
168168
'skip("Add a hash of attributes valid for your model")',
169169
'{}'
170+
171+
# adds validation to widget so our test for happy and unhappy path will be ready to test validation
172+
gsub_file 'spec/requests/widgets_spec.rb',
173+
'skip("Add a hash of attributes invalid for your model")',
174+
'{ name: "" }'
175+
176+
gsub_file 'spec/requests/widgets_spec.rb',
177+
'skip("Add a hash of attributes valid for your model")',
178+
'{ name: "lorem" }'
179+
180+
gsub_file 'app/models/widget.rb',
181+
'end',
182+
'validates :name, presence: true; end'
170183
final_tasks

0 commit comments

Comments
 (0)