質問編集履歴

1

エラーメッセージの追加

2019/04/07 11:10

投稿

xKxAxKx
xKxAxKx

スコア9

test CHANGED
File without changes
test CHANGED
@@ -96,6 +96,40 @@
96
96
 
97
97
  Postのtitleカラムにはnot null制約がかけられているため、2つ目のテスト `is not valid with title` は通るはずだと思うのですが、このテストが落ちてしまいます。
98
98
 
99
+ 以下、エラー内容。
100
+
101
+ ```
102
+
103
+ Failures:
104
+
105
+
106
+
107
+ 1) Post is not valid with title
108
+
109
+ Failure/Error: expect(post).not_to be_valid
110
+
111
+ expected #<Post id: nil, title: nil, created_at: nil, updated_at: nil> not to be valid
112
+
113
+ # ./spec/models/post_spec.rb:16:in `block (2 levels) in <top (required)>'
114
+
115
+
116
+
117
+ Finished in 0.10574 seconds (files took 8.18 seconds to load)
118
+
119
+ 2 examples, 1 failure
120
+
121
+
122
+
123
+ Failed examples:
124
+
125
+
126
+
127
+ rspec ./spec/models/post_spec.rb:12 # Post is not valid with title
128
+
129
+ ```
130
+
131
+
132
+
99
133
  また、` expect(post).not_to be_valid` の部分を `expect(post).to be_valid` にした場合は、テストがとおります。
100
134
 
101
135
  念の為、テスト用DBで `show create table` をしてみたところ、正しくnot null制約がかかっていました。