質問編集履歴
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
`
|
39
|
+
`user_spec.rb`
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
`
|
11
|
+
`user.rb`
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
|
3
修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
子インスタンスを持つ親スタンスメソッドでnilを返したい
|
1
|
+
子インスタンスを持つ親スタンスメソッドでnilよりfalseを返したい
|
test
CHANGED
File without changes
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,39 @@
|
|
33
33
|
NoMethodError:
|
34
34
|
|
35
35
|
undefined method `created_at' for nil:NilClass
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
`diary_spec.rb`
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
|
43
|
+
describe 'cannot_post?' do
|
44
|
+
|
45
|
+
context '1日以内に投稿した場合' do
|
46
|
+
|
47
|
+
it 'trueを返す' do
|
48
|
+
|
49
|
+
create(:diary, user: user_a, created_at: Time.zone.now)
|
50
|
+
|
51
|
+
expect(user_a.cannot_post?).to be true
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
context '1日以内に投稿していない場合' do
|
58
|
+
|
59
|
+
let(:can_post_user) { create(:user) }
|
60
|
+
|
61
|
+
it 'falseを返す' do
|
62
|
+
|
63
|
+
expect(can_post_user.cannot_post?).to be false
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
```
|
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,3 +23,13 @@
|
|
23
23
|
end
|
24
24
|
|
25
25
|
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
> 1) User インスタンスメソッド cannot_post? 1日以内に投稿していない場合 falseを返す
|
30
|
+
|
31
|
+
Failure/Error: (Time.zone.now - latest_diary.first.created_at) < 1.day
|
32
|
+
|
33
|
+
NoMethodError:
|
34
|
+
|
35
|
+
undefined method `created_at' for nil:NilClass
|