Skip to content

Commit 124cbcb

Browse files
authored
Merge pull request #2800 from rspec/revert-2799-main
Revert "Improve consistency with official controller spec style"
2 parents 46726b8 + 9eeea15 commit 124cbcb

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

features/matchers/redirect_to_matcher.feature

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,25 @@ Feature: `redirect_to` matcher
1313
require "rails_helper"
1414
1515
RSpec.describe WidgetsController do
16+
1617
describe "#create" do
17-
it "redirects to widget_url(@widget)" do
18-
post :create, :params => { :widget => { :name => "Foo" } }
18+
subject { post :create, :params => { :widget => { :name => "Foo" } } }
1919
20-
expect(response).to redirect_to(widget_url(assigns(:widget)))
20+
it "redirects to widget_url(@widget)" do
21+
expect(subject).to redirect_to(widget_url(assigns(:widget)))
2122
end
2223
2324
it "redirects_to :action => :show" do
24-
post :create, :params => { :widget => { :name => "Foo" } }
25-
26-
expect(response).to redirect_to :action => :show,
25+
expect(subject).to redirect_to :action => :show,
2726
:id => assigns(:widget).id
2827
end
2928
3029
it "redirects_to(@widget)" do
31-
post :create, :params => { :widget => { :name => "Foo" } }
32-
33-
expect(response).to redirect_to(assigns(:widget))
30+
expect(subject).to redirect_to(assigns(:widget))
3431
end
3532
3633
it "redirects_to /widgets/:id" do
37-
post :create, :params => { :widget => { :name => "Foo" } }
38-
39-
expect(response).to redirect_to("/widgets/#{assigns(:widget).id}")
34+
expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}")
4035
end
4136
end
4237
end

features/matchers/render_template_matcher.feature

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ Feature: `render_template` matcher
1616
1717
RSpec.describe GadgetsController do
1818
describe "GET #index" do
19-
it "renders the index template" do
20-
get :index
19+
subject { get :index }
2120
22-
expect(response).to render_template(:index)
23-
expect(response).to render_template("index")
24-
expect(response).to render_template("gadgets/index")
21+
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")
2525
end
2626
2727
it "does not render a different template" do
28-
get :index
29-
30-
expect(response).to_not render_template("gadgets/show")
28+
expect(subject).to_not render_template("gadgets/show")
3129
end
3230
end
3331
end
@@ -42,16 +40,14 @@ Feature: `render_template` matcher
4240
4341
RSpec.describe GadgetsController do
4442
describe "GET #index" do
45-
it "renders the application layout" do
46-
get :index
43+
subject { get :index }
4744
48-
expect(response).to render_template("layouts/application")
45+
it "renders the application layout" do
46+
expect(subject).to render_template("layouts/application")
4947
end
5048
5149
it "does not render a different layout" do
52-
get :index
53-
54-
expect(response).to_not render_template("layouts/admin")
50+
expect(subject).to_not render_template("layouts/admin")
5551
end
5652
end
5753
end

0 commit comments

Comments
 (0)