質問編集履歴

3

<code>をやってみました。

2019/12/08 09:15

投稿

helo
helo

スコア36

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,62 @@
1
+ ```ここに言語を入力
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+
5
+ def Setup
6
+
7
+ @user = User.new(name: "Example User", email: "user@example.com")
8
+
9
+ end
10
+
11
+
12
+
13
+ test "should be valid" do
14
+
15
+ assert_equal @user.valid?
16
+
17
+ end
18
+
19
+
20
+
21
+ test "name should be present" do
22
+
23
+ @user.name = " "
24
+
25
+ assert_not @user.valid?
26
+
27
+ end
28
+
29
+
30
+
31
+ test "email should be present" do
32
+
33
+ @user.email = " "
34
+
35
+ assert_not @user.valid?
36
+
37
+ end
38
+
39
+ end
40
+
41
+
42
+
43
+ ーーーーーーーーーーーーーーーーーーーーーーー
44
+
45
+
46
+
47
+ class User < ApplicationRecord
48
+
49
+ validates :name, presence: true
50
+
51
+ validates :email, presence: true
52
+
53
+ end
54
+
55
+
56
+
57
+
58
+
1
- ### 前提・実現したいこと
59
+ ```### 前提・実現したいこと
2
60
 
3
61
  現在、Railsチュートリアルの第6章にて、name、email等の賊子の検証テストを行っているのですが、どうしても、No Method errorが出て2か所パスが出来ません。いろいろ他サイトを調べたのですが、適切な答えが見つからず前に進めません。
4
62
 

2

ソースコードをシングルクオーテーションで囲みました。

2019/12/08 09:15

投稿

helo
helo

スコア36

test CHANGED
File without changes
test CHANGED
@@ -50,7 +50,7 @@
50
50
 
51
51
         ↓
52
52
 
53
- <code>
53
+ '''
54
54
 
55
55
  require_relative '../test_helper'
56
56
 
@@ -94,7 +94,7 @@
94
94
 
95
95
  end
96
96
 
97
- </code>
97
+ '''
98
98
 
99
99
 
100
100
 
@@ -102,9 +102,7 @@
102
102
 
103
103
      ↓
104
104
 
105
- <code>
105
+ '''
106
-
107
-
108
106
 
109
107
  class User < ApplicationRecord
110
108
 
@@ -114,9 +112,7 @@
114
112
 
115
113
  end
116
114
 
117
-
118
-
119
- </code>
115
+ '''
120
116
 
121
117
 
122
118
 

1

ソースコードの部分を<code>タグで囲みました。

2019/12/08 09:06

投稿

helo
helo

スコア36

test CHANGED
File without changes
test CHANGED
@@ -50,6 +50,8 @@
50
50
 
51
51
         ↓
52
52
 
53
+ <code>
54
+
53
55
  require_relative '../test_helper'
54
56
 
55
57
 
@@ -92,11 +94,17 @@
92
94
 
93
95
  end
94
96
 
97
+ </code>
98
+
95
99
 
96
100
 
97
101
  app/models/user.rbファイル
98
102
 
99
103
      ↓
104
+
105
+ <code>
106
+
107
+
100
108
 
101
109
  class User < ApplicationRecord
102
110
 
@@ -107,6 +115,8 @@
107
115
  end
108
116
 
109
117
 
118
+
119
+ </code>
110
120
 
111
121
 
112
122