質問編集履歴

1

エラーの箇所を追記しました

2018/10/11 04:23

投稿

mac_spec
mac_spec

スコア8

test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,24 @@
5
5
  うまくいかず質問させていただきました!
6
6
 
7
7
 
8
+
9
+ ## 発生しているエラー
10
+
11
+ ```
12
+
13
+ Exception:
14
+
15
+ Exception
16
+
17
+ # ./spec/requests/errors_spec.rb:38:in `block (2 levels) in <top (required)>'
18
+
19
+ ```
20
+
21
+ 下記のerrors_spec.rbで意図的にExceptionエラーを発生させているのですが、RSpecがここで止まってしまって、これ以降の処理を実行してくれない状況です。
22
+
23
+
24
+
25
+ ## 前提とソースコード
8
26
 
9
27
  エラーハンドリングは以下の手順で行っています。
10
28
 
@@ -82,7 +100,7 @@
82
100
 
83
101
  it "renders 500" do
84
102
 
85
- expect_any_instance_of(ErrorsController).to receive(:show).and_throw(Exception)
103
+ allow_any_instance_of(ErrorsController).to receive(:show).and_return(raise Exception)
86
104
 
87
105
  expect(response).to render_template("errors/500.ja")
88
106