diff --git a/features/matchers/redirect_to_matcher.feature b/features/matchers/redirect_to_matcher.feature index ee3c277fe..5abfe3eef 100644 --- a/features/matchers/redirect_to_matcher.feature +++ b/features/matchers/redirect_to_matcher.feature @@ -13,30 +13,25 @@ Feature: `redirect_to` matcher require "rails_helper" RSpec.describe WidgetsController do + describe "#create" do - it "redirects to widget_url(@widget)" do - post :create, :params => { :widget => { :name => "Foo" } } + subject { post :create, :params => { :widget => { :name => "Foo" } } } - expect(response).to redirect_to(widget_url(assigns(:widget))) + it "redirects to widget_url(@widget)" do + expect(subject).to redirect_to(widget_url(assigns(:widget))) end it "redirects_to :action => :show" do - post :create, :params => { :widget => { :name => "Foo" } } - - expect(response).to redirect_to :action => :show, + expect(subject).to redirect_to :action => :show, :id => assigns(:widget).id end it "redirects_to(@widget)" do - post :create, :params => { :widget => { :name => "Foo" } } - - expect(response).to redirect_to(assigns(:widget)) + expect(subject).to redirect_to(assigns(:widget)) end it "redirects_to /widgets/:id" do - post :create, :params => { :widget => { :name => "Foo" } } - - expect(response).to redirect_to("/widgets/#{assigns(:widget).id}") + expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}") end end end diff --git a/features/matchers/render_template_matcher.feature b/features/matchers/render_template_matcher.feature index 0f4e159bb..e8f7f3f91 100644 --- a/features/matchers/render_template_matcher.feature +++ b/features/matchers/render_template_matcher.feature @@ -16,18 +16,16 @@ Feature: `render_template` matcher RSpec.describe GadgetsController do describe "GET #index" do - it "renders the index template" do - get :index + subject { get :index } - expect(response).to render_template(:index) - expect(response).to render_template("index") - expect(response).to render_template("gadgets/index") + it "renders the index template" do + expect(subject).to render_template(:index) + expect(subject).to render_template("index") + expect(subject).to render_template("gadgets/index") end it "does not render a different template" do - get :index - - expect(response).to_not render_template("gadgets/show") + expect(subject).to_not render_template("gadgets/show") end end end @@ -42,16 +40,14 @@ Feature: `render_template` matcher RSpec.describe GadgetsController do describe "GET #index" do - it "renders the application layout" do - get :index + subject { get :index } - expect(response).to render_template("layouts/application") + it "renders the application layout" do + expect(subject).to render_template("layouts/application") end it "does not render a different layout" do - get :index - - expect(response).to_not render_template("layouts/admin") + expect(subject).to_not render_template("layouts/admin") end end end