質問編集履歴

1

テストについての補足を追加

2021/05/06 06:42

投稿

takuma_lol
takuma_lol

スコア0

test CHANGED
File without changes
test CHANGED
@@ -110,4 +110,48 @@
110
110
 
111
111
 
112
112
 
113
- ここにり詳細情報記載しください。
113
+ 以下のテスト書いおり、
114
+
115
+
116
+
117
+ test "login with valid information followed by logout" do
118
+
119
+ get login_path
120
+
121
+ post login_path, params: { session: { email: @user.email,
122
+
123
+ password: 'password' } }
124
+
125
+ assert is_logged_in?
126
+
127
+ assert_redirected_to @user
128
+
129
+ follow_redirect!
130
+
131
+ assert_template 'users/show'
132
+
133
+ assert_select "a[href=?]", login_path, count: 0
134
+
135
+ assert_select "a[href=?]", logout_path
136
+
137
+ assert_select "a[href=?]", user_path(@user)
138
+
139
+ delete logout_path
140
+
141
+ assert_not is_logged_in?
142
+
143
+ assert_redirected_to root_url
144
+
145
+ follow_redirect!
146
+
147
+ assert_select "a[href=?]", login_path
148
+
149
+ assert_select "a[href=?]", logout_path, count: 0
150
+
151
+ assert_select "a[href=?]", user_path(@user), count: 0
152
+
153
+ end
154
+
155
+
156
+
157
+ logoutボタンを押した後にリダイレクトに失敗している(?)ため、このテストは本来であればREDになると思うのですが、なぜかGREENで通ってしまいます。