質問編集履歴

1

一部ではなくすべてのテストを記載させていただきました。

2020/08/27 23:19

投稿

koukinkouka
koukinkouka

スコア5

test CHANGED
File without changes
test CHANGED
@@ -204,7 +204,7 @@
204
204
 
205
205
  ### 該当のソースコード
206
206
 
207
- 一部のテストを記載します。
207
+
208
208
 
209
209
 
210
210
 
@@ -212,6 +212,162 @@
212
212
 
213
213
 
214
214
 
215
+ class StaticPagesControllerTest < ActionDispatch::IntegrationTest
216
+
217
+
218
+
219
+ def setup
220
+
221
+ @base_title = "Ruby on Rails Tutorial Sample App"
222
+
223
+ end
224
+
225
+
226
+
227
+ test "should get root" do
228
+
229
+ get root_path
230
+
231
+ assert_response :success
232
+
233
+ end
234
+
235
+
236
+
237
+ test "should get home" do
238
+
239
+ get root_path
240
+
241
+ assert_response :success
242
+
243
+ assert_select "title", "Ruby on Rails Tutorial Sample App"
244
+
245
+ end
246
+
247
+
248
+
249
+ test "should get help" do
250
+
251
+ get help_path
252
+
253
+ assert_response :success
254
+
255
+ assert_select "title", "Help | #{@base_title}"
256
+
257
+ end
258
+
259
+
260
+
261
+ test "should get about" do
262
+
263
+ get about_path
264
+
265
+ assert_response :success
266
+
267
+ assert_select "title", "About | #{@base_title}"
268
+
269
+ end
270
+
271
+
272
+
273
+ test "should get contact" do
274
+
275
+ get contact_path
276
+
277
+ assert_response :success
278
+
279
+ assert_select "title", "Contact | #{@base_title}"
280
+
281
+ end
282
+
283
+ end
284
+
285
+ ---------------------------------------------------
286
+
287
+
288
+
289
+ require 'test_helper'
290
+
291
+
292
+
293
+ class UsersControllerTest < ActionDispatch::IntegrationTest
294
+
295
+
296
+
297
+ test "should get new" do
298
+
299
+ get signup_path
300
+
301
+ assert_response :success
302
+
303
+ end
304
+
305
+ end
306
+
307
+
308
+
309
+ ---------------------------------------
310
+
311
+ require 'test_helper'
312
+
313
+
314
+
315
+ class UserTest < ActiveSupport::TestCase
316
+
317
+ def setup
318
+
319
+ @user = User.new(name: "Example User", email: "user@example.com")
320
+
321
+ end
322
+
323
+
324
+
325
+ test "should be valid" do
326
+
327
+ assert @user.valid?
328
+
329
+ end
330
+
331
+
332
+
333
+ test "name should be present" do
334
+
335
+ @user.name = " "
336
+
337
+ assert_not @user.valid?
338
+
339
+ end
340
+
341
+
342
+
343
+ test "name should not be too long" do
344
+
345
+ @user.name = "a" * 51
346
+
347
+ assert_not @user.valid?
348
+
349
+ end
350
+
351
+
352
+
353
+ test "email should not be too long" do
354
+
355
+ @user.email = "a" * 244 + "@example.com"
356
+
357
+ assert_not @user.valid?
358
+
359
+ end
360
+
361
+ end
362
+
363
+
364
+
365
+ ----------------------------------------------------------
366
+
367
+ require 'test_helper'
368
+
369
+
370
+
215
371
  class SiteLayoutTest < ActionDispatch::IntegrationTest
216
372
 
217
373
 
@@ -238,6 +394,10 @@
238
394
 
239
395
 
240
396
 
397
+
398
+
399
+
400
+
241
401
  ### 試したこと
242
402
 
243
403