File tree Expand file tree Collapse file tree 2 files changed +26
-17
lines changed Expand file tree Collapse file tree 2 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -13,25 +13,30 @@ Feature: `redirect_to` matcher
13
13
require "rails_helper"
14
14
15
15
RSpec.describe WidgetsController do
16
-
17
16
describe "#create" do
18
- subject { post :create, :params => { :widget => { :name => "Foo" } } }
19
-
20
17
it "redirects to widget_url(@widget)" do
21
- expect(subject).to redirect_to(widget_url(assigns(:widget)))
18
+ post :create, :params => { :widget => { :name => "Foo" } }
19
+
20
+ expect(response).to redirect_to(widget_url(assigns(:widget)))
22
21
end
23
22
24
23
it "redirects_to :action => :show" do
25
- expect(subject).to redirect_to :action => :show,
24
+ post :create, :params => { :widget => { :name => "Foo" } }
25
+
26
+ expect(response).to redirect_to :action => :show,
26
27
:id => assigns(:widget).id
27
28
end
28
29
29
30
it "redirects_to(@widget)" do
30
- expect(subject).to redirect_to(assigns(:widget))
31
+ post :create, :params => { :widget => { :name => "Foo" } }
32
+
33
+ expect(response).to redirect_to(assigns(:widget))
31
34
end
32
35
33
36
it "redirects_to /widgets/:id" do
34
- expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}")
37
+ post :create, :params => { :widget => { :name => "Foo" } }
38
+
39
+ expect(response).to redirect_to("/widgets/#{assigns(:widget).id}")
35
40
end
36
41
end
37
42
end
Original file line number Diff line number Diff line change @@ -16,16 +16,18 @@ Feature: `render_template` matcher
16
16
17
17
RSpec.describe GadgetsController do
18
18
describe "GET #index" do
19
- subject { get :index }
20
-
21
19
it "renders the index template" do
22
- expect(subject).to render_template(:index)
23
- expect(subject).to render_template("index")
24
- expect(subject).to render_template("gadgets/index")
20
+ get :index
21
+
22
+ expect(response).to render_template(:index)
23
+ expect(response).to render_template("index")
24
+ expect(response).to render_template("gadgets/index")
25
25
end
26
26
27
27
it "does not render a different template" do
28
- expect(subject).to_not render_template("gadgets/show")
28
+ get :index
29
+
30
+ expect(response).to_not render_template("gadgets/show")
29
31
end
30
32
end
31
33
end
@@ -40,14 +42,16 @@ Feature: `render_template` matcher
40
42
41
43
RSpec.describe GadgetsController do
42
44
describe "GET #index" do
43
- subject { get :index }
44
-
45
45
it "renders the application layout" do
46
- expect(subject).to render_template("layouts/application")
46
+ get :index
47
+
48
+ expect(response).to render_template("layouts/application")
47
49
end
48
50
49
51
it "does not render a different layout" do
50
- expect(subject).to_not render_template("layouts/admin")
52
+ get :index
53
+
54
+ expect(response).to_not render_template("layouts/admin")
51
55
end
52
56
end
53
57
end
You can’t perform that action at this time.
0 commit comments